summaryrefslogtreecommitdiffstats
path: root/hw/qdev-properties.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>
* qdev: implement qdev_prop_set_bit().Isaku Yamahata2010-07-111-0/+5
| | | | | | | implement qdev_prop_set_bit(). Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* block: Catch attempt to attach multiple devices to a blockdevMarkus Armbruster2010-07-021-1/+21
| | | | | | | | | | | | | | | 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-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* blockdev: Clean up automatic drive deletionMarkus Armbruster2010-07-021-0/+10
| | | | | | | | | | | | | | | | | | | | | We automatically delete blockdev host parts on unplug of the guest device. Too much magic, but we can't change that now. The delete happens early in the guest device teardown, before the connection to the host part is severed. Thus, the guest part's pointer to the host part dangles for a brief time. No actual harm comes from this, but we'll catch such dangling pointers a few commits down the road. Clean up the dangling pointers by delaying the automatic deletion until the guest part's pointer is gone. Device usb-storage deliberately makes two qdev properties refer to the same drive, because it automatically creates a second device. Again, too much magic we can't change now. Multiple references worked okay before, but now free_drive() dies for the second one. Zap the extra reference. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qdev-properties: Fix (u)intXX parsersKevin Wolf2010-06-301-15/+35
| | | | | | | | | | | scanf calls must not use PRI constants, they have probably the wrong size and corrupt memory. We could replace them by SCN ones, but strtol is simpler than scanf here anyway. While at it, also fix the parsers to reject garbage after the number ("4096xyz" was accepted before). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Richard Henderson <rth@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* blockdev: Collect block device code in new blockdev.cMarkus Armbruster2010-06-041-1/+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>
* qdev: Don't leak string property value on hot unplugMarkus Armbruster2010-06-041-0/+6
| | | | | | | | | | | | | parse_string() qemu_strdup()s the property value. It is never freed. It needs to be freed along with the device. Otherwise, the value of scsi-disk property "ver" gets leaked when hot-unplugging the disk, for instance. Call new PropertyInfo method free() from qdev_free(). Implement it for qdev_prop_string. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qdev: New qdev_prop_set_string()Markus Armbruster2010-06-041-0/+5
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Make qemu-config available for toolsKevin Wolf2010-04-231-1/+18
| | | | | | | | To be able to use config files for blkdebug, we need to make these functions available in the tools. This involves moving two functions that can only be built in the context of the emulator. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* error: Trim includes after "Move qemu_error & friends..."Markus Armbruster2010-03-271-0/+1
| | | | | | | Missed in commit 2f792016. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* qdev: convert setting device properties to QErrorMarkus Armbruster2010-03-161-8/+7
|
* qdev: Hide "ptr" properties from usersMarkus Armbruster2010-03-161-13/+8
| | | | | | | | | | | Users can't set them, so qdev_device_help() shouldn't list them. Fix that. Also make qdev_prop_parse() hide them instead of printing a meaningless "has no parser" error message. Their value means nothing to users, so qdev_print_props() shouldn't print it. Fix by removing their print method. Their only use is dirty hacks. Document that.
* qdev: Catch attempt to attach more than one device to a netdevMarkus Armbruster2010-03-091-0/+7
| | | | | | | | | | | | | | | | | | Guest device and host netdev are peers, i.e. it's a 1:1 relation. However, we fail to enforce that: $ qemu -nodefaults --nographic -netdev user,id=net0 -device e1000,netdev=net0 -device virtio-net-pci,netdev=net0 -monitor stdio QEMU 0.12.50 monitor - type 'help' for more information (qemu) info network Devices not on any VLAN: net0: net=10.0.2.0, restricted=n peer=virtio-net-pci.0 e1000.0: model=e1000,macaddr=52:54:00:12:34:56 peer=net0 virtio-net-pci.0: model=virtio-net-pci,macaddr=52:54:00:12:34:57 peer=net0 It's all downhill from there. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: Improve diagnostics for bad property valuesMarkus Armbruster2010-03-091-23/+34
| | | | | | | | | | | | | | Property "vlan" reports "failed to parse" even when the value parses just fine, but the result doesn't name an existing VLAN. Similarly, properties "drive", "chr" and "netdev" misleadingly report "failed to parse" when the value doesn't name an existing host device. Change PropertyInfo method parse to return an error code, so that qdev_prop_parse() can report the error more accurately. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Revert "qdev: Add help for device properties"Markus Armbruster2010-02-031-13/+2
| | | | | | | | | | | | | | | | | This reverts commit 2ba6edf0dd740166632df80caa85992b20791a68. The commit has two issues: * When it runs from the monitor, e.g. "device_add e1000,?", it prints to stderr instead of the monitor. * Help looks to callers just like failed device creation. This makes main() exit unsuccessfully on "-device e1000,?". We need to do this differently. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Revert "qdev: Add help for property value"Markus Armbruster2010-02-031-7/+2
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 922910ce42d15bdb7c2347436b1b5798b5401de4. The commit has four issues: * When it runs from the monitor, e.g. "device_add e1000,mac=?", it prints to stderr instead of the monitor. * Help looks to callers just like failed device creation. This makes main() exit unsuccessfully on "-device e1000,mac=?". * It has an undocumented side effect on -global: "-global e1000.mac=?" prints help, but only when we actually add an e1000 device. * It does not work for properties that accept the value "?". We need to do this differently. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: Add help for property valueStefan Weil2010-01-261-2/+7
| | | | | | | | | | | | | | | When called with property value "?", a help text will be printed (instead of an error message). This is useful for command lines like qemu -device e1000,mac=? and is already standard for other command line options. A better help text could be provided by extending the Property structure with a desc field. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: Add help for device propertiesStefan Weil2010-01-261-2/+13
| | | | | | | | | | | | When called with property "?", a list of supported properties will be printed (instead of an error message). This is useful for command lines like qemu -device e1000,? and was already standard for other options like model=? Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: fix thinko leading to guest crashesMichael S. Tsirkin2010-01-121-1/+1
| | | | | | | Without this fix, guest crashes with drive=virtio. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: add bit property typeMichael S. Tsirkin2010-01-111-7/+55
| | | | | | | | | | This adds "bit" property type, which is a boolean stored in a 32 bit integer field, with legal values on and off. Will be used by virtio for feature bits. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: improve property error reporting.Gerd Hoffmann2009-12-181-2/+7
| | | | | | | | | | | | Add a error message in case we fail to parse a qdev property. Also make qemu not abort() in case setting a global property can't be set. This used to be a clear programming error. The introduction of the -global switch changed that though, so better exit instead (after printing the new error message). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: also match bus name for global propertiesGerd Hoffmann2009-12-121-1/+2
| | | | | | | | | i.e. -global PCI.<property>=<value> will set a default property for all PCI devices. Also works for the compat properties used by machine types. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: make compat stuff more genericGerd Hoffmann2009-12-121-8/+14
| | | | | | | | | This patch renames the compat properties into global properties and makes them more generic. The compatibility stuff is only one of multiple possible users now. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: add qdev_prop_exists()Gerd Hoffmann2009-10-271-0/+5
| | | | | | | Function test whenever a driver has a specific property. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: add vlan propertyGerd Hoffmann2009-10-271-0/+39
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: add netdev propertyGerd Hoffmann2009-10-271-0/+36
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: mac addr property fixupsGerd Hoffmann2009-10-271-10/+21
| | | | | | | Make the mac property use the newly added type for the mac address. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: add string property.Gerd Hoffmann2009-10-211-0/+28
| | | | | | | Patchworks-ID: 35755 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: don't crash on unset drive properties.Gerd Hoffmann2009-10-051-1/+1
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: Add support for uint8_tJuan Quintela2009-10-051-0/+33
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: add parser for chardev propertiesGerd Hoffmann2009-09-111-0/+11
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: add property type for 32bit signed integers.Gerd Hoffmann2009-09-101-0/+28
| | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* Suppress kraxelismsBlue Swirl2009-08-281-1/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Unbreak Sparc32 and PPCBlue Swirl2009-08-131-1/+6
| | | | | | Convert qdev ptr type to chr, allow a NULL pointer. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qdev/prop: add CharDriverState property.Gerd Hoffmann2009-08-101-0/+20
| | | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
* qdev/prop: add drive property.Gerd Hoffmann2009-08-101-0/+32
| | | | | | | | | Adds a (host) drive property, intended to be used by virtual disk backend drivers. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
* qdev/prop: add pci devfn propertyGerd Hoffmann2009-07-271-0/+43
| | | | | | | So we can parse "$slot.$fn" strings into devfn numbers. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: add 64 bit typeBlue Swirl2009-07-211-0/+58
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* isxdigit -> qemu_isxdigitChristoph Egger2009-07-171-2/+2
| | | | | | | | | | | | | | | | | Hi! Attached patch uses qemu_isxdigit() instead of isxdigit(). Fixes build warning on NetBSD. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
* qdev/compat: compat property infrastructure.Gerd Hoffmann2009-07-161-0/+23
| | | | | | | | | | 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>
* qdev: rework device properties.Gerd Hoffmann2009-07-161-0/+246
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>
OpenPOWER on IntegriCloud