使用blkdeviotune可以设置虚拟机的读写速度和iops
参数如下: --total-bytes-sec total throughput limit in bytes per second --read-bytes-sec read throughput limit in bytes per second --write-bytes-sec write throughput limit in bytes per second --total-iops-sec total I/O operations limit per second --read-iops-sec read I/O operations limit per second --write-iops-sec write I/O operations limit per second --config affect next boot --live affect running domain --current affect current domain
例子 virsh blkdeviotune 8 hda --total_bytes_sec 10240 --total-bytes-sec 10240 --read-bytes-sec 4096 --write-bytes-sec 2028 \ --total-iops-sec 30 --read-iops-sec 15 --write-iops-sec 15
Xml文档格式为
10000000 400000 100000
注意:实际在centos6.3的环境下,使用blkdeviotune,会出现虚拟机不能启动的情况,经过查询redhat官网,这个是libvirt和qemu之间配合的一个bug,在fedora17上做了同样的测试,有同样的问题。
virsh # start w2k3.64.e1000
error: Failed to start domain w2k3.64.e1000
error: unsupported configuration: block I/O throttling not supported with this QEMU binary
如果要使用这个功能,可能需要等待官方的修复。 5. 网络带宽的控制
Xml文档格式为
单位kilobytes
使用方法:在网卡interface中加入
以下是关于各项参数的解释:
mandatory attribute:
average: It specifies average bit rate on interface being shaped.
optional attributes:
peak: which specifies maximum rate at which interface can send data,
burst: amount of bytes that can be burst at peak speed.
Accepted values: integer numbers.
units:
average: kilobytes per second
peak: kilobytes per second
burst: kilobytes.
命令行命令为: virsh # help attach-interface NAME attach-interface - attach network interface
OPTIONS [--domain] domain name, id or uuid [--type] network interface type [--source] source of network interface [--target] target network name [--mac] MAC address [--script] script used to bridge network interface [--model] model type --persistent persist interface attachment [--inbound] control domain's incoming traffics [--outbound] control domain's outgoing traffics 6. CPU资源的控制
Xml文档格式为