]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
monitor: Add chardev-remove command completion.
authorHani Benhabiles <kroosec@gmail.com>
Wed, 7 May 2014 22:41:28 +0000 (23:41 +0100)
committerLuiz Capitulino <lcapitulino@redhat.com>
Thu, 15 May 2014 19:16:01 +0000 (15:16 -0400)
Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
hmp-commands.hx
hmp.h
monitor.c

index b4b23c8b04c035a29f75c8170122c4ec17c09402..ba88e2a183d72baf55287a1a604f25a14d520736 100644 (file)
@@ -1639,6 +1639,7 @@ ETEXI
         .params     = "id",
         .help       = "remove chardev",
         .mhandler.cmd = hmp_chardev_remove,
+        .command_completion = chardev_remove_completion,
     },
 
 STEXI
diff --git a/hmp.h b/hmp.h
index 12e21e73dde78142d55df9f455c7c4f6e521f1cf..affc2b695d3a2ffd73cd10127ee251fa537b6ae4 100644 (file)
--- a/hmp.h
+++ b/hmp.h
@@ -98,5 +98,6 @@ void object_del_completion(ReadLineState *rs, int nb_args, const char *str);
 void device_add_completion(ReadLineState *rs, int nb_args, const char *str);
 void device_del_completion(ReadLineState *rs, int nb_args, const char *str);
 void sendkey_completion(ReadLineState *rs, int nb_args, const char *str);
+void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str);
 
 #endif
index cb9b2c25bbef9030fc563eda4d6bb18de9effc19..55e56969d404a8062ff1b9bd44e46ed6821c6dec 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -4339,6 +4339,29 @@ static void device_del_bus_completion(ReadLineState *rs,  BusState *bus,
     }
 }
 
+void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    size_t len;
+    ChardevInfoList *list, *start;
+
+    if (nb_args != 2) {
+        return;
+    }
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+
+    start = list = qmp_query_chardev(NULL);
+    while (list) {
+        ChardevInfo *chr = list->value;
+
+        if (!strncmp(chr->label, str, len)) {
+            readline_add_completion(rs, chr->label);
+        }
+        list = list->next;
+    }
+    qapi_free_ChardevInfoList(start);
+}
+
 void device_del_completion(ReadLineState *rs, int nb_args, const char *str)
 {
     size_t len;