6ae9ed
From 48aa8017cfcb6ebdb18cc455deae9a76fb035e11 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <48aa8017cfcb6ebdb18cc455deae9a76fb035e11@dist-git>
6ae9ed
From: John Ferlan <jferlan@redhat.com>
6ae9ed
Date: Mon, 25 Jul 2016 12:42:50 -0400
6ae9ed
Subject: [PATCH] qemu: Introduce helper qemuDomainSecretDiskCapable
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1301021
6ae9ed
6ae9ed
Introduce a helper to help determine if a disk src could be possibly used
6ae9ed
for a disk secret... Going to need this for hot unplug.
6ae9ed
6ae9ed
Signed-off-by: John Ferlan <jferlan@redhat.com>
6ae9ed
(cherry picked from commit 60c40ce3be0c123a26ef83dbf4022706579da7a3)
6ae9ed
---
6ae9ed
 src/qemu/qemu_domain.c | 20 +++++++++++++++-----
6ae9ed
 src/qemu/qemu_domain.h |  3 +++
6ae9ed
 2 files changed, 18 insertions(+), 5 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
6ae9ed
index 8b0f847..f298366 100644
6ae9ed
--- a/src/qemu/qemu_domain.c
6ae9ed
+++ b/src/qemu/qemu_domain.c
6ae9ed
@@ -973,6 +973,20 @@ qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
6ae9ed
 }
6ae9ed
 
6ae9ed
 
6ae9ed
+bool
6ae9ed
+qemuDomainSecretDiskCapable(virStorageSourcePtr src)
6ae9ed
+{
6ae9ed
+    if (!virStorageSourceIsEmpty(src) &&
6ae9ed
+        virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK &&
6ae9ed
+        src->auth &&
6ae9ed
+        (src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI ||
6ae9ed
+         src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD))
6ae9ed
+        return true;
6ae9ed
+
6ae9ed
+    return false;
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
 /* qemuDomainSecretDiskPrepare:
6ae9ed
  * @conn: Pointer to connection
6ae9ed
  * @priv: pointer to domain private object
6ae9ed
@@ -990,11 +1004,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
6ae9ed
     virStorageSourcePtr src = disk->src;
6ae9ed
     qemuDomainSecretInfoPtr secinfo = NULL;
6ae9ed
 
6ae9ed
-    if (conn && !virStorageSourceIsEmpty(src) &&
6ae9ed
-        virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK &&
6ae9ed
-        src->auth &&
6ae9ed
-        (src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI ||
6ae9ed
-         src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
6ae9ed
+    if (conn && qemuDomainSecretDiskCapable(src)) {
6ae9ed
 
6ae9ed
         virSecretUsageType secretUsageType = VIR_SECRET_USAGE_TYPE_ISCSI;
6ae9ed
         qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
6ae9ed
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
6ae9ed
index b71a28d..bbec0d4 100644
6ae9ed
--- a/src/qemu/qemu_domain.h
6ae9ed
+++ b/src/qemu/qemu_domain.h
6ae9ed
@@ -671,6 +671,9 @@ void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);
6ae9ed
 void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
6ae9ed
     ATTRIBUTE_NONNULL(1);
6ae9ed
 
6ae9ed
+bool qemuDomainSecretDiskCapable(virStorageSourcePtr src)
6ae9ed
+    ATTRIBUTE_NONNULL(1);
6ae9ed
+
6ae9ed
 int qemuDomainSecretDiskPrepare(virConnectPtr conn,
6ae9ed
                                 qemuDomainObjPrivatePtr priv,
6ae9ed
                                 virDomainDiskDefPtr disk)
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed