qemu: driver: Use virDomainDiskDefParseSource in qemuDomainBlockCopy

qemuDomainBlockCopy needs just the source portion of the disk but uses
the disk parser for it. Since we have a specific function now, refactor
the code to avoid having to deal with the unused virDomainDiskDef.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2021-04-14 16:43:22 +02:00
parent fb0238414e
commit 0202467c4b

View File

@ -15273,7 +15273,6 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
unsigned long long bandwidth = 0;
unsigned int granularity = 0;
unsigned long long buf_size = 0;
virDomainDiskDef *diskdef = NULL;
virStorageSource *dest = NULL;
size_t i;
@ -15326,18 +15325,14 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
}
}
if (!(diskdef = virDomainDiskDefParse(destxml, driver->xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE |
VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)))
if (!(dest = virDomainDiskDefParseSource(destxml, driver->xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto cleanup;
dest = g_steal_pointer(&diskdef->src);
ret = qemuDomainBlockCopyCommon(vm, dom->conn, disk, dest, bandwidth,
granularity, buf_size, flags, false);
cleanup:
virDomainDiskDefFree(diskdef);
virDomainObjEndAPI(&vm);
return ret;
}