[libvirt] [PATCH 2/9] conf: properly translate iscsi-direct storage pool

Pavel Hrdina phrdina at redhat.com
Tue Aug 7 13:55:21 UTC 2018


We cannot simply used the same code as for iscsi storage pool because
the default mode is 'host' which is not possible with iscsi-direct.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/conf/domain_conf.c | 61 +++++++++++++++++++++++++++++-------------
 1 file changed, 43 insertions(+), 18 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7dcbe8a20b..d1504610a1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30143,6 +30143,34 @@ virDomainDiskTranslateSourcePoolAuth(virDomainDiskDefPtr def,
 }
 
 
+static int
+virDomainDiskTranslateISCSIDircect(virDomainDiskDefPtr def,
+                                   virStoragePoolDefPtr pooldef)
+{
+    def->src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK;
+    def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
+
+    if (virDomainDiskTranslateSourcePoolAuth(def,
+                                             &pooldef->source) < 0)
+        return -1;
+
+    /* Source pool may not fill in the secrettype field,
+     * so we need to do so here
+     */
+    if (def->src->auth && !def->src->auth->secrettype) {
+        const char *secrettype =
+            virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI);
+        if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0)
+            return -1;
+    }
+
+    if (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 int
 virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
 {
@@ -30253,6 +30281,20 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
         break;
 
     case VIR_STORAGE_POOL_ISCSI_DIRECT:
+        if (def->startupPolicy) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("'startupPolicy' is only valid for "
+                             "'file' type volume"));
+            goto cleanup;
+        }
+
+        def->src->srcpool->mode = VIR_STORAGE_SOURCE_POOL_MODE_DIRECT;
+
+        if (virDomainDiskTranslateISCSIDircect(def, pooldef) < 0)
+            goto cleanup;
+
+        break;
+
     case VIR_STORAGE_POOL_ISCSI:
         if (def->startupPolicy) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -30273,24 +30315,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
            break;
 
        case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT:
-           def->src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK;
-           def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
-
-           if (virDomainDiskTranslateSourcePoolAuth(def,
-                                                    &pooldef->source) < 0)
-               goto cleanup;
-
-           /* Source pool may not fill in the secrettype field,
-            * so we need to do so here
-            */
-           if (def->src->auth && !def->src->auth->secrettype) {
-               const char *secrettype =
-                   virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI);
-               if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0)
-                   goto cleanup;
-           }
-
-           if (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0)
+           if (virDomainDiskTranslateISCSIDircect(def, pooldef) < 0)
                goto cleanup;
            break;
        }
-- 
2.17.1




More information about the libvir-list mailing list