mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
Introduce filesystem limits to virDomainFSDef
This commit is contained in:
parent
b46e005459
commit
41f1db6a0c
@ -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>
|
||||
|
@ -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>
|
||||
<!--
|
||||
|
@ -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='bytes'>"
|
||||
"%llu</space_hard_limit>\n", def->space_hard_limit);
|
||||
if (def->space_soft_limit) {
|
||||
virBufferAsprintf(buf, " <space_soft_limit unit='bytes'>"
|
||||
"%llu</space_soft_limit>\n", def->space_soft_limit);
|
||||
}
|
||||
virBufferAddLit(buf, " </filesystem>\n");
|
||||
|
||||
return 0;
|
||||
|
@ -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 */
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user