5. 网络带宽的控制
Xml文档格式为
<devices>
<interface type='network'>
<source network='default'/>
<target dev='vnet0'/>
<link state='down'/>
</interface>
<bandwidth>
<inbound average='1000' peak='5000' burst='1024'/>
<outbound average='128' peak='256' burst='256'/>
</bandwidth>
单位kilobytes
命令行命令为:
virsh # help attach-interface
NAME
attach-interface - attach network interface
SYNOPSIS
attach-interface <domain> <type> <source> [<target>] [<mac>] [<script>] [<model>] [--persistent] [<inbound>] [<outbound>]
DESCRIPTION
Attach new network interface.
OPTIONS
[--domain] <string> domain name, id or uuid
[--type] <string> network interface type
[--source] <string> source of network interface
[--target] <string> target network name
[--mac] <string> MAC address
[--script] <string> script used to bridge network interface
[--model] <string> model type
--persistent persist interface attachment
[--inbound] <string> control domain's incoming traffics
[--outbound] <string> control domain's outgoing traffics
6. CPU资源的控制
Xml文档格式为
<domain>
...
<cputune>
<vcpupin vcpu="0" cpuset="1-4,^2"/>
<vcpupin vcpu="1" cpuset="0,1"/>
<vcpupin vcpu="2" cpuset="2,3"/>
<vcpupin vcpu="3" cpuset="0,4"/>
<emulatorpin cpuset="1-3"/>
<shares>2048</shares>
<period>1000000</period>
<quota>-1</quota>
<emulator_period>1000000</emulator_period>
<emulator_quota>-1</emulator_quota>
</cputune>
...
</domain>
主要参数说明:
shares cpu权重,没有固定的数值,和其他的虚拟机相比较,那个的数值大,那个可以使用的cpu资源就多,比如设置2048值得虚拟机,就比设置1024数值的虚拟机可以多使用2倍的cpu资源。
period vcpu强制间隔的时间周期,单位微妙,范围[1000, 1000000],每一个vcpu不能使用超过period时间周期。
quota vcpu最大允许带宽,单位微妙,范围[1000, 18446744073709551]
emulator_period 强制间隔的时间周期,单位微妙,范围[1000, 1000000],虚拟机进程(qemu)不能使用超过period时间周期。
emulator_quota 虚拟机进程(qemu)最大允许带宽,单位微妙,范围[1000, 18446744073709551]。
7. 内存资源的控制
Xml文档格式为
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<memtune>
<hard_limit unit='KiB'>4194304</hard_limit>
<soft_limit unit='KiB'>8388608</soft_limit>
<min_guarantee unit='Kib'>1024000</min_guarantee>>
<swap_hard_limit unit='KiB'>4194304</swap_hard_limit>
</memtune>
命令行命令为
virsh # help memtune
NAME
memtune - Get or set memory parameters
SYNOPSIS
memtune <domain> [--hard-limit <number>] [--soft-limit <number>] [--swap-hard-limit <number>] [--min-guarantee <number>] [--config] [--live] [--current]
DESCRIPTION
Get or set the current memory parameters for a guest domain.
To get the memory parameters use following command:
virsh # memtune <domain>
OPTIONS
[--domain] <string> domain name, id or uuid
--hard-limit <number> 强制最大内存 (default KiB)
--soft-limit <number> 可用最大内存 (default KiB)
--swap-hard-limit <number> 强制最大swap使用大小(default KiB)
--min-guarantee <number> 最小保证的内存 (default KiB)
--config 下次重启生效
--live 在线生效
--current 只在当前生效
例子:
memtune 6 --hard-limit 4194304 --soft-limit 8388608 --swap-hard-limit 4194304 --config