Commit Graph

89 Commits

Author SHA1 Message Date
Markus Armbruster e17ba87c52 error: Use QERR_INVALID_PARAMETER_VALUE instead of QERR_INVALID_PARAMETER
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-18 23:46:48 +02:00
Markus Armbruster 17a38eaa2f monitor: convert do_device_del() to QObject, QError
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-18 23:46:48 +02:00
Markus Armbruster cc601cb785 qdev: Convert qdev_unplug() to QError
Note: our device unplug methods don't need conversion work, because
they can't currently fail.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-18 23:46:48 +02:00
Markus Armbruster 8bc27249f0 monitor: convert do_device_add() to QObject 2010-03-16 17:45:35 +01:00
Markus Armbruster c7e4e8ceb3 monitor: Use argument type 'O' for device_add
While there, improve the params help text.
2010-03-16 17:45:35 +01:00
Markus Armbruster 8212c64f0e qemu-option: Move the implied first name into QemuOptsList
We sometimes permit omitting the first option name, for example
-device foo is short for -device driver=foo.  The name to use
("driver" in the example) is passed as argument to qemu_opts_parse().
For each QemuOptsList, we use at most one such name.

Move the name into QemuOptsList, and pass whether to permit the
abbreviation.  This ensures continued consistency, and simplifies the
commit after next in this series.
2010-03-16 17:45:34 +01:00
Markus Armbruster 0204276bc9 error: Convert do_device_add() to QError
Conversion to QObject is still missing.
2010-03-16 17:45:34 +01:00
Markus Armbruster 3801cf8ae5 Revert "qdev: Use QError for 'device not found' error"
This reverts commit 3ced9f7a36.

The next commit will convert all of qdev_device_add() to QError, and
it'll be clearer with this partial conversion reverted.
2010-03-16 17:45:34 +01:00
Markus Armbruster ac8dae6794 qdev: Convert qbus_find() to QError 2010-03-16 17:45:34 +01:00
Markus Armbruster fc98eb430e qdev: Relax parsing of bus option
Treat multiple successive slashes as a one slash.  Ignore trailing
slashes.  This is how POSIX pathnames work.
2010-03-16 17:45:34 +01:00
Markus Armbruster fdcfa190ab qdev: convert setting device properties to QError 2010-03-16 17:45:26 +01:00
Markus Armbruster 036f7166c7 qdev: Hide "ptr" properties from users
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-16 17:01:08 +01:00
Markus Armbruster c64eafaf0c qdev: Hide "no_user" devices from users
Users can't create them, so qdev_device_help() shouldn't list them.
Fix that.

Also make qdev_device_add() pretend they don't exist.  Before, it
rejected them with a "can't be added via command line" message, which
wasn't quite right for monitor command device_add.
2010-03-16 16:58:32 +01:00
Markus Armbruster 0c17542d90 qdev: Factor qdev_create_from_info() out of qdev_create()
To make it obvious that -device and device_add can't die in
hw_error().
2010-03-16 16:58:32 +01:00
Markus Armbruster 327867b62a qdev: Fix -device and device_add to handle unsuitable bus gracefully
"device_add isa-serial,bus=pci.0" kills QEMU.  Not good.
2010-03-16 16:58:32 +01:00
Markus Armbruster ab5b027ee6 error: Rename qemu_error_new() to qerror_report() 2010-03-16 16:58:32 +01:00
Markus Armbruster 1ecda02b24 error: Replace qemu_error() by error_report()
error_report() terminates the message with a newline.  Strip it it
from its arguments.

This fixes a few error messages lacking a newline:
net_handle_fd_param()'s "No file descriptor named %s found", and
tap_open()'s "vnet_hdr=1 requested, but no kernel support for
IFF_VNET_HDR available" (all three versions).

There's one place that passes arguments without newlines
intentionally: load_vmstate().  Fix it up.
2010-03-16 16:58:32 +01:00
Markus Armbruster 53db16b5b0 error: Don't abuse qemu_error() for non-error in qbus_find()
qbus_find() adds an informational line to error messages, and prints
both lines with one qemu_error().  Use error_printf() for the
informational line instead.

While there, simplify: instead of printing buffers filled by
qbus_list_bus() and qbus_list_dev() in one go, make them print it.
2010-03-16 16:55:05 +01:00
Markus Armbruster 8a9662ca67 error: Don't abuse qemu_error() for non-error in qdev_device_help()
qdev_device_help() prints device information with qemu_error().  A
later commit will make qemu_error() print additional stuff that is
only appropriate for proper errors, and then this will break.  Use
error_printf() instead.

While there, simplify: instead of printing a buffer filled by
qdev_print_devinfo() in one go, make qdev_print_devinfo() print it.
2010-03-16 16:55:05 +01:00
Amit Shah 75422b0d38 qdev: Add a DEV_NVECTORS_UNSPECIFIED enum for unspecified nr of MSI vectors
net.c used a constant to signify no MSI vectors were specified. Extend
that to all qdev devices.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reported-by: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-08 11:30:09 -06:00
Kevin Wolf 0f853a3867 qdev: Free opts on failed do_device_add
If the device can't be created, don't leak the QemuOpts and release the id of
the device that should have been added by the failed device_add.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:53:54 -06:00
Markus Armbruster 117f8eb81d qdev: Add rudimentary help for property value
This provides the same information as reverted commit 2ba6edf0.  Not
much, just better than nothing.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:39:01 -06:00
Markus Armbruster 08350cf06a qdev: Add help for device properties
Option "-device DRIVER,?" and monitor command "device_add DRIVER,?"
print the supported properties instead of creating a device.  The
former also terminates the program.

This is commit 2ba6edf0 (just reverted) done right.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:39:01 -06:00
Markus Armbruster ff952ba25d qdev: Fix exit code for -device ?
Help was shoehorned into device creation, qdev_device_add().  Since
help doesn't create a device, it returns NULL, which looks to callers
just like failed device creation.  Monitor handler do_device_add()
doesn't care, but main() exits unsuccessfully.

Move help out of device creation, into new qdev_device_help().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:39:01 -06:00
Amit Shah 98b19252cf virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.

The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.

This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.

As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using

    -virtioconsole ...

is maintained, but the new, preferred way is to use

    -device virtio-serial -device virtconsole,chardev=...

With this commit, multiple devices as well as multiple ports with a
single device can be supported.

For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.

In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.

This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-20 08:25:23 -06:00
Gerd Hoffmann 458fb6792d qdev: make compat stuff more generic
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-12-12 07:59:40 -06:00
Juan Quintela 70cca6d872 qdev: enable vmstate_unregister() support
Now vmstate_unregister have the right type

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:55 -06:00
Luiz Capitulino 3ced9f7a36 qdev: Use QError for 'device not found' error
Please, note that we will lose the "Try -device '?' for a list"
hint as it's qdev specific.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:20 -06:00
Amit Shah 593831de5d qdev: Check if unplug handler exists before calling it
A bus may have hotplugging enabled but not have the 'unplug'
callback defined, which would lead to a crash on trying to
unplug a device on the bus.

Fix by introducing an assert to check if the callback is valid.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-12 11:23:54 -06:00
Gerd Hoffmann 0958b4cc8f usb core: use qdev for -usbdevice
This patchs adds infrastructure to handle -usbdevice via qdev callbacks.
USBDeviceInfo gets a name field (for the -usbdevice driver name) and a
callback for -usbdevice parameter parsing.

The new usbdevice_create() function walks the qdev driver list and looks
for a usb driver with a matching name.  When a parameter parsing
callback is present it is called, otherwise the device is created via
usb_create_simple().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:30 -05:00
Gerd Hoffmann 1cc33683c8 zap DeviceState->nd
No users left.
Also cleanup obsolete helper functions.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27 12:28:41 -05:00
Gerd Hoffmann 97b156213e virtio: use qdev properties for configuration.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27 12:28:40 -05:00
Gerd Hoffmann ed16ab5afa qdev/net: common nic property bits
Add a new type for properties common to all nics.
Add helper functions and macros to deal with it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27 12:28:38 -05:00
Mark McLoughlin 283c7c63f5 net: allow NICs to be connected to netdevs
Introduce a 'peer' member to VLANClientState as an alternative
to a vlan. The idea being that packets are transfered directly
from peer clients rather than going through a vlan.

Patchworks-ID: 35516
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:02 -05:00
Markus Armbruster 5c17ca2505 Clean up test for qdev_init() failure
Some callers test for != 0, some for < 0.  Normalize to < 0.

Patchworks-ID: 35171
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-07 08:54:55 -05:00
Markus Armbruster e23a1b33b5 New qdev_init_nofail()
Like qdev_init(), but terminate program via hw_error() instead of
returning an error value.

Use it instead of qdev_init() where terminating the program on failure
is okay, either because it's during machine construction, or because
we know that failure can't happen.

Because relying in the latter is somewhat unclean, and the former is
not always obvious, it would be nice to go back to qdev_init() in the
not-so-obvious cases, only with proper error handling.  I'm leaving
that for another day, because it involves making sure that error
values are properly checked by all callers.

Patchworks-ID: 35168
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-07 08:54:54 -05:00
Markus Armbruster 18cfeb52d1 Make qdev_init() destroy the device on failure
Before, every caller had to do this.  Only two actually did.

Patchworks-ID: 35170
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-07 08:54:53 -05:00
Gerd Hoffmann cdaed7c793 qdev: move comment
Move comment back next to main_system_bus to avoid confusion.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:46:10 -05:00
Amit Shah c8cd1fcd66 qdev: show name of device that fails init
When initialising a device fails, show the name of the failing device.

The current behaviour is to silently exit on such errors.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:52 -05:00
Michael S. Tsirkin 7f23f812c4 qemu/qdev: type safety in reset handler
Add type safety to qdev reset handlers, by declaring them as
DeviceState * rather than void *.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:50 -05:00
Gerd Hoffmann ef80b46623 store a pointer to QemuOpts in DeviceState, release it when zapping a device.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:49 -05:00
Gerd Hoffmann 3418bd25e1 qdev hotplug: infrastructure and monitor commands.
Adds device_add and device_del commands.  device_add accepts accepts
the same syntax like the -device command line switch.  device_del
expects a device id.  So you should tag your devices with ids if you
want to remove them later on, like this:

  device_add pci-ohci,id=ohci
  device_del ohci

Unplugging via pci_del or usb_del works too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:48 -05:00
Gerd Hoffmann d29275f103 Add exit callback to DeviceInfo.
This adds a exit callback for device destruction to DeviceInfo, so
we can hook cleanups into qdev device destruction.

Followup patches will put that into use.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:48 -05:00
Gerd Hoffmann 131ec1bd7d qdev: device free fixups.
Two bug fixes:
 * When freeing a device we unregister even stuff we didn't register in
   the first place because the ->init() callback failed.
 * When freeing a device with child busses attached, we fail to zap the
   child bus (and the devices attached to it).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:48 -05:00
Gerd Hoffmann cd739fb6e9 allow qdev busses allocations be inplace
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:45 -05:00
Mark McLoughlin 3df04ac3c6 Fix coding style issue
Replace:

  if (-1 == foo())

with:

  if (foo() == -1)

While this coding style is not in direct contravention of our currently
ratified CODING_STYLE treaty, it could be argued that the Article 3 of
the European Convention on Human Rights (prohibiting torture and "inhuman
or degrading treatment") reads on the matter.

[This commit message was brought to you without humour, as is evidenced
by the absence of any emoticons]

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-25 19:57:51 +00:00
Blue Swirl 72cf2d4f0e Fix sys-queue.h conflict for good
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 15cc923584,
f40d753718,
96555a96d7 and
3990d09adf 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-12 07:36:22 +00:00
Gerd Hoffmann 391a079edb qdev: integrate vmstate
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09 14:57:20 -05:00
Gerd Hoffmann 959f733a29 qdev: integrate reset
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09 14:57:20 -05:00
Gerd Hoffmann d52affa7f6 qdev/scsi: add scsi bus support to qdev, convert drivers.
* 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-09 14:57:19 -05:00