[RFC PATCH 06/12] qemu: domain: Add helper to generate indexed backing store names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The code is currently simple, but if we later add node names, it will be
necessary to generate the names based on the node name. Add a helper so
that there's a central point to fix once we add self-generated node
names.
---
 src/qemu/qemu_domain.c | 22 ++++++++++++++++++++++
 src/qemu/qemu_domain.h |  4 ++++
 2 files changed, 26 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4b446f1e8..b8a65cfd5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8319,3 +8319,25 @@ qemuDomainDiskLookupByNodename(virDomainDefPtr def,

     return NULL;
 }
+
+
+/**
+ * qemuDomainDiskBackingStoreGetName:
+ *
+ * Creates a name using the indexed syntax (vda[1])for the given backing store
+ * entry for a disk.
+ */
+char *
+qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
+                                  virStorageSourcePtr src ATTRIBUTE_UNUSED,
+                                  unsigned int idx)
+{
+    char *ret = NULL;
+
+    if (idx)
+        ignore_value(virAsprintf(&ret, "%s[%d]", disk->dst, idx));
+    else
+        ignore_value(VIR_STRDUP(ret, disk->dst));
+
+    return ret;
+}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 03377645f..6e847c7ae 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -855,4 +855,8 @@ virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virDomainDefPtr def,
                                                    virStorageSourcePtr *src,
                                                    unsigned int *idx);

+char *qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
+                                        virStorageSourcePtr src,
+                                        unsigned int idx);
+
 #endif /* __QEMU_DOMAIN_H__ */
-- 
2.11.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux