3e5111
From 70c60798f09324a9e4d91f787cad493a1ceca5d9 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <70c60798f09324a9e4d91f787cad493a1ceca5d9@dist-git>
3e5111
From: John Ferlan <jferlan@redhat.com>
3e5111
Date: Wed, 24 May 2017 10:27:57 -0400
3e5111
Subject: [PATCH] conf: Resolve corner case on fc_host deletion
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1420740
3e5111
3e5111
Testing found an inventive way to cause an error at shutdown by providing the
3e5111
parent name for the fc host creation using the "same name" as the HBA. Since
3e5111
the code thus assumed the parent host name provided was the parent HBA and
3e5111
just extracted out the host number and sent that along to the vport_destroy
3e5111
this avoided checks made for equality.
3e5111
3e5111
So just add the equality check to that path to resolve.
3e5111
3e5111
(cherry picked from commit 2c8e30ee7e287d6490f643ccd2d7653a834e75e5)
3e5111
Signed-off-by: John Ferlan <jferlan@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/conf/node_device_conf.c | 14 +++++++++++---
3e5111
 1 file changed, 11 insertions(+), 3 deletions(-)
3e5111
3e5111
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
3e5111
index ac61db34c..2d0b14850 100644
3e5111
--- a/src/conf/node_device_conf.c
3e5111
+++ b/src/conf/node_device_conf.c
3e5111
@@ -2300,17 +2300,25 @@ virNodeDeviceDeleteVport(virConnectPtr conn,
3e5111
         goto cleanup;
3e5111
     }
3e5111
 
3e5111
+    if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
3e5111
+        goto cleanup;
3e5111
+
3e5111
     /* If at startup time we provided a parent, then use that to
3e5111
      * get the parent_host value; otherwise, we have to determine
3e5111
      * the parent scsi_host which we did not save at startup time
3e5111
      */
3e5111
     if (fchost->parent) {
3e5111
+        /* Someone provided a parent string at startup time that
3e5111
+         * was the same as the scsi_host - meaning we have a pool
3e5111
+         * backed to an HBA, so there won't be a vHBA to delete */
3e5111
+        if (STREQ(scsi_host_name, fchost->parent)) {
3e5111
+            ret = 0;
3e5111
+            goto cleanup;
3e5111
+        }
3e5111
+
3e5111
         if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0)
3e5111
             goto cleanup;
3e5111
     } else {
3e5111
-        if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
3e5111
-            goto cleanup;
3e5111
-
3e5111
         if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
3e5111
             goto cleanup;
3e5111
 
3e5111
-- 
3e5111
2.13.0
3e5111