mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virDomainShmemDef: Use g_auto*
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
9cc23ee498
commit
0ed95ae926
@ -13601,15 +13601,11 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virDomainShmemDef *def = NULL;
|
g_autoptr(virDomainShmemDef) def = g_new0(virDomainShmemDef, 1);
|
||||||
virDomainShmemDef *ret = NULL;
|
|
||||||
xmlNodePtr msi = NULL;
|
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
|
||||||
xmlNodePtr server = NULL;
|
|
||||||
xmlNodePtr model;
|
xmlNodePtr model;
|
||||||
g_autofree char *tmp = NULL;
|
xmlNodePtr msi;
|
||||||
|
xmlNodePtr server;
|
||||||
def = g_new0(virDomainShmemDef, 1);
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
@ -13619,33 +13615,33 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
* compatibility reasons. */
|
* compatibility reasons. */
|
||||||
if (virXMLPropEnum(model, "type", virDomainShmemModelTypeFromString,
|
if (virXMLPropEnum(model, "type", virDomainShmemModelTypeFromString,
|
||||||
VIR_XML_PROP_NONE, &def->model) < 0)
|
VIR_XML_PROP_NONE, &def->model) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
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"));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->model != VIR_DOMAIN_SHMEM_MODEL_IVSHMEM) {
|
if (def->model != VIR_DOMAIN_SHMEM_MODEL_IVSHMEM) {
|
||||||
if (virXMLPropEnum(node, "role", virDomainShmemRoleTypeFromString,
|
if (virXMLPropEnum(node, "role", virDomainShmemRoleTypeFromString,
|
||||||
VIR_XML_PROP_NONZERO, &def->role) < 0)
|
VIR_XML_PROP_NONZERO, &def->role) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
return NULL;
|
||||||
|
|
||||||
if ((server = virXPathNode("./server[1]", ctxt))) {
|
if ((server = virXPathNode("./server[1]", ctxt))) {
|
||||||
def->server.enabled = true;
|
g_autofree char *tmp = NULL;
|
||||||
|
|
||||||
|
def->server.enabled = true;
|
||||||
def->server.chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
def->server.chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
||||||
def->server.chr.data.nix.listen = false;
|
def->server.chr.data.nix.listen = false;
|
||||||
if ((tmp = virXMLPropString(server, "path")))
|
if ((tmp = virXMLPropString(server, "path")))
|
||||||
def->server.chr.data.nix.path = virFileSanitizePath(tmp);
|
def->server.chr.data.nix.path = virFileSanitizePath(tmp);
|
||||||
VIR_FREE(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((msi = virXPathNode("./msi[1]", ctxt))) {
|
if ((msi = virXPathNode("./msi[1]", ctxt))) {
|
||||||
@ -13653,28 +13649,25 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
|
|
||||||
if (virXMLPropUInt(msi, "vectors", 0, VIR_XML_PROP_NONE,
|
if (virXMLPropUInt(msi, "vectors", 0, VIR_XML_PROP_NONE,
|
||||||
&def->msi.vectors) < 0)
|
&def->msi.vectors) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (virXMLPropTristateSwitch(msi, "ioeventfd", VIR_XML_PROP_NONE,
|
if (virXMLPropTristateSwitch(msi, "ioeventfd", VIR_XML_PROP_NONE,
|
||||||
&def->msi.ioeventfd) < 0)
|
&def->msi.ioeventfd) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("msi option is only supported with a server"));
|
_("msi option is only supported with a server"));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0)
|
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
|
|
||||||
ret = g_steal_pointer(&def);
|
return g_steal_pointer(&def);
|
||||||
cleanup:
|
|
||||||
virDomainShmemDefFree(def);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user