aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev.c
AgeCommit message (Collapse)AuthorFilesLines
2012-01-27pci: convert to QEMU Object ModelAnthony Liguori1-0/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: add class_init to DeviceInfoAnthony Liguori1-0/+4
Since we are still dynamically creating TypeInfo, we need to chain the class_init function in order to be able to make use of it within subclasses of TYPE_DEVICE. This will disappear once we register TypeInfos directly. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: add a interface to register subclassesAnthony Liguori1-2/+7
In order to introduce inheritance while still using the qdev registration interfaces, we need to be able to use a parent other than TYPE_DEVICE. Add a new interface that allows this. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: use a wrapper to access reset and promote reset to a class methodAnthony Liguori1-5/+17
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: don't access name through infoAnthony Liguori1-8/+8
We already have a QOM interface for this so let's use it. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: move qdev->info to classAnthony Liguori1-29/+41
Right now, DeviceInfo acts as the class for qdev. In order to switch to a proper ObjectClass derivative, we need to ween all of the callers off of interacting directly with the info pointer. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: integrate with QEMU Object Model (v2)Anthony Liguori1-2/+25
This is a very shallow integration. We register a TYPE_DEVICE but only use QOM as basically a memory allocator. This will make all devices show up as QOM objects but they will all carry the TYPE_DEVICE. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- v1 -> v2 - update for new location of object.h
2012-01-22vga: improve VGA logicBlue Swirl1-0/+4
Improve VGA selection logic, push check for device availabilty to vl.c. Create the devices at board level unconditionally. Remove now unused pci_try_create*() functions. Make PCI VGA devices optional. Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-01-13qdev: fix device_del by refactoring reference countingAnthony Liguori1-6/+39
Commit 8eb0283 broken device_del by having too overzealous reference counting checks. Move the reference count checks to qdev_free(), make sure to remove the parent link on free, and decrement the reference count on property removal. Reported-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-19qdev: fix hotplug when no -device is specifiedAnthony Liguori1-0/+6
The peripheral[-anon] containers are initialized lazily but since they sit on sysbus, they can not be created after realize. This was causing an abort() to occur during hotplug if no -device option was used. This was spotted by qemu-test::device-add.sh Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-19qom: register qdev properties also as non-legacy propertiesPaolo Bonzini1-3/+25
Push legacy properties into a "legacy-..." namespace, and make them available with correct types too. For now, all properties come in both variants. This need not be the case for string properties. We will revisit this after -device is changed to actually use the legacy properties. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-19qom: distinguish "legacy" property type name from QOM type namePaolo Bonzini1-3/+6
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-19qom: interpret the return value when setting legacy propertiesPaolo Bonzini1-4/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-19qom: push permission checks up into qdev_property_add_legacyPaolo Bonzini1-27/+19
qdev_property_get and qdev_property_set can generate permission denied errors themselves. Do not duplicate this functionality in qdev_get/set_legacy_property, and clean up excessive indentation. Reviewed-by: Anthony Liguori <anthony@codemonkey.ws> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-19qom: fix swapped parametersPaolo Bonzini1-1/+1
Reviewed-by: Anthony Liguori <anthony@codemonkey.ws> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qdev: add a qdev_get_type() function and expose as a 'type' propertyAnthony Liguori1-0/+7
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qom: add string property typeAnthony Liguori1-0/+59
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qom: optimize qdev_get_canonical_path using a parent linkAnthony Liguori1-32/+24
The full tree search was a bit unreasonable. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15dev: add an anonymous peripheral containerAnthony Liguori1-1/+20
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qdev: add explicitly named devices to the root complexAnthony Liguori1-0/+14
We first add a 'peripheral' container to the root device that we add user created devices to. This provides all user created devices with a unique and isolated namespace. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qom: add link properties (v2)Anthony Liguori1-0/+74
Links represent an ephemeral relationship between devices. They are meant to replace the qdev concept of busses by allowing more informal relationships between devices. Links are fairly limited in their usefulness without implementing QOM-style subclassing and interfaces. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qom: add child properties (composition) (v3)Anthony Liguori1-0/+26
Child properties express a relationship of composition. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qdev: provide a path resolution (v2)Anthony Liguori1-0/+103
There are two types of supported paths--absolute paths and partial paths. Absolute paths are derived from the root device and can follow child<> or link<> properties. Since they can follow link<> properties, they can be arbitrarily long. Absolute paths look like absolute filenames and are prefixed with a leading slash. Partial paths are look like relative filenames. They do not begin with a prefix. The matching rules for partial paths are subtle but designed to make specifying devices easy. At each level of the composition tree, the partial path is matched as an absolute path. The first match is not returned. At least two matches are searched for. A successful result is only returned if only one match is founded. If more than one match is found, a flag is returned to indicate that the match was ambiguous. At the end of the day, partial path support means that if you create a device called 'ide0', you can just say 'ide0' as the path name and it will Just Work. If we internally create a device called 'i440fx', you can just say 'i440fx' and it will Just Work and long as you don't do anything silly. A management tool should probably always use absolute paths since then they don't have to deal with the possibility of ambiguity. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qdev: provide an interface to return canonical path from root (v2)Anthony Liguori1-0/+48
The canonical path is the path in the composition tree from the root to the device. This is effectively the name of the device. This is an incredibly unefficient implementation that will be optimized in a future patch. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qom: introduce root deviceAnthony Liguori1-0/+12
This is based on Jan's suggestion for how to do unique naming. The root device is the root of composition. All devices are reachable via child<> links from this device. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qom: register legacy properties as new style properties (v2)Anthony Liguori1-0/+86
Expose all legacy properties through the new QOM property mechanism. The qdev property types are exposed through the 'legacy<>' namespace. They are always visited as strings since they do their own string parsing. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qom: add new dynamic property infrastructure based on Visitors (v2)Anthony Liguori1-0/+97
qdev properties are settable only during construction and static to classes. This isn't flexible enough for QOM. This patch introduces a property interface for qdev that provides dynamic properties that are tied to objects, instead of classes. These properties are Visitor based instead of string based too. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15qom: add a reference count to qdev objectsAnthony Liguori1-0/+16
To ensure that a device isn't removed from the graph until all of its links are broken. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-10qdev: Fix crash on -device '?=x'Markus Armbruster1-1/+1
Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-28qdev: switch children device list to QTAILQPaolo Bonzini1-12/+12
SCSI buses will need to read the children list first-to-last. This requires using a QTAILQ, because hell breaks loose if you just try inserting at the tail (thus reversing the order of all existing visits from last-to-first to first-to-tail). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-16qdev: print bus properties tooGerd Hoffmann1-0/+6
Make qdev_device_help print both device and bus properties. Helps libvirt to figure whenever bus properties such as PCI.multifunction are supported present or not. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-10/+10
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-11hw/qdev: Don't crash if qdev_create(NULL, ...) failsPeter Maydell1-1/+6
If an attempt to create a qdev device on the default sysbus (by passing NULL as the bus to qdev_create) fails, print a useful error message rather than crashing trying to dereference a NULL pointer. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-08-05qdev: Eliminate duplicate resetIsaku Yamahata1-2/+12
qbus_reset_all_fn was registered twice, so a lot of device reset functions were also called twice when QEMU started. Which was introduced by 80376c3fc2c38fdd45354e4b0eb45031f35587ed This patch fixes it by making the main_system_bus creation not register reset handler. Cc: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Tested-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-29qdev: Reset hot-plugged devicesJan Kiszka1-0/+3
Device models rely on the core invoking their reset handlers after init. We do this in the cold-plug case, but so far we miss this step after hot-plug. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-23net: Consistently use qemu_macaddr_default_if_unsetJan Kiszka1-1/+1
Drop the open-coded MAC assignment from net_init_nic and replace it with standard qemu_macaddr_default_if_unset which is also used by qdev. That avoid creating colliding MACs when instantiating NICs via different mechanisms. This change requires to store the MAC as MACAddr in NICInfo, and the remaining nd_table users need to be updated. Based on suggestion by Peter Maydell. CC: Markus Armbruster <armbru@redhat.com> CC: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-06-24Strip trailing '\n' from error_report()'s first argumentMarkus Armbruster1-1/+1
error_report() prepends location, and appends a newline. The message constructed from the arguments should not contain a newline. Fix the obvious offenders. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-06-22net: Warn about "-net nic" options which were ignoredPeter Maydell1-0/+1
Diagnose the case where the user asked for a NIC via "-net nic" but the board didn't instantiate that NIC (for example where the user asked for two NICs but the board only supports one). Note that this diagnostic doesn't apply to NICs created through -device, because those are always instantiated. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-04-07qdev: Fix comment around qdev_init_nofail()Michael Tokarev1-1/+2
In previous life qdev_init_nofail() used to call hw_error() which did register dump and other scary things. Now it calls error_report() and does a regular exit(1). Fix the comment to match reality. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-02-12qdev: add creation function that may failBlue Swirl1-1/+13
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-01-31blockdev: Fix regression in -drive if=scsi,index=NMarkus Armbruster1-1/+0
Before commit 622b520f, index=12 meant bus=1,unit=5. Since the commit, it means bus=0,unit=12. The drive is created, but not the guest device. That's because the controllers we use with if=scsi drives (lsi53c895a and esp) support only 7 units, and scsi_bus_legacy_handle_cmdline() ignores drives with unit numbers exceeding that limit. Changing the mapping of index to bus, unit is a regression. Breaking -drive invocations that used to work just makes it worse. Revert the part of commit 622b520f that causes this, and clean up some. Note that the fix only affects if=scsi. You can still put more than 7 units on a SCSI bus with -device & friends. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-31blockdev: New drive_get_next(), replacing qdev_init_bdrv()Markus Armbruster1-14/+0
qdev_init_bdrv() doesn't belong into qdev.c; it's about drives, not qdevs. Rename to drive_get_next, move to blockdev.c, drop the bogus DeviceState argument, and return DriveInfo instead of BlockDriverState. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-05qdev: Track runtime machine modificationsAlex Williamson1-0/+10
Create a trivial interface to track whether the machine has been modified since boot. Adding or removing devices will trigger this to return true. An example usage scenario for such an interface is the rtl8139 driver which includes a cpu_register_io_memory() value in it's migration stream. For the majority of migrations, where no hotplug has occured in the machine, this works correctly. Once the machine is modified, we can use this interface to detect that and include a subsection for the device to prevent migrations to rtl8139 versions with this bug. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-12-24qdev: export qdev_find_recursive() for later useIsaku Yamahata1-1/+1
This patch exports qdev_find_recursive() for later use. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-12-21qdev: remove an unused functionMichael S. Tsirkin1-6/+1
qbus_reset_all is unused, remove it Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-12-20qbus: register reset handler for qbus whose parent is NULLIsaku Yamahata1-1/+13
Stefan Weil reported the regression caused by ec990eb622ad46df5ddcb1e94c418c271894d416 as follows > The second regression also occurs with MIPS malta. > Networking no longer works with the default pcnet nic. > > This is caused because the reset function for pcnet is no > longer called during system boot. The result in an invalid > mac address (all zero) and a non-working nic. > > For this second regression I still have no simple solution. > Of course mips_malta.c should be converted to qdev which > would fix both problems (but only for malta system emulation). The issue is, it is assumed that all qbuses, qdeves are under main_system_bus. But there are qbuses whose parent is NULL. So it is necessary to trigger reset for those qbuses. (On the other hand, if NULL is passed to qdev_create(), its parent bus is main_system_bus.) Ideally those buses should be moved under bus controller device which is qdev. But it's not done yet. So register qbus reset handler for qbus whose parent is NULL. Reported-by: Stefan Weil <weil@mail.berlios.de> Signed-off-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>
2010-12-19qdev: sysbus_get_default must not return a NULL pointer (fix regression)Stefan Weil1-4/+5
Every system should have some sort of main system bus, so sysbus_get_default should always return a valid bus. Without this patch, at least mipssim and malta no longer start but raise a null pointer access exception (caused by commit ec990eb622ad46df5ddcb1e94c418c271894d416). Cc: Anthony Liguori <anthony@codemonkey.ws> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-12-11Add bootindex parameter to net/block/fd deviceGleb Natapov1-0/+32
If bootindex is specified on command line a string that describes device in firmware readable way is added into sorted list. Later this list will be passed into firmware to control boot order. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-11-22qdev: trigger reset from a given deviceIsaku Yamahata1-0/+5
Introduce a helper function which triggers reset from a given device. Will be used by pci bus emulation. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-11-22qdev: introduce reset call back for qbus levelIsaku Yamahata1-1/+9
and make it called via qbus_reset_all(). The qbus reset callback will be used by pci bus reset. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>