aboutsummaryrefslogtreecommitdiffstats
path: root/hw/device-hotplug.c
AgeCommit message (Collapse)AuthorFilesLines
2012-01-04Add generic drive hotpluggingAlexander Graf1-0/+47
The monitor command for hotplugging is in i386 specific code. This is just plain wrong, as S390 just learned how to do hotplugging too and needs to get drives for that. So let's add a generic copy to generic code that handles drive_add in a way that doesn't have pci dependencies. All pci specific code can then be handled in a pci specific function. Signed-off-by: Alexander Graf <agraf@suse.de> --- v1 -> v2: - align generic drive_add to pci specific one - rework to split between generic and pci code v2 -> v3: - remove comment
2011-01-31blockdev: Fix drive_add for drives without mediaMarkus Armbruster1-2/+1
Watch this: (qemu) drive_add 0 if=none (qemu) info block none0: type=hd removable=0 [not inserted] (qemu) drive_del none0 Segmentation fault (core dumped) add_init_drive() is confused about drive_init()'s failure modes, and cleans up when it shouldn't. This leaves the DriveInfo with member opts dangling. drive_del attempts to free it, and dies. drive_init() behaves as follows: * If it created a drive with media, it returns its DriveInfo. * If it created a drive without media, it clears *fatal_error and returns NULL. * If it couldn't create a drive, it sets *fatal_error and returns NULL. Of its three callers: * drive_init_func() is correct. * usb_msd_init() assumes drive_init() failed when it returns NULL. This is correct only because it always passes option "file", and "drive without media" can't happen then. * add_init_drive() assumes drive_init() failed when it returns NULL. This is incorrect. Clean up drive_init() to return NULL on failure and only on failure. Drop its parameter fatal_error. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-31blockdev: Make drive_add() take explicit type, index parametersMarkus Armbruster1-1/+1
Before, type & index were hidden in printf-like fmt, ... parameters, which get expanded into an option string. Rather inconvenient for uses later in this series. New IF_DEFAULT to ask for the machine's default interface. Before, that was done by having no option "if" in the option string. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-08-24Rearrange block headersBlue Swirl1-0/+1
Changing block.h or blockdev.h resulted in recompiling most objects. Move DriveInfo typedef and BlockInterfaceType enum definitions to qemu-common.h and rearrange blockdev.h use to decrease churn. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-04blockdev: Collect block device code in new blockdev.cMarkus Armbruster1-2/+0
Anything that moves hundreds of lines out of vl.c can't be all bad. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-04blockdev: Hide QEMUMachine from drive_init()Markus Armbruster1-1/+1
To pave the way for moving it out of vl.c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2009-10-27kill dead nic unplug code.Gerd Hoffmann1-16/+0
Cleanup on unplug happens via qdev->exit() callback now. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05drive cleanup fixes.Gerd Hoffmann1-18/+0
Changes: * drive_uninit() wants a DriveInfo now. * drive_uninit() also calls bdrv_delete(), so callers don't need to do that. * drive_uninit() calls are moved over to the ->exit() callbacks, destroy_bdrvs() is zapped. * setting bdrv->private is not needed any more as the only user (destroy_bdrvs) is gone. * usb-storage needs no drive_uninit, scsi-disk will handle that. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-12Fix sys-queue.h conflict for goodBlue Swirl1-1/+1
Problem: Our file sys-queue.h is a copy of the BSD file, but there are some additions and it's not entirely compatible. Because of that, there have been conflicts with system headers on BSD systems. Some hacks have been introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-27switch -drive to QemuOpts.Gerd Hoffmann1-6/+6
Demo QemuOpts in action ;) Implementing a alternative way to specify the filename should be just a few lines of code now once we decided how the cmd line syntax should look like. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27kill drives_optGerd Hoffmann1-5/+5
cleanup pretty simliar to the drives_table removal patch: - drop the table and make a linked list out of it. - pass around struct pointers instead of table indices. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27kill drives_tableGerd Hoffmann1-11/+12
First step cleaning up the drives handling. This one does nothing but removing drives_table[], still it became seriously big. drive_get_index() is gone and is replaced by drives_get() which hands out DriveInfo pointers instead of a table index. This needs adaption in *tons* of places all over. The drives are now maintained as linked list. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-09Don't leak VLANClientState on PCI hot removeMark McLoughlin1-6/+1
destroy_nic() requires that NICInfo::private by a PCIDevice pointer, but then goes on to require that the same pointer matches VLANClientState::opaque. That is no longer the case for virtio-net since qdev and wasn't previously the case for rtl8139, ne2k_pci or eepro100. Make the situation a lot more clear by maintaining a VLANClientState pointer in NICInfo. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-02-26fix pci net hot-remove (Marcelo Tosatti)aliguori1-1/+2
Missing brackets, doh. 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@6645 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-11qemu: PCI device, disk and host network hot-add / hot-remove (Marcelo Tosatti)aliguori1-0/+85
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