aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev-properties.c
AgeCommit message (Collapse)Author
2012-08-01net: Rename VLANClientState to NetClientStateStefan Hajnoczi
The vlan feature is no longer part of net core. Rename VLANClientState to NetClientState because net clients are not explicitly associated with a vlan at all, instead they have a peer net client to which they are connected. This patch is a mechanical search-and-replace except for a few whitespace fixups where changing VLANClientState to NetClientState misaligned whitespace. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2012-08-01net: Remove VLANStateStefan Hajnoczi
VLANState is no longer used and can be removed. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2012-08-01net: Convert qdev_prop_vlan to peer with hubZhi Yong Wu
Instead of using VLANState use net/hub.h to support the vlan qdev property. The vlan qdev property becomes an alias for the peer qdev property but is represented as a VLAN ID number. When a VLAN ID is selected the device will really peer with a hub port. Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2012-07-18Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori
* kwolf/for-anthony: (41 commits) fdc-test: Clean up a bit fdc-test: introduce test_relative_seek fdc: fix relative seek qemu-iotests: Valgrind support coroutine-ucontext: Help valgrind understand coroutines qemu-io: Fix memory leaks hw/block-common: Factor out fall back to legacy -drive cyls=... blockdev: Don't limit DriveInfo serial to 20 characters hw/block-common: Factor out fall back to legacy -drive serial=... hw/block-common: Move BlockConf & friends from block.h Relax IDE CHS limits from 16383,16,63 to 65535,16,255 blockdev: Drop redundant CHS validation for if=ide hd-geometry: Compute BIOS CHS translation in one place qtest: Test we don't put hard disk info into CMOS for a CD-ROM ide pc: Put hard disk info into CMOS only for hard disks block: Geometry and translation hints are now useless, purge them qtest: Cover qdev property for BIOS CHS translation ide: qdev property for BIOS CHS translation qdev: New property type chs-translation qdev: Collect private helpers in one place ...
2012-07-17constify value pointer for qdev_prop_set_stringChristian Borntraeger
qdev_prop_set_string uses object_property_set_str, which takes a const char * for the value. Lets propagate the constness into qdev_prop_set_string. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-07-17block: Geometry and translation hints are now useless, purge themMarkus Armbruster
There are two producers of these hints: drive_init() on behalf of -drive, and hd_geometry_guess(). The only consumer of the hint is hd_geometry_guess(). The callers of hd_geometry_guess() call it only when drive_init() didn't set the hints. Therefore, drive_init()'s hints are never used. Thus, hd_geometry_guess() only ever sees hints it produced itself in a prior call. Only the first call computes something, subsequent calls just repeat the first call's results. However, hd_geometry_guess() is never called more than once: the device models don't, and the block device is destroyed on unplug. Thus, dropping the repeat feature doesn't break anything now. If a block device wasn't destroyed on unplug and could be reused with a new device, then repeating old results would be wrong. Thus, dropping the repeat feature prevents future breakage. This renders the hints unused. Purge them from the block layer. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17qdev: New property type chs-translationMarkus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17qdev: Collect private helpers in one placeMarkus Armbruster
Just code motion, with one long line wrapped to keep checkpatch.pl happy. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-06-21qdev-properties: Introduce pci-host-devaddr.Anthony PERARD
This new property will be used to specify a host pci device address. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2012-06-18qdev: Remove qdev_prop_exists()Paolo Bonzini
Can be replaced everywhere with object_property_find(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-18qdev: Remove qdev_prop_set_defaultsPaolo Bonzini
Instead, qdev_property_add_static can set the default. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-18qdev: Move bus properties to abstract superclassesPaolo Bonzini
In qdev, each bus in practice identified an abstract superclass, but this was mostly hidden. In QOM, instead, these abstract classes are explicit so we can move bus properties there. All bus property walks are removed, and all device property walks are changed to look along the class hierarchy instead. We would have duplicates if class A defines some properties and its subclass B does not define any, because class_b->props will be left equal to class_a->props. The solution here is to reintroduce the class_base_init TypeInfo callback, that was present in one of the early QOM versions but removed (on my request...) before committing. This breaks global bus properties, an obscure feature when used with the command-line which is actually useful and used when used by backwards-compatible machine types. So this patch also adjusts the global bus properties in hw/pc_piix.c to refer to the abstract class. Globals and other properties must be modified in the same patch to avoid complications related to initialization ordering. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-08qdev: Remove PropertyInfo range checkingPaolo Bonzini
Range checking in PropertyInfo is now used only for pci_devfn properties and some error reporting. Remove all code that implements it in the various property types, and the now unused fields. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Fix blocksize min/max for 32-bit hosts by using const int64_t.] Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-08qdev: Switch property accessors to fixed-width visitor interfacesMichael Roth
This introduces {get,set}_uint{8,16,32,64}() functions for the respective qdev types. TADDR and VLAN are switched to explicit int64, BLOCKSIZE to uint16. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-08qdev: Use int32_t container for devfn propertyMichael Roth
Valid range for devfn is -1 to 255 (-1 for automatic assignment). We do not currently validate this due to devfn being stored as a uint32_t. This can lead to segfaults and other strange behavior. We could technically just cast it to int32_t to implement the checking, but this will not work for visitor-based setting where we may do additional bounds-checking based on target container type, which is int32_t for this case. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-05-21qdev: Fix memory leakdunrong huang
The str allocated in visit_type_str was not freed. The visit_type_str function is an input visitor(<QMP/String/etc>-to-native) here, it will allocate memory for caller, so the caller is responsible for freeing the memory. Reviewed-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: dunrong huang <riegamaths@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-05-03qdev: Fix memory leak in function set_pci_devfnStefan Weil
Valgrind reported this memory leak which occured very often. Test scenario: qemu-system-i386 (no arguments), only BIOS started, terminate with monitor command (quit). v2: Use error_free instead of g_free (hint from Andreas Färber, thanks). Signed-off-by: Stefan Weil <sw@weilnetz.de> Acked-by: Andreas Färber <afaerber@suse.de>
2012-04-05qdev: add blocksize property typeStefan Hajnoczi
Storage interfaces like virtio-blk can be configured with block size information so that the guest can take advantage of efficient I/O request sizes. According to the SCSI Block Commands (SBC) standard a device's block size is "almost always greater than one byte and may be a multiple of 512 bytes". QEMU currently has a 512 byte minimum block size because the block layer functions work at that granularity. Furthermore, the block size should be a power of 2 because QEMU calculates bitmasks from the value. Introduce a "blocksize" property type so devices can enforce these constraints on block size values. If the constraints are relaxed in the future then this property can be updated. Introduce the new PropertyValueNotPowerOf2 QError so QMP clients know exactly why a block size value was rejected. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-03-12qdev: accept empty string propertiesPaolo Bonzini
These were stored as NULL due to wrong cut-and-paste from set_pointer. Reported-by: Gerhard Wiesinger <lists@wiesinger.com> Tested-by: Gerhard Wiesinger <lists@wiesinger.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-22qdev: drop unnecessary parse/print methodsPaolo Bonzini
More qdev printers could have been removed in the previous series, and object_property_parse also made several parsers unnecessary. In fact, the new code is even more robust with respect to overflows, so clean them up! Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-22qdev: use built-in QOM string parserPaolo Bonzini
object_property_parse lets us drop the legacy setters when their task is done just as well by the string visitors. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-22qdev: accept hex properties only if prefixed by 0xPaolo Bonzini
Hex properties are an obstacle to removal of old qdev string parsing, but even here we can lay down the foundations for future simplification. In general, they are rarely used and their printed form is more interesting than the parsing. For example you'd usually set isa-serial.index instead of isa-serial.iobase. And luckily our main client, libvirt only cares about few of these, and always sets them with a 0x prefix. So the series stops accepting bare hexadecimal numbers, preparing for making legacy properties read-only in 1.3 or so. The read side will stay as long as "info qtree" is with us. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-22qdev: accept both strings and integers for PCI addressesPaolo Bonzini
Visitors allow a limited form of polymorphism. Exploit it to support setting the non-legacy PCI address property both as a DD.F string and as an 8-bit integer. The 8-bit integer form is just too clumsy, it is unlikely that we will ever drop it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-14qdev: print error message before abortingPaolo Bonzini
qdev_prop_set_* functions are always called by machine init functions that should know what they're doing, so they abort on error. Still, an assert(!errp) does not aid debugging. Print an error before aborting. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-02-14qdev: allow setting properties to NULLPaolo Bonzini
SPARC and PPC set properties to NULL. This can be done with an empty string value. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-02-07qdev: remove unused fields from PropertyInfoPaolo Bonzini
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: initialize properties via QOMPaolo Bonzini
Similarly, use the object properties also to set the default values of the qdev properties. This requires reordering registration and initialization. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: inline qdev_prop_set into qdev_prop_set_ptrPaolo Bonzini
qdev_prop_set is not needed anymore except for hacks, simplify it and inline it. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: access properties via QOMPaolo Bonzini
Do not poke anymore in the struct when accessing qdev properties. Instead, ask the object to set the right value. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: fix off-by-onePaolo Bonzini
Integer properties did not work. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: let QOM free propertiesPaolo Bonzini
Drop the special free callback. Instead, register a "regular" release method in the non-legacy property. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: remove parse/print methods for pointer propertiesPaolo Bonzini
Pointer properties (except for PROP_PTR of course) should not need a legacy counterpart. In the future, relative paths will ensure that QEMU will support the same syntax as now for drives etc.. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: make the non-legacy pci address property accept an integerPaolo Bonzini
PCI addresses are set with qdev_prop_uint32. Thus we make the QOM property accept a device and function encoded in an 8-bit integer, instead of the magic dd.f hex string. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: remove parse/print methods for mac propertiesPaolo Bonzini
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: remove print/parse methods from LostTickPolicy propertiesPaolo Bonzini
Also generalize the code so that we can have more enum properties in the future. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: remove parse method for string propertiesPaolo Bonzini
We need the print method to put double quotes, but parsing is not special. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-07qdev: remove direct calls to print/parsePaolo Bonzini
There's no need to call into ->parse and ->print manually. The QOM legacy properties do that for us. Furthermore, in some cases legacy and static properties have exactly the same behavior, and we could drop the legacy properties right away. Add an appropriate fallback to prepare for this. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-03qom: move properties from qdev to objectAnthony Liguori
This is mostly code movement although not entirely. This makes properties part of the Object base class which means that we can now start using Object in a meaningful way outside of qdev. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-03qdev: make DeviceInfo privateAnthony Liguori
Introduce accessors and remove any code that directly accesses DeviceInfo members. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-01qdev: Introduce lost tick policy propertyJan Kiszka
Potentially tick-generating timer devices will gain a common property: lock_tick_policy. It allows to encode 4 different ways how to deal with tick events the guest did not process in time: discard - ignore lost ticks (e.g. if the guest compensates for them already) delay - replay all lost ticks in a row once the guest accepts them again merge - if multiple ticks are lost, all of them are merged into one which is replayed once the guest accepts it again slew - lost ticks are gradually replayed at a higher frequency than the original tick Not all timer device will need to support all modes. However, all need to accept the configuration via this common property. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: don't access name through infoAnthony Liguori
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 Liguori
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-property: Make bit property parsing stricterJan Kiszka
By using strncasecmp, we allow for arbitrary characters after the "on"/"off" string. Fix this by switching to strcasecmp. Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-01-13qdev: Add a 'free' method to disassociate chardev from qdev deviceAmit Shah
When a device is removed, remove the association with a chardev, if any, so that the chardev can be re-used later for other devices. Reported-by: Qunfang Zhang <qzhang@redhat.com> Fix-suggested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-19qom: distinguish "legacy" property type name from QOM type namePaolo Bonzini
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: introduce get/set methods for PropertyPaolo Bonzini
This patch adds a visitor interface to Property. This way, QOM will be able to expose Properties that access a fixed field in a struct without exposing also the everything-is-a-string "feature" of qdev properties. Whenever the printed representation in both QOM and qdev (which is typically the case for device backends), parse/print code can be reused via get_generic/set_generic. Dually, whenever multiple PropertyInfos have the same representation in both the struct and the visitors the code can be reused (for example among all of int32/uint32/hex32). 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 Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-16qdev: Add HEX8 propertyJan Kiszka
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-23pci-devfn: check that device/slot number is within rangeDonald Dutile
Need to check that guest slot/device number is not > 31 or walk off the devfn table when checking if a devfn is available or not in a guest. before this fix, passing in an addr=abc or addr=34, can crash qemu, sometimes fail gracefully if data past end of devfn table fails the availability test. with this fix, get clean error: Property 'pci-assign.addr' doesn't take value '34' also tested when no addr= param passed for guest (pcicfg) address, and that worked as well. Signed-off-by: Don Dutile <ddutile@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-06block: Attach non-qdev devices as wellMarkus Armbruster
For now, this just protects against programming errors like having the same drive back multiple non-qdev devices, or untimely bdrv_delete(). Later commits will add other interesting uses. While there, rename BlockDriverState member peer to dev, bdrv_attach() to bdrv_attach_dev(), bdrv_detach() to bdrv_detach_dev(), and bdrv_get_attached() to bdrv_get_attached_dev(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>