summaryrefslogtreecommitdiff
path: root/hw/qdev-properties.c
AgeCommit message (Collapse)AuthorFilesLines
2011-09-06block: Attach non-qdev devices as wellMarkus Armbruster1-3/+3
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>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-4/+4
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-04-28char: Allow devices to use a single multiplexed chardev.Kusanagi Kouichi1-2/+2
This fixes regression caused by commit 2d6c1ef40f3678ab47a4d14fb5dadaa486bfcda6 ("char: Prevent multiple devices opening same chardev"): -nodefaults -nographic -chardev stdio,id=stdio,mux=on,signal=off \ -mon stdio -device virtio-serial-pci \ -device virtconsole,chardev=stdio -device isa-serial,chardev=stdio fails with: qemu-system-x86_64: -device isa-serial,chardev=stdio: Property 'isa-serial.chardev' can't take value 'stdio', it's in use Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2011-03-21char: Prevent multiple devices opening same chardevAmit Shah1-1/+6
Prevent: -chardev socket,path=/tmp/foo,server,nowait,id=c0 \ -device virtserialport,chardev=c0,id=vs0 \ -device virtserialport,chardev=c0,id=vs1 Reported-by: Mike Cao <bcao@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2011-02-20qdev: Fix printout of bit device properties with bit index >= 8David 'Digit' Turner1-1/+1
Signed-off-by: David 'Digit' Turner <digit@google.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-08-24Rearrange block headersBlue Swirl1-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>
2010-08-22QemuOpts: make most qemu_*_opts staticGerd Hoffmann1-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>
2010-07-11qdev: implement qdev_prop_set_bit().Isaku Yamahata1-0/+5
implement qdev_prop_set_bit(). Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-07-02block: Catch attempt to attach multiple devices to a blockdevMarkus Armbruster1-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>
2010-07-02qdev: Decouple qdev_prop_drive from DriveInfoMarkus Armbruster1-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>
2010-07-02blockdev: Clean up automatic drive deletionMarkus Armbruster1-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>
2010-06-30qdev-properties: Fix (u)intXX parsersKevin Wolf1-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>
2010-06-04blockdev: Collect block device code in new blockdev.cMarkus Armbruster1-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>
2010-06-04qdev: Don't leak string property value on hot unplugMarkus Armbruster1-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>
2010-06-04qdev: New qdev_prop_set_string()Markus Armbruster1-0/+5
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-04-23Make qemu-config available for toolsKevin Wolf1-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>
2010-03-27error: Trim includes after "Move qemu_error & friends..."Markus Armbruster1-0/+1
Missed in commit 2f792016. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-16qdev: convert setting device properties to QErrorMarkus Armbruster1-8/+7
2010-03-16qdev: Hide "ptr" properties from usersMarkus Armbruster1-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.
2010-03-09qdev: Catch attempt to attach more than one device to a netdevMarkus Armbruster1-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>
2010-03-09qdev: Improve diagnostics for bad property valuesMarkus Armbruster1-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>
2010-02-03Revert "qdev: Add help for device properties"Markus Armbruster1-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>
2010-02-03Revert "qdev: Add help for property value"Markus Armbruster1-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>
2010-01-26qdev: Add help for property valueStefan Weil1-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>
2010-01-26qdev: Add help for device propertiesStefan Weil1-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>
2010-01-12qdev: fix thinko leading to guest crashesMichael S. Tsirkin1-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>
2010-01-11qdev: add bit property typeMichael S. Tsirkin1-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>
2009-12-18qdev: improve property error reporting.Gerd Hoffmann1-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>
2009-12-12qdev: also match bus name for global propertiesGerd Hoffmann1-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>
2009-12-12qdev: make compat stuff more genericGerd Hoffmann1-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>
2009-10-27qdev: add qdev_prop_exists()Gerd Hoffmann1-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>
2009-10-27qdev: add vlan propertyGerd Hoffmann1-0/+39
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27qdev: add netdev propertyGerd Hoffmann1-0/+36
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27qdev: mac addr property fixupsGerd Hoffmann1-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>
2009-10-21qdev: add string property.Gerd Hoffmann1-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>
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-05qdev: Add support for uint8_tJuan Quintela1-0/+33
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11qdev: add parser for chardev propertiesGerd Hoffmann1-0/+11
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-10qdev: add property type for 32bit signed integers.Gerd Hoffmann1-0/+28
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2009-08-28Suppress kraxelismsBlue Swirl1-1/+1
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-13Unbreak Sparc32 and PPCBlue Swirl1-1/+6
Convert qdev ptr type to chr, allow a NULL pointer. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-10qdev/prop: add CharDriverState property.Gerd Hoffmann1-0/+20
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
2009-08-10qdev/prop: add drive property.Gerd Hoffmann1-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:
2009-07-27qdev/prop: add pci devfn propertyGerd Hoffmann1-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>
2009-07-21qdev: add 64 bit typeBlue Swirl1-0/+58
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-17isxdigit -> qemu_isxdigitChristoph Egger1-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
2009-07-16qdev/compat: compat property infrastructure.Gerd Hoffmann1-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>
2009-07-16qdev: rework device properties.Gerd Hoffmann1-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>