提交 7bf3198d 编写于 作者: D Dmitry Andreev 提交者: John Ferlan

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.

Introduce a new optional balloon device attribute 'autodeflate' to
enable or disable this feature.
上级 2eb7a975
...@@ -5962,6 +5962,16 @@ qemu-kvm -net nic,model=? /dev/null ...@@ -5962,6 +5962,16 @@ qemu-kvm -net nic,model=? /dev/null
<li>'xen' &mdash; default with Xen</li> <li>'xen' &mdash; default with Xen</li>
</ul> </ul>
</dd> </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> <dt><code>period</code></dt>
<dd> <dd>
<p> <p>
......
...@@ -3420,6 +3420,11 @@ ...@@ -3420,6 +3420,11 @@
<value>none</value> <value>none</value>
</choice> </choice>
</attribute> </attribute>
<optional>
<attribute name="autodeflate">
<ref name="virOnOff"/>
</attribute>
</optional>
<interleave> <interleave>
<optional> <optional>
<ref name="alias"/> <ref name="alias"/>
......
...@@ -11354,6 +11354,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, ...@@ -11354,6 +11354,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
unsigned int flags) unsigned int flags)
{ {
char *model; char *model;
char *deflate;
virDomainMemballoonDefPtr def; virDomainMemballoonDefPtr def;
xmlNodePtr save = ctxt->node; xmlNodePtr save = ctxt->node;
unsigned int period = 0; unsigned int period = 0;
...@@ -11374,6 +11375,13 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, ...@@ -11374,6 +11375,13 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
goto error; 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; ctxt->node = node;
if (virXPathUInt("string(./stats/@period)", ctxt, &period) < -1) { if (virXPathUInt("string(./stats/@period)", ctxt, &period) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
...@@ -11392,6 +11400,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, ...@@ -11392,6 +11400,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
cleanup: cleanup:
VIR_FREE(model); VIR_FREE(model);
VIR_FREE(deflate);
ctxt->node = save; ctxt->node = save;
return def; return def;
...@@ -17342,6 +17351,15 @@ virDomainMemballoonDefCheckABIStability(virDomainMemballoonDefPtr src, ...@@ -17342,6 +17351,15 @@ virDomainMemballoonDefCheckABIStability(virDomainMemballoonDefPtr src,
return false; 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)) if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
return false; return false;
...@@ -20523,6 +20541,11 @@ virDomainMemballoonDefFormat(virBufferPtr buf, ...@@ -20523,6 +20541,11 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
} }
virBufferAsprintf(buf, "<memballoon model='%s'", model); virBufferAsprintf(buf, "<memballoon model='%s'", model);
if (def->autodeflate != VIR_TRISTATE_SWITCH_ABSENT)
virBufferAsprintf(buf, " autodeflate='%s'",
virTristateSwitchTypeToString(def->autodeflate));
virBufferAdjustIndent(&childrenBuf, indent + 2); virBufferAdjustIndent(&childrenBuf, indent + 2);
if (def->period) if (def->period)
......
...@@ -1635,6 +1635,7 @@ struct _virDomainMemballoonDef { ...@@ -1635,6 +1635,7 @@ struct _virDomainMemballoonDef {
int model; int model;
virDomainDeviceInfo info; virDomainDeviceInfo info;
int period; /* seconds between collections */ int period; /* seconds between collections */
int autodeflate; /* enum virTristateSwitch */
}; };
struct _virDomainNVRAMDef { struct _virDomainNVRAMDef {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册