[libvirt] [PATCH v10 17/19] backup: qemu: Add helper API for looking up node name

Eric Blake posted 19 patches 6 years, 6 months ago
[libvirt] [PATCH v10 17/19] backup: qemu: Add helper API for looking up node name
Posted by Eric Blake 6 years, 6 months ago
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.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 src/qemu/qemu_domain.h |  3 +++
 src/qemu/qemu_domain.c | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

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,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 44ac7eb73e..d71b7d1984 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -10260,6 +10260,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)
 {
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v10 17/19] backup: qemu: Add helper API for looking up node name
Posted by Daniel P. Berrangé 6 years, 6 months ago
On Wed, Jul 24, 2019 at 12:56:07AM -0500, Eric Blake wrote:
> 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.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  src/qemu/qemu_domain.h |  3 +++
>  src/qemu/qemu_domain.c | 15 +++++++++++++++
>  2 files changed, 18 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list