mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
conf: Refactor/rename virDomainDiskDefSourceParse
Make the function more usable by returning the full disk definition and fix the only caller for the new semantics. The new name for the function is virDomainDiskDefParse. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
dff110d232
commit
295b128e09
@ -15864,44 +15864,35 @@ virDomainDeviceDefParse(const char *xmlStr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virStorageSourcePtr
|
virDomainDiskDefPtr
|
||||||
virDomainDiskDefSourceParse(const char *xmlStr,
|
virDomainDiskDefParse(const char *xmlStr,
|
||||||
const virDomainDef *def,
|
const virDomainDef *def,
|
||||||
virDomainXMLOptionPtr xmlopt,
|
virDomainXMLOptionPtr xmlopt,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
xmlDocPtr xml;
|
xmlDocPtr xml;
|
||||||
xmlNodePtr node;
|
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
virDomainDiskDefPtr disk = NULL;
|
virDomainDiskDefPtr disk = NULL;
|
||||||
virStorageSourcePtr ret = NULL;
|
|
||||||
|
|
||||||
if (!(xml = virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &ctxt)))
|
if (!(xml = virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &ctxt)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
node = ctxt->node;
|
|
||||||
|
|
||||||
if (!virXMLNodeNameEqual(node, "disk")) {
|
if (!virXMLNodeNameEqual(ctxt->node, "disk")) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("expecting root element of 'disk', not '%s'"),
|
_("expecting root element of 'disk', not '%s'"),
|
||||||
node->name);
|
ctxt->node->name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags |= VIR_DOMAIN_DEF_PARSE_DISK_SOURCE;
|
disk = virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt,
|
||||||
if (!(disk = virDomainDiskDefParseXML(xmlopt, node, ctxt,
|
NULL, def->seclabels,
|
||||||
NULL, def->seclabels,
|
def->nseclabels,
|
||||||
def->nseclabels,
|
flags);
|
||||||
flags)))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = disk->src;
|
|
||||||
disk->src = NULL;
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDiskDefFree(disk);
|
|
||||||
xmlFreeDoc(xml);
|
xmlFreeDoc(xml);
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
return ret;
|
return disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2935,10 +2935,10 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
|
|||||||
virCapsPtr caps,
|
virCapsPtr caps,
|
||||||
virDomainXMLOptionPtr xmlopt,
|
virDomainXMLOptionPtr xmlopt,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
virStorageSourcePtr virDomainDiskDefSourceParse(const char *xmlStr,
|
virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr,
|
||||||
const virDomainDef *def,
|
const virDomainDef *def,
|
||||||
virDomainXMLOptionPtr xmlopt,
|
virDomainXMLOptionPtr xmlopt,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
|
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
|
||||||
virCapsPtr caps,
|
virCapsPtr caps,
|
||||||
virDomainXMLOptionPtr xmlopt,
|
virDomainXMLOptionPtr xmlopt,
|
||||||
|
@ -315,7 +315,7 @@ virDomainDiskDefCheckDuplicateInfo;
|
|||||||
virDomainDiskDefForeachPath;
|
virDomainDiskDefForeachPath;
|
||||||
virDomainDiskDefFree;
|
virDomainDiskDefFree;
|
||||||
virDomainDiskDefNew;
|
virDomainDiskDefNew;
|
||||||
virDomainDiskDefSourceParse;
|
virDomainDiskDefParse;
|
||||||
virDomainDiskDetectZeroesTypeFromString;
|
virDomainDiskDetectZeroesTypeFromString;
|
||||||
virDomainDiskDetectZeroesTypeToString;
|
virDomainDiskDetectZeroesTypeToString;
|
||||||
virDomainDiskDeviceTypeToString;
|
virDomainDiskDeviceTypeToString;
|
||||||
|
@ -17456,6 +17456,7 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
|
|||||||
unsigned long long bandwidth = 0;
|
unsigned long long bandwidth = 0;
|
||||||
unsigned int granularity = 0;
|
unsigned int granularity = 0;
|
||||||
unsigned long long buf_size = 0;
|
unsigned long long buf_size = 0;
|
||||||
|
virDomainDiskDefPtr diskdef = NULL;
|
||||||
virStorageSourcePtr dest = NULL;
|
virStorageSourcePtr dest = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -17508,14 +17509,18 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dest = virDomainDiskDefSourceParse(destxml, vm->def, driver->xmlopt,
|
if (!(diskdef = virDomainDiskDefParse(destxml, vm->def, driver->xmlopt,
|
||||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||||
|
VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
VIR_STEAL_PTR(dest, diskdef->src);
|
||||||
|
|
||||||
ret = qemuDomainBlockCopyCommon(vm, dom->conn, disk, dest, bandwidth,
|
ret = qemuDomainBlockCopyCommon(vm, dom->conn, disk, dest, bandwidth,
|
||||||
granularity, buf_size, flags, false);
|
granularity, buf_size, flags, false);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virDomainDiskDefFree(diskdef);
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user