[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 14/21] monitor: New commands netdev_add, netdev_del
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 14/21] monitor: New commands netdev_add, netdev_del |
Date: |
Mon, 5 Apr 2010 17:33:55 -0300 |
From: Markus Armbruster <address@hidden>
Monitor commands to go with -netdev.
Signed-off-by: Markus Armbruster <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
net.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
net.h | 2 ++
qemu-monitor.hx | 30 ++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 0 deletions(-)
diff --git a/net.c b/net.c
index 71c0828..9a95451 100644
--- a/net.c
+++ b/net.c
@@ -1194,6 +1194,61 @@ void net_host_device_remove(Monitor *mon, const QDict
*qdict)
qemu_del_vlan_client(vc);
}
+/**
+ * do_netdev_add(): Add a host network device
+ *
+ * Argument qdict contains
+ * - "type": the device type, "tap", "user", ...
+ * - "id": the device's ID (must be unique)
+ * - device options
+ *
+ * Example:
+ *
+ * { "type": "user", "id": "netdev1", "hostname": "a-guest" }
+ */
+int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+ QemuOpts *opts;
+ int res;
+
+ opts = qemu_opts_from_qdict(&qemu_netdev_opts, qdict);
+ if (!opts) {
+ return -1;
+ }
+
+ res = net_client_init(mon, opts, 1);
+ return res;
+}
+
+/**
+ * do_netdev_del(): Delete a host network device
+ *
+ * Argument qdict contains
+ * - "id": the device's ID
+ *
+ * Example:
+ *
+ * { "id": "netdev1" }
+ */
+int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+ const char *id = qdict_get_str(qdict, "id");
+ VLANClientState *vc;
+
+ vc = qemu_find_netdev(id);
+ if (!vc || vc->info->type == NET_CLIENT_TYPE_NIC) {
+ qerror_report(QERR_DEVICE_NOT_FOUND, id);
+ return -1;
+ }
+ if (vc->peer) {
+ qerror_report(QERR_DEVICE_IN_USE, id);
+ return -1;
+ }
+ qemu_del_vlan_client(vc);
+ qemu_opts_del(qemu_opts_find(&qemu_netdev_opts, id));
+ return 0;
+}
+
void net_set_boot_mask(int net_boot_mask)
{
int i;
diff --git a/net.h b/net.h
index 16f19c5..ce9e2c6 100644
--- a/net.h
+++ b/net.h
@@ -166,6 +166,8 @@ void net_cleanup(void);
void net_set_boot_mask(int boot_mask);
void net_host_device_add(Monitor *mon, const QDict *qdict);
void net_host_device_remove(Monitor *mon, const QDict *qdict);
+int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index d290b4b..31087bd 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -914,6 +914,36 @@ STEXI
Remove host VLAN client.
ETEXI
+ {
+ .name = "netdev_add",
+ .args_type = "netdev:O",
+ .params = "[user|tap|socket],id=str[,prop=value][,...]",
+ .help = "add host network device",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_netdev_add,
+ },
+
+STEXI
address@hidden netdev_add
address@hidden netdev_add
+Add host network device.
+ETEXI
+
+ {
+ .name = "netdev_del",
+ .args_type = "id:s",
+ .params = "id",
+ .help = "remove host network device",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_netdev_del,
+ },
+
+STEXI
address@hidden netdev_del
address@hidden netdev_del
+Remove host network device.
+ETEXI
+
#ifdef CONFIG_SLIRP
{
.name = "hostfwd_add",
--
1.7.0.4.297.g6555b1
- [Qemu-devel] [PATCH 04/21] error: Put error definitions back in alphabetical order, (continued)
- [Qemu-devel] [PATCH 04/21] error: Put error definitions back in alphabetical order, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 12/21] error: Convert net_client_init() to QError, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 20/21] QMP: Improve RTC_CHANGE event description, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 17/21] monitor: Use argument type 'b' for set_link, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 02/21] monitor: convert do_device_del() to QObject, QError, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 15/21] monitor: Rename argument type 'b' to 'f', Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 09/21] error: Drop extra messages after qemu_opts_set() and qemu_opts_parse(), Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 05/21] error: New QERR_DUPLICATE_ID, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 08/21] error: Convert qemu_opts_set() to QError, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 16/21] monitor: New argument type 'b', Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 14/21] monitor: New commands netdev_add, netdev_del,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 13/21] error: New QERR_DEVICE_IN_USE, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 11/21] error: Convert qemu_opts_validate() to QError, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 19/21] virtio-blk: Fix use after free in error case, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 21/21] Monitor: Convert do_screen_dump() to QObject, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 18/21] monitor: Convert do_set_link() to QObject, QError, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 10/21] error: Use QERR_INVALID_PARAMETER_VALUE instead of QERR_INVALID_PARAMETER, Luiz Capitulino, 2010/04/05
- [Qemu-devel] [PATCH 03/21] Add qerror message if the 'change' target filename can't be opened, Luiz Capitulino, 2010/04/05
- Re: [Qemu-devel] [PATCH 00/21][PULL]: QMP/Monitor queue, Aurelien Jarno, 2010/04/18