diff mbox

[v3,01/14] monitor: Use BB list for BB name completion

Message ID 1455646106-2047-2-git-send-email-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Max Reitz Feb. 16, 2016, 6:08 p.m. UTC
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 monitor.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Kevin Wolf Feb. 17, 2016, 10:09 a.m. UTC | #1
Am 16.02.2016 um 19:08 hat Max Reitz geschrieben:
> Signed-off-by: Max Reitz <mreitz@redhat.com>

In the long run, I guess we want to have to separate types, one of which
accepts only BlockBackend names and the other one BB and BDS names.
Though I think that most HMP commands currently require a BB, so this
patch is okay for now.

Kevin
Max Reitz Feb. 17, 2016, 3:35 p.m. UTC | #2
On 17.02.2016 11:09, Kevin Wolf wrote:
> Am 16.02.2016 um 19:08 hat Max Reitz geschrieben:
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
> 
> In the long run, I guess we want to have to separate types, one of which
> accepts only BlockBackend names and the other one BB and BDS names.

Well, for the second type we shouldn't use bdrv_next() either but
bdrv_next_node() instead (and bdrv_get_node_name() instead of
bdrv_get_device_name()).

Max

> Though I think that most HMP commands currently require a BB, so this
> patch is okay for now.
> 
> Kevin
>
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index 73eac17..7620e20 100644
--- a/monitor.c
+++ b/monitor.c
@@ -42,6 +42,7 @@ 
 #include "ui/console.h"
 #include "ui/input.h"
 #include "sysemu/blockdev.h"
+#include "sysemu/block-backend.h"
 #include "audio/audio.h"
 #include "disas/disas.h"
 #include "sysemu/balloon.h"
@@ -3467,7 +3468,7 @@  static void monitor_find_completion_by_table(Monitor *mon,
     int i;
     const char *ptype, *str, *name;
     const mon_cmd_t *cmd;
-    BlockDriverState *bs;
+    BlockBackend *blk = NULL;
 
     if (nb_args <= 1) {
         /* command completion */
@@ -3522,8 +3523,8 @@  static void monitor_find_completion_by_table(Monitor *mon,
         case 'B':
             /* block device name completion */
             readline_set_completion_index(mon->rs, strlen(str));
-            for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
-                name = bdrv_get_device_name(bs);
+            while ((blk = blk_next(blk)) != NULL) {
+                name = blk_name(blk);
                 if (str[0] == '\0' ||
                     !strncmp(name, str, strlen(str))) {
                     readline_add_completion(mon->rs, name);