Blob Blame History Raw
From c1f1c134797e9ee7f68038e11e58171d255d37c3 Mon Sep 17 00:00:00 2001
Message-Id: <c1f1c134797e9ee7f68038e11e58171d255d37c3.1391001809.git.jdenemar@redhat.com>
From: Osier Yang <jyang@redhat.com>
Date: Mon, 27 Jan 2014 20:39:31 +0800
Subject: [PATCH] storage: Fix autostart of pool with "fc_host" type adapter

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

The "checkPool" is a bit different for pool with "fc_host"
type source adapter, since the vHBA it's based on might be
not created yet (it's created by "startPool", which is
involked after "checkPool" in storageDriverAutostart). So it
should not fail, otherwise the "autostart" of the pool will
fail either.

The problem is easy to reproduce:
    * Enable "autostart" for the pool
    * Restart libvirtd service
    * Check the pool's state
(cherry picked from commit 2340f0196f6339f95274f73699d54e0b5e07c362)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/storage/storage_backend_scsi.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 7437488..26baf4a 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -704,8 +704,19 @@ virStorageBackendSCSICheckPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     *isActive = false;
 
-    if (!(name = getAdapterName(pool->def->source.adapter)))
-        return -1;
+    if (!(name = getAdapterName(pool->def->source.adapter))) {
+        /* It's normal for the pool with "fc_host" type source
+         * adapter fails to get the adapter name, since the vHBA
+         * the adapter based on might be not created yet.
+         */
+        if (pool->def->source.adapter.type ==
+            VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
+            virResetLastError();
+            return 0;
+        } else {
+            return -1;
+        }
+    }
 
     if (getHostNumber(name, &host) < 0)
         goto cleanup;
-- 
1.8.5.3