render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
99cbc7
From 95c8eb63a3078bfd4a568b02898be2be91e3cd95 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <95c8eb63a3078bfd4a568b02898be2be91e3cd95@dist-git>
99cbc7
From: John Ferlan <jferlan@redhat.com>
99cbc7
Date: Tue, 12 Mar 2019 13:55:59 -0400
99cbc7
Subject: [PATCH] storage: Fetch a unique key for vHBA/NPIV LUNs
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1687715 (7.6.z)
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1657468 (7.7.0)
99cbc7
99cbc7
Commit be1bb6c95 changed the way volumes were stored from a forward
99cbc7
linked list to a hash table. In doing so, it required that each vol
99cbc7
object would have 3 unique values as keys into tables - key, name,
99cbc7
and path. Due to how vHBA/NPIV LUNs are created/used this resulted
99cbc7
in a failure to utilize all the LUN's found during processing.
99cbc7
99cbc7
During virStorageBackendSCSINewLun processing fetch the key (or
99cbc7
serial value) for NPIV LUN's using virStorageFileGetNPIVKey which
99cbc7
will formulate a more unique key based on the serial value and
99cbc7
the port for the LUN.
99cbc7
99cbc7
Signed-off-by: John Ferlan <jferlan@redhat.com>
99cbc7
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
(cherry picked from commit 850cfd75beb7872b20439eccda0bcf7b68cab525)
99cbc7
Message-Id: <20190312175559.13583-5-jferlan@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/storage/storage_util.c | 13 ++++++++++---
99cbc7
 1 file changed, 10 insertions(+), 3 deletions(-)
99cbc7
99cbc7
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
99cbc7
index d1659c0c8d..19e6e0544b 100644
99cbc7
--- a/src/storage/storage_util.c
99cbc7
+++ b/src/storage/storage_util.c
99cbc7
@@ -3694,12 +3694,16 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
99cbc7
 
99cbc7
 
99cbc7
 static char *
99cbc7
-virStorageBackendSCSISerial(const char *dev)
99cbc7
+virStorageBackendSCSISerial(const char *dev,
99cbc7
+                            bool isNPIV)
99cbc7
 {
99cbc7
     int rc;
99cbc7
     char *serial = NULL;
99cbc7
 
99cbc7
-    rc = virStorageFileGetSCSIKey(dev, &serial, true);
99cbc7
+    if (isNPIV)
99cbc7
+        rc = virStorageFileGetNPIVKey(dev, &serial);
99cbc7
+    else
99cbc7
+        rc = virStorageFileGetSCSIKey(dev, &serial, true);
99cbc7
     if (rc == 0 && serial)
99cbc7
         return serial;
99cbc7
 
99cbc7
@@ -3796,7 +3800,10 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
99cbc7
                                                  VIR_STORAGE_VOL_READ_NOERROR)) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    if (!(vol->key = virStorageBackendSCSISerial(vol->target.path)))
99cbc7
+    vol->key = virStorageBackendSCSISerial(vol->target.path,
99cbc7
+                                           (def->source.adapter.type ==
99cbc7
+                                            VIR_STORAGE_ADAPTER_TYPE_FC_HOST));
99cbc7
+    if (!vol->key)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
     def->capacity += vol->target.capacity;
99cbc7
-- 
99cbc7
2.21.0
99cbc7