Revision ae82d324
b/net.c | ||
---|---|---|
1194 | 1194 |
qemu_del_vlan_client(vc); |
1195 | 1195 |
} |
1196 | 1196 |
|
1197 |
/** |
|
1198 |
* do_netdev_add(): Add a host network device |
|
1199 |
* |
|
1200 |
* Argument qdict contains |
|
1201 |
* - "type": the device type, "tap", "user", ... |
|
1202 |
* - "id": the device's ID (must be unique) |
|
1203 |
* - device options |
|
1204 |
* |
|
1205 |
* Example: |
|
1206 |
* |
|
1207 |
* { "type": "user", "id": "netdev1", "hostname": "a-guest" } |
|
1208 |
*/ |
|
1209 |
int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data) |
|
1210 |
{ |
|
1211 |
QemuOpts *opts; |
|
1212 |
int res; |
|
1213 |
|
|
1214 |
opts = qemu_opts_from_qdict(&qemu_netdev_opts, qdict); |
|
1215 |
if (!opts) { |
|
1216 |
return -1; |
|
1217 |
} |
|
1218 |
|
|
1219 |
res = net_client_init(mon, opts, 1); |
|
1220 |
return res; |
|
1221 |
} |
|
1222 |
|
|
1223 |
/** |
|
1224 |
* do_netdev_del(): Delete a host network device |
|
1225 |
* |
|
1226 |
* Argument qdict contains |
|
1227 |
* - "id": the device's ID |
|
1228 |
* |
|
1229 |
* Example: |
|
1230 |
* |
|
1231 |
* { "id": "netdev1" } |
|
1232 |
*/ |
|
1233 |
int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data) |
|
1234 |
{ |
|
1235 |
const char *id = qdict_get_str(qdict, "id"); |
|
1236 |
VLANClientState *vc; |
|
1237 |
|
|
1238 |
vc = qemu_find_netdev(id); |
|
1239 |
if (!vc || vc->info->type == NET_CLIENT_TYPE_NIC) { |
|
1240 |
qerror_report(QERR_DEVICE_NOT_FOUND, id); |
|
1241 |
return -1; |
|
1242 |
} |
|
1243 |
if (vc->peer) { |
|
1244 |
qerror_report(QERR_DEVICE_IN_USE, id); |
|
1245 |
return -1; |
|
1246 |
} |
|
1247 |
qemu_del_vlan_client(vc); |
|
1248 |
qemu_opts_del(qemu_opts_find(&qemu_netdev_opts, id)); |
|
1249 |
return 0; |
|
1250 |
} |
|
1251 |
|
|
1197 | 1252 |
void do_info_network(Monitor *mon) |
1198 | 1253 |
{ |
1199 | 1254 |
VLANState *vlan; |
b/net.h | ||
---|---|---|
164 | 164 |
void net_cleanup(void); |
165 | 165 |
void net_host_device_add(Monitor *mon, const QDict *qdict); |
166 | 166 |
void net_host_device_remove(Monitor *mon, const QDict *qdict); |
167 |
int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data); |
|
168 |
int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data); |
|
167 | 169 |
|
168 | 170 |
#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" |
169 | 171 |
#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" |
b/qemu-monitor.hx | ||
---|---|---|
914 | 914 |
Remove host VLAN client. |
915 | 915 |
ETEXI |
916 | 916 |
|
917 |
{ |
|
918 |
.name = "netdev_add", |
|
919 |
.args_type = "netdev:O", |
|
920 |
.params = "[user|tap|socket],id=str[,prop=value][,...]", |
|
921 |
.help = "add host network device", |
|
922 |
.user_print = monitor_user_noop, |
|
923 |
.mhandler.cmd_new = do_netdev_add, |
|
924 |
}, |
|
925 |
|
|
926 |
STEXI |
|
927 |
@item netdev_add |
|
928 |
@findex netdev_add |
|
929 |
Add host network device. |
|
930 |
ETEXI |
|
931 |
|
|
932 |
{ |
|
933 |
.name = "netdev_del", |
|
934 |
.args_type = "id:s", |
|
935 |
.params = "id", |
|
936 |
.help = "remove host network device", |
|
937 |
.user_print = monitor_user_noop, |
|
938 |
.mhandler.cmd_new = do_netdev_del, |
|
939 |
}, |
|
940 |
|
|
941 |
STEXI |
|
942 |
@item netdev_del |
|
943 |
@findex netdev_del |
|
944 |
Remove host network device. |
|
945 |
ETEXI |
|
946 |
|
|
917 | 947 |
#ifdef CONFIG_SLIRP |
918 | 948 |
{ |
919 | 949 |
.name = "hostfwd_add", |
Also available in: Unified diff