Commit graph

12110 commits

Author SHA1 Message Date
Gerd Hoffmann fd42deeb4c Add exit notifiers.
Hook up any cleanup work which needs to be done here.  Advantages over
using atexit(3):

  (1) You get passed in a pointer to the notifier.  If you embed that
      into your state struct you can use container_of() to get get your
      state info.
  (2) You can unregister, say when un-plugging a device.

[ v2: move code out of #ifndef _WIN32 ]

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Alex Williamson 4cf3e6f3d8 acpi_piix4: save gpe and pci hotplug slot status
PCI hotplug currently doesn't work after a migration because
we don't migrate the enable bits of the GPE state.  Pull hotplug
structs into vmstate.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Markus Armbruster b560a9ab9b qemu-option: Reject anti-social IDs
Restrict IDs to letters, digits, '-', '.', '_', starting with a
letter.

This takes care of '/' in qdev IDs breaking qbus_find().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Markus Armbruster 1bb6504200 qdev: Revert the hack to let -net nic and pci_add set qdev ID
Setting the ID in pci_nic_init() is a blatant violation of the
DeviceState abstraction.  Which even carries a comment advising
against this:

/* This structure should not be accessed directly.  We declare it here
   so that it can be embedded in individual device state structures.  */

What's worse, it bypasses the code ensuring unique qdev IDs: "-device
virtio-net-pci,id=foo -net nic,id=foo -net nic,name=foo" happily
creates three qdevs with ID "foo".  That's because qdev relies on
qemu_opts_create() to ensure unique IDs, but -net nic uses a different
QemuOptsList, which means id is in a different namespace.  And its
name is not checked for uniqueness at all.

-net nic and pci_add are legacy.  Use -device and device_add if you
want a NIC with a qdev ID.

This reverts what's still left of commit eb54b6dc "qdev: add id=
support for pci nics."

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Daniel P. Berrange 3709c1b7cc Clarify error message when a PCI slot is already in use (v2)
When mistakenly configuring two devices in the same PCI slot,
QEMU gives a not entirely obvious message about a 'devfn' being
in use:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu-kvm: -device virtio-balloon-pci,bus=pci.0,addr=0x3: PCI: devfn 24 not available for virtio-balloon-pci, in use by rtl8139

The user does not configure 'devfn' numbers, they use slot+function.
Thus the error messages should be reported back to the user with that
same terminology rather than the internal QEMU terminology. This
patch makes it report:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu: -device virtio-balloon-pci,bus=pci.0,addr=0x3.7: PCI: slot 3 function 0 not available for virtio-balloon-pci, in use by rtl8139

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Christoph Hellwig c20fd87225 virtio-blk: simplify multiwrite calling conventions
Pass the MultiReqBuffer structure down all the way to the I/O submission
instead of takin it apart.  Also mark num_writes unsigned as it can't
go negative, and take the check for any pending I/O requests into the
submission function.  Last but not least rename do_multiwrite to
virtio_submit_multiwrite to fit the general naming scheme and make clear
what it does.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Christoph Hellwig 7e608e8903 virtio-blk: stop tracking old_bs
There is a 1:1 relation between VirtIOBlock and BlockDriverState instances,
no need to track it because it won't change.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Jes Sorensen 46aaebff40 un-register kbd driver in case of USB kbd unplug.
If a USB keyboard is unplugged, the keyboard eventhandler is never
removed, and events will continue to be passed through to the device,
causing crashes or memory corruption.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Paolo Bonzini 55541c8afc make qemu_thread_create block all signals
All signals will thus be routed through the IO thread.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Yoshiaki Tamura 304e3a7c80 migration-tcp: call migrate_fd_error() instead of close() and free().
This patch fixes the following error report.  When changing
migration-tcp.c to call migrate_fd_error() instead of close() and
free() by itself, monitor is resumed, and returns allocated mig_state
is set to current_migration in migration.c allows us to print "info
migrate".

Reported-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Yoshiaki Tamura faa1f8ddc1 migration: use qemu_free() instead of free().
Although there is no difference, other migration related code use
qemu_free(), and it should be better to be consistent.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 15:46:28 -05:00
Edgar E. Iglesias f2fcffbbe8 etrax-ser: Support the uart rx fifo.
Add support for the rx fifo to speed up bulk transfers.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@axis.com>
2010-06-14 18:41:12 +02:00
Alex Williamson f471a17e9d ram_blocks: Convert to a QLIST
This makes the RAM block list easier to manipulate.  Also incorporate
relevant variables into the RAMList struct.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Chris Wright <chrisw@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 11:12:53 -05:00
Markus Armbruster 2ffcb18de0 Make netdev_del delete the netdev even when it's in use
To hot-unplug guest and host part of a network device, you do:

    device_del NIC-ID
    netdev_del NETDEV-ID

For PCI devices, device_del merely tells ACPI to unplug the device.
The device goes away for real only after the guest processed the ACPI
unplug event.

You have to wait until then (e.g. by polling info pci) before you can
unplug the netdev.  Not good.

Fix by removing the "in use" check from do_netdev_del().  Deleting a
netdev while it's in use is safe; packets simply get routed to the bit
bucket.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 11:12:53 -05:00
Gleb Natapov 40ac17cd56 pass info about hpets to seabios.]
Currently HPET ACPI table is created regardless of whether qemu actually
created hpet device. This may confuse some guests that don't check that
hpet is functional before using it. Solve this by passing info about
hpets in qemu to seabios via fw config interface. Additional benefit is
that seabios no longer uses hard coded hpet configuration. Proposed
interface supports up to 8 hpets. This is the number defined by hpet
spec.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 11:12:53 -05:00
Jan Kiszka 072c2c31c2 hpet: Init capability register only once
The capability register is read-only from guest POV, so we do not need
to update it on reset.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 11:12:53 -05:00
Kevin Wolf bd69fe8448 qemu-option: Fix uninitialized value in append_option_parameter
When dest is NULL, i.e. a new copy of the list is created, we don't get a
properly terminated list after the realloc. Initialize it as an empty list.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 11:12:53 -05:00
Jes Sorensen 271248886e Change #define DEBUG to #define E1000_DEBUG in hw/e1000.c
Change #define DEBUG to #define E1000_DEBUG in hw/e1000.c to make
it possible to build QEMU with -DDEBUG

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 10:58:08 -05:00
Jes Sorensen ac7045cff7 Remove unused DEBUG defines from hw/msix.c
Remove unused DEBUG defines from hw/msix.c to avoid having anything
define the word DEBUG without any additions such as MSIX_DEBUG.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14 10:58:08 -05:00
Anthony Liguori a4673e2762 Merge remote branch 'kwolf/for-anthony' into staging
Conflicts:
	hw/pc.c
2010-06-14 10:33:36 -05:00
Anthony Liguori a2da0395c1 Merge remote branch 'qmp/for-anthony' into staging 2010-06-14 09:39:01 -05:00
Paul Brook 09564574b8 OHCI address decoding fix
Ignore high address bits when PCI memory window is not mapped on a page
boundary.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-06-13 23:37:31 +01:00
Paul Brook 11165820d1 Move stdbool.h
Move inclusion of stdbool.h to common header files, instead of including
in an ad-hoc manner.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-06-13 19:00:50 +01:00
Jan Kiszka ea4e78e590 monitor/QMP: Drop info hpet / query-hpet
This command was of minimal use before, now it is useless as the hpet
become a qdev device and is thus easily discoverable. We should
definitely not set query-hpet in QMP's stone, and there is also no good
reason to keep it for the interactive monitor.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:33:02 +03:00
Jan Kiszka 8caa0065b8 hpet: Add MSI support
This implements the HPET capability of routing IRQs to the front-side
bus, aka MSI support. This feature can be enabled via the qdev property
"msi" and is off by default.

Note that switching it on can cause guests (at least Linux) to use the
HPET as timer instead of the LAPIC. KVM users should recall that only
the latter is currently available as fast in-kernel model.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:33:01 +03:00
Jan Kiszka be4b44c59b hpet: Make number of timers configurable
One HPET block supports up to 32 timers. Allow to instantiate more than
the recommended and implemented minimum of 3. The number is configured
via the qdev property "timers". It is also saved/restored so that it
need not match between migration peers.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:33:01 +03:00
Jan Kiszka cea1adfda7 vmstate: Add VMSTATE_STRUCT_VARRAY_UINT8
Required for hpet.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:33:01 +03:00
Jan Kiszka 22a9fe38a3 hpet: Add support for level-triggered interrupts
By implementing this feature we can also remove a nasty way to kill qemu
(by trying to enable level-triggered hpet interrupts).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:33:00 +03:00
Jan Kiszka b7eaa6c77c hpet: Drop static state
Instead of keeping a static reference around, pass the state to
hpet_enabled and hpet_get_ticks. All callers now have it at hand. Will
once allow to instantiate the HPET more than a single time.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:33:00 +03:00
Jan Kiszka 7d932dfdc5 hpet/rtc: Rework RTC IRQ replacement by HPET
Allow the intercept the RTC IRQ for the HPET legacy mode. Then push
routing to IRQ8 completely into the HPET. This allows to turn
hpet_in_legacy_mode() into a private function. Furthermore, this stops
the RTC from clearing IRQ8 even if the HPET is in control.

This patch comes with a side effect: The RTC timers will no longer be
stoppend when there is no IRQ consumer, possibly causing a minor
performance degration. But as the guest may want to redirect the RTC to
the SCI in that mode, it should normally disable unused IRQ source
anyway.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:33:00 +03:00
Jan Kiszka 9cec89e8db hpet: Start/stop timer when HPET_TN_ENABLE is modified
We have to update the qemu timer when the per-timer enable bit is
toggled, just like for HPET_CFG_ENABLE changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:32:59 +03:00
Jan Kiszka 822557eb8e hpet: Convert to qdev
Register the HPET as a sysbus device and create it that way. As it can
route its IRQs to any ISA IRQ, we need to connect it to all 24 of them.
Once converted to qdev, we can move reset handler and vmstate
registration into its hands as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:32:59 +03:00
Jan Kiszka 7afbecc9ef hpet: Move static timer field initialization
Properly initialize HPETTimer::tn and HPETTimer::state once during
hpet_init instead of (re-)writing them on every reset.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:32:59 +03:00
Jan Kiszka ad0a655161 hpet: Silence warning on write to running main counter
Setting the main counter while the HPET is enabled may not be a good
idea of the guest, but it is supported and should, thus, not spam the
host console with warnings.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:32:59 +03:00
Jan Kiszka 27bb0b2d6f hpet: Coding style cleanups and some refactorings
This moves the private HPET structures into the C module, simplifies
some helper functions and fixes most coding style issues (biggest chunk
was improper switch-case indention). No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:32:58 +03:00
Jan Kiszka 6982d6647e hpet: Catch out-of-bounds timer access
Also prevent out-of-bounds write access to the timers but don't spam the
host console if it triggers.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-13 15:32:58 +03:00
Jan Kiszka c3d96978d0 configure: Fix evaluation of config-host.mak in create_config
Only match on true dir variable assignments, avoid generating garbage
due to the "# Configured with: ..." line which may contain "*dir=" as
well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-06-13 12:50:30 +02:00
Aurelien Jarno d66ed0eae9 tcg-s390: correctly detect s390 with a 64-bit kernel
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-06-13 12:28:21 +02:00
Blue Swirl b0cb640ac1 Compile OS specific files only once for all targets
OS specific files are not target dependent, so they can be compiled
once for all targets.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 05:49:30 +00:00
Jes Sorensen ce798cf2a2 Move set_proc_name() to OS specific files.
Move handling to change process name to POSIX specific files
plus add a better error message to cover the case where the
feature isn't supported.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:15 +03:00
Jes Sorensen 9156d76331 Move line-buffering setup to OS specific files.
Move line-buffering setup to OS specific files.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:15 +03:00
Jes Sorensen e06eb601b0 Make os_change_process_uid and os_change_root os-posix.c local
os_change_process_uid() and os_change_root() are now only called
from os-posix.c, so no need to keep win32 stubs for them.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:15 +03:00
Jes Sorensen eb505be11b Move daemonize handling to OS specific files
Move daemonize handling from vl.c to OS specific files. Provide dummy
stubs for Win32.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:15 +03:00
Jes Sorensen 0766379d4c Move chroot handling to OS specific files.
Move chroot handling to OS specific files.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:15 +03:00
Jes Sorensen 8847cfe8aa Move runas handling from vl.c to OS specific files.
Move code to handle runas, ie. change of user id of QEMU process
to OS specific files and provide dummy stub for Win32.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:15 +03:00
Jes Sorensen 59a5264b99 Introduce OS specific cmdline argument handling and move SMB arg to os-posix.c
Introduce OS specific cmdline argument handling by calling
os_parse_cmd_args() at the end of switch() statement. Move option
enum to qemu-options.h and have it included from os-posix.c and
os-win32.c in addition to vl.c.

In addition move SMB argument to os-posix.c

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:15 +03:00
Jes Sorensen 9f16732a06 Rename qemu-options.h to qemu-options.def
Rename qemu-options.h to qemu-options.def as it is not a header file
for general use and this leaves space for a proper qemu-options.h

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:15 +03:00
Jes Sorensen 6170540b82 Move find_datadir to OS specific files.
This moves the win32 and POSIX versions of find_datadir() to OS
specific files, and removes some #ifdef clutter from vl.c

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:14 +03:00
Jes Sorensen 8d963e6ae7 Move main signal handler setup to os specificfiles.
Move main signal handler setup to os specific files.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:14 +03:00
Jes Sorensen fe98ac1461 Rename os_setup_signal_handling() to os_setup_early_signal_handling()
Rename os_setup_signal_handling() to os_setup_early_signal_handling()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-12 08:49:14 +03:00