--- docs/formatdomain.html.in | 14 ++++++++++++++ docs/schemas/domaincommon.rng | 12 ++++++++++++ src/conf/domain_conf.c | 30 +++++++++++++++++++++++++++--- src/conf/domain_conf.h | 2 ++ 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3875167..c56a793 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1686,6 +1686,20 @@ default read-write access is given (currently only works for QEMU/KVM driver). </dd> + + <dt><code>space_hard_limit</code></dt> + <dd> + Maximum space available to this guest's filesystem. + <span class="since">Since 0.9.13</span> + </dd> + + <dt><code>space_soft_limit</code></dt> + <dd> + Maximum space available to this guest's filesystem. The container is + permitted to exceed its soft limits for a grace period of time. Afterwards the + hard limit is enforced. + <span class="since">Since 0.9.13</span> + </dd> </dl> <h4><a name="elementsAddress">Device Addresses</a></h4> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 34f63c3..62c28c8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1316,6 +1316,18 @@ <ref name="address"/> </optional> </interleave> + <interleave> + <optional> + <element name="space_hard_limit"> + <ref name='scaledInteger'/> + </element> + </optional> + <optional> + <element name="space_soft_limit"> + <ref name='scaledInteger'/> + </element> + </optional> + </interleave> </element> </define> <!-- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5ac911e..a75e7e8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4200,9 +4200,10 @@ cleanup: */ static virDomainFSDefPtr virDomainFSDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, unsigned int flags) { virDomainFSDefPtr def; - xmlNodePtr cur; + xmlNodePtr cur, save_node = ctxt->node; char *type = NULL; char *fsdriver = NULL; char *source = NULL; @@ -4210,6 +4211,8 @@ virDomainFSDefParseXML(xmlNodePtr node, char *accessmode = NULL; char *wrpolicy = NULL; + ctxt->node = node; + if (VIR_ALLOC(def) < 0) { virReportOOMError(); return NULL; @@ -4237,6 +4240,18 @@ virDomainFSDefParseXML(xmlNodePtr node, def->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH; } + if (virDomainParseScaledValue("./space_hard_limit[1]", ctxt, + &def->space_hard_limit, 1, + ULONG_LONG_MAX, + false) < 0) + goto error; + + if (virDomainParseScaledValue("./space_soft_limit[1]", ctxt, + &def->space_soft_limit, 1, + ULONG_LONG_MAX, + false) < 0) + goto error; + cur = node->children; while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE) { @@ -4303,6 +4318,7 @@ virDomainFSDefParseXML(xmlNodePtr node, goto error; cleanup: + ctxt->node = save_node; VIR_FREE(type); VIR_FREE(fsdriver); VIR_FREE(target); @@ -7076,7 +7092,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, goto error; } else if (xmlStrEqual(node->name, BAD_CAST "filesystem")) { dev->type = VIR_DOMAIN_DEVICE_FS; - if (!(dev->data.fs = virDomainFSDefParseXML(node, flags))) + if (!(dev->data.fs = virDomainFSDefParseXML(node, ctxt, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "interface")) { dev->type = VIR_DOMAIN_DEVICE_NET; @@ -8621,7 +8637,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (n && VIR_ALLOC_N(def->fss, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainFSDefPtr fs = virDomainFSDefParseXML(nodes[i], + virDomainFSDefPtr fs = virDomainFSDefParseXML(nodes[i], ctxt, flags); if (!fs) goto error; @@ -11319,6 +11335,14 @@ virDomainFSDefFormat(virBufferPtr buf, if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) return -1; + + if (def->space_hard_limit) + virBufferAsprintf(buf, " <space_hard_limit unit='B'>" + "%llu</space_hard_limit>\n", def->space_hard_limit); + if (def->space_soft_limit) { + virBufferAsprintf(buf, " <space_soft_limit unit='B'>" + "%llu</space_soft_limit>\n", def->space_soft_limit); + } virBufferAddLit(buf, " </filesystem>\n"); return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4c56902..8d5b35a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -699,6 +699,8 @@ struct _virDomainFSDef { char *dst; unsigned int readonly : 1; virDomainDeviceInfo info; + unsigned long long space_hard_limit; /* in bytes */ + unsigned long long space_soft_limit; /* in bytes */ }; -- 1.7.10 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list