The disk backend alias was historically the alias of the -drive backing
the storage. For setups with -blockdev this will become more complex as
it will depend on other configs and generally will differ.
---
src/qemu/qemu_domain.c | 28
src/qemu/qemu_domain.h | 6 ++
2 files changed, 34 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c92ac8c926..f8a621a5c9 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8449,6 +8449,34 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
}
+/**
+ * qemuDomainDiskGetBackendAlias:
+ * @disk: disk definition
+ * @qemuCaps: emulator capabilities
+ * @backendAlias: filled with the alias of the disk storage backend
+ *
+ * Returns the correct alias for the disk backend. This may be the alias of
+ * -drive for legacy setup or the correct node name for -blockdev setups.
+ *
+ * @backendAlias may be NULL on success if the backend does not exist
+ * (disk is empty). Caller is responsible for freeing @backendAlias.
+ *
+ * Returns 0 on success, -1 on error with libvirt error reported.
+ */
+int
+qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
+ virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
+ char **backendAlias)
+{
+*backendAlias = NULL;
+
+if (!(*backendAlias = qemuAliasDiskDriveFromDisk(disk)))
+return -1;
+
+return 0;
+}
+
+
/**
* qemuDomainDiskChainElementRevoke:
*
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 1692fa9838..22c3a51354 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -732,6 +732,12 @@ int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
virStorageSourcePtr parent);
char *qemuDomainStorageAlias(const char *device, int depth);
+int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
+ virQEMUCapsPtr qemuCaps,
+ char **backendAlias)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
+ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
+
void qemuDomainDiskChainElementRevoke(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virStorageSourcePtr elem);
--
2.16.2
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list