[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id argument completion.
From: |
Hani Benhabiles |
Subject: |
[Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id argument completion. |
Date: |
Sun, 27 Apr 2014 17:00:08 +0100 |
Signed-off-by: Hani Benhabiles <address@hidden>
---
hmp-commands.hx | 1 +
hmp.h | 1 +
monitor.c | 26 ++++++++++++++++++++++++++
3 files changed, 28 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 73fbe54..f10f52f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1245,6 +1245,7 @@ ETEXI
.params = "id",
.help = "remove host network device",
.mhandler.cmd = hmp_netdev_del,
+ .command_completion = netdev_del_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index 7b85834..98b599a 100644
--- a/hmp.h
+++ b/hmp.h
@@ -103,5 +103,6 @@ void chardev_remove_completion(ReadLineState *rs, int
nb_args, const char *str);
void chardev_add_completion(ReadLineState *rs, int nb_args, const char *str);
void set_link_completion(ReadLineState *rs, int nb_args, const char *str);
void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str);
+void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str);
#endif
diff --git a/monitor.c b/monitor.c
index cc6d01b..c48f9db 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4519,6 +4519,32 @@ void set_link_completion(ReadLineState *rs, int nb_args,
const char *str)
}
}
+void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+ int len, count, i;
+ NetClientState *ncs[255];
+
+ if (nb_args != 2) {
+ return;
+ }
+
+ len = strlen(str);
+ readline_set_completion_index(rs, len);
+ count = qemu_find_net_clients_except(NULL, ncs,
NET_CLIENT_OPTIONS_KIND_NIC,
+ 255);
+ for (i = 0; i < count; i++) {
+ QemuOpts *opts;
+ const char *name = ncs[i]->name;
+ if (strncmp(str, name, len)) {
+ continue;
+ }
+ opts = qemu_opts_find(qemu_find_opts_err("netdev", NULL), name);
+ if (opts) {
+ readline_add_completion(rs, name);
+ }
+ }
+}
+
static void monitor_find_completion_by_table(Monitor *mon,
const mon_cmd_t *cmd_table,
char **args,
--
1.8.3.2
- [Qemu-devel] [PATCH 0/7] Miscellaneous command completion patches, Hani Benhabiles, 2014/04/27
- [Qemu-devel] [PATCH 1/7] monitor: Convert sendkey to use command_completion., Hani Benhabiles, 2014/04/27
- [Qemu-devel] [PATCH 2/7] monitor: Convert help|? to use command_completion., Hani Benhabiles, 2014/04/27
- [Qemu-devel] [PATCH 3/7] monitor: Add chardev-remove command completion., Hani Benhabiles, 2014/04/27
- [Qemu-devel] [PATCH 4/7] monitor: Add chardev-add backend argument completion., Hani Benhabiles, 2014/04/27
- [Qemu-devel] [PATCH 5/7] monitor: Add set_link arguments completion., Hani Benhabiles, 2014/04/27
- [Qemu-devel] [PATCH 6/7] monitor: Add netdev_add type argument completion., Hani Benhabiles, 2014/04/27
- [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id argument completion.,
Hani Benhabiles <=