[libvirt] [PATCHv2 3/3] qemu: add support of optional 'autodeflate' attribute
John Ferlan
jferlan at redhat.com
Tue Jan 5 16:13:20 UTC 2016
On 12/23/2015 07:33 AM, Dmitry Andreev wrote:
> Autodeflate can be enabled/disabled for memballon device
> of model 'virtio'.
>
> xml:
> <devices>
> <memballoon model='virtio' autodeflate='on'/>
> </devices>
>
> qemu:
> qemu -device virtio-balloon-pci,...,deflate-on-oom=on
>
> Autodeflate cannot be enabled/disabled for running domain.
> ---
> src/qemu/qemu_command.c | 11 ++++++++
> .../qemuxml2argv-balloon-ccw-deflate.args | 20 +++++++++++++++
> .../qemuxml2argv-balloon-ccw-deflate.xml | 21 +++++++++++++++
> .../qemuxml2argv-balloon-device-deflate-off.args | 23 +++++++++++++++++
> .../qemuxml2argv-balloon-device-deflate-off.xml | 25 ++++++++++++++++++
> .../qemuxml2argv-balloon-device-deflate.args | 23 +++++++++++++++++
> .../qemuxml2argv-balloon-device-deflate.xml | 25 ++++++++++++++++++
> .../qemuxml2argv-balloon-mmio-deflate.args | 25 ++++++++++++++++++
> .../qemuxml2argv-balloon-mmio-deflate.xml | 30 ++++++++++++++++++++++
> tests/qemuxml2argvtest.c | 9 +++++++
> 10 files changed, 212 insertions(+)
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.args
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.xml
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate-off.args
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate-off.xml
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate.args
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate.xml
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 9822cf7..912cb36 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -5708,6 +5708,17 @@ qemuBuildMemballoonDevStr(virDomainDefPtr def,
> if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
> goto error;
>
> + if (dev->autodeflate > 0) {
s/> 0/ != VIR_TRISTATE_SWITCH_ABSENT/
John
> + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE)) {
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> + _("deflate-on-oom is not supported by this QEMU binary"));
> + goto error;
> + }
> +
> + virBufferAsprintf(&buf, ",deflate-on-oom=%s",
> + virTristateSwitchTypeToString(dev->autodeflate));
> + }
> +
> if (virBufferCheckError(&buf) < 0)
> goto error;
>
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.args
> new file mode 100644
> index 0000000..8dfced6
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.args
> @@ -0,0 +1,20 @@
> +LC_ALL=C \
> +PATH=/bin \
> +HOME=/home/test \
> +USER=test \
> +LOGNAME=test \
> +QEMU_AUDIO_DRV=none \
> +/usr/bin/qemu \
> +-name QEMUGuest1 \
> +-S \
> +-M s390-ccw \
> +-m 214 \
> +-smp 1 \
> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
> +-nographic \
> +-nodefconfig \
> +-nodefaults \
> +-monitor unix:/tmp/test-monitor,server,nowait \
> +-no-acpi \
> +-boot c \
> +-device virtio-balloon-ccw,id=balloon0,devno=fe.0.000a,deflate-on-oom=on
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.xml b/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.xml
> new file mode 100644
> index 0000000..248b609
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.xml
> @@ -0,0 +1,21 @@
> +<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='s390x' machine='s390-ccw'>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>
> + <memballoon model='virtio' autodeflate='on'>
> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0a'/>
> + </memballoon>
> + </devices>
> +</domain>
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate-off.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate-off.args
> new file mode 100644
> index 0000000..1e64c1a
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate-off.args
> @@ -0,0 +1,23 @@
> +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 \
> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
> +-nographic \
> +-nodefconfig \
> +-nodefaults \
> +-monitor unix:/tmp/test-monitor,server,nowait \
> +-no-acpi \
> +-boot c \
> +-usb \
> +-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0,format=raw \
> +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
> +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x12,deflate-on-oom=off
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate-off.xml b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate-off.xml
> new file mode 100644
> index 0000000..bc7c6f3
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate-off.xml
> @@ -0,0 +1,25 @@
> +<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'/>
> + </disk>
> + <memballoon model='virtio' autodeflate='off'>
> + <address type='pci' domain='0' bus='0' slot='18' function='0'/>
> + </memballoon>
> + </devices>
> +</domain>
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate.args
> new file mode 100644
> index 0000000..18a2df9
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate.args
> @@ -0,0 +1,23 @@
> +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 \
> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
> +-nographic \
> +-nodefconfig \
> +-nodefaults \
> +-monitor unix:/tmp/test-monitor,server,nowait \
> +-no-acpi \
> +-boot c \
> +-usb \
> +-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0,format=raw \
> +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
> +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x12,deflate-on-oom=on
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate.xml b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate.xml
> new file mode 100644
> index 0000000..3c25ad5
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-deflate.xml
> @@ -0,0 +1,25 @@
> +<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'/>
> + </disk>
> + <memballoon model='virtio' autodeflate='on'>
> + <address type='pci' domain='0' bus='0' slot='18' function='0'/>
> + </memballoon>
> + </devices>
> +</domain>
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
> new file mode 100644
> index 0000000..bb70bf8
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
> @@ -0,0 +1,25 @@
> +LC_ALL=C \
> +PATH=/bin \
> +HOME=/home/test \
> +USER=test \
> +LOGNAME=test \
> +QEMU_AUDIO_DRV=none \
> +/usr/bin/qemu-system-aarch64 \
> +-name aarch64test \
> +-S \
> +-M virt \
> +-cpu cortex-a53 \
> +-m 1024 \
> +-smp 1 \
> +-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
> +-nographic \
> +-nodefconfig \
> +-nodefaults \
> +-monitor unix:/tmp/test-monitor,server,nowait \
> +-boot c \
> +-kernel /aarch64.kernel \
> +-initrd /aarch64.initrd \
> +-append 'earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait' \
> +-dtb /aarch64.dtb \
> +-usb \
> +-device virtio-balloon-device,id=balloon0,deflate-on-oom=on
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
> new file mode 100644
> index 0000000..1b5b48c
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
> @@ -0,0 +1,30 @@
> +<domain type="qemu">
> + <name>aarch64test</name>
> + <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
> + <memory>1048576</memory>
> + <currentMemory>1048576</currentMemory>
> + <vcpu placement='static'>1</vcpu>
> + <os>
> + <type arch="aarch64" machine="virt">hvm</type>
> + <kernel>/aarch64.kernel</kernel>
> + <initrd>/aarch64.initrd</initrd>
> + <dtb>/aarch64.dtb</dtb>
> + <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
> + </os>
> + <features>
> + <acpi/>
> + <apic/>
> + <pae/>
> + </features>
> + <cpu match='exact'>
> + <model>cortex-a53</model>
> + </cpu>
> + <clock offset="utc"/>
> + <on_poweroff>destroy</on_poweroff>
> + <on_reboot>restart</on_reboot>
> + <on_crash>restart</on_crash>
> + <devices>
> + <emulator>/usr/bin/qemu-system-aarch64</emulator>
> + <memballoon model='virtio' autodeflate='on'/>
> + </devices>
> +</domain>
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 37f806e..0726ee1 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -1194,6 +1194,15 @@ mymain(void)
> QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
> QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390);
> DO_TEST("balloon-device", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
> + DO_TEST("balloon-device-deflate", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
> + QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
> + DO_TEST("balloon-ccw-deflate", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
> + QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
> + DO_TEST("balloon-mmio-deflate", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
> + QEMU_CAPS_DTB, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
> + QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
> + DO_TEST("balloon-device-deflate-off", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
> + QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
> DO_TEST("balloon-device-auto",
> QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
> DO_TEST("balloon-device-period", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
>
More information about the libvir-list
mailing list