diff options
author | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-02-11 15:21:54 +0000 |
---|---|---|
committer | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-02-11 15:21:54 +0000 |
commit | 6f338c3469297d748be33aea864161e36e068436 (patch) | |
tree | 99f66dd4c49c9f6ded9b1d13f47e33900a96e47c /net.c | |
parent | 880345c484df16a1ec91febb8751d43b5fb8fc77 (diff) |
qemu: PCI device, disk and host network hot-add / hot-remove (Marcelo Tosatti)
Add monitor command to hot-add PCI devices (nic and storage).
Syntax is:
pci_add pci_addr=[[<domain>:]<bus>:]<slot> nic|storage params
It returns the domain, bus and slot for the newly added device on success.
It is possible to attach a disk to a device after PCI initialization via
the drive_add command. If so, a manual scan of the SCSI bus on the guest
is necessary.
Save QEMUMachine necessary for drive_init.
Add monitor command to hot-remove devices, remove device data on _EJ0 notification.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6610 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'net.c')
-rw-r--r-- | net.c | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -1734,6 +1734,62 @@ void net_client_uninit(NICInfo *nd) free((void *)nd->model); } +static int net_host_check_device(const char *device) +{ + int i; + const char *valid_param_list[] = { "tap", "socket" +#ifdef CONFIG_SLIRP + ,"user" +#endif +#ifdef CONFIG_VDE + ,"vde" +#endif + }; + for (i = 0; i < sizeof(valid_param_list) / sizeof(char *); i++) { + if (!strncmp(valid_param_list[i], device, + strlen(valid_param_list[i]))) + return 1; + } + + return 0; +} + +void net_host_device_add(const char *device, const char *opts) +{ + if (!net_host_check_device(device)) { + term_printf("invalid host network device %s\n", device); + return; + } + net_client_init(device, opts); +} + +void net_host_device_remove(int vlan_id, const char *device) +{ + VLANState *vlan; + VLANClientState *vc; + + if (!net_host_check_device(device)) { + term_printf("invalid host network device %s\n", device); + return; + } + + vlan = qemu_find_vlan(vlan_id); + if (!vlan) { + term_printf("can't find vlan %d\n", vlan_id); + return; + } + + for(vc = vlan->first_client; vc != NULL; vc = vc->next) + if (!strcmp(vc->name, device)) + break; + + if (!vc) { + term_printf("can't find device %s\n", device); + return; + } + qemu_del_vlan_client(vc); +} + int net_client_parse(const char *str) { const char *p; |