diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ae7c0d9b71ab2332d32b8516f3aaca178fc0fee7..e2bad48cc887003c4241da75318bdf5077ca5724 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15864,44 +15864,35 @@ virDomainDeviceDefParse(const char *xmlStr, } -virStorageSourcePtr -virDomainDiskDefSourceParse(const char *xmlStr, - const virDomainDef *def, - virDomainXMLOptionPtr xmlopt, - unsigned int flags) +virDomainDiskDefPtr +virDomainDiskDefParse(const char *xmlStr, + const virDomainDef *def, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) { xmlDocPtr xml; - xmlNodePtr node; xmlXPathContextPtr ctxt = NULL; virDomainDiskDefPtr disk = NULL; - virStorageSourcePtr ret = NULL; if (!(xml = virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &ctxt))) goto cleanup; - node = ctxt->node; - if (!virXMLNodeNameEqual(node, "disk")) { + if (!virXMLNodeNameEqual(ctxt->node, "disk")) { virReportError(VIR_ERR_XML_ERROR, _("expecting root element of 'disk', not '%s'"), - node->name); + ctxt->node->name); goto cleanup; } - flags |= VIR_DOMAIN_DEF_PARSE_DISK_SOURCE; - if (!(disk = virDomainDiskDefParseXML(xmlopt, node, ctxt, - NULL, def->seclabels, - def->nseclabels, - flags))) - goto cleanup; - - ret = disk->src; - disk->src = NULL; + disk = virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt, + NULL, def->seclabels, + def->nseclabels, + flags); cleanup: - virDomainDiskDefFree(disk); xmlFreeDoc(xml); xmlXPathFreeContext(ctxt); - return ret; + return disk; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 61379e50fed5e2c65b23e49b3b4f6d7ac08fed86..650901c1f49b93eab6de45f3d10bfa7453d095db 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2935,10 +2935,10 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags); -virStorageSourcePtr virDomainDiskDefSourceParse(const char *xmlStr, - const virDomainDef *def, - virDomainXMLOptionPtr xmlopt, - unsigned int flags); +virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr, + const virDomainDef *def, + virDomainXMLOptionPtr xmlopt, + unsigned int flags); virDomainDefPtr virDomainDefParseString(const char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 989411cdcaa4a97d94862d9b5a141830c12476b9..73f25d1c79285a50ff85e596befa696a23dcf051 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -315,7 +315,7 @@ virDomainDiskDefCheckDuplicateInfo; virDomainDiskDefForeachPath; virDomainDiskDefFree; virDomainDiskDefNew; -virDomainDiskDefSourceParse; +virDomainDiskDefParse; virDomainDiskDetectZeroesTypeFromString; virDomainDiskDetectZeroesTypeToString; virDomainDiskDeviceTypeToString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 20c7cefccfa422a2507246da9d2d883375c32b9a..5c31dfdd58942a4b4f5fdc9411de7f3c335744ee 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17456,6 +17456,7 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml, unsigned long long bandwidth = 0; unsigned int granularity = 0; unsigned long long buf_size = 0; + virDomainDiskDefPtr diskdef = NULL; virStorageSourcePtr dest = NULL; size_t i; @@ -17508,14 +17509,18 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml, } } - if (!(dest = virDomainDiskDefSourceParse(destxml, vm->def, driver->xmlopt, - VIR_DOMAIN_DEF_PARSE_INACTIVE))) + if (!(diskdef = virDomainDiskDefParse(destxml, vm->def, driver->xmlopt, + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_DISK_SOURCE))) goto cleanup; + VIR_STEAL_PTR(dest, diskdef->src); + ret = qemuDomainBlockCopyCommon(vm, dom->conn, disk, dest, bandwidth, granularity, buf_size, flags, false); cleanup: + virDomainDiskDefFree(diskdef); virDomainObjEndAPI(&vm); return ret; }