]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Fix autostart of pool with "fc_host" type adapter
authorOsier Yang <jyang@redhat.com>
Mon, 6 Jan 2014 10:19:34 +0000 (18:19 +0800)
committerOsier Yang <jyang@redhat.com>
Thu, 23 Jan 2014 09:50:29 +0000 (17:50 +0800)
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

src/storage/storage_backend_scsi.c

index 08e13313ac5a30f0df97664b2246c3d58b208e60..fce2bae481e32d933d12dec0126e74f4705acd32 100644 (file)
@@ -707,8 +707,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;