]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
backup: qemu: Add helper API for looking up node name
authorEric Blake <eblake@redhat.com>
Mon, 22 Jul 2019 16:22:05 +0000 (11:22 -0500)
committerEric Blake <eblake@redhat.com>
Mon, 29 Jul 2019 13:15:11 +0000 (08:15 -0500)
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 <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h

index aaa27ba7d2c5c784e51fcca8e7e9e4f7c7bace1c..4fa1a4ac768d521dfd7a297c0edfa4c3cf3642e3 100644 (file)
@@ -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)
 {
index eeb07180b7709c5f981ad5850b6aab509d238999..b76d3cace9245c19fe9c32a9c930aacc279efbef 100644 (file)
@@ -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,