qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] block: prefer protocol_name over format_name in bdr


From: Jeff Cody
Subject: [Qemu-devel] [PATCH] block: prefer protocol_name over format_name in bdrv_iterate_format
Date: Tue, 15 Apr 2014 09:28:54 -0400

Some block drivers have multiple BlockDriver instances with identical
format_name fields (e.g. gluster, nbd).  In those cases, the
protocol_name is usually the more unique identifier (e.g. gluster+tcp).

Both qemu-img and qemu will use bdrv_iterate_format() to list the
supported formats when a help option is invoked.  When just the
format_name is used, redundant listings of formats occur (e.g.,
"Supported formats: ... gluster gluster gluster gluster ... ").

If we prefer the protocol_name over the format_name (when the
protocol name exists), then that provides a more informative
help message:

"Supported formats: ... gluster gluster+tcp gluster+unix
gluster+rdma ... "

Signed-off-by: Jeff Cody <address@hidden>
---
 block.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/block.c b/block.c
index 990a754..0587257 100644
--- a/block.c
+++ b/block.c
@@ -3576,7 +3576,13 @@ void bdrv_iterate_format(void (*it)(void *opaque, const 
char *name),
     BlockDriver *drv;
 
     QLIST_FOREACH(drv, &bdrv_drivers, list) {
-        it(opaque, drv->format_name);
+        /* format_name may be duplicate, if multiple protocols exist for a
+         * format. If there is a protocol, use that more unique name instead */
+        if (drv->protocol_name) {
+            it(opaque, drv->protocol_name);
+        } else {
+            it(opaque, drv->format_name);
+        }
     }
 }
 
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]