[libvirt] [PATCHv3 0/3] 'autodeflate' attribute for mememory balloon

This patch-set adds support for the new feature 'deflate-on-oom' that has been added to the QEMU virtio memory balloon a month ago. This feature lets a guest OS deflate balloon on OOM. With 'deflate-on-oom' enabled virtio balloon will release it's memory if possible right before an OOM termination of processes. QEMU commit with the complete feature description: http://git.qemu.org/?p=qemu.git;a=commit;h=e3816255bf4b6377bb405331e2ee0dc14... v3 * pull head & merge * reword commit message [1/3] [2/3] * docs: s/OOM-/Out of Memory / [1/3] * merge and fix qemu 2.6.0 caps test [2/3] * s/> 0/ != VIR_TRISTATE_SWITCH_ABSENT/ [3/3] Dmitry Andreev (3): conf: introduce 'autodeflate' attribute for memballoon device qemu: add capability check for memballoon 'deflate-on-oom' feature qemu: add support of optional 'autodeflate' attribute docs/formatdomain.html.in | 10 ++ docs/schemas/domaincommon.rng | 5 + src/conf/domain_conf.c | 23 +++ src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 11 ++ src/qemu/qemu_capabilities.h | 2 + src/qemu/qemu_command.c | 11 ++ tests/qemucapabilitiesdata/caps_1.2.2-1.replies | 68 ++++++++- tests/qemucapabilitiesdata/caps_1.3.1-1.replies | 68 ++++++++- tests/qemucapabilitiesdata/caps_1.4.2-1.replies | 68 ++++++++- tests/qemucapabilitiesdata/caps_1.5.3-1.replies | 66 ++++++++- tests/qemucapabilitiesdata/caps_1.6.0-1.replies | 66 ++++++++- tests/qemucapabilitiesdata/caps_1.6.50-1.replies | 66 ++++++++- tests/qemucapabilitiesdata/caps_2.1.1-1.replies | 78 +++++++++- tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.4.0-1.replies | 146 ++++++++++++++++++- tests/qemucapabilitiesdata/caps_2.5.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.5.0-1.replies | 161 ++++++++++++++++++++- tests/qemucapabilitiesdata/caps_2.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.6.0-1.replies | 161 ++++++++++++++++++++- .../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 ++ 29 files changed, 1145 insertions(+), 70 deletions(-) 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 -- 1.8.3.1

Excessive memory balloon inflation can cause invocation of OOM-killer, when Linux is under severe memory pressure. QEMU memballoon device has a feature to release some memory at the last moment before some process will be get killed by OOM-killer. Introduce a new optional balloon device attribute 'autodeflate' to enable or disable this feature. --- docs/formatdomain.html.in | 10 ++++++++++ docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 23 +++++++++++++++++++++++ src/conf/domain_conf.h | 1 + 4 files changed, 39 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 889e721..b3187bb 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5962,6 +5962,16 @@ qemu-kvm -net nic,model=? /dev/null <li>'xen' — default with Xen</li> </ul> </dd> + <dt><code>autodeflate</code></dt> + <dd> + <p> + The optional <code>autodeflate</code> attribute allows to + enable/disable (values "on"/"off", respectively) the ability of the + QEMU virtio memory balloon to release some memory at the last moment + before a guest's process get killed by Out of Memory killer. + <span class="since">Since 1.3.1, QEMU and KVM only</span> + </p> + </dd> <dt><code>period</code></dt> <dd> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 7c47f60..5deb17b 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3420,6 +3420,11 @@ <value>none</value> </choice> </attribute> + <optional> + <attribute name="autodeflate"> + <ref name="virOnOff"/> + </attribute> + </optional> <interleave> <optional> <ref name="alias"/> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9d47846..34a896d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11327,6 +11327,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, unsigned int flags) { char *model; + char *deflate; virDomainMemballoonDefPtr def; xmlNodePtr save = ctxt->node; unsigned int period = 0; @@ -11347,6 +11348,13 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, goto error; } + if ((deflate = virXMLPropString(node, "autodeflate")) && + (def->autodeflate = virTristateSwitchTypeFromString(deflate)) <= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid autodeflate attribute value '%s'"), deflate); + goto error; + } + ctxt->node = node; if (virXPathUInt("string(./stats/@period)", ctxt, &period) < -1) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -11365,6 +11373,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, cleanup: VIR_FREE(model); + VIR_FREE(deflate); ctxt->node = save; return def; @@ -17238,6 +17247,15 @@ virDomainMemballoonDefCheckABIStability(virDomainMemballoonDefPtr src, return false; } + if (src->autodeflate != dst->autodeflate) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target balloon autodeflate attribute value " + "'%s' does not match source '%s'"), + virTristateSwitchTypeToString(dst->autodeflate), + virTristateSwitchTypeToString(src->autodeflate)); + return false; + } + if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) return false; @@ -20419,6 +20437,11 @@ virDomainMemballoonDefFormat(virBufferPtr buf, } virBufferAsprintf(buf, "<memballoon model='%s'", model); + + if (def->autodeflate != VIR_TRISTATE_SWITCH_ABSENT) + virBufferAsprintf(buf, " autodeflate='%s'", + virTristateSwitchTypeToString(def->autodeflate)); + virBufferAdjustIndent(&childrenBuf, indent + 2); if (def->period) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ae6d546..5d2682d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1635,6 +1635,7 @@ struct _virDomainMemballoonDef { int model; virDomainDeviceInfo info; int period; /* seconds between collections */ + int autodeflate; /* enum virTristateSwitch */ }; struct _virDomainNVRAMDef { -- 1.8.3.1

Add appropriate capability check and new virQEMUCaps flag for the new virtio balloon feature. QEMU commit with the complete feature description: http://git.qemu.org/?p=qemu.git;a=commit;h=e3816255bf4b6377bb405331e2ee0dc14... --- src/qemu/qemu_capabilities.c | 11 ++ src/qemu/qemu_capabilities.h | 2 + tests/qemucapabilitiesdata/caps_1.2.2-1.replies | 68 +++++++++- tests/qemucapabilitiesdata/caps_1.3.1-1.replies | 68 +++++++++- tests/qemucapabilitiesdata/caps_1.4.2-1.replies | 68 +++++++++- tests/qemucapabilitiesdata/caps_1.5.3-1.replies | 66 +++++++++- tests/qemucapabilitiesdata/caps_1.6.0-1.replies | 66 +++++++++- tests/qemucapabilitiesdata/caps_1.6.50-1.replies | 66 +++++++++- tests/qemucapabilitiesdata/caps_2.1.1-1.replies | 78 ++++++++++- tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.4.0-1.replies | 146 +++++++++++++++++++- tests/qemucapabilitiesdata/caps_2.5.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.5.0-1.replies | 161 ++++++++++++++++++++++- tests/qemucapabilitiesdata/caps_2.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.6.0-1.replies | 161 ++++++++++++++++++++++- 15 files changed, 894 insertions(+), 70 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7b30441..4b0e883 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -309,6 +309,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-tablet", /* 205 */ "virtio-input-host", "chardev-file-append", + "virtio-balloon-pci.deflate-on-oom", ); @@ -1563,6 +1564,10 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "virtio-input-host-pci", QEMU_CAPS_VIRTIO_INPUT_HOST }, }; +static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = { + { "deflate-on-oom", QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE }, +}; + static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { { "multifunction", QEMU_CAPS_PCI_MULTIFUNCTION }, { "bootindex", QEMU_CAPS_BOOTINDEX }, @@ -1705,6 +1710,12 @@ static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = { ARRAY_CARDINALITY(virQEMUCapsObjectPropsQxlVga) }, { "virtio-gpu-pci", virQEMUCapsObjectPropsVirtioGpu, ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu) }, + { "virtio-balloon-pci", virQEMUCapsObjectPropsVirtioBalloon, + ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) }, + { "virtio-balloon-ccw", virQEMUCapsObjectPropsVirtioBalloon, + ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) }, + { "virtio-balloon-device", virQEMUCapsObjectPropsVirtioBalloon, + ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) }, }; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index c148f2d..03b51b6 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -336,6 +336,8 @@ typedef enum { QEMU_CAPS_VIRTIO_TABLET, /* -device virtio-tablet-{device,pci} */ QEMU_CAPS_VIRTIO_INPUT_HOST, /* -device virtio-input-host-{device,pci} */ QEMU_CAPS_CHARDEV_FILE_APPEND, /* -chardev file,append=on|off */ + QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE, /* virtio-balloon-{device,pci,ccw}. + * deflate-on-oom */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.replies b/tests/qemucapabilitiesdata/caps_1.2.2-1.replies index e7de77b..7e245c3 100644 --- a/tests/qemucapabilitiesdata/caps_1.2.2-1.replies +++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.replies @@ -1608,6 +1608,60 @@ { "return": [ { + "name": "command_serr_enable", + "type": "on/off" + }, + { + "name": "multifunction", + "type": "on/off" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "romfile", + "type": "string" + }, + { + "name": "addr", + "type": "pci-devfn" + }, + { + "name": "class", + "type": "hex32" + }, + { + "name": "event_idx", + "type": "on/off" + }, + { + "name": "indirect_desc", + "type": "on/off" + } + ], + "id": "libvirt-32" +} + +{ + "id": "libvirt-33", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-device' not found" + } +} + +{ + "return": [ + { "name": "xenpv" }, { @@ -1649,7 +1703,7 @@ "name": "none" } ], - "id": "libvirt-32" + "id": "libvirt-35" } { @@ -1721,7 +1775,7 @@ "name": "Opteron_G4" } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -1729,11 +1783,11 @@ "enabled": false, "present": true }, - "id": "libvirt-34" + "id": "libvirt-37" } { - "id": "libvirt-35", + "id": "libvirt-38", "error": { "class": "CommandNotFound", "desc": "The command query-tpm-models has not been found" @@ -1741,7 +1795,7 @@ } { - "id": "libvirt-36", + "id": "libvirt-39", "error": { "class": "CommandNotFound", "desc": "The command query-tpm-types has not been found" @@ -1749,7 +1803,7 @@ } { - "id": "libvirt-37", + "id": "libvirt-40", "error": { "class": "CommandNotFound", "desc": "The command query-command-line-options has not been found" @@ -1763,5 +1817,5 @@ "state": false } ], - "id": "libvirt-38" + "id": "libvirt-41" } diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.replies b/tests/qemucapabilitiesdata/caps_1.3.1-1.replies index bf9cbad..584778e 100644 --- a/tests/qemucapabilitiesdata/caps_1.3.1-1.replies +++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.replies @@ -1787,6 +1787,60 @@ { "return": [ { + "name": "command_serr_enable", + "type": "on/off" + }, + { + "name": "multifunction", + "type": "on/off" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "romfile", + "type": "string" + }, + { + "name": "addr", + "type": "pci-devfn" + }, + { + "name": "class", + "type": "hex32" + }, + { + "name": "event_idx", + "type": "on/off" + }, + { + "name": "indirect_desc", + "type": "on/off" + } + ], + "id": "libvirt-33" +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "id": "libvirt-35", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-device' not found" + } +} + +{ + "return": [ + { "name": "xenpv" }, { @@ -1835,7 +1889,7 @@ "name": "none" } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -1913,7 +1967,7 @@ "name": "Opteron_G5" } ], - "id": "libvirt-34" + "id": "libvirt-37" } { @@ -1921,11 +1975,11 @@ "enabled": false, "present": true }, - "id": "libvirt-35" + "id": "libvirt-38" } { - "id": "libvirt-36", + "id": "libvirt-39", "error": { "class": "CommandNotFound", "desc": "The command query-tpm-models has not been found" @@ -1933,7 +1987,7 @@ } { - "id": "libvirt-37", + "id": "libvirt-40", "error": { "class": "CommandNotFound", "desc": "The command query-tpm-types has not been found" @@ -1941,7 +1995,7 @@ } { - "id": "libvirt-38", + "id": "libvirt-41", "error": { "class": "CommandNotFound", "desc": "The command query-command-line-options has not been found" @@ -1955,5 +2009,5 @@ "state": false } ], - "id": "libvirt-39" + "id": "libvirt-42" } diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.replies b/tests/qemucapabilitiesdata/caps_1.4.2-1.replies index bd7980f..410eb14 100644 --- a/tests/qemucapabilitiesdata/caps_1.4.2-1.replies +++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.replies @@ -1834,6 +1834,60 @@ { "return": [ { + "name": "command_serr_enable", + "type": "on/off" + }, + { + "name": "multifunction", + "type": "on/off" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "romfile", + "type": "string" + }, + { + "name": "addr", + "type": "pci-devfn" + }, + { + "name": "class", + "type": "hex32" + }, + { + "name": "event_idx", + "type": "on/off" + }, + { + "name": "indirect_desc", + "type": "on/off" + } + ], + "id": "libvirt-33" +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "id": "libvirt-35", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-device' not found" + } +} + +{ + "return": [ + { "name": "xenpv" }, { @@ -1885,7 +1939,7 @@ "name": "none" } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -1963,7 +2017,7 @@ "name": "qemu64" } ], - "id": "libvirt-34" + "id": "libvirt-37" } { @@ -1971,11 +2025,11 @@ "enabled": false, "present": true }, - "id": "libvirt-35" + "id": "libvirt-38" } { - "id": "libvirt-36", + "id": "libvirt-39", "error": { "class": "CommandNotFound", "desc": "The command query-tpm-models has not been found" @@ -1983,7 +2037,7 @@ } { - "id": "libvirt-37", + "id": "libvirt-40", "error": { "class": "CommandNotFound", "desc": "The command query-tpm-types has not been found" @@ -1991,7 +2045,7 @@ } { - "id": "libvirt-38", + "id": "libvirt-41", "error": { "class": "CommandNotFound", "desc": "The command query-command-line-options has not been found" @@ -2005,5 +2059,5 @@ "state": false } ], - "id": "libvirt-39" + "id": "libvirt-42" } diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.replies b/tests/qemucapabilitiesdata/caps_1.5.3-1.replies index abdba6c..1170d13 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.replies +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.replies @@ -1908,6 +1908,58 @@ { "return": [ { + "name": "command_serr_enable", + "type": "on/off" + }, + { + "name": "multifunction", + "type": "on/off" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "romfile", + "type": "string" + }, + { + "name": "addr", + "type": "pci-devfn" + }, + { + "name": "class", + "type": "hex32" + }, + { + "name": "event_idx", + "type": "on/off" + }, + { + "name": "indirect_desc", + "type": "on/off" + } + ], + "id": "libvirt-33" +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "return": [ + ], + "id": "libvirt-35" +} + +{ + "return": [ + { "name": "pc-q35-1.4", "cpu-max": 255 }, @@ -1975,7 +2027,7 @@ "cpu-max": 1 } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -2053,7 +2105,7 @@ "name": "qemu64" } ], - "id": "libvirt-34" + "id": "libvirt-37" } { @@ -2061,19 +2113,19 @@ "enabled": false, "present": true }, - "id": "libvirt-35" + "id": "libvirt-38" } { "return": [ ], - "id": "libvirt-36" + "id": "libvirt-39" } { "return": [ ], - "id": "libvirt-37" + "id": "libvirt-40" } { @@ -2749,7 +2801,7 @@ "option": "drive" } ], - "id": "libvirt-38" + "id": "libvirt-41" } { @@ -2759,5 +2811,5 @@ "state": false } ], - "id": "libvirt-39" + "id": "libvirt-42" } diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.replies b/tests/qemucapabilitiesdata/caps_1.6.0-1.replies index 26a0e9d..bbd5ca6 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.replies +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.replies @@ -1970,6 +1970,58 @@ { "return": [ { + "name": "command_serr_enable", + "type": "on/off" + }, + { + "name": "multifunction", + "type": "on/off" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "romfile", + "type": "string" + }, + { + "name": "addr", + "type": "pci-devfn" + }, + { + "name": "class", + "type": "hex32" + }, + { + "name": "event_idx", + "type": "on/off" + }, + { + "name": "indirect_desc", + "type": "on/off" + } + ], + "id": "libvirt-33" +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "return": [ + ], + "id": "libvirt-35" +} + +{ + "return": [ + { "name": "xenpv", "cpu-max": 1 }, @@ -2053,7 +2105,7 @@ "cpu-max": 1 } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -2131,7 +2183,7 @@ "name": "qemu64" } ], - "id": "libvirt-34" + "id": "libvirt-37" } { @@ -2139,19 +2191,19 @@ "enabled": false, "present": true }, - "id": "libvirt-35" + "id": "libvirt-38" } { "return": [ ], - "id": "libvirt-36" + "id": "libvirt-39" } { "return": [ ], - "id": "libvirt-37" + "id": "libvirt-40" } { @@ -2729,7 +2781,7 @@ "option": "drive" } ], - "id": "libvirt-38" + "id": "libvirt-41" } { @@ -2751,5 +2803,5 @@ "state": false } ], - "id": "libvirt-39" + "id": "libvirt-42" } diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.replies b/tests/qemucapabilitiesdata/caps_1.6.50-1.replies index 5c493b7..319d33f 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.replies +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.replies @@ -1934,6 +1934,58 @@ { "return": [ { + "name": "command_serr_enable", + "type": "on/off" + }, + { + "name": "multifunction", + "type": "on/off" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "romfile", + "type": "string" + }, + { + "name": "addr", + "type": "pci-devfn" + }, + { + "name": "class", + "type": "hex32" + }, + { + "name": "event_idx", + "type": "on/off" + }, + { + "name": "indirect_desc", + "type": "on/off" + } + ], + "id": "libvirt-33" +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "return": [ + ], + "id": "libvirt-35" +} + +{ + "return": [ + { "name": "xenpv", "cpu-max": 1 }, @@ -2025,7 +2077,7 @@ "cpu-max": 1 } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -2103,7 +2155,7 @@ "name": "qemu64" } ], - "id": "libvirt-34" + "id": "libvirt-37" } { @@ -2111,19 +2163,19 @@ "enabled": false, "present": true }, - "id": "libvirt-35" + "id": "libvirt-38" } { "return": [ ], - "id": "libvirt-36" + "id": "libvirt-39" } { "return": [ ], - "id": "libvirt-37" + "id": "libvirt-40" } { @@ -2711,7 +2763,7 @@ "option": "drive" } ], - "id": "libvirt-38" + "id": "libvirt-41" } { @@ -2733,5 +2785,5 @@ "state": false } ], - "id": "libvirt-39" + "id": "libvirt-42" } diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.replies b/tests/qemucapabilitiesdata/caps_2.1.1-1.replies index ba85b28..754067a 100644 --- a/tests/qemucapabilitiesdata/caps_2.1.1-1.replies +++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.replies @@ -2380,6 +2380,70 @@ { "return": [ { + "name": "guest-stats-polling-interval", + "type": "int" + }, + { + "name": "guest-stats", + "type": "guest statistics" + }, + { + "name": "virtio-backend", + "type": "child<virtio-balloon-device>" + }, + { + "name": "command_serr_enable", + "type": "on/off" + }, + { + "name": "multifunction", + "type": "on/off" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "romfile", + "type": "str" + }, + { + "name": "addr", + "type": "pci-devfn" + }, + { + "name": "event_idx", + "type": "on/off" + }, + { + "name": "indirect_desc", + "type": "on/off" + }, + { + "name": "class", + "type": "uint32" + } + ], + "id": "libvirt-33" +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "return": [ + ], + "id": "libvirt-35" +} + +{ + "return": [ + { "name": "pc-1.3", "cpu-max": 255 }, @@ -2487,7 +2551,7 @@ "cpu-max": 255 } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -2568,7 +2632,7 @@ "name": "qemu64" } ], - "id": "libvirt-34" + "id": "libvirt-37" } { @@ -2576,21 +2640,21 @@ "enabled": false, "present": true }, - "id": "libvirt-35" + "id": "libvirt-38" } { "return": [ "tpm-tis" ], - "id": "libvirt-36" + "id": "libvirt-39" } { "return": [ "passthrough" ], - "id": "libvirt-37" + "id": "libvirt-40" } { @@ -3450,7 +3514,7 @@ "option": "drive" } ], - "id": "libvirt-38" + "id": "libvirt-41" } { @@ -3472,5 +3536,5 @@ "capability": "zero-blocks" } ], - "id": "libvirt-39" + "id": "libvirt-42" } diff --git a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps index d67a48d..ab8357d 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps @@ -167,4 +167,5 @@ <flag name='virtio-mouse'/> <flag name='virtio-tablet'/> <flag name='virtio-input-host'/> + <flag name='virtio-balloon-pci.deflate-on-oom'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_2.4.0-1.replies b/tests/qemucapabilitiesdata/caps_2.4.0-1.replies index 8f50128..3381377 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0-1.replies +++ b/tests/qemucapabilitiesdata/caps_2.4.0-1.replies @@ -2761,6 +2761,138 @@ { "return": [ { + "name": "guest-stats-polling-interval", + "type": "int" + }, + { + "name": "guest-stats", + "type": "guest statistics" + }, + { + "name": "any_layout", + "description": "on/off", + "type": "bool" + }, + { + "name": "notify_on_empty", + "description": "on/off", + "type": "bool" + }, + { + "name": "event_idx", + "description": "on/off", + "type": "bool" + }, + { + "name": "indirect_desc", + "description": "on/off", + "type": "bool" + }, + { + "name": "deflate-on-oom", + "description": "on/off", + "type": "bool" + }, + { + "name": "virtio-backend", + "type": "child<virtio-balloon-device>" + }, + { + "name": "command_serr_enable", + "description": "on/off", + "type": "bool" + }, + { + "name": "multifunction", + "description": "on/off", + "type": "bool" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "romfile", + "type": "str" + }, + { + "name": "addr", + "description": "Slot and optional function number, example: 06.0 or 06", + "type": "int32" + }, + { + "name": "disable-modern", + "description": "on/off", + "type": "bool" + }, + { + "name": "disable-legacy", + "description": "on/off", + "type": "bool" + }, + { + "name": "virtio-pci-bus-master-bug-migration", + "description": "on/off", + "type": "bool" + }, + { + "name": "class", + "type": "uint32" + } + ], + "id": "libvirt-33" +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "return": [ + { + "name": "guest-stats-polling-interval", + "type": "int" + }, + { + "name": "guest-stats", + "type": "guest statistics" + }, + { + "name": "any_layout", + "description": "on/off", + "type": "bool" + }, + { + "name": "notify_on_empty", + "description": "on/off", + "type": "bool" + }, + { + "name": "event_idx", + "description": "on/off", + "type": "bool" + }, + { + "name": "indirect_desc", + "description": "on/off", + "type": "bool" + }, + { + "name": "deflate-on-oom", + "description": "on/off", + "type": "bool" + } + ], + "id": "libvirt-35" +} + +{ + "return": [ + { "name": "pc-i440fx-2.4", "is-default": true, "cpu-max": 255, @@ -2884,7 +3016,7 @@ "cpu-max": 255 } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -2974,7 +3106,7 @@ "name": "qemu64" } ], - "id": "libvirt-34" + "id": "libvirt-37" } { @@ -2982,21 +3114,21 @@ "enabled": false, "present": true }, - "id": "libvirt-35" + "id": "libvirt-38" } { "return": [ "tpm-tis" ], - "id": "libvirt-36" + "id": "libvirt-39" } { "return": [ "passthrough" ], - "id": "libvirt-37" + "id": "libvirt-40" } { @@ -4000,7 +4132,7 @@ "option": "drive" } ], - "id": "libvirt-38" + "id": "libvirt-41" } { @@ -4030,5 +4162,5 @@ "capability": "events" } ], - "id": "libvirt-39" + "id": "libvirt-42" } diff --git a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps index f4f3673..e3c7d14 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps @@ -168,4 +168,5 @@ <flag name='virtio-mouse'/> <flag name='virtio-tablet'/> <flag name='virtio-input-host'/> + <flag name='virtio-balloon-pci.deflate-on-oom'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_2.5.0-1.replies b/tests/qemucapabilitiesdata/caps_2.5.0-1.replies index d90a74b..29429f6 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0-1.replies +++ b/tests/qemucapabilitiesdata/caps_2.5.0-1.replies @@ -2766,6 +2766,153 @@ { "return": [ { + "name": "disable-modern", + "description": "on/off", + "type": "bool" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "virtio-pci-bus-master-bug-migration", + "description": "on/off", + "type": "bool" + }, + { + "name": "class", + "type": "uint32" + }, + { + "name": "indirect_desc", + "description": "on/off", + "type": "bool" + }, + { + "name": "guest-stats-polling-interval", + "type": "int" + }, + { + "name": "guest-stats", + "type": "guest statistics" + }, + { + "name": "multifunction", + "description": "on/off", + "type": "bool" + }, + { + "name": "migrate-extra", + "description": "on/off", + "type": "bool" + }, + { + "name": "event_idx", + "description": "on/off", + "type": "bool" + }, + { + "name": "modern-pio-notify", + "description": "on/off", + "type": "bool" + }, + { + "name": "romfile", + "type": "str" + }, + { + "name": "virtio-backend", + "type": "child<virtio-balloon-device>" + }, + { + "name": "disable-legacy", + "description": "on/off", + "type": "bool" + }, + { + "name": "command_serr_enable", + "description": "on/off", + "type": "bool" + }, + { + "name": "x-disable-pcie", + "description": "on/off", + "type": "bool" + }, + { + "name": "addr", + "description": "Slot and optional function number, example: 06.0 or 06", + "type": "int32" + }, + { + "name": "any_layout", + "description": "on/off", + "type": "bool" + }, + { + "name": "notify_on_empty", + "description": "on/off", + "type": "bool" + }, + { + "name": "deflate-on-oom", + "description": "on/off", + "type": "bool" + } + ], + "id": "libvirt-33" +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "return": [ + { + "name": "notify_on_empty", + "description": "on/off", + "type": "bool" + }, + { + "name": "any_layout", + "description": "on/off", + "type": "bool" + }, + { + "name": "indirect_desc", + "description": "on/off", + "type": "bool" + }, + { + "name": "guest-stats-polling-interval", + "type": "int" + }, + { + "name": "guest-stats", + "type": "guest statistics" + }, + { + "name": "event_idx", + "description": "on/off", + "type": "bool" + }, + { + "name": "deflate-on-oom", + "description": "on/off", + "type": "bool" + } + ], + "id": "libvirt-35" +} + +{ + "return": [ + { "name": "pc-i440fx-2.4", "is-default": true, "cpu-max": 255, @@ -2889,7 +3036,7 @@ "cpu-max": 255 } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -2979,7 +3126,7 @@ "name": "qemu64" } ], - "id": "libvirt-34" + "id": "libvirt-37" } { @@ -2987,21 +3134,21 @@ "enabled": false, "present": true }, - "id": "libvirt-35" + "id": "libvirt-38" } { "return": [ "tpm-tis" ], - "id": "libvirt-36" + "id": "libvirt-39" } { "return": [ "passthrough" ], - "id": "libvirt-37" + "id": "libvirt-40" } { @@ -4005,7 +4152,7 @@ "option": "drive" } ], - "id": "libvirt-38" + "id": "libvirt-41" } { @@ -4035,5 +4182,5 @@ "capability": "events" } ], - "id": "libvirt-39" + "id": "libvirt-42" } diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-1.caps b/tests/qemucapabilitiesdata/caps_2.6.0-1.caps index e296efc..2adb3c6 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.6.0-1.caps @@ -170,4 +170,5 @@ <flag name='virtio-tablet'/> <flag name='virtio-input-host'/> <flag name='chardev-file-append'/> + <flag name='virtio-balloon-pci.deflate-on-oom'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-1.replies b/tests/qemucapabilitiesdata/caps_2.6.0-1.replies index 90a1d61..5d33fc9 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-1.replies +++ b/tests/qemucapabilitiesdata/caps_2.6.0-1.replies @@ -2766,6 +2766,153 @@ { "return": [ { + "name": "disable-modern", + "description": "on/off", + "type": "bool" + }, + { + "name": "rombar", + "type": "uint32" + }, + { + "name": "virtio-pci-bus-master-bug-migration", + "description": "on/off", + "type": "bool" + }, + { + "name": "class", + "type": "uint32" + }, + { + "name": "indirect_desc", + "description": "on/off", + "type": "bool" + }, + { + "name": "guest-stats-polling-interval", + "type": "int" + }, + { + "name": "guest-stats", + "type": "guest statistics" + }, + { + "name": "multifunction", + "description": "on/off", + "type": "bool" + }, + { + "name": "migrate-extra", + "description": "on/off", + "type": "bool" + }, + { + "name": "event_idx", + "description": "on/off", + "type": "bool" + }, + { + "name": "modern-pio-notify", + "description": "on/off", + "type": "bool" + }, + { + "name": "romfile", + "type": "str" + }, + { + "name": "virtio-backend", + "type": "child<virtio-balloon-device>" + }, + { + "name": "disable-legacy", + "description": "on/off", + "type": "bool" + }, + { + "name": "command_serr_enable", + "description": "on/off", + "type": "bool" + }, + { + "name": "x-disable-pcie", + "description": "on/off", + "type": "bool" + }, + { + "name": "addr", + "description": "Slot and optional function number, example: 06.0 or 06", + "type": "int32" + }, + { + "name": "any_layout", + "description": "on/off", + "type": "bool" + }, + { + "name": "notify_on_empty", + "description": "on/off", + "type": "bool" + }, + { + "name": "deflate-on-oom", + "description": "on/off", + "type": "bool" + } + ], + "id": "libvirt-33" +} + +{ + "id": "libvirt-34", + "error": { + "class": "DeviceNotFound", + "desc": "Device 'virtio-balloon-ccw' not found" + } +} + +{ + "return": [ + { + "name": "notify_on_empty", + "description": "on/off", + "type": "bool" + }, + { + "name": "any_layout", + "description": "on/off", + "type": "bool" + }, + { + "name": "indirect_desc", + "description": "on/off", + "type": "bool" + }, + { + "name": "guest-stats-polling-interval", + "type": "int" + }, + { + "name": "guest-stats", + "type": "guest statistics" + }, + { + "name": "event_idx", + "description": "on/off", + "type": "bool" + }, + { + "name": "deflate-on-oom", + "description": "on/off", + "type": "bool" + } + ], + "id": "libvirt-35" +} + +{ + "return": [ + { "name": "pc-i440fx-2.4", "is-default": true, "cpu-max": 255, @@ -2889,7 +3036,7 @@ "cpu-max": 255 } ], - "id": "libvirt-33" + "id": "libvirt-36" } { @@ -2979,7 +3126,7 @@ "name": "qemu64" } ], - "id": "libvirt-34" + "id": "libvirt-37" } { @@ -2987,21 +3134,21 @@ "enabled": false, "present": true }, - "id": "libvirt-35" + "id": "libvirt-38" } { "return": [ "tpm-tis" ], - "id": "libvirt-36" + "id": "libvirt-39" } { "return": [ "passthrough" ], - "id": "libvirt-37" + "id": "libvirt-40" } { @@ -4009,7 +4156,7 @@ "option": "drive" } ], - "id": "libvirt-38" + "id": "libvirt-41" } { @@ -4039,5 +4186,5 @@ "capability": "events" } ], - "id": "libvirt-39" + "id": "libvirt-42" } -- 1.8.3.1

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 1f05935..3b480f2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5709,6 +5709,17 @@ qemuBuildMemballoonDevStr(virDomainDefPtr def, if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0) goto error; + if (dev->autodeflate != VIR_TRISTATE_SWITCH_ABSENT) { + 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..86f6336 --- /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,format=raw,if=none,id=drive-ide0-0-0 \ +-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..9a0332f --- /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,format=raw,if=none,id=drive-ide0-0-0 \ +-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 63480ce..79a5c7c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1195,6 +1195,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); -- 1.8.3.1

On 01/08/2016 05:45 AM, Dmitry Andreev wrote:
This patch-set adds support for the new feature 'deflate-on-oom' that has been added to the QEMU virtio memory balloon a month ago. This feature lets a guest OS deflate balloon on OOM.
With 'deflate-on-oom' enabled virtio balloon will release it's memory if possible right before an OOM termination of processes.
QEMU commit with the complete feature description: http://git.qemu.org/?p=qemu.git;a=commit;h=e3816255bf4b6377bb405331e2ee0dc14...
v3 * pull head & merge * reword commit message [1/3] [2/3] * docs: s/OOM-/Out of Memory / [1/3] * merge and fix qemu 2.6.0 caps test [2/3] * s/> 0/ != VIR_TRISTATE_SWITCH_ABSENT/ [3/3]
Dmitry Andreev (3): conf: introduce 'autodeflate' attribute for memballoon device qemu: add capability check for memballoon 'deflate-on-oom' feature qemu: add support of optional 'autodeflate' attribute
docs/formatdomain.html.in | 10 ++ docs/schemas/domaincommon.rng | 5 + src/conf/domain_conf.c | 23 +++ src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 11 ++ src/qemu/qemu_capabilities.h | 2 + src/qemu/qemu_command.c | 11 ++ tests/qemucapabilitiesdata/caps_1.2.2-1.replies | 68 ++++++++- tests/qemucapabilitiesdata/caps_1.3.1-1.replies | 68 ++++++++- tests/qemucapabilitiesdata/caps_1.4.2-1.replies | 68 ++++++++- tests/qemucapabilitiesdata/caps_1.5.3-1.replies | 66 ++++++++- tests/qemucapabilitiesdata/caps_1.6.0-1.replies | 66 ++++++++- tests/qemucapabilitiesdata/caps_1.6.50-1.replies | 66 ++++++++- tests/qemucapabilitiesdata/caps_2.1.1-1.replies | 78 +++++++++- tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.4.0-1.replies | 146 ++++++++++++++++++- tests/qemucapabilitiesdata/caps_2.5.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.5.0-1.replies | 161 ++++++++++++++++++++- tests/qemucapabilitiesdata/caps_2.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.6.0-1.replies | 161 ++++++++++++++++++++- .../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 ++ 29 files changed, 1145 insertions(+), 70 deletions(-) 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
Had to update/merge in recent caps changes... Also had the same wierd problem in domain_conf.c and qemu_command.c w/r/t 'git am -3' merging code into wrong place... ACK - will push shortly (this was done before freeze, but I only got to it today...Prior version only needed minor updates... The default setting is to not enable feature, so should be safe.) Tks - John

On Tue, Jan 12, 2016 at 10:44:58AM -0500, John Ferlan wrote:
On 01/08/2016 05:45 AM, Dmitry Andreev wrote:
This patch-set adds support for the new feature 'deflate-on-oom' that has been added to the QEMU virtio memory balloon a month ago. This feature lets a guest OS deflate balloon on OOM.
With 'deflate-on-oom' enabled virtio balloon will release it's memory if possible right before an OOM termination of processes.
QEMU commit with the complete feature description: http://git.qemu.org/?p=qemu.git;a=commit;h=e3816255bf4b6377bb405331e2ee0dc14...
v3 * pull head & merge * reword commit message [1/3] [2/3] * docs: s/OOM-/Out of Memory / [1/3] * merge and fix qemu 2.6.0 caps test [2/3] * s/> 0/ != VIR_TRISTATE_SWITCH_ABSENT/ [3/3]
Dmitry Andreev (3): conf: introduce 'autodeflate' attribute for memballoon device qemu: add capability check for memballoon 'deflate-on-oom' feature qemu: add support of optional 'autodeflate' attribute
Had to update/merge in recent caps changes... Also had the same wierd problem in domain_conf.c and qemu_command.c w/r/t 'git am -3' merging code into wrong place...
ACK - will push shortly (this was done before freeze, but I only got to it today...Prior version only needed minor updates... The default setting is to not enable feature, so should be safe.)
That effectively disables the freeze. https://www.redhat.com/archives/libvir-list/2015-February/msg01079.html This series is not safe - it introduces an invalid free in the XML parser, giving the user with a read-write connection a possibility to crash libvirtd before we get to the ACL checks. Jan

This series is not safe - it introduces an invalid free in the XML parser, giving the user with a read-write connection a possibility to crash libvirtd before we get to the ACL checks.
Based on the lack of details, I assume you may be referring to: @@ -11327,6 +11327,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, unsigned int flags) { char *model; + char *deflate; virDomainMemballoonDefPtr def; Where deflate should be set to NULL. I don't have the time/desire to chase down empirical evidence, but from memory this is not the first time a missed initialization such as this has occurred during a freeze. Simple enough adjustment. John
participants (3)
-
Dmitry Andreev
-
John Ferlan
-
Ján Tomko