monitor: New commands netdev_add, netdev_del
Monitor commands to go with -netdev. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
5124eb5927
commit
ae82d3242d
55
net.c
55
net.c
@ -1194,6 +1194,61 @@ void net_host_device_remove(Monitor *mon, const QDict *qdict)
|
|||||||
qemu_del_vlan_client(vc);
|
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 do_info_network(Monitor *mon)
|
void do_info_network(Monitor *mon)
|
||||||
{
|
{
|
||||||
VLANState *vlan;
|
VLANState *vlan;
|
||||||
|
2
net.h
2
net.h
@ -164,6 +164,8 @@ void net_check_clients(void);
|
|||||||
void net_cleanup(void);
|
void net_cleanup(void);
|
||||||
void net_host_device_add(Monitor *mon, const QDict *qdict);
|
void net_host_device_add(Monitor *mon, const QDict *qdict);
|
||||||
void net_host_device_remove(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_SCRIPT "/etc/qemu-ifup"
|
||||||
#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
|
#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
|
||||||
|
@ -912,6 +912,36 @@ STEXI
|
|||||||
@item host_net_remove
|
@item host_net_remove
|
||||||
@findex host_net_remove
|
@findex host_net_remove
|
||||||
Remove host VLAN client.
|
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
|
||||||
|
@item netdev_add
|
||||||
|
@findex 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
|
||||||
|
@item netdev_del
|
||||||
|
@findex netdev_del
|
||||||
|
Remove host network device.
|
||||||
ETEXI
|
ETEXI
|
||||||
|
|
||||||
#ifdef CONFIG_SLIRP
|
#ifdef CONFIG_SLIRP
|
||||||
|
Loading…
Reference in New Issue
Block a user