mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 14:03:49 +03:00
conf: refactor virDomainResourceDefParse
There is no need to error out for empty <partition></partition> element as we can just simply ignore it. This allows to simplify the function and prepare it for new sub-elements of <resource>. It makes the <partition> element optional so we need to reflect the change in schema as well. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
10c2c0b249
commit
77b53057c7
@ -1172,9 +1172,11 @@
|
||||
|
||||
<define name="respartition">
|
||||
<element name="resource">
|
||||
<element name="partition">
|
||||
<ref name="absFilePath"/>
|
||||
</element>
|
||||
<optional>
|
||||
<element name="partition">
|
||||
<ref name="absFilePath"/>
|
||||
</element>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
|
@ -17284,23 +17284,19 @@ virDomainResourceDefParse(xmlNodePtr node,
|
||||
{
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
virDomainResourceDef *def = NULL;
|
||||
char *partition = NULL;
|
||||
|
||||
ctxt->node = node;
|
||||
|
||||
def = g_new0(virDomainResourceDef, 1);
|
||||
partition = virXPathString("string(./partition)", ctxt);
|
||||
|
||||
/* Find out what type of virtualization to use */
|
||||
if (!(def->partition = virXPathString("string(./partition)", ctxt))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("missing resource partition attribute"));
|
||||
goto error;
|
||||
}
|
||||
if (!partition)
|
||||
return NULL;
|
||||
|
||||
def = g_new0(virDomainResourceDef, 1);
|
||||
def->partition = partition;
|
||||
|
||||
return def;
|
||||
|
||||
error:
|
||||
virDomainResourceDefFree(def);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user