我有一个KVM guest,我想dynamic地改变内存分配。
此刻,要改变客人的记忆,我必须运行:
sudo virsh edit $GUEST_DOMAIN
然后从configuration中更改以下部分中显示的第一行
... <memory unit='KiB'>512000</memory> <currentMemory unit='KiB'>512000</currentMemory> <memtune> <hard_limit unit='KiB'>256000</hard_limit> </memtune> ...
然后用virsh shutdown和virsh start重新启动guest virsh start 。
我一直在尝试使用virsh memtune --hard-limit 512000 --domain $GUEST_ID ( 引用 ),但它似乎没有效果。
我也尝试从使用文档在这里的客人内部“气球”,但我不断收到错误balloon: command not found
题
有没有办法使用主机的命令dynamic调整KVM guest虚拟机的大小。 如果没有,至less有一种方法来调整内存的命令,而不必编辑一个configuration文件(或保持virsh文件可以用sed编辑)?
额外的信息
客人正在使用qcow2稀疏文件。
下面是从sudo virsh edit $GUEST的完整configuration
<domain type='kvm'> <name>svn.mydomain.com</name> <uuid>8463ab11-628a-c07c-4366-4f768247934a</uuid> <memory unit='KiB'>512000</memory> <currentMemory unit='KiB'>512000</currentMemory> <memtune> <hard_limit unit='KiB'>256000</hard_limit> </memtune> <vcpu placement='static'>4</vcpu> <os> <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/kvm-spice</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/media/storage/kvm/vms/svn.mydomain.com.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </disk> <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='pci' index='0' model='pci-root'/> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='bridge'> <mac address='52:54:00:a2:4a:f6'/> <source bridge='kvmbr0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </memballoon> </devices> </domain>
你不需要搞乱<memtune><hard_limit> 。 当应用于KVM客人时,这实际上是一个相当危险的设置 。 我会立即删除该部分。
然而,QEMU和KVM的用户强烈build议不要设置这个限制,因为如果猜测太低,域可能被内核杀死。 确定进程运行所需的内存是一个不可判定的问题 。
要减lessKVM guest <currentMemory>有权访问的内存量,请更改<currentMemory> 。 客人可以拥有的最大值由<memory>指定,并且更改它需要closures客人。