From e3a4b8f461a204d531f9c04c3f196e07ae1a6c8e Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 22 Jul 2019 11:22:05 -0500 Subject: [PATCH] backup: qemu: Add helper API for looking up node name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é --- src/qemu/qemu_domain.c | 15 +++++++++++++++ src/qemu/qemu_domain.h | 3 +++ 2 files changed, 18 insertions(+) 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,