From 3e4dfad2dbda54bf6eefbf5c2e39f936ed0f8445 Mon Sep 17 00:00:00 2001 From: Gabriel Krisman Bertazi Date: Mon, 14 Sep 2015 12:01:17 -0300 Subject: [PATCH] libmultipath: Fix information not shown when first path is down. vendor_id and product_id information is 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 --- libmultipath/print.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libmultipath/print.c b/libmultipath/print.c index 6594fee..48b50d8 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