On 12/14/2015 06:35 AM, Dmitry Andreev wrote:
xml:
<devices>
<memballoon model='virtio' deflate-on-oom='on'/>
</devices>
qemu:
qemu -device virtio-balloon-pci,...,deflate-on-oom=on
Little light on the commit message
Next question to be asked - how about being able to enable/disable for
the running domain?!
If the memory period/seconds can be adjusted dynamically I begin to
wonder whether the feature is available for the running domain and
perhaps through something for a setmem option?
---
src/qemu/qemu_command.c | 4 ++++
.../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 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 4 ++++
6 files changed, 104 insertions(+)
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
Nice - tests. obvious updates as a result of comments in 1/2...
Just making sure - all the address types support in qemu_command.c can
support this feature, right? PCI, CCW, MMIO
Your tests only show PCI.
Of course I have to ask - since as you note in your cover this feature
was added to QEMU "a month ago" - why is there no capabilities check?
What happens when (and it will happen) this is run on a host that
doesn't have that capability for the balloon driver?
You'll need to add some sort of capabilities or version check. If qemu
didn't create one for this feature, then that really needs to be done.
John
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d2f37e4..227ba8a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5708,6 +5708,10 @@ qemuBuildMemballoonDevStr(virDomainDefPtr def,
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
goto error;
+ if (dev->deflate > 0)
+ virBufferAsprintf(&buf, ",deflate-on-oom=%s",
+ virTristateSwitchTypeToString(dev->deflate));
+
if (virBufferCheckError(&buf) < 0)
goto error;
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..5e536a1
--- /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' deflate-on-oom='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..efecbc6
--- /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' deflate-on-oom='on'>
+ <address type='pci' domain='0' bus='0'
slot='18' function='0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 37f806e..42a6aed 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1194,6 +1194,10 @@ 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);
+ DO_TEST("balloon-device-deflate-off",
+ QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("balloon-device-auto",
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("balloon-device-period", QEMU_CAPS_DEVICE,
QEMU_CAPS_NODEFCONFIG);