render / rpms / libvirt

Forked from rpms/libvirt 11 months ago
Clone
6ae9ed
From 7b5a14e1402fe13052f1d632d3f95307ea829a75 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <7b5a14e1402fe13052f1d632d3f95307ea829a75@dist-git>
6ae9ed
From: John Ferlan <jferlan@redhat.com>
6ae9ed
Date: Tue, 2 Aug 2016 12:04:38 -0400
6ae9ed
Subject: [PATCH] qemu: Introduce qemuAliasFromHostdev
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1289391
6ae9ed
6ae9ed
Introduce a common API to generate the alias for a host device
6ae9ed
6ae9ed
(cherry picked from commit 647bc753d453dcf9ffafe95a3233cb4fbbffca5a)
6ae9ed
6ae9ed
Resolved conflicts since upstream commit 'dd0dbe1d' is not present
6ae9ed
(e.g. qemuAliasDiskDriveSkipPrefix)
6ae9ed
6ae9ed
Signed-off-by: John Ferlan <jferlan@redhat.com>
6ae9ed
---
6ae9ed
 src/qemu/qemu_alias.c | 23 +++++++++++++++++++++++
6ae9ed
 src/qemu/qemu_alias.h |  2 ++
6ae9ed
 2 files changed, 25 insertions(+)
6ae9ed
6ae9ed
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
6ae9ed
index 51a654a..a85d3d1 100644
6ae9ed
--- a/src/qemu/qemu_alias.c
6ae9ed
+++ b/src/qemu/qemu_alias.c
6ae9ed
@@ -467,6 +467,29 @@ qemuAliasFromDisk(const virDomainDiskDef *disk)
6ae9ed
 }
6ae9ed
 
6ae9ed
 
6ae9ed
+/* qemuAliasFromHostdev
6ae9ed
+ * @hostdev: Pointer to host device
6ae9ed
+ *
6ae9ed
+ * Generate and return a string containing a drive alias
6ae9ed
+ */
6ae9ed
+char *
6ae9ed
+qemuAliasFromHostdev(const virDomainHostdevDef *hostdev)
6ae9ed
+{
6ae9ed
+    char *ret;
6ae9ed
+
6ae9ed
+    if (!hostdev->info->alias) {
6ae9ed
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
6ae9ed
+                       _("hostdev does not have an alias"));
6ae9ed
+        return NULL;
6ae9ed
+    }
6ae9ed
+
6ae9ed
+    ignore_value(virAsprintf(&ret, "%s-%s",
6ae9ed
+                 virDomainDeviceAddressTypeToString(hostdev->info->type),
6ae9ed
+                 hostdev->info->alias));
6ae9ed
+    return ret;
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
 /* qemuDomainGetMasterKeyAlias:
6ae9ed
  *
6ae9ed
  * Generate and return the masterKey alias
6ae9ed
diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h
6ae9ed
index d1c6ba8..bb19710 100644
6ae9ed
--- a/src/qemu/qemu_alias.h
6ae9ed
+++ b/src/qemu/qemu_alias.h
6ae9ed
@@ -67,6 +67,8 @@ int qemuDomainDeviceAliasIndex(const virDomainDeviceInfo *info,
6ae9ed
 
6ae9ed
 char *qemuAliasFromDisk(const virDomainDiskDef *disk);
6ae9ed
 
6ae9ed
+char *qemuAliasFromHostdev(const virDomainHostdevDef *hostdev);
6ae9ed
+
6ae9ed
 char *qemuDomainGetMasterKeyAlias(void);
6ae9ed
 
6ae9ed
 char *qemuDomainGetSecretAESAlias(const char *srcalias,
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed