summaryrefslogtreecommitdiffstats
path: root/hw/pci-hotplug.c
Commit message (Collapse)AuthorAgeFilesLines
* Rearrange block headersBlue Swirl2010-08-241-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>
* QemuOpts: make most qemu_*_opts staticGerd Hoffmann2010-08-221-1/+1
| | | | | | | | Switch tree to lookup-by-name using qemu_find_opts(). Also hook up virtfs options so qemu_find_opts works for them too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* pci hotplug: make pci_device_hot_remove() staticIsaku Yamahata2010-07-111-1/+1
| | | | | | Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* block: Catch attempt to attach multiple devices to a blockdevMarkus Armbruster2010-07-021-1/+5
| | | | | | | | | | | | | | | For instance, -device scsi-disk,drive=foo -device scsi-disk,drive=foo happily creates two SCSI disks connected to the same block device. It's all downhill from there. Device usb-storage deliberately attaches twice to the same blockdev, which fails with the fix in place. Detach before the second attach there. Also catch attempt to delete while a guest device model is attached. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qdev: Decouple qdev_prop_drive from DriveInfoMarkus Armbruster2010-07-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Make the property point to BlockDriverState, cutting out the DriveInfo middleman. This prepares the ground for block devices that don't have a DriveInfo. Currently all user-defined ones have a DriveInfo, because the only way to define one is -drive & friends (they go through drive_init()). DriveInfo is closely tied to -drive, and like -drive, it mixes information about host and guest part of the block device. I'm working towards a new way to define block devices, with clean host/guest separation, and I need to get DriveInfo out of the way for that. Fortunately, the device models are perfectly happy with BlockDriverState, except for two places: ide_drive_initfn() and scsi_disk_initfn() need to check the DriveInfo for a serial number set with legacy -drive serial=... Use drive_get_by_blockdev() there. Device model code should now use DriveInfo only when explicitly dealing with drives defined the old way, i.e. without -device. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: scsi_bus_legacy_handle_cmdline() can fail, fix callersMarkus Armbruster2010-07-021-0/+3
| | | | | | | | | | | | | | None of its callers checks for failure. scsi_hot_add() can crash because of that: (qemu) drive_add 4 if=scsi,format=host_device,file=/dev/sg1 scsi-generic: scsi generic interface too old Segmentation fault (core dumped) Fix all callers, not just scsi_hot_add(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blockdev: Collect block device code in new blockdev.cMarkus Armbruster2010-06-041-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>
* pci-hotplug: make them aware of pci domain.Isaku Yamahata2010-05-311-3/+4
| | | | | | | | add helper function which converts root bus to pci domain. make them aware of pci domain. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* Revert "monitor: Convert do_pci_device_hot_remove() to QObject"Markus Armbruster2010-05-191-3/+2
| | | | | | | | | | | | | We don't want pci_del in QMP. Use device_del instead. This reverts commit 6848d827162fea039f2658414a4adb6164a4f9b0. Conflicts: hw/pci-hotplug.c sysemu.h Signed-off-by: Markus Armbruster <armbru@redhat.com>
* Revert "PCI: Convert pci_device_hot_add() to QObject"Markus Armbruster2010-05-191-41/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Short story: We don't want pci_add in QMP. Long story follows. pci_add can do two things: * Hot plug a PCI NIC. device_add is more general. * Hot plug a PCI disk controller, and a drive connected to it. The controller is either virtio-blk-pci (if=virtio) or lsi53c895a (if=scsi). With the latter, the drive is optional. Use drive_add to hotplug additional SCSI drives. Except drive_add is not available in QMP. device_add is more general for controllers and the guest part of drives. I'm working on a more general alternative for the host part of drives. Why am I proposing to remove pci_add from QMP before its replacement is ready? I want it out sooner rather than later, because it isn't fully functional (errors and drive_add are missing), and we do not plan to complete the job. In other words, it's not really usable over QMP now, and it's not what we want for QMP anyway. Since we don't want it to be used over QMP, we should take it out, not leave it around as a trap for the uninitiated. Dan Berrange confirmed that libvirt has no need for pci_add & friends over QMP. This reverts commit 7a344f7ac7bb651d0556a933ed8060d3a9e5d949. Conflicts: hw/pci-hotplug.c sysemu.h Signed-off-by: Markus Armbruster <armbru@redhat.com>
* x86: remove dead assignments, spotted by clang analyzerBlue Swirl2010-04-251-2/+1
| | | | | | Value stored is never read. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* error: Drop extra messages after qemu_opts_set() and qemu_opts_parse()Markus Armbruster2010-04-181-2/+0
| | | | | | | | Both functions report errors nicely enough now, no need for additional messages. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qemu-option: Move the implied first name into QemuOptsListMarkus Armbruster2010-03-161-1/+1
| | | | | | | | | | | We sometimes permit omitting the first option name, for example -device foo is short for -device driver=foo. The name to use ("driver" in the example) is passed as argument to qemu_opts_parse(). For each QemuOptsList, we use at most one such name. Move the name into QemuOptsList, and pass whether to permit the abbreviation. This ensures continued consistency, and simplifies the commit after next in this series.
* error: Replace qemu_error() by error_report()Markus Armbruster2010-03-161-1/+1
| | | | | | | | | | | | | error_report() terminates the message with a newline. Strip it it from its arguments. This fixes a few error messages lacking a newline: net_handle_fd_param()'s "No file descriptor named %s found", and tap_open()'s "vnet_hdr=1 requested, but no kernel support for IFF_VNET_HDR available" (all three versions). There's one place that passes arguments without newlines intentionally: load_vmstate(). Fix it up.
* error: Don't abuse qemu_error() for non-error in scsi_hot_add()Markus Armbruster2010-03-161-4/+6
| | | | | | | | Commit 30d335d6 converted an informational message from monitor_printf() to qemu_error(), probably because the latter doesn't need a mon argument. A later commit will make qemu_error() print additional stuff that is only appropriate for proper errors, and then this will break. Clean it up.
* Monitor: Convert pci_device_hot_remove() to cmd_new_ret()Luiz Capitulino2010-02-191-7/+7
| | | | | Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Monitor: Convert pci_device_hot_add() to cmd_new_ret()Luiz Capitulino2010-02-191-5/+11
| | | | | Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Monitor: remove unneeded checksLuiz Capitulino2010-02-101-1/+0
| | | | | | | | It's not needed to check the return of qobject_from_jsonf() anymore, as an assert() has been added there. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix backcompat for hotplug of SCSI controllersDaniel P. Berrange2009-12-181-5/+1
| | | | | | | | | | | | | | | | | | | | SCSI controllers have no trouble existing without any attached disks. This could be achieved with the (legacy) monitor syntax pci_add pci_addr=auto storage if=scsi This is now denied with scsi requires a backing file/device. failed to add if=scsi There is no need for this denial and it breaks compatability with existing QEMU usage, so remove the check for presence of a drive. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* PCI: Convert pci_device_hot_add() to QObjectLuiz Capitulino2009-12-121-4/+36
| | | | | | | | | | | | | Return a QDict with information about the just added device. This commit should not change user output. Please, note that this patch does not do error handling conversion. In error conditions the handler still calls monitor_printf(). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* scsi: fix drive hotplug.Gerd Hoffmann2009-12-121-0/+1
| | | | | | | | | | | | | This patch fills the DriveInfo->unit after hotplugging a scsi disk. It makes a difference when auto-assigning a scsi id, where unit was left filled with '-1' instead of the actual scsi id. With this patch applied the the drive naming logic in drive_init() works as good as it did in previous releases. Which means it works fine with a single scsi bus. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* pci: don't abort() when trying to hotplug with acpi off.Gerd Hoffmann2009-12-121-1/+16
| | | | | | | | | | | The PCI bus on x86 requires ACPI for hotplug support, thus disbling ACPI also disables hotplug for the PCI bus. This patch makes qemu check whenever the PCI bus in question can handle hotplug before trying to add devices. This is needed because qdev will abort() on any attempt to hotplug devices into a non-hotpluggable bus. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* pci: s/pci_find_host_bus/pci_find_root_bus/gIsaku Yamahata2009-12-011-2/+2
| | | | | | | | This patch renames pci_find_host_bus() to pci_find_root_bus() as suggested by "Michael S. Tsirkin" <mst@redhat.com>. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: make pci configuration transaction more accurate.Isaku Yamahata2009-11-091-2/+2
| | | | | | | | | | | | | | | | | | | | This patch sorts out/enhances pci code to track pci bus topology more accurately. - Track host bus bridge with pci domain number. Although the current qemu implementation supports only pci domian 0 yet. - Track pci bridge parent-child relationship. When looking down from pci host bus for pci sub bus, be aware of secondary bus/subordinate bus. Thus pci configuration transaction is more accurately emulated. This patch adds new member to PCIBus to track pci bus topology. Since qdev already tracks down bus relationship, those new member wouldn't be necessary. However it would be addressed later because not all the pci device isn't converted to qdev yet. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* scsi: move scsi-disk.h -> scsi.hGerd Hoffmann2009-11-091-1/+1
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Convert do_pci_device_hot_remove() to QObjectLuiz Capitulino2009-10-271-1/+2
| | | | | | | | Errors are still directly printed, as we are only converting regular output. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* hotplug: more fixes for scsi disk hotplug.Gerd Hoffmann2009-10-271-10/+34
| | | | | | | | | | | | Changes: - create common scsi_hot_add function for adding a scsi disk to a adapter. - Add sanity checks. You can't drive_add disks to the VGA any more. - Ignore the unit value calculated by drive_init, add a comment explaining why. Review the patch to find the details ;) Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* hotplug: fix "pci_add storage if=scsi"Gerd Hoffmann2009-10-271-2/+13
| | | | | | | | | Explicitly add the drive to the bus of the newly created scsi adapter instead of hoping that scsi_bus_legacy_handle_cmdline() picks it up correctly. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* kill dead nic unplug code.Gerd Hoffmann2009-10-271-25/+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>
* net: handle -netdevice optionsMark McLoughlin2009-10-151-1/+1
| | | | | | | | | | | | | Same as for -net except for: - only tap, user, vde and socket types are supported - the vlan parameter is not allowed - the name parameter is not allowed but the id parameter is required Patchworks-ID: 35517 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* TARGET_I386 is always defined if TARGET_X86_64 is definedJuan Quintela2009-10-121-1/+1
| | | | | | Patchworks-ID: 35378 Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Check return value of qdev_init()Markus Armbruster2009-10-071-2/+2
| | | | | | | | | But do so only where it may actually fail. Leave the rest for the next commit. Patchworks-ID: 35167 Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Final net cleanup after conversion to QemuOptsMark McLoughlin2009-10-061-1/+1
| | | | | | | | | | | | | | | | Now that net_client_init() has no users, kill it off and rename net_client_init_from_opts(). There is no further need for the old code in net_client_parse() either. We use qemu_opts_parse() 'firstname' facitity for that. Instead, move the special handling of the 'vmchannel' type there. Simplify the vl.c code into merely call net_client_parse() for each -net command line option and then calling net_init_clients() later to iterate over the options and create the clients. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Port PCI NIC hotplug to QemuOptsMark McLoughlin2009-10-061-2/+14
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Revert "Fix exit on 'pci_add' Monitor command"Anthony Liguori2009-10-061-4/+0
| | | | | | | | This reverts commit 0148fde54c2478ea8a47c8dbfe4c0fb8bda4d996. As requested by Luiz. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Rename pci_create_noinit() to pci_create()Markus Armbruster2009-10-051-2/+2
| | | | | | | It's qdev_create() specialized for PCI, so name it accordingly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix pci_add storage not to exit on bad first argumentMarkus Armbruster2009-10-051-2/+10
| | | | | | | | | | | | Monitor command "pci_add ADDR storage ..." does its work in qemu_pci_hot_add_nic(). It called pci_create(..., ADDR) to create the device. That's wrong, because pci_create() terminates the program when ADDR is invalid. Use pci_get_bus_devfn() and pci_create_noinit() instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* allow if=none for drive_addGerd Hoffmann2009-10-051-0/+3
| | | | | | | | | | | | | | | | | Allow adding unconnected host drives by specifying if=none like it is possible with -drive. They can be put in use with drive attributes, like this: drive_add dummy if=none,id=mydisk,file=/some/disk.img device_add virtio-blk-pci,drive=mydisk which is the monitor aequivalent to these command line switches: -drive if=none,id=mydisk,file=/some/disk.img -device virtio-blk-pci,drive=mydisk Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* refactor drive_hot_addGerd Hoffmann2009-10-051-19/+19
| | | | | | | | move pci device lookup into the "case IF_SCSI" section, so we can do something else for other interface types. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* drive cleanup fixes.Gerd Hoffmann2009-10-051-3/+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>
* pci: windup acpi-based hotplugGerd Hoffmann2009-10-051-13/+2
| | | | | | | | Switch over acpi-based PCI hotplug for pc over to the new qdev-based pci hotplugging. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* pci: use qdev for device destruction.Gerd Hoffmann2009-10-051-1/+1
| | | | | | | | pci_unregister_device is static now and hooked into Devicestate->exit. qdev_free(pci_device) works now. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix exit on 'pci_add' Monitor commandLuiz Capitulino2009-10-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the user issues one of the following commands to the Monitor: pci_add pci_addr=auto nic model=None pci_add pci_addr=auto nic model=? QEMU will exit, because the function used to perform sanity checks (qemu_check_nic_model_list()) exits on error. This function is used by the startup code, where it makes sense to exit on error, but in the Monitor it doesn't. Changing qemu_check_nic_model_list() to not exit on error is not possible though, as it's used by the board init code (the PC one), where all board specific code must have void return. The way I've chosen to fix this was to introduce a new function called pci_nic_supported(), which checks if the NIC is supported and returns true or false accordingly. The new function is used only by the Monitor, it performs the necessary check and returns an error in case the NIC is not supported, thus qemu_check_nic_model_list()'s exit is never trigged. The following should be observed: 1. Only the specified NIC is checked, the default one is assumed to be supported 2. The NIC query command (model=?) won't work with pci_add, the right way to do this with the Monitor is to add a new command Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix sys-queue.h conflict for goodBlue Swirl2009-09-121-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>
* qdev/scsi: add scsi bus support to qdev, convert drivers.Gerd Hoffmann2009-09-091-2/+5
| | | | | | | | | | | | | | | | | | * Add SCSIBus. * Add SCSIDeviceInfo, move device callbacks here. * add qdev/scsi helper functions. * convert drivers. Adding scsi disks via -device works now, i.e. you can do: -drive id=sda,if=none,... -device lsi -device scsi-disk,drive=sda legacy command lines (-drive if=scsi,...) continue to work. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Port handler_3 to use QDictLuiz Capitulino2009-09-041-2/+4
| | | | | | | | This commit ports command handlers that receive three arguments to use the new monitor's dictionary. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Port handler_2 to use QDictLuiz Capitulino2009-09-041-1/+3
| | | | | | | | This commit ports command handlers that receive two arguments to use the new monitor's dictionary. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Port handler_1 to use QDictLuiz Capitulino2009-09-041-2/+2
| | | | | | | | This commit ports command handlers that receive one argument to use the new monitor's dictionary. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Add wrappers to functions used by the MonitorLuiz Capitulino2009-09-041-0/+5
| | | | | | | | | | | | | | | | | | | | | Some functions exported to be used by the Monitor as command handlers are also called in other places as regular functions. When those functions got ported to use the Monitor dictionary to pass argments, the callers will have to setup a dictionary to be able to call them. To avoid this problem, this commit add wrappers to those functions, so that we change the wrapper to accept the dictionary, letting the current functions as is. The following wrappers are being added: - do_help_cmd() - do_pci_device_hot_remove() Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* pci-hotplug: initialize dinfo to NULL in pci_device_hot_addSebastian Herbszt2009-08-271-1/+1
| | | | | | | | | | | | Suppress the following compiler warning emitted by at least gcc version 4.2.1 (SUSE Linux) and gcc version 3.4.5 (mingw32 special): hw/pci-hotplug.c: In function 'pci_device_hot_add': hw/pci-hotplug.c:102: warning: 'dinfo' may be used uninitialized in this function hw/pci-hotplug.c:102: note: 'dinfo' was declared here Signed-off-by: Sebastian Herbszt <herbszt@gmx.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
OpenPOWER on IntegriCloud