[PATCH] libmultipath: Fix information not shown when first path is down.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
---
 libmultipath/print.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/libmultipath/print.c b/libmultipath/print.c
index 6594fee..fb2551e 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -248,11 +248,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
-- 
2.1.0

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux