static int
virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
- virDomainHostdevSubsysSCSIPtr def)
+ virDomainHostdevSubsysSCSIPtr def,
+ xmlXPathContextPtr ctxt)
{
int ret = -1;
int auth_secret_usage = -1;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE &&
virXMLNodeNameEqual(cur, "auth")) {
- if (!(authdef = virStorageAuthDefParse(sourcenode->doc, cur)))
+ if (!(authdef = virStorageAuthDefParse(cur, ctxt)))
goto cleanup;
if ((auth_secret_usage =
virSecretUsageTypeFromString(authdef->secrettype)) < 0) {
static int
virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,
- virDomainHostdevSubsysSCSIPtr scsisrc)
+ virDomainHostdevSubsysSCSIPtr scsisrc,
+ xmlXPathContextPtr ctxt)
{
char *protocol = NULL;
int ret = -1;
}
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
- ret = virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsisrc);
+ ret = virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsisrc, ctxt);
else
ret = virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc);
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
- if (virDomainHostdevSubsysSCSIDefParseXML(sourcenode, scsisrc) < 0)
+ if (virDomainHostdevSubsysSCSIDefParseXML(sourcenode, scsisrc, ctxt) < 0)
goto error;
break;
static int
virDomainDiskSourceAuthParse(xmlNodePtr node,
- virStorageAuthDefPtr *authdefsrc)
+ virStorageAuthDefPtr *authdefsrc,
+ xmlXPathContextPtr ctxt)
{
xmlNodePtr child;
virStorageAuthDefPtr authdef;
if (child->type == XML_ELEMENT_NODE &&
virXMLNodeNameEqual(child, "auth")) {
- if (!(authdef = virStorageAuthDefParse(node->doc, child)))
+ if (!(authdef = virStorageAuthDefParse(child, ctxt)))
return -1;
*authdefsrc = authdef;
goto cleanup;
}
- if (virDomainDiskSourceAuthParse(node, &src->auth) < 0)
+ if (virDomainDiskSourceAuthParse(node, &src->auth, ctxt) < 0)
goto cleanup;
if (virDomainDiskSourceEncryptionParse(node, &src->encryption) < 0)
goto error;
}
- if (!(authdef = virStorageAuthDefParse(node->doc, cur)))
+ if (!(authdef = virStorageAuthDefParse(cur, ctxt)))
goto error;
} else if (virXMLNodeNameEqual(cur, "iotune")) {
if (virDomainDiskDefIotuneParse(def, ctxt) < 0)
}
-static virStorageAuthDefPtr
-virStorageAuthDefParseXML(xmlXPathContextPtr ctxt)
+virStorageAuthDefPtr
+virStorageAuthDefParse(xmlNodePtr node,
+ xmlXPathContextPtr ctxt)
{
+ xmlNodePtr saveNode = ctxt->node;
virStorageAuthDefPtr authdef = NULL;
virStorageAuthDefPtr ret = NULL;
xmlNodePtr secretnode = NULL;
char *authtype = NULL;
+ ctxt->node = node;
+
if (VIR_ALLOC(authdef) < 0)
- return NULL;
+ goto cleanup;
if (!(authdef->username = virXPathString("string(./@username)", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
cleanup:
VIR_FREE(authtype);
virStorageAuthDefFree(authdef);
+ ctxt->node = saveNode;
return ret;
}
-virStorageAuthDefPtr
-virStorageAuthDefParse(xmlDocPtr xml, xmlNodePtr root)
-{
- xmlXPathContextPtr ctxt = NULL;
- virStorageAuthDefPtr authdef = NULL;
-
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
- goto cleanup;
- }
-
- ctxt->node = root;
- authdef = virStorageAuthDefParseXML(ctxt);
-
- cleanup:
- xmlXPathFreeContext(ctxt);
- return authdef;
-}
-
-
void
virStorageAuthDefFormat(virBufferPtr buf,
virStorageAuthDefPtr authdef)