[6610] qemu: PCI device, disk and host network hot-add / hot-remove ( Marcelo Tosatti)
Revision: 6610
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6610 Author: aliguori Date: 2009-02-11 15:21:54 +0000 (Wed, 11 Feb 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/Makefile.target
trunk/hw/acpi.c
trunk/hw/boards.h
trunk/hw/pci.h
trunk/monitor.c
trunk/net.c
trunk/net.h
trunk/sysemu.h
trunk/vl.c
Added Paths:
-----------
trunk/hw/device-hotplug.c
trunk/hw/pci-hotplug.c
Modified: trunk/Makefile.target
===================================================================
Makefile.target +1 -0
@@ -583,6 +583,7 @@ OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o +OBJS += device-hotplug.o pci-hotplug.o CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE endif ifeq ($(TARGET_BASE_ARCH), ppc)
Modified: trunk/hw/acpi.c
===================================================================
hw/acpi.c +4 -0
@@ -679,8 +679,12 @@static void pciej_write (void *opaque,uint32_t addr,uint32_t val) { +#if defined (TARGET_I386 )int slot =ffs (val) -1 ; +pci_device_hot_remove_success (0 , slot); +#endif +#if defined(DEBUG )printf ("pciej write %lx <== %d\n" , addr, val);#endif
Modified: trunk/hw/boards.h
===================================================================
hw/boards.h +2 -0
@@ -25,6 +25,8 @@int qemu_register_machine (QEMUMachine *m);void register_machines (void ); +extern QEMUMachine *current_machine; +/* Axis ETRAX. */ extern QEMUMachine bareetraxfs_machine;extern QEMUMachine axisdev88_machine;
Added: trunk/hw/device-hotplug.c
===================================================================
hw/device-hotplug.c +85 -0
85 lines not on this page · raw message
Added: trunk/hw/pci-hotplug.c
===================================================================
hw/pci-hotplug.c +219 -0
219 lines not on this page · raw message
Modified: trunk/hw/pci.h
===================================================================
hw/pci.h +3 -0
@@ -14,6 +14,9 @@/* Device classes and subclasses */ +#define PCI_BASE_CLASS_STORAGE 0x01 +#define PCI_BASE_CLASS_NETWORK 0x02 +#define PCI_CLASS_STORAGE_SCSI 0x0100#define PCI_CLASS_STORAGE_IDE 0x0101#define PCI_CLASS_STORAGE_OTHER 0x0180
Modified: trunk/monitor.c
===================================================================
monitor.c +14 -0
@@ -1511,6 +1511,20 @@ "", "cancel the current VM migration" }, { "migrate_set_speed", "s", do_migrate_set_speed, "value", "set maximum speed (in bytes) for migrations" }, +#if defined(TARGET_I386) + {"drive_add" ,"ss" , drive_hot_add,"pci_addr=[[<domain>:]<bus>:]<slot>\n" +"[file=file][,if=type][,bus=n]\n" +"[,unit=m][,media=d][index=i]\n" +"[,cyls=c,heads=h,secs=s[,trans=t]]\n" +"[snapshot=on|off][,cache=on|off]" , + "add drive to PCI storage controller" }, + { "pci_add", "sss", pci_device_hot_add, "pci_addr=auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" }, + { "pci_del", "s", pci_device_hot_remove, "pci_addr=[[<domain>:]<bus>:]<slot>", "hot remove PCI device" }, + { "host_net_add", "ss", net_host_device_add, + "[tap,user,socket,vde] options", "add host VLAN client" }, + { "host_net_remove", "is", net_host_device_remove, + "vlan_id name", "remove host VLAN client" }, +#endif { "balloon", "i", do_balloon, "target", "request VM to change it's memory allocation (in MB)" }, { "set_link", "ss", do_set_link,
Modified: trunk/net.c
===================================================================
net.c +56 -0
62 lines not on this page · raw message
Modified: trunk/net.h
===================================================================
net.h +2 -0
@@ -102,6 +102,8 @@void net_cleanup (void );int slirp_is_inited (void );void net_client_check (void ); +void net_host_device_add (const char *device,const char *opts); +void net_host_device_remove (int vlan_id,const char *device);#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
Modified: trunk/sysemu.h
===================================================================
sysemu.h +14 -0
@@ -170,6 +170,20 @@void qemu_system_hot_add_init (void );void qemu_system_device_hot_add (int pcibus,int slot,int state); +/* device-hotplug */ + +typedef int (dev_match_fn )(void *dev_private,void *arg); + +int add_init_drive (const char *opts); +void destroy_nic (dev_match_fn *match_fn,void *arg); +void destroy_bdrvs (dev_match_fn *match_fn,void *arg); + +/* pci-hotplug */ +void pci_device_hot_add (const char *pci_addr,const char *type,const char *opts); +void drive_hot_add (const char *pci_addr,const char *opts); +void pci_device_hot_remove (const char *pci_addr); +void pci_device_hot_remove_success (int pcibus,int slot); +/* serial ports */ #define MAX_SERIAL_PORTS 4
Modified: trunk/vl.c
===================================================================
vl.c +3 -0
@@ -3405,6 +3405,7 @@/* machine registration */ static QEMUMachine *first_machine =NULL ; +QEMUMachine *current_machine =NULL ;int qemu_register_machine (QEMUMachine *m) {
@@ -5587,6 +5588,8 @@ machine->init (ram_size, vga_ram_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model); + current_machine = machine; +/* Set KVM's vcpu state to qemu's initial CPUState. */ if (kvm_enabled ()) {int ret;