1
0
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:
Pavel Hrdina 2021-08-05 15:27:17 +02:00
parent 10c2c0b249
commit 77b53057c7
2 changed files with 12 additions and 14 deletions

View File

@ -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>

View File

@ -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;
}