Commit Graph

10546 Commits

Author SHA1 Message Date
Jan Kiszka 19ccb8ea17 KVM: x86: Fix up misreported CPU features
From qemu-kvm: Kernels before 2.6.30 misreported some essential CPU
features via KVM_GET_SUPPORTED_CPUID. Fix them up.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2010-02-03 19:47:34 -02:00
Jan Kiszka aee028b95d KVM: Request setting of nmi_pending and sipi_vector
The final version of VCPU events in 2.6.33 will allow to skip
nmi_pending and sipi_vector on KVM_SET_VCPU_EVENTS. For now let's write
them unconditionally, which is unproblematic for upstream due to missing
SMP support. Future version which enable SMP will write them only on
reset.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-02-03 19:47:33 -02:00
Sheng Yang 62a2744ca0 kvm: Flush coalesced MMIO buffer periodly
The default action of coalesced MMIO is, cache the writing in buffer, until:
1. The buffer is full.
2. Or the exit to QEmu due to other reasons.

But this would result in a very late writing in some condition.
1. The each time write to MMIO content is small.
2. The writing interval is big.
3. No need for input or accessing other devices frequently.

This issue was observed in a experimental embbed system. The test image
simply print "test" every 1 seconds. The output in QEmu meets expectation,
but the output in KVM is delayed for seconds.

Per Avi's suggestion, I hooked flushing coalesced MMIO buffer in VGA update
handler. By this way, We don't need vcpu explicit exit to QEmu to
handle this issue.

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-02-03 19:47:33 -02: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 40ea285c14 qdev: update help on -device
While there, use "property" rather than "option", for consistency with
-global.

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 5137b6accd Revert "qdev: Add help for device properties"
This reverts commit 2ba6edf0dd.

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-03 12:39:01 -06:00
Markus Armbruster eecbb9fe6f Revert "qdev: Add help for property value"
This reverts commit 922910ce42.

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-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
Markus Armbruster 4a2594ddd3 qemu-option: Make qemu_opts_foreach() accumulate return values
Return the bitwise inclusive or of all return values instead of the
last call's value.  This lets you find out whether any of the calls
returned a non-zero value.

No functional change, as existing users either don't care for the
value, or pass non-zero abort_on_failure, which breaks the loop on the
first non-zero return value.

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 f34e568853 Revert "QError: New QERR_INVALID_CPU_INDEX"
This reverts commit 64a34bb14c.

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 cc0c4185e5 monitor: Use QERR_INVALID_PARAMETER instead of QERR_INVALID_CPU_INDEX
This changes the error message from "Invalid CPU index" to "Invalid
parameter index" in the human monitor.

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 c6027f56dc monitor: convert do_migrate_set_downtime() to QObject
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:26 -06:00
Markus Armbruster b0fbf7d342 monitor: Use argument type 'T' for migrate_set_downtime
Before, it used type 's', which strips quotes and interprets escapes,
and is quite inappropriate for QMP.

Negative arguments are no flushed to zero.  Before, they were cast to
uint32_t, which wrecked the sign.

Ridiculously large arguments including infinities are now rejected.
Before, they were interpreted as zero.  Same for NaN.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:26 -06:00
Markus Armbruster fccfb11e0d monitor: New argument type 'T'
This is a double value with optional suffixes ms, us, ns.  We'll need
this to get migrate_set_downtime() QMP-ready.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:26 -06:00
Markus Armbruster 5fd9083cd8 monitor: convert do_migrate_set_speed() to QObject
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:26 -06:00
Markus Armbruster 5667c493c4 monitor: Use argument type 'b' for migrate_set_speed
Before, it used type 's', which strips quotes and interprets escapes,
and is quite inappropriate for QMP.

Negative arguments are no flushed to zero.  Before, they were cast to
uint32_t, which wrecked the sign.

Ridiculously large arguments including infinities are now rejected.
Before, they were interpreted as zero.  Same for NaN.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:26 -06:00
Markus Armbruster 3350a4dd07 monitor: New argument type 'b'
This is a double value with optional suffixes G, g, M, m, K, k.  We'll
need this to get migrate_set_speed() QMP-ready.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:26 -06:00
Markus Armbruster acc3b0336c QDict: New qdict_get_double()
Helper function just like qdict_get_int(), just for QFloat/double.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:25 -06:00
Markus Armbruster 9fec543fa6 monitor: Document argument type 'M'
Was forgotten in commit b6e098d7.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:25 -06:00
Anthony Liguori 9da92c4944 seabios: use correct submodule hash
Commit 392ecf543d introduced an accidental change
to the roms/seabios submodule.  This commit partially reverts that commit to
ensure the seabios module points to the right commit.

Reported-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:25 -06:00
Blue Swirl 059bca46bb bsd/darwin-user: mmap_frag() users only check for -1 error
See also ee636500d6.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-31 13:41:07 +00:00
Edgar E. Iglesias 416c60602f cris: Prettify register dumps.
Use friendly names for registers in the dumps.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2010-01-31 11:26:54 +01:00
Artyom Tarasenko 698235aab6 sparc32 don't mark page dirty when failing
if the access check fails, the page can not be modified
and shouldn't be marked dirty.
The patch fixes the "hsfs_putpage: dirty HSFS page"
error in Solaris guests.

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-31 07:49:26 +00:00
Blue Swirl 95819af015 sparc64: implement basic IOMMU/interrupt handling
Also add reset control.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-30 19:48:12 +00:00
Blue Swirl a4d5f62ceb Sparc64: byte swap IO port access
This requires an updated OpenBIOS image.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-29 18:15:21 +00:00
Kevin Wolf 6c510fbf60 virtio-blk: Fix error cases which ignored rerror/werror
If an I/O request fails right away instead of getting an error only in the
callback, we still need to consider rerror/werror.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:01 -06:00
Kevin Wolf f1b5286803 virtio-blk: Fix restart after read error
Current code assumes that only write requests are ever going to be restarted.
This is wrong since rerror=stop exists. Instead of directly starting writes,
use the same request processing as used for new requests.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:01 -06:00
Kevin Wolf bc6694d43a virtio_blk: Factor virtio_blk_handle_request out
We need a function that handles a single request. Create one by splitting out
code from virtio_blk_handle_output.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:00 -06:00
Jan Kiszka 4516e45f82 cirrus: Properly re-register cirrus_linear_io_addr on vram unmap
This fixes CONFIG_FB_CIRRUS for Linux guests and probably much more:

When switching away from linearly mapped vram, we also have to restore
the I/O handlers for the LFB.

This regression was once introduced by commit 2bec46dc97.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:00 -06:00
Amit Shah 9ae84f0a6d virtio-serial-bus: Fix bus initialisation and allow for bus identification
This commit enables one to use multiple virtio-serial devices and to
assign ports to arbitrary devices like this:

  -device virtio-serial,id=foo -device virtio-serial,id=bar \
  -device virtserialport,bus=foo.0,name=foo \
  -device virtserialport,bus=bar.0,name=bar

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:00 -06:00
Edgar E. Iglesias 794401ca9c softmmu: Dont clobber retaddr in slow_ldx().
When splitting up unaligned IO accesses, ld calls slow_ld which was
clobbering retaddr.

AFAIK the problem only shows up when running emulations with -icount
that may abort TB execution on IO accesses.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2010-01-28 22:46:13 +01:00
Loïc Minier 6792aa115e Solaris: test for presence of commands with has()
Signed-off-by: Loïc Minier <lool@dooz.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-28 21:27:46 +00:00
Loïc Minier 0dba619507 Add and use has() and path_of() funcs
Add has() and path_of() funcs and use them across configure; has()
will test whether a command or builtin is available; path_of() will
search the PATH for executables and return the full pathname if found.

Signed-off-by: Loïc Minier <lool@dooz.org
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-28 21:26:51 +00:00
Loïc Minier a0dfd8a415 Check for sdl-config before calling it
Check whether sdl-config is available before calling it, otherwise
./configure triggers a warning:
    ./configure: 957: sdl-config: not found

If neither the .pc file not sdl-config are present, disable SDL support.

Signed-off-by: Loïc Minier <lool@dooz.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-28 21:15:18 +00:00
Luiz Capitulino 82617d7ce3 Monitor: Fix command execution regression
Function is_async_return() added by commit 940cc30d0d assumes
that 'data', which is returned by handlers, is always a QDict.

This is not true, as QLists can also be returned, in this case
we'll get a segfault.

Fix that by checking if 'data' is a QDict.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-28 19:09:44 +00:00
Igor V. Kovalenko 8f4efc5588 sparc64: reimplement tick timers v4
sparc64 timer has tick counter which can be set and read,
and tick compare value used as deadline to fire timer interrupt.
The timer is not used as periodic timer, instead deadline
is set each time new timer interrupt is needed.

v3 -> v4:
- coding style

v2 -> v3:
- added missing timer debug output macro
- CPUTimer struct and typedef moved to cpu.h
- change CPU_SAVE_VERSION to 6, older save formats not supported

v1 -> v2:
- new conversion helpers cpu_to_timer_ticks and timer_to_cpu_ticks
- save offset from clock source to implement cpu_tick_set_count
- renamed struct sun4u_timer to CPUTimer
- load and save cpu timers

v0 -> v1:
- coding style

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-27 21:21:57 +00:00
Igor V. Kovalenko 4f690853bb sparc64: correct write extra bits to cwp
- correctly fit to cwp if provided window number is out of range

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-27 17:47:48 +00:00
Blue Swirl 28b150bfb0 Fix BSD build
<sys/wait.h> must be included in order to use WIF* macros.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-27 17:47:33 +00:00
Anthony Liguori 28e68d68b0 Fix regression in option parsing
Commit ec229bbe7 broke invocation without a specific -hda.  IOW, qemu foo.img.
The lack of an optind update caused an infinite loop.

Reported-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-27 10:50:14 -06:00
Edgar E. Iglesias b4bf0a9a69 pflash: Buffer block writes
Buffer block writes to avoid flushing every word access onto backing
storage device. This significantly speeds up flash emulation for flashes
connected through an 8 or 16-bit bus combined with backing storage (-pflash).

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
2010-01-27 13:01:53 +01:00
Adam Litke 625a5befc2 virtio: Add memory statistics reporting to the balloon driver
When using ballooning to manage overcommitted memory on a host, a system for
guests to communicate their memory usage to the host can provide information
that will minimize the impact of ballooning on the guests.  The current method
employs a daemon running in each guest that communicates memory statistics to a
host daemon at a specified time interval.  The host daemon aggregates this
information and inflates and/or deflates balloons according to the level of
host memory pressure.  This approach is effective but overly complex since a
daemon must be installed inside each guest and coordinated to communicate with
the host.  A simpler approach is to collect memory statistics in the virtio
balloon driver and communicate them directly to the hypervisor.

Signed-off-by: Adam Litke <agl@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 17:08:03 -06:00
Adam Litke 940cc30d0d New API for asynchronous monitor commands
Qemu has a number of commands that can operate asynchronously (savevm, migrate,
etc) and it will be getting more.  For these commands, the user monitor needs
to be suspended, but QMP monitors could continue to to accept other commands.
This patch introduces a new command API that isolates the details of handling
different monitor types from the actual command execution.

A monitor command can use this API by implementing the mhandler.cmd_async
handler (or info_async if appropriate).  This function is responsible for
submitting the command and does not return any data although it may raise
errors.  When the command completes, the QMPCompletion callback should be
invoked with its opaque data and the command result.

The process for submitting and completing an asynchronous command is different
for QMP and user monitors.  A user monitor must be suspended at submit time and
resumed at completion time.  The user_print() function must be passed to the
QMPCompletion callback so the result can be displayed properly.  QMP monitors
are simpler.  No submit time setup is required.  When the command completes,
monitor_protocol_emitter() writes the result in JSON format.

This API can also be used to implement synchronous commands.  In this case, the
cmd_async handler should immediately call the QMPCompletion callback.  It is my
hope that this new interface will work for all commands, leading to a
drastically simplified monitor.c once all commands are ported.

Signed-off-by: Adam Litke <agl@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 17:08:03 -06:00
Christoph Hellwig e2a305fb13 block: avoid creating too large iovecs in multiwrite_merge
If we go over the maximum number of iovecs support by syscall we get
back EINVAL from the kernel which translate to I/O errors for the guest.

Add a MAX_IOV defintion for platforms that don't have it.  For now we use
the same 1024 define that's used on Linux and various other platforms,
but until the windows block backend implements some kind of vectored I/O
it doesn't matter.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 17:08:03 -06:00
Stefano Stabellini 6185c5783c vnc_refresh: calling vnc_update_client might free vs
Hi all,
this patch fixes another bug in vnc_refresh: calling vnc_update_client
might cause vs to be free()ed, in this case we cannot access vs->next
right after to examine the next item on the list.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 17:08:02 -06:00
Kevin Wolf 053965c7ff block/raw-posix: Abort on pread beyond end of non-growable file
This shouldn't happen under any normal circumstances. However, it looks like
it's possible to achieve this with corrupted images. Without this patch
raw_pread is hanging in an endless loop in such cases.

The patch is not affecting growable files, for which such reads happen in
normal use cases. raw_pread_aligned already handles these cases and won't
return zero in the first place.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 16:41:07 -06:00
Herve Poussineau f8a83245d9 win32: pair qemu_memalign() with qemu_vfree()
Win32 suffers from a very big memory leak when dealing with SCSI devices.
Each read/write request allocates memory with qemu_memalign (ie
VirtualAlloc) but frees it with qemu_free (ie free).
Pair all qemu_memalign() calls with qemu_vfree() to prevent such leaks.

Signed-off-by: Herve Poussineau <hpoussin@reactos.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 16:41:06 -06:00
Herve Poussineau a35aed57bf win32/sdl: Fix toggle full screen
Toggle full screen on Win32/SDL 1.2.13 was broken by commit
c18a2c360e. Re-add the call to
do_sdl_resize() which was removed in this revision

Signed-off-by: Herve Poussineau <hpoussin@reactos.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 16:28:46 -06:00
Stefan Weil d2d5adcb58 Tell users about out-of-memory errors
Aborting without an error message when memory is short
is not helpful, so print the reason for the abort.

Try
	qemu -m 1000000
or
	qemu -m 2000 (win32)

to force an out-of-memory error.

v2:
* Fix error message for win32.
* Fix error message for posix_memalign.

Thanks to malc for the hints.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 16:28:46 -06:00
Blue Swirl 776e1bbb6c PCI: fix bridge configuration
PCI bridges' qdev info structures must indicate bridge header type,
otherwise critical bridge registers (esp. PCI_PRIMARY_BUS,
PCI_SECONDARY_BUS, PCI_SUBORDINATE_BUS) will not be writable.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-26 21:59:57 +00:00