From: Eric Blake Date: Mon, 22 Jul 2019 16:22:05 +0000 (-0500) Subject: backup: qemu: Add helper API for looking up node name X-Git-Tag: v5.6.0-rc1~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e3a4b8f461a204d531f9c04c3f196e07ae1a6c8e;p=thirdparty%2Flibvirt.git backup: qemu: Add helper API for looking up node name Qemu bitmap operations require knowing the node name associated with the format layer (the qcow2 file); as upcoming patches will be grabbing that information frequently, make a helper function to access it. Another potential benefit of this function is that we have a single place where we could insert a QMP node-name scraping call if we don't currently know the node name, when -blockdev is not supported; however, the goal is that we hopefully don't ever have to do that because we instead scrape node names only at the point where they change. Signed-off-by: Eric Blake Reviewed-by: Daniel P. Berrangé --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index aaa27ba7d2..4fa1a4ac76 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10360,6 +10360,21 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk, return true; } + +/* Return the format node name for a given disk of an online guest */ +const char * +qemuDomainDiskNodeFormatLookup(virDomainObjPtr vm, + const char *disk) +{ + size_t i; + + for (i = 0; i < vm->def->ndisks; i++) { + if (STREQ(vm->def->disks[i]->dst, disk)) + return vm->def->disks[i]->src->nodeformat; + } + return NULL; +} + bool qemuDomainDiskBlockJobIsActive(virDomainDiskDefPtr disk) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index eeb07180b7..b76d3cace9 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -804,6 +804,9 @@ int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk, virDomainDiskDefPtr orig_disk); +const char *qemuDomainDiskNodeFormatLookup(virDomainObjPtr vm, + const char *disk); + int qemuDomainStorageFileInit(virQEMUDriverPtr driver, virDomainObjPtr vm, virStorageSourcePtr src,