aboutsummaryrefslogtreecommitdiffstats
path: root/hw/qdev.c
AgeCommit message (Collapse)AuthorFilesLines
2009-09-12Fix sys-queue.h conflict for goodBlue Swirl1-16/+16
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-09-09qdev: integrate vmstateGerd Hoffmann1-0/+6
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09qdev: integrate resetGerd Hoffmann1-1/+10
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09qdev/scsi: add scsi bus support to qdev, convert drivers.Gerd Hoffmann1-19/+0
* 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>
2009-09-09qdev: add error message to qdev_device_add().Gerd Hoffmann1-1/+4
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27qdev error loggingGerd Hoffmann1-17/+17
Use the new qemu_error() function in qdev.c Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27qdev: add return value to init() callbacks.Gerd Hoffmann1-3/+6
Sorry folks, but it has to be. One more of these invasive qdev patches. We have a serious design bug in the qdev interface: device init callbacks can't signal failure because the init() callback has no return value. This patch fixes it. We have already one case in-tree where this is needed: Try -device virtio-blk-pci (without drive= specified) and watch qemu segfault. This patch fixes it. With usb+scsi being converted to qdev we'll get more devices where the init callback can fail for various reasons. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-10rename "info qdrv" to "info qdm"Gerd Hoffmann1-1/+1
As requested by avi: driver != device model. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
2009-08-10fix qdev_print_devinfo()Gerd Hoffmann1-8/+16
snprintf returns number of bytes needed for the output, not the number of bytes actually written. Thus the math is wrong ... Spotted by Markus Armbruster. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
2009-08-10QemuOpts: switch over -device.Gerd Hoffmann1-40/+38
Make -device switch use the QemuOpts framework. Everything should continue to work like it did before. New: "-set device.$id.$property=$value" works. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
2009-08-10tolower -> qemu_tolowerChristoph Egger1-1/+1
Use qemu_tolower() instead of tolower(). Fixes warning on NetBSD. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
2009-07-30qdev/core: add monitor command to list all driversGerd Hoffmann1-0/+11
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-30qdev: factor out qdev_print_devinfo.Gerd Hoffmann1-1/+18
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27kill drives_tableGerd Hoffmann1-10/+7
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-27qdev: bus walker + qdev_device_add()Gerd Hoffmann1-0/+251
This patch implements a parser and qdev tree walker for bus paths and adds qdev_device_add on top of this. A bus path can be: (1) full path, i.e. /i440FX-pcihost/pci.0/lsi/scsi.0 (2) bus name, i.e. "scsi.0". Best used together with id= to make sure this is unique. (3) relative path starting with a bus name, i.e. "pci.0/lsi/scsi.0" For the (common) case of a single child bus being attached to a device it is enougth to specify the device only, i.e. "pci.0/lsi" will be accepted too. qdev_device_add() adds devices and accepts bus= parameters to find the bus the device should be attached to. Without bus= being specified it takes the first bus it finds where the device can be attached to (i.e. first pci bus for pci devices, ...). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27qdev: create default bus names.Gerd Hoffmann1-1/+24
Create a default bus name if none is passed to qbus_create(). If the parent device has DeviceState->id set it will be used to create the bus name,. i.e. -device lsi,id=foo will give you a scsi bus named "foo.0". If there is no id BusInfo->name (lowercased) will be used instead, i.e. -device lsi will give you a scsi bus named "scsi.0". A scsi adapter with two scsi busses would have "scsi.0" and "scsi.1" or "$id.0" and "$id.1" busses. The numbers of the child busses are per device, i.e. when adding two lsi adapters both will have a "*.0" child bus. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-17Suppress a Sparse warningBlue Swirl1-1/+0
Move the export to a file used by both qdev.c and sysbus.c. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-16qdev: add user-specified identifier to devices.Gerd Hoffmann1-2/+4
Add id field to DeviceState. Make "info qtree" print it. This helps users and management apps identifying devices in monitor output, which is especially useful with otherwise identical devices such as two virtio disks. This patch doesn't add a way to set the id, followup patches will do. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16qdev: add no_user, alias and descGerd Hoffmann1-0/+12
no_user: prevent users from adding certain devices. desc: description of the device. alias: to allow user friendly shortcuts on the command line, i.e. -device usbmouse instead of -device "QEMU USB Mouse" or -device lsi instead of -device lsi53c895a Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16qdev/compat: compat property infrastructure.Gerd Hoffmann1-0/+1
This add support for switching devices into a compatibility mode using device properties. Machine types can have a list of properties for specific devices attached to allow the easy creation of machine types compatible to older qemu versions. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16qdev: factor out driver search to qdev_find_info()Gerd Hoffmann1-7/+15
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16qdev: rework device properties.Gerd Hoffmann1-121/+20
This patch is a major overhaul of the device properties. The properties are saved directly in the device state struct now, the linked list of property values is gone. Advantages: * We don't have to maintain the list with the property values. * The value in the property list and the value actually used by the device can't go out of sync any more (used to happen for the pci.devfn == -1 case) because there is only one place where the value is stored. * A record describing the property is required now, you can't set random properties any more. There are bus-specific and device-specific properties. The former should be used for properties common to all bus drivers. Typical use case is bus addressing, i.e. pci.devfn and i2c.address. Properties have a PropertyInfo struct attached with name, size and function pointers to parse and print properties. A few common property types have PropertyInfos defined in qdev-properties.c. Drivers are free to implement their own very special property parsers if needed. Properties can have default values. If unset they are zero-filled. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16Update to a hopefully more future proof FSF addressBlue Swirl1-2/+1
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-09Don't leak VLANClientState on PCI hot removeMark McLoughlin1-2/+3
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-07-09qdev: remove DeviceTypeGerd Hoffmann1-23/+15
The only purpose DeviceType serves is creating a linked list of DeviceInfo structs. This removes DeviceType and add a next field to DeviceInfo instead, so the DeviceInfo structs can be changed that way. Elimitates a pointless extra level of indirection. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2009-07-09qdev: replace bus_type enum with bus_info struct.Gerd Hoffmann1-38/+20
BusInfo is filled with name and size (pretty much like I did for DeviceInfo as well). There is also a function pointer to print bus-specific device information to the monitor. sysbus is hooked up there, I've also added a print function for PCI. Device creation is slightly modified as well: The device type search loop now also checks the bus type while scanning the list instead of complaining thereafter in case of a mismatch. This effectively gives each bus a private namespace for device names. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-06-11qdev: move name+size into DeviceInfo (v2)Gerd Hoffmann1-11/+7
Rationale: move device information from code to data structures. v2: Adapt the drivers missed in the first version. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2009-06-10Merge branch 'net-queue'Anthony Liguori1-4/+5
* net-queue: (28 commits) virtio-net: Increase filter and control limits virtio-net: Add new RX filter controls virtio-net: MAC filter optimization virtio-net: Fix MAC filter overflow handling virtio-net: reorganize receive_filter() virtio-net: Use a byte to store RX mode flags virtio-net: Add version_id 7 placeholder for vnet header support virtio-net: implement rx packet queueing net: make use of async packet sending API in tap client net: add qemu_send_packet_async() net: split out packet queueing and flushing into separate functions net: return status from qemu_deliver_packet() net: add return value to packet receive handler net: pass VLANClientState* as first arg to receive handlers net: re-name vc->fd_read() to vc->receive() net: add fd_readv() handler to qemu_new_vlan_client() args net: only read from tapfd when we can send net: vlan clients with no fd_can_read() can always receive net: move the tap buffer into TAPState net: factor tap_read_packet() out of tap_send() ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-09Fix Sparse warningBlue Swirl1-1/+1
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-06-09net: re-name vc->fd_read() to vc->receive()Mark McLoughlin1-5/+5
VLANClientState's fd_read() handler doesn't read from file descriptors, it adds a buffer to the client's receive queue. Re-name the handlers to make things a little less confusing. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: add fd_readv() handler to qemu_new_vlan_client() argsMark McLoughlin1-3/+4
This, apparently, is the style we prefer - all VLANClientState should be an argument to qemu_new_vlan_client(). Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-08qdev: c99 initilaizers for bus_type_namesGerd Hoffmann1-5/+5
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2009-06-06Fix typoPaul Brook1-1/+1
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-06-05qdev: add monitor command to dump the tree.Gerd Hoffmann1-0/+73
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-06-05Record device property typesPaul Brook1-7/+32
Record device property types, and provide a list of properties at device registration time. Add a "device" property type that holds a reference to annother device. Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-06-04qdev: kill DeviceState->nameGerd Hoffmann1-2/+1
is redundant with DeviceState->type->name Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2009-05-26Remove qdev irq sink handlingPaul Brook1-13/+0
We have both IRQ sinks and GPIO inputs. These are in principle exactly the same thing, so remove the former. Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-23Add common BusStatePaul Brook1-36/+53
Implement and use a common device bus state. The main side-effect is that creating a bus and attaching it to a parent device are no longer separate operations. For legacy code we allow a NULL parent, but that should go away eventually. Also tweak creation code to veriry theat a device in on the right bus. Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-17Consistently use uint64_t for int propertiesPaul Brook1-2/+2
I apparently failed to do this properly on the first attempt. Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-14PCI network qdev conversionPaul Brook1-0/+25
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-14qdev scsi bus infrastructurePaul Brook1-0/+19
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-14qdev child bus supportPaul Brook1-0/+30
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-14Basic qdev infrastructure.Paul Brook1-0/+237
Signed-off-by: Paul Brook <paul@codesourcery.com>