render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 48aa8017cfcb6ebdb18cc455deae9a76fb035e11 Mon Sep 17 00:00:00 2001
Message-Id: <48aa8017cfcb6ebdb18cc455deae9a76fb035e11@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 25 Jul 2016 12:42:50 -0400
Subject: [PATCH] qemu: Introduce helper qemuDomainSecretDiskCapable

https://bugzilla.redhat.com/show_bug.cgi?id=1301021

Introduce a helper to help determine if a disk src could be possibly used
for a disk secret... Going to need this for hot unplug.

Signed-off-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit 60c40ce3be0c123a26ef83dbf4022706579da7a3)
---
 src/qemu/qemu_domain.c | 20 +++++++++++++++-----
 src/qemu/qemu_domain.h |  3 +++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8b0f847..f298366 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -973,6 +973,20 @@ qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
 }
 
 
+bool
+qemuDomainSecretDiskCapable(virStorageSourcePtr src)
+{
+    if (!virStorageSourceIsEmpty(src) &&
+        virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK &&
+        src->auth &&
+        (src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI ||
+         src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD))
+        return true;
+
+    return false;
+}
+
+
 /* qemuDomainSecretDiskPrepare:
  * @conn: Pointer to connection
  * @priv: pointer to domain private object
@@ -990,11 +1004,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
     virStorageSourcePtr src = disk->src;
     qemuDomainSecretInfoPtr secinfo = NULL;
 
-    if (conn && !virStorageSourceIsEmpty(src) &&
-        virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK &&
-        src->auth &&
-        (src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI ||
-         src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
+    if (conn && qemuDomainSecretDiskCapable(src)) {
 
         virSecretUsageType secretUsageType = VIR_SECRET_USAGE_TYPE_ISCSI;
         qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index b71a28d..bbec0d4 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -671,6 +671,9 @@ void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);
 void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
     ATTRIBUTE_NONNULL(1);
 
+bool qemuDomainSecretDiskCapable(virStorageSourcePtr src)
+    ATTRIBUTE_NONNULL(1);
+
 int qemuDomainSecretDiskPrepare(virConnectPtr conn,
                                 qemuDomainObjPrivatePtr priv,
                                 virDomainDiskDefPtr disk)
-- 
2.9.2