mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
conf: don't format memtune with unlimited values
When changing memtune limits to unlimited with AFFECT_CONFIG, the values in virDomainDef are set to PARAM_UNLIMITED, which causes the whole <memtune> to be formatted. This can be changed in all drivers, but it also makes sense to use the default (0) as another value for "unlimited", since zero memory limit makes no sense. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
8d7c668e64
commit
ea130e3bf6
@ -16643,8 +16643,13 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add memtune only if there are any */
|
/* add memtune only if there are any */
|
||||||
if (def->mem.hard_limit || def->mem.soft_limit || def->mem.min_guarantee ||
|
if ((def->mem.hard_limit &&
|
||||||
def->mem.swap_hard_limit)
|
def->mem.hard_limit != VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) ||
|
||||||
|
(def->mem.soft_limit &&
|
||||||
|
def->mem.hard_limit != VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) ||
|
||||||
|
(def->mem.swap_hard_limit &&
|
||||||
|
def->mem.hard_limit != VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) ||
|
||||||
|
def->mem.min_guarantee) {
|
||||||
virBufferAddLit(buf, " <memtune>\n");
|
virBufferAddLit(buf, " <memtune>\n");
|
||||||
if (def->mem.hard_limit) {
|
if (def->mem.hard_limit) {
|
||||||
virBufferAsprintf(buf, " <hard_limit unit='KiB'>"
|
virBufferAsprintf(buf, " <hard_limit unit='KiB'>"
|
||||||
@ -16662,9 +16667,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
|||||||
virBufferAsprintf(buf, " <swap_hard_limit unit='KiB'>"
|
virBufferAsprintf(buf, " <swap_hard_limit unit='KiB'>"
|
||||||
"%llu</swap_hard_limit>\n", def->mem.swap_hard_limit);
|
"%llu</swap_hard_limit>\n", def->mem.swap_hard_limit);
|
||||||
}
|
}
|
||||||
if (def->mem.hard_limit || def->mem.soft_limit || def->mem.min_guarantee ||
|
|
||||||
def->mem.swap_hard_limit)
|
|
||||||
virBufferAddLit(buf, " </memtune>\n");
|
virBufferAddLit(buf, " </memtune>\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (def->mem.hugepage_backed || def->mem.nosharepages || def->mem.locked) {
|
if (def->mem.hugepage_backed || def->mem.nosharepages || def->mem.locked) {
|
||||||
virBufferAddLit(buf, " <memoryBacking>\n");
|
virBufferAddLit(buf, " <memoryBacking>\n");
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||||
|
/usr/bin/qemu \
|
||||||
|
-name QEMUGuest1 -S -M pc -m 214 -smp 1 -nographic -monitor \
|
||||||
|
unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
|
||||||
|
-hda /dev/HostVG/QEMUGuest1 -net none -serial \
|
||||||
|
none -parallel none
|
29
tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.xml
Normal file
29
tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='MiB'>214</memory>
|
||||||
|
<currentMemory unit='KiB'>219136</currentMemory>
|
||||||
|
<memtune>
|
||||||
|
<hard_limit unit='KiB'>9007199254740991</hard_limit>
|
||||||
|
</memtune>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -1126,6 +1126,7 @@ mymain(void)
|
|||||||
QEMU_CAPS_KVM, QEMU_CAPS_CPU_HOST);
|
QEMU_CAPS_KVM, QEMU_CAPS_CPU_HOST);
|
||||||
|
|
||||||
DO_TEST("memtune", QEMU_CAPS_NAME);
|
DO_TEST("memtune", QEMU_CAPS_NAME);
|
||||||
|
DO_TEST("memtune-unlimited", QEMU_CAPS_NAME);
|
||||||
DO_TEST("blkiotune", QEMU_CAPS_NAME);
|
DO_TEST("blkiotune", QEMU_CAPS_NAME);
|
||||||
DO_TEST("blkiotune-device", QEMU_CAPS_NAME);
|
DO_TEST("blkiotune-device", QEMU_CAPS_NAME);
|
||||||
DO_TEST("cputune", QEMU_CAPS_NAME);
|
DO_TEST("cputune", QEMU_CAPS_NAME);
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>219136</memory>
|
||||||
|
<currentMemory unit='KiB'>219136</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -247,6 +247,7 @@ mymain(void)
|
|||||||
|
|
||||||
DO_TEST("encrypted-disk");
|
DO_TEST("encrypted-disk");
|
||||||
DO_TEST_DIFFERENT("memtune");
|
DO_TEST_DIFFERENT("memtune");
|
||||||
|
DO_TEST_DIFFERENT("memtune-unlimited");
|
||||||
DO_TEST("blkiotune");
|
DO_TEST("blkiotune");
|
||||||
DO_TEST("blkiotune-device");
|
DO_TEST("blkiotune-device");
|
||||||
DO_TEST("cputune");
|
DO_TEST("cputune");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user