libmultipath: Fix information not shown when first path is down.
authorGabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
Mon, 5 Oct 2015 20:19:17 +0000 (17:19 -0300)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 6 Oct 2015 06:53:36 +0000 (08:53 +0200)
vendor_id and product_id information are not shown when displaying
multipath topology if the first path is down.

0QEMU_QEMU_HARDDISK_HELLOWORLD dm-0 ,      <--- Missing vendor and product
size=10G features='0' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=0 status=active
| `- #:#:#:# -   #:#  active undef running
`-+- policy='service-time 0' prio=0 status=enabled
  `- 2:0:1:0 sdd 8:48 active undef running

This happens because we only look at the first_path when printing the
topology.  This patch looks at every slot in the path vector until we
find one with the correct value.

Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
libmultipath/print.c

index 5d63ed3..ff79180 100644 (file)
@@ -249,11 +249,20 @@ snprint_multipath_uuid (char * buff, size_t len, struct multipath * mpp)
 static int
 snprint_multipath_vpr (char * buff, size_t len, struct multipath * mpp)
 {
-       struct path * pp = first_path(mpp);
-       if (!pp)
-               return 0;
-       return snprintf(buff, len, "%s,%s",
-                       pp->vendor_id, pp->product_id);
+       struct pathgroup * pgp;
+       struct path * pp;
+       int i, j;
+
+       vector_foreach_slot(mpp->pg, pgp, i) {
+               if (!pgp)
+                       continue;
+               vector_foreach_slot(pgp->paths, pp, j) {
+                       if (strlen(pp->vendor_id) && strlen(pp->product_id))
+                               return snprintf(buff, len, "%s,%s",
+                                               pp->vendor_id, pp->product_id);
+               }
+       }
+       return snprintf(buff, len, "##,##");
 }
 
 static int