[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 15/17] monitor: Add host_net_remove arguments com
From: |
Hani Benhabiles |
Subject: |
[Qemu-devel] [PATCH v2 15/17] monitor: Add host_net_remove arguments completion. |
Date: |
Sun, 30 Mar 2014 11:58:37 +0100 |
Relies on readline unique completion strings patch to make the added vlan/hub
completion values unique, instead of using something like a hash table.
Signed-off-by: Hani Benhabiles <address@hidden>
---
hmp-commands.hx | 1 +
hmp.h | 2 ++
monitor.c | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 9da5866..b41a6d6 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1219,6 +1219,7 @@ ETEXI
.params = "vlan_id name",
.help = "remove host VLAN client",
.mhandler.cmd = net_host_device_remove,
+ .command_completion = host_net_remove_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index c82fd87..12f0364 100644
--- a/hmp.h
+++ b/hmp.h
@@ -110,5 +110,7 @@ void watchdog_action_completion(ReadLineState *rs, int
nb_args,
void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
const char *str);
void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str);
+void host_net_remove_completion(ReadLineState *rs, int nb_args,
+ const char *str);
#endif
diff --git a/monitor.c b/monitor.c
index 4c20bc5..9781ee2 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4619,6 +4619,44 @@ void host_net_add_completion(ReadLineState *rs, int
nb_args, const char *str)
add_completion_option(rs, str, "bridge");
}
+void host_net_remove_completion(ReadLineState *rs, int nb_args, const char
*str)
+{
+ NetClientState *ncs[255];
+ int count, i, len;
+
+ len = strlen(str);
+ readline_set_completion_index(rs, len);
+ if (nb_args == 2) {
+ count = qemu_find_net_clients_except(NULL, ncs,
+ NET_CLIENT_OPTIONS_KIND_NONE,
255);
+ for (i = 0; i < count; i++) {
+ int id;
+ char name[16];
+
+ if (net_hub_id_for_client(ncs[i], &id)) {
+ continue;
+ }
+ snprintf(name, sizeof(name), "%d", id);
+ if (!strncmp(str, name, len)) {
+ readline_add_completion(rs, name);
+ }
+ }
+ return;
+ } else if (nb_args == 3) {
+ count = qemu_find_net_clients_except(NULL, ncs,
+ NET_CLIENT_OPTIONS_KIND_NIC, 255);
+ for (i = 0; i < count; i++) {
+ const char *name;
+
+ name = ncs[i]->name;
+ if (!strncmp(str, name, len)) {
+ readline_add_completion(rs, name);
+ }
+ }
+ return;
+ }
+}
+
static void monitor_find_completion_by_table(Monitor *mon,
const mon_cmd_t *cmd_table,
char **args,
--
1.8.3.2
- [Qemu-devel] [PATCH v2 05/17] monitor: Add chardev-add backend argument completion., (continued)
- [Qemu-devel] [PATCH v2 05/17] monitor: Add chardev-add backend argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 06/17] monitor: Add cpu index argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 07/17] monitor: Add set_link arguments completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 08/17] monitor: Add netdev_add type argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 09/17] monitor: Add netdev_del id argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 10/17] monitor: Add ringbuf_write and ringbuf_read argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 11/17] monitor: Add watchdog_action argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 12/17] monitor: Add migrate_set_capability completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 13/17] monitor: Add host_net_add device argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 14/17] readline: Make completion strings always unique., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 15/17] monitor: Add host_net_remove arguments completion.,
Hani Benhabiles <=
- [Qemu-devel] [PATCH v2 16/17] monitor: Add mouse_set index argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 17/17] monitor: Add delvm and loadvm argument completion., Hani Benhabiles, 2014/03/30