[libvirt] [PATCHv2 1/3] conf: introduce 'autodeflate' attribute for memballoon device

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. Introduced attribute allows 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 a8bd48e..7d04471 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5954,6 +5954,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 OOM-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 4804c69..512a268 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3415,6 +3415,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 5200c27..0786d08 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11312,6 +11312,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, unsigned int flags) { char *model; + char *deflate; virDomainMemballoonDefPtr def; xmlNodePtr save = ctxt->node; unsigned int period = 0; @@ -11332,6 +11333,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", @@ -11350,6 +11358,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, cleanup: VIR_FREE(model); + VIR_FREE(deflate); ctxt->node = save; return def; @@ -17223,6 +17232,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; @@ -20400,6 +20418,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 952d3cc..31a0a05 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1634,6 +1634,7 @@ struct _virDomainMemballoonDef { int model; virDomainDeviceInfo info; int period; /* seconds between collections */ + int autodeflate; /* enum virTristateSwitch */ }; struct _virDomainNVRAMDef { -- 1.8.3.1

New attribute 'autodeflate' for memballoon was introduced. This commit adds appropriate capability check and new virQEMUCaps flag. --- 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 ++++++++++++++++++++++- 13 files changed, 739 insertions(+), 63 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6e5d203..74decbb 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -308,6 +308,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-tablet", /* 205 */ "virtio-input-host", + "virtio-balloon-pci.deflate-on-oom", ); @@ -1562,6 +1563,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 }, @@ -1704,6 +1709,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 61d6379..d76aa5a 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -335,6 +335,8 @@ typedef enum { /* 205 */ QEMU_CAPS_VIRTIO_TABLET, /* -device virtio-tablet-{device,pci} */ QEMU_CAPS_VIRTIO_INPUT_HOST, /* -device virtio-input-host-{device,pci} */ + 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" } -- 1.8.3.1

On 12/23/2015 07:33 AM, Dmitry Andreev wrote:
New attribute 'autodeflate' for memballoon was introduced. This commit adds appropriate capability check and new virQEMUCaps flag.
So I see from these changes and the qemu sources, the feature was added in QEMU 2.4; however, your cover letter indicates "the new feature 'deflate-on-oom' that has been added to the QEMU virtio memory balloon a month ago."... Since 2.5 was recently released it seems a bit more than a month ago... In any case, perhaps it's best to pull in that cover letter info into here (e.g at least the link to the qemu commit) so it's not just on libvir-list.
--- 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 ++++++++++++++++++++++- 13 files changed, 739 insertions(+), 63 deletions(-)
Since commit id '429b421' there's a 2.6.0-1 'caps' and 'replies' which you'll need to adjust as well. John
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6e5d203..74decbb 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -308,6 +308,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"virtio-tablet", /* 205 */ "virtio-input-host", + "virtio-balloon-pci.deflate-on-oom", );
@@ -1562,6 +1563,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 }, @@ -1704,6 +1709,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 61d6379..d76aa5a 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -335,6 +335,8 @@ typedef enum { /* 205 */ QEMU_CAPS_VIRTIO_TABLET, /* -device virtio-tablet-{device,pci} */ QEMU_CAPS_VIRTIO_INPUT_HOST, /* -device virtio-input-host-{device,pci} */ + 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" }

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) { + 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); -- 1.8.3.1

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);

On 12/23/2015 07:33 AM, Dmitry Andreev wrote:
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.
Introduced attribute allows to enable or disable this feature.
How about instead of that one sentence... 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 a8bd48e..7d04471 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5954,6 +5954,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 OOM-killer.
s/OOM-/Out of Memory / Yes, 99.999% of the world probably knows what OOM is...
+ <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 4804c69..512a268 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3415,6 +3415,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 5200c27..0786d08 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11312,6 +11312,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, unsigned int flags) { char *model; + char *deflate; virDomainMemballoonDefPtr def; xmlNodePtr save = ctxt->node; unsigned int period = 0; @@ -11332,6 +11333,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", @@ -11350,6 +11358,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
cleanup: VIR_FREE(model); + VIR_FREE(deflate);
ctxt->node = save; return def; @@ -17223,6 +17232,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; + } +
Very strange - not sure if it was because I had applied this on the most recent head, but this coded ended up being merged (via git am) into virDomainWatchdogDefCheckABIStability John
if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) return false;
@@ -20400,6 +20418,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 952d3cc..31a0a05 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1634,6 +1634,7 @@ struct _virDomainMemballoonDef { int model; virDomainDeviceInfo info; int period; /* seconds between collections */ + int autodeflate; /* enum virTristateSwitch */ };
struct _virDomainNVRAMDef {
participants (2)
-
Dmitry Andreev
-
John Ferlan