aboutsummaryrefslogtreecommitdiff
path: root/hw
AgeCommit message (Collapse)AuthorFilesLines
2009-10-07New qdev_init_nofail()Markus Armbruster34-58/+72
Like qdev_init(), but terminate program via hw_error() instead of returning an error value. Use it instead of qdev_init() where terminating the program on failure is okay, either because it's during machine construction, or because we know that failure can't happen. Because relying in the latter is somewhat unclean, and the former is not always obvious, it would be nice to go back to qdev_init() in the not-so-obvious cases, only with proper error handling. I'm leaving that for another day, because it involves making sure that error values are properly checked by all callers. Patchworks-ID: 35168 Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-07Check return value of qdev_init()Markus Armbruster4-4/+8
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>
2009-10-07Make qdev_init() destroy the device on failureMarkus Armbruster2-4/+6
Before, every caller had to do this. Only two actually did. Patchworks-ID: 35170 Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06qdev: move commentGerd Hoffmann1-1/+1
Move comment back next to main_system_bus to avoid confusion. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06qemu/pci: make pci not depend on msixMichael S. Tsirkin2-3/+9
Making pci device cleanup msix automatically makes pci.c depend on msix.c, which is IMO messy. Since devices do msix_init it's easy and natural for them to also do msix_uninit. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06qemu/pci: clarify pci config load routineMichael S. Tsirkin1-4/+5
PCI load routine has to be called with size equal to 256 (otherwise it will crash in weird ways). So assert this, making code clearer. Also avoid dynamically sized array on stack - good for portability. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Cc: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Final net cleanup after conversion to QemuOptsMark McLoughlin1-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>
2009-10-06Port PCI NIC hotplug to QemuOptsMark McLoughlin1-2/+14
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Make NICInfo string fields non-constMark McLoughlin2-2/+2
We now only assign strdup()ed strings to these fields, never static strings. aliguori: fix build for ppc_prep and mips_jazz Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Revert "Fix exit on 'pci_add' Monitor command"Anthony Liguori3-16/+0
This reverts commit 0148fde54c2478ea8a47c8dbfe4c0fb8bda4d996. As requested by Luiz. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Reorganize option rom (+linux kernel) loading.Gerd Hoffmann4-248/+312
This patch adds infrastructure to maintain memory regions which must be restored on reset. That includes roms (vga bios and option roms on pc), but is also used when loading linux kernels directly. Features: - loading files is supported. - passing blobs is supported. - target address range is supported (for optionrom area). - fixed target memory address is supported (linux kernel). New in v2: - writes to ROM are done only at initial boot. - also handle aout and uimage loaders. - drop unused fread_targphys() function. The final memory layout is created once all memory regions are registered. The option roms get addresses assigned and the registered regions are checked against overlaps. Finally all data is copyed to the guest memory. Advantages: (1) Filling memory on initial boot and on reset takes the same code path, making reset more robust. (2) The need to keep track of the option rom load address is gone. (3) Due to (2) option roms can be loaded outside pc_init(). This allows to move the pxe rom loading into the nic drivers for example. Additional bonus: There is a 'info roms' monitor command now. The patch also switches over pc.c and removes the option_rom_setup_reset() and load_option_rom() functions. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06eepro100: support 16 bit read from SCBCmd (== 2)=?UTF-8?q?Reimar=20D=C3=B6ffinger?=1-0/+1
This is necessary to support OpenBSD 4.2 install, without this change it triggers an assert. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Improve error reporting on file accessJustin M. Forbes1-6/+6
By making the error reporting include strerror(errno), it gives the user a bit more indication as to why qemu failed. This is particularly important for people running qemu as a non root user. Signed-off-by: Justin M. Forbes <jforbes@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Rename pci_create_noinit() to pci_create()Markus Armbruster5-9/+9
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>
2009-10-05pci_create() is now unused, remove itMarkus Armbruster2-19/+0
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Fix pci_add nic not to exit on bad modelMarkus Armbruster13-14/+43
Monitor command "pci_add ADDR nic model=MODEL" uses pci_nic_init() to create the NIC. When MODEL is unknown or "?", this prints to stderr and terminates the program. Change pci_nic_init() not to treat "?" specially, and to return NULL on failure. Switch uses during startup to new convenience wrapper pci_nic_init_nofail(), which behaves just like pci_nic_init() used to do. Bonus bug fix: we now check for qdev_init() failing there. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Make it obvious that pci_nic_init() can't failMarkus Armbruster1-16/+9
Before this patch, pci_nic_init() returns NULL when it can't find the model in pci_nic_models[]. Except this can't happen, because qemu_check_nic_model_list() just searched for model in pci_nic_models[], and terminated the program on failure. Repeating the search here is pointless. Instead, change qemu_check_nic_model_list() to return the model's array index. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Fix pci_add storage not to exit on bad first argumentMarkus Armbruster3-3/+12
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>
2009-10-05Fix pci_vga_init() not to ignore bus argumentMarkus Armbruster1-1/+1
Commit a414c306 converted all VGA devices to qdev. It used pci_create_simple() for all devices, except for this one it used pci_create(). That's wrong, because it uses PCI bus#0 regardless of the bus argument. Fix by switching to pci_create_noinit(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05set correct CS seg limit and flags on sipiGleb Natapov1-1/+1
TCG works with incorrect values somehow. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Set revision in eeprom correctly for 82557 versions.=?UTF-8?q?Reimar=20D=C3=B6ffinger?=1-0/+2
This is necessary to make FreeBSD recognize the device as 82557 - otherwise its driver will use unsupported features and fail to work. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05virtio-pci: return error if virtio_console_init failsAmit Shah1-0/+3
Currently only one virtio_console device is supported. Trying to add multiple devices fails and such failure should be reported back to the qdev init functions. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qdev: show name of device that fails initAmit Shah1-0/+1
When initialising a device fails, show the name of the failing device. The current behaviour is to silently exit on such errors. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05eepro100: Don't allow guests to fail assertionsKevin Wolf1-11/+35
The idea of using assert() for input validation is rather questionable. Let's remove it from eepro100, so that guests need to find more interesting ways if they want to crash qemu. This patch replaces asserts that are directly dependent on guest-accessible data by other means of error handling. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qemu/virtio-pci: remove unnecessary checkMichael S. Tsirkin1-2/+1
it's safe to call msix_write_config if msix is disabled, so call it unconditionally on pci config write. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qemu: clean up target page usage in msixMichael S. Tsirkin4-36/+27
Since cpu_register_phys_memory does not require size to be a multiple of target page size, simply make msix page size 0x1000. Do this in msix, reverting part of 5e520a7d500ec2569d22d80f9ef4272a34cb3c80, as we no longer have to pass target page around. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qemu/pci: reset device registers on bus resetMichael S. Tsirkin1-0/+13
Reset BARs and a couple of other registers on bus reset, as per PCI spec. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qemu/pci: refactor code/symbolic constantsMichael S. Tsirkin2-20/+23
refactor code slightly, adding symbolic constants and functions, and using macros where possible. This will also make following reset patches easier. No functional changes. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qemu/virtio: fix reset with device removalMichael S. Tsirkin1-6/+8
virtio pci registers its own reset handler, but fails to unregister it, which will lead to crashes after device removal. Solve this problem by switching to qdev reset handler, which is automatically unregistered. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qemu/qdev: type safety in reset handlerMichael S. Tsirkin4-13/+19
Add type safety to qdev reset handlers, by declaring them as DeviceState * rather than void *. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05serial: convert isa to qdevGerd Hoffmann7-28/+75
Everything using standard isa I/O ports and IRQ windup is considerd being an actual isa device. That are all serial_init() users except mips_mipssim() which seems to have a non-standard IRQ windup. baud rate is fixed at 115200 now as no caller passed in something else. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qdev: don't crash on unset drive properties.Gerd Hoffmann1-1/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05floppy: move dma setup + drive connect to fdctrl_init_common()Gerd Hoffmann1-20/+11
isa-fdc is completely qdev-ified with this patch applied, all configuration uses properties. sysbus-fdc needs dma_channel config fixed. There is only one user (mips_jazz) which uses dma channel 0. Can anyone knowing this platform suggest how to deal with it? Is hardcoding fine? Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05floppy: add drive properties.Gerd Hoffmann8-46/+55
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05store a pointer to QemuOpts in DeviceState, release it when zapping a device.Gerd Hoffmann2-0/+4
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05allow if=none for drive_addGerd Hoffmann1-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>
2009-10-05refactor drive_hot_addGerd Hoffmann1-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>
2009-10-05drive cleanup fixes.Gerd Hoffmann7-30/+19
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-10-05pci: windup acpi-based hotplugGerd Hoffmann4-36/+25
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>
2009-10-05pci: hotplug windupGerd Hoffmann2-2/+25
Create qdev infrastructure for pci hotplug. PCI bus implementations must register a handler for hotplug. Creating a new PCI device will automagically hot-plug it in case the PCI bus in question supports this. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05scsi: hotplug windupGerd Hoffmann2-0/+3
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05usb: hotplug windupGerd Hoffmann1-0/+2
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qdev hotplug: infrastructure and monitor commands.Gerd Hoffmann2-2/+89
Adds device_add and device_del commands. device_add accepts accepts the same syntax like the -device command line switch. device_del expects a device id. So you should tag your devices with ids if you want to remove them later on, like this: device_add pci-ohci,id=ohci device_del ohci Unplugging via pci_del or usb_del works too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05usb: hook unplug into qdev, cleanups + fixes.Gerd Hoffmann8-15/+56
Hook into DeviceInfo->exit(). handle_destroy() must not free the state struct, this is handled by the new usb_qdev_exit() function now. qdev_free(usb_device) works now. Fix usb hub to qdev_free() all connected devices on unplug. Unplugging a usb hub works now. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05pci: move unregister from PCIDevice to PCIDeviceInfoGerd Hoffmann8-11/+13
One more cleanup while being at it ;) Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05pci: use qdev for device destruction.Gerd Hoffmann3-5/+4
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>
2009-10-05Implement scsi device destructionGerd Hoffmann3-11/+21
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Add exit callback to DeviceInfo.Gerd Hoffmann2-0/+4
This adds a exit callback for device destruction to DeviceInfo, so we can hook cleanups into qdev device destruction. Followup patches will put that into use. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qdev: device free fixups.Gerd Hoffmann2-4/+38
Two bug fixes: * When freeing a device we unregister even stuff we didn't register in the first place because the ->init() callback failed. * When freeing a device with child busses attached, we fail to zap the child bus (and the devices attached to it). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05parallel: convert isa to qdevGerd Hoffmann5-14/+57
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>