1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

virDomainShmemDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-04-27 17:04:38 +02:00 committed by Ján Tomko
parent c0e5c370c8
commit 567efa85c2

View File

@ -13606,26 +13606,20 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlopt,
xmlNodePtr msi = NULL; xmlNodePtr msi = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt) VIR_XPATH_NODE_AUTORESTORE(ctxt)
xmlNodePtr server = NULL; xmlNodePtr server = NULL;
xmlNodePtr model;
g_autofree char *tmp = NULL; g_autofree char *tmp = NULL;
def = g_new0(virDomainShmemDef, 1); def = g_new0(virDomainShmemDef, 1);
ctxt->node = node; ctxt->node = node;
tmp = virXPathString("string(./model/@type)", ctxt); if ((model = virXPathNode("./model", ctxt))) {
if (tmp) {
int model;
/* If there's none, we will automatically have the first one /* If there's none, we will automatically have the first one
* (as default). Unfortunately this has to be done for * (as default). Unfortunately this has to be done for
* compatibility reasons. */ * compatibility reasons. */
if ((model = virDomainShmemModelTypeFromString(tmp)) < 0) { if (virXMLPropEnum(model, "type", virDomainShmemModelTypeFromString,
virReportError(VIR_ERR_XML_ERROR, VIR_XML_PROP_NONE, &def->model) < 0)
_("Unknown shmem model type '%s'"), tmp);
goto cleanup; goto cleanup;
}
def->model = model;
VIR_FREE(tmp);
} }
if (!(def->name = virXMLPropString(node, "name"))) { if (!(def->name = virXMLPropString(node, "name"))) {
@ -13635,18 +13629,9 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlopt,
} }
if (def->model != VIR_DOMAIN_SHMEM_MODEL_IVSHMEM) { if (def->model != VIR_DOMAIN_SHMEM_MODEL_IVSHMEM) {
tmp = virXMLPropString(node, "role"); if (virXMLPropEnum(node, "role", virDomainShmemRoleTypeFromString,
if (tmp) { VIR_XML_PROP_NONZERO, &def->role) < 0)
int role; goto cleanup;
if ((role = virDomainShmemRoleTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Unknown shmem role type '%s'"), tmp);
goto cleanup;
}
def->role = role;
VIR_FREE(tmp);
}
} }
if (virParseScaledValue("./size[1]", NULL, ctxt, if (virParseScaledValue("./size[1]", NULL, ctxt,
@ -13666,26 +13651,13 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlopt,
if ((msi = virXPathNode("./msi[1]", ctxt))) { if ((msi = virXPathNode("./msi[1]", ctxt))) {
def->msi.enabled = true; def->msi.enabled = true;
if ((tmp = virXMLPropString(msi, "vectors")) && if (virXMLPropUInt(msi, "vectors", 0, VIR_XML_PROP_NONE,
virStrToLong_uip(tmp, NULL, 0, &def->msi.vectors) < 0) { &def->msi.vectors) < 0)
virReportError(VIR_ERR_XML_ERROR,
_("invalid number of vectors for shmem: '%s'"),
tmp);
goto cleanup; goto cleanup;
}
VIR_FREE(tmp);
if ((tmp = virXMLPropString(msi, "ioeventfd"))) { if (virXMLPropTristateSwitch(msi, "ioeventfd", VIR_XML_PROP_NONE,
int val; &def->msi.ioeventfd) < 0)
goto cleanup;
if ((val = virTristateSwitchTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid msi ioeventfd setting for shmem: '%s'"),
tmp);
goto cleanup;
}
def->msi.ioeventfd = val;
}
} }
/* msi option is only relevant with a server */ /* msi option is only relevant with a server */