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:
parent
c0e5c370c8
commit
567efa85c2
@ -13606,28 +13606,22 @@ 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"))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("shmem element must contain 'name' attribute"));
|
_("shmem element must contain 'name' attribute"));
|
||||||
@ -13635,20 +13629,11 @@ 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;
|
|
||||||
if ((role = virDomainShmemRoleTypeFromString(tmp)) <= 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Unknown shmem role type '%s'"), tmp);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
def->role = role;
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virParseScaledValue("./size[1]", NULL, ctxt,
|
if (virParseScaledValue("./size[1]", NULL, ctxt,
|
||||||
&def->size, 1, ULLONG_MAX, false) < 0)
|
&def->size, 1, ULLONG_MAX, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -13666,27 +13651,14 @@ 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)
|
||||||
|
|
||||||
if ((val = virTristateSwitchTypeFromString(tmp)) <= 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("invalid msi ioeventfd setting for shmem: '%s'"),
|
|
||||||
tmp);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
def->msi.ioeventfd = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* msi option is only relevant with a server */
|
/* msi option is only relevant with a server */
|
||||||
if (def->msi.enabled && !def->server.enabled) {
|
if (def->msi.enabled && !def->server.enabled) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user