sdk/emulator/qemu.git
14 years agoConvert atexit users to exit_notifier
Anthony Liguori [Wed, 17 Mar 2010 22:59:26 +0000 (17:59 -0500)]
Convert atexit users to exit_notifier

All of these users have global state so we really don't see a benefit from
exit_notifier.  However, using exit_notifier means that there's one less
justification for having global state in the first place.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAdd exit notifiers
Anthony Liguori [Wed, 17 Mar 2010 22:44:48 +0000 (17:44 -0500)]
Add exit notifiers

Like atexit() but with state

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosdl: use mouse mode notifier
Anthony Liguori [Wed, 10 Mar 2010 15:42:58 +0000 (09:42 -0600)]
sdl: use mouse mode notifier

Today we poll the mouse mode whenever there is a mouse movement.  There is a
subtle usability problem with this though.

If we're in relative mode and grab is enabled, when we change to absolute mode,
we break grab.  This gives a user a seamless transition when the new pointer
is enabled.

But because we poll for mouse change, this grab break won't occur until the user
attempts to move the mouse.  By using notifiers, the grab break happens as soon
as possible.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoinput: make vnc use mouse mode notifiers
Anthony Liguori [Wed, 10 Mar 2010 15:38:29 +0000 (09:38 -0600)]
input: make vnc use mouse mode notifiers

When we switch to absolute mode, we send out a notification (if the client
supports it).  Today, we only send this notification when the client sends us
a mouse event and we're in the wrong mode.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoExpose whether a mouse is an absolute device via QMP and the human monitor.
Anthony Liguori [Wed, 10 Mar 2010 02:58:07 +0000 (20:58 -0600)]
Expose whether a mouse is an absolute device via QMP and the human monitor.

For QMP, we just add an attribute which is backwards compatible.  For the human
monitor, we add (absolute) to the end of the line.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAdd notifier for mouse mode changes
Anthony Liguori [Tue, 9 Mar 2010 19:25:00 +0000 (13:25 -0600)]
Add notifier for mouse mode changes

Right now, DisplayState clients rely on polling the mouse mode to determine
when the device is changed to an absolute device.  Use a notification list to
add an explicit notification.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAdd kbd_mouse_has_absolute()
Anthony Liguori [Tue, 9 Mar 2010 20:26:40 +0000 (14:26 -0600)]
Add kbd_mouse_has_absolute()

kbd_mouse_is_absolute tells us whether the current mouse handler is an absolute
device.  kbd_mouse_has_absolute tells us whether we have any device that is
capable of absolute input.

This lets us tell a user that they have configured an absolute device but that
the guest is not currently using it.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoRewrite mouse handlers to use QTAILQ and to have an activation function
Anthony Liguori [Wed, 10 Mar 2010 02:52:22 +0000 (20:52 -0600)]
Rewrite mouse handlers to use QTAILQ and to have an activation function

And convert usb-hid to use it (to avoid regression with bisection)

Right now, when we do info mice and we've added a usb tablet, we don't see it
until the guest starts using the tablet.  We implement this behavior in order
to provide a means to delay registration of a mouse handler since we treat
the last registered handler as the current handler.

This is a usability problem though as we would like to give the user feedback
that they've either 1) not added an absolute device 2) there is an absolute
device but the guest isn't using it 3) we have an absolute device and it's
active.

By using QTAILQ and having an explicit activation function that moves the
handler to the front of the queue, we can implement the same semantics as
before with respect to automatically switching to usb tablet while providing
the user with a whole lot more information.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAdd support for generic notifier lists
Anthony Liguori [Tue, 9 Mar 2010 19:16:14 +0000 (13:16 -0600)]
Add support for generic notifier lists

Notifiers are data-less callbacks and a notifier list is a list of registered
notifiers that all are interested in a particular event.

We'll use this in a few patches to implement mouse change notification.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1 -> v2
 - Do not do memory allocations by placing list nodes in notifier

14 years agoRevert "usb-linux: remove unreachable default in switch statement"
Anthony Liguori [Wed, 17 Mar 2010 21:00:24 +0000 (16:00 -0500)]
Revert "usb-linux: remove unreachable default in switch statement"

This reverts commit 3c9c706c3b66d838942aba53c0d3fdcdf06c7423.

This breaks build (gcc 4.3.2):
    CC    usb-linux.o
 cc1: warnings being treated as errors
 /src/qemu/usb-linux.c: In function 'usb_linux_update_endp_table':
 /src/qemu/usb-linux.c:759: error: 'type' may be used uninitialized in
 this function

Reported-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoHandle deleted IOHandlers in a single buffer
Juan Quintela [Thu, 11 Mar 2010 16:55:41 +0000 (17:55 +0100)]
Handle deleted IOHandlers in a single buffer

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agobt: remove bt_host_read_poll()
Juan Quintela [Thu, 11 Mar 2010 16:55:40 +0000 (17:55 +0100)]
bt: remove bt_host_read_poll()

It allways returned true, that is the equivalent of not having the
callback.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agorename IOCanRWHandler to IOCanReadHandler
Juan Quintela [Thu, 11 Mar 2010 16:55:39 +0000 (17:55 +0100)]
rename IOCanRWHandler to IOCanReadHandler

It was always only used for reads

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoremove useless cast
Juan Quintela [Thu, 11 Mar 2010 16:55:38 +0000 (17:55 +0100)]
remove useless cast

values are already pointers, no need to cast them to void *

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoConvert io handlers to QLIST
Juan Quintela [Thu, 11 Mar 2010 16:55:37 +0000 (17:55 +0100)]
Convert io handlers to QLIST

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoCODING_STYLE: Reserve qemu_ prefix for library wrappers
Avi Kivity [Thu, 11 Mar 2010 14:48:43 +0000 (16:48 +0200)]
CODING_STYLE: Reserve qemu_ prefix for library wrappers

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoFix OpenBSD linker warning
Blue Swirl [Thu, 18 Mar 2010 20:48:19 +0000 (20:48 +0000)]
Fix OpenBSD linker warning

qemu-option.o(.text+0x20f8): In function `qemu_opts_from_qdict_1':
/src/qemu/qemu-option.c:813: warning: strcpy() is almost always misused, please use strlcpy()

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoReplace assert(0) with abort() or cpu_abort()
Blue Swirl [Thu, 18 Mar 2010 18:41:57 +0000 (18:41 +0000)]
Replace assert(0) with abort() or cpu_abort()

When building with -DNDEBUG, assert(0) will not stop execution
so it must not be used for abnormal termination.

Use cpu_abort() when in CPU context, abort() otherwise.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoFix manpage errors
Blue Swirl [Thu, 18 Mar 2010 18:41:49 +0000 (18:41 +0000)]
Fix manpage errors

Split long unbreakable lines to smaller sections.

Spotted by Debian Lintian tool:
http://lintian.debian.org/full/pkg-qemu-devel@lists.alioth.debian.org.html#qemu

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agohw/usb-msd: fix some usb requests
Arnaud Patard (Rtp) [Wed, 10 Mar 2010 09:45:12 +0000 (10:45 +0100)]
hw/usb-msd: fix some usb requests

The usb-msd device emulation needs some small tweaks in the requests
emulations. For instance, the reset/maxlun requests are class/interface
specific so requests for them with the type class and recipient interface
bits sets have to be handled.

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: fix buffer overflow
Gerd Hoffmann [Wed, 10 Mar 2010 16:47:17 +0000 (17:47 +0100)]
scsi-disk: fix buffer overflow

In case s->version is shorter than 4 bytes we overflow the memcpy src
buffer.  Fix it by clearing the target buffer, then copy only the
amount of bytes we actually have.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovnc: add no-lock-key-sync option
Gerd Hoffmann [Wed, 10 Mar 2010 16:12:02 +0000 (17:12 +0100)]
vnc: add no-lock-key-sync option

Add an option to disable the heuristics which try to keep
capslock and numlock state for guest and host in sync.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomigration: unix migration should obey autostart are the other ones
Juan Quintela [Tue, 9 Mar 2010 23:10:36 +0000 (00:10 +0100)]
migration: unix migration should obey autostart are the other ones

This was the only incoming migration without autostart check

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomigration: Clear fd also in error cases
Juan Quintela [Tue, 9 Mar 2010 23:10:35 +0000 (00:10 +0100)]
migration: Clear fd also in error cases

Not clearing the fd and closing the file makes qemu spin using 100%CPU
after incoming migration error.

See for instance bug:
https://bugzilla.redhat.com/show_bug.cgi?id=518032

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoread-only: Another minor cleanup
Naphtali Sprei [Thu, 11 Mar 2010 14:44:34 +0000 (16:44 +0200)]
read-only: Another minor cleanup

Don't rely on CDROM hint for read_only attribute

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoread-only: minor cleanup
Naphtali Sprei [Sun, 14 Mar 2010 13:19:57 +0000 (15:19 +0200)]
read-only: minor cleanup

Really use read-only flags for opening the file when asked for read-only

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosplit out qemu-timer.c
Paolo Bonzini [Wed, 10 Mar 2010 10:38:55 +0000 (11:38 +0100)]
split out qemu-timer.c

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agodisentangle tcg and deadline calculation
Paolo Bonzini [Wed, 10 Mar 2010 10:38:54 +0000 (11:38 +0100)]
disentangle tcg and deadline calculation

Just tell main_loop_wait whether to be blocking or nonblocking, so that
there is no need to call qemu_cpus_have_work from the timer subsystem.
Instead, tcg_cpu_exec can say "we want the main loop not to block because
we have stuff to do".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoplace together more #ifdef CONFIG_IOTHREAD blocks
Paolo Bonzini [Wed, 10 Mar 2010 10:38:53 +0000 (11:38 +0100)]
place together more #ifdef CONFIG_IOTHREAD blocks

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomove vmstate registration of vmstate_timers earlier
Paolo Bonzini [Wed, 10 Mar 2010 10:38:52 +0000 (11:38 +0100)]
move vmstate registration of vmstate_timers earlier

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonew function qemu_icount_delta
Paolo Bonzini [Wed, 10 Mar 2010 10:38:51 +0000 (11:38 +0100)]
new function qemu_icount_delta

Tweaking the rounding in qemu_next_deadline ensures that there's
no change whatsoever.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoadd qemu_alarm_pending
Paolo Bonzini [Wed, 10 Mar 2010 10:38:50 +0000 (11:38 +0100)]
add qemu_alarm_pending

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoadd qemu_icount_round
Paolo Bonzini [Wed, 10 Mar 2010 10:38:49 +0000 (11:38 +0100)]
add qemu_icount_round

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agocentralize handling of -icount
Paolo Bonzini [Wed, 10 Mar 2010 10:38:48 +0000 (11:38 +0100)]
centralize handling of -icount

A simple patch to place together all handling of -icount.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agointroduce and use qemu_clock_enable
Paolo Bonzini [Wed, 10 Mar 2010 10:38:47 +0000 (11:38 +0100)]
introduce and use qemu_clock_enable

By adding the possibility to turn on/off a clock, yet another
incestuous relationship between timers and CPUs can be disentangled.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agochange qemu_run_timers interface
Paolo Bonzini [Wed, 10 Mar 2010 10:38:46 +0000 (11:38 +0100)]
change qemu_run_timers interface

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoextract timer handling out of main_loop_wait
Paolo Bonzini [Wed, 10 Mar 2010 10:38:45 +0000 (11:38 +0100)]
extract timer handling out of main_loop_wait

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoremove qemu_rearm_alarm_timer from main loop
Paolo Bonzini [Wed, 10 Mar 2010 10:38:44 +0000 (11:38 +0100)]
remove qemu_rearm_alarm_timer from main loop

Make the timer subsystem register its own callback instead.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agotweak qemu_notify_event
Paolo Bonzini [Wed, 10 Mar 2010 10:38:43 +0000 (11:38 +0100)]
tweak qemu_notify_event

Instead of testing specially next_cpu in host_alarm_handler, just do
that in qemu_notify_event.  The idea is, if we are not running (or
not yet running) target CPU code, prepare things so that the execution
loop is exited asap; just make that clear.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agodo not use qemu_event_increment outside qemu_notify_event
Paolo Bonzini [Wed, 10 Mar 2010 10:38:42 +0000 (11:38 +0100)]
do not use qemu_event_increment outside qemu_notify_event

qemu_notify_event in the non-iothread case is only stopping the current
CPU.  However, if the CPU is idle and the main loop is in the select
call then a call to qemu_event_increment is needed too (as done in
host_alarm_handler).  Since in general one doesn't know whether the CPU
is executing or not, it is a safe bet to always do qemu_event_increment.

Another way to see it: after this patch qemu_event_increment is the
"common part" of qemu_notify_event for both the CONFIG_IOTHREAD and
!CONFIG_IOTHREAD cases, which makes sense.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomore alarm timer cleanup
Paolo Bonzini [Wed, 10 Mar 2010 10:38:41 +0000 (11:38 +0100)]
more alarm timer cleanup

The timer_alarm_pending variable is related to the alarm timer but not
placed in the struct.  Also, in qemu_mod_timer the wrong flag was being
tested: the timer is rearmed in the alarm timer "bottom half", so the
right flag to test there is the "pending" flag.

Finally, I hoisted the NULL checks from alarm_has_dynticks to
host_alarm_handler.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoonly one flag is needed for alarm_timer
Paolo Bonzini [Wed, 10 Mar 2010 10:38:40 +0000 (11:38 +0100)]
only one flag is needed for alarm_timer

The ALARM_FLAG_DYNTICKS can be testing simply by checking if there is
a rearm function.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agofix error in win32_rearm_timer
Paolo Bonzini [Wed, 10 Mar 2010 10:38:39 +0000 (11:38 +0100)]
fix error in win32_rearm_timer

The TIME_ONESHOT and TIME_PERIODIC flags are mutually exclusive.
The code after the patch matches the flags used in win32_start_timer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoavoid dubiously clever code in win32_start_timer
Paolo Bonzini [Wed, 10 Mar 2010 10:38:38 +0000 (11:38 +0100)]
avoid dubiously clever code in win32_start_timer

The code is initializing an unsigned int to UINT_MAX using "-1", so that
the following always-true comparison seems to be always-false at a
first look.  Since alarm timer initializations are never nested, it is
simpler to unconditionally store the result of timeGetDevCaps into
data->period.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoballoon: Do not save VM state wrt asynchronous virtio operations
Adam Litke [Tue, 9 Mar 2010 18:54:09 +0000 (12:54 -0600)]
balloon: Do not save VM state wrt asynchronous virtio operations

When working with the VM state (for loadvm/savevm and migration), it is not
valid to load and store pointers since the validity of those pointers cannot be
assured in the new qemu address space.  Therefore, virtio_balloon_save() and
virtio_balloon_load() must not handle the stats-related fields in struct
VirtIOBalloon.

If a memory stats request is in-flight at the time of a migration or savevm,
the request will not complete and should be resubmitted once migration or
loadvm completes.  Note that this extremely small race window can only be
triggered using QMP so it is not possible to hang the user monitor.

Signed-off-by: Adam Litke <agl@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock: add logical_block_size property
Christoph Hellwig [Thu, 4 Mar 2010 13:20:17 +0000 (14:20 +0100)]
block: add logical_block_size property

Add a logical block size attribute as various guest side tools only
increase the filesystem sector size based on it, not the advisory
physical block size.

For scsi we already have support for a different logical block size
in place for CDROMs that we can built upon.  Only my recent block
device characteristics VPD page needs some fixups.  Note that we
leave the logial block size for CDROMs hardcoded as the 2k value
is expected for it in general.

For virtio-blk we already have a feature flag claiming to support
a variable logical block size that was added for the s390 kuli
hypervisor.  Interestingly it does not actually change the units
in which the protocol works, which is still fixed at 512 bytes,
but only communicates a different minimum I/O granularity.  So
all we need to do in virtio is to add a trap for unaligned I/O
and round down the device size to the next multiple of the logical
block size.

IDE does not support any other logical block size than 512 bytes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAvoid crash on '-usbdevice <device>' without parameters
Jan Kiszka [Sun, 7 Mar 2010 11:17:08 +0000 (12:17 +0100)]
Avoid crash on '-usbdevice <device>' without parameters

Many usbdevice_init implementors assume params is non-NULL.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoFix SIGFPE for vnc display of width/height = 1
Chris Webb [Mon, 8 Mar 2010 14:34:49 +0000 (14:34 +0000)]
Fix SIGFPE for vnc display of width/height = 1

During boot, the screen gets resized to height 1 and a mouse click at this
point will cause a division by zero when calculating the absolute pointer
position from the pixel (x, y). Return a click in the middle of the screen
instead in this case.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agousb-linux: remove unreachable default in switch statement
Paul Bolle [Mon, 8 Mar 2010 12:58:35 +0000 (13:58 +0100)]
usb-linux: remove unreachable default in switch statement

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosdl: improve error message on fatal error
Bjørn Mork [Mon, 8 Mar 2010 12:07:14 +0000 (13:07 +0100)]
sdl: improve error message on fatal error

The SDL_SetVideoMode() error condition is easily triggered by a user by
simply configure a guest with a host unsupported display resolution
and attempting to enable fullscreen.  Since the error is fatal, adding
a bit of debugging help can't harm.

Sample output with this change:

 (qemu) Could not open SDL display (1280x1024x32): No video mode large enough for 1280x1024

The width x height might seem redundant as SDL also provides it in
SDL_GetError(), but I believe there are situations where it is
useful.  I.e. if there is some other SDL error.  Anyway, redundant
information in fatal error messages has never harmed a single gerbil.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoWrong error message in block_passwd command
Shahar Havivi [Fri, 5 Mar 2010 22:26:13 +0000 (00:26 +0200)]
Wrong error message in block_passwd command

Signed-off-by: Shahar Havivi <shaharh@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQError: New QERR_DEVICE_NOT_ENCRYPTED
Shahar Havivi [Fri, 5 Mar 2010 22:25:35 +0000 (00:25 +0200)]
QError: New QERR_DEVICE_NOT_ENCRYPTED

Signed-off-by: Shahar Havivi <shaharh@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoMerge remote branch 'markus/qerror' into staging
Anthony Liguori [Wed, 17 Mar 2010 14:44:37 +0000 (09:44 -0500)]
Merge remote branch 'markus/qerror' into staging

14 years agoMerge remote branch 'mst/pci' into staging
Anthony Liguori [Wed, 17 Mar 2010 14:42:58 +0000 (09:42 -0500)]
Merge remote branch 'mst/pci' into staging

14 years agoLarge page TLB flush
Paul Brook [Wed, 17 Mar 2010 02:14:28 +0000 (02:14 +0000)]
Large page TLB flush

QEMU uses a fixed page size for the CPU TLB.  If the guest uses large
pages then we effectively split these into multiple smaller pages, and
populate the corresponding TLB entries on demand.

When the guest invalidates the TLB by virtual address we must invalidate
all entries covered by the large page.  However the address used to
invalidate the entry may not be present in the QEMU TLB, so we do not
know which regions to clear.

Implementing a full vaiable size TLB is hard and slow, so just keep a
simple address/mask pair to record which addresses may have been mapped by
large pages.  If the guest invalidates this region then flush the
whole TLB.

Signed-off-by: Paul Brook <paul@codesourcery.com>
14 years agomonitor: convert do_device_add() to QObject
Markus Armbruster [Wed, 10 Feb 2010 19:52:01 +0000 (20:52 +0100)]
monitor: convert do_device_add() to QObject

14 years agomonitor: Use argument type 'O' for device_add
Markus Armbruster [Wed, 10 Feb 2010 19:47:28 +0000 (20:47 +0100)]
monitor: Use argument type 'O' for device_add

While there, improve the params help text.

14 years agomonitor: New argument type 'O'
Markus Armbruster [Wed, 10 Feb 2010 19:24:35 +0000 (20:24 +0100)]
monitor: New argument type 'O'

In the human monitor, it declares a single optional argument to be
parsed according to the QemuOptsList given by its name.

In QMP, it declares an optional argument for each member of the
QemuOptsList.

Restriction: only lists with empty desc are supported for now.  Good
enough for the job at hand.  We'll lift the restriction when we need
that.

14 years agoqemu-option: Rename find_list() to qemu_find_opts() & external linkage
Markus Armbruster [Wed, 10 Feb 2010 19:09:14 +0000 (20:09 +0100)]
qemu-option: Rename find_list() to qemu_find_opts() & external linkage

Next commit wants to use it.

14 years agoqemu-option: Move the implied first name into QemuOptsList
Markus Armbruster [Wed, 10 Feb 2010 18:52:18 +0000 (19:52 +0100)]
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.

14 years agoqemu-option: Functions to convert to/from QDict
Markus Armbruster [Wed, 10 Feb 2010 19:15:29 +0000 (20:15 +0100)]
qemu-option: Functions to convert to/from QDict

The functions are somewhat restricted.  Good enough for the job at
hand.  We'll extend them when we need more.

14 years agoerror: Convert do_device_add() to QError
Markus Armbruster [Fri, 19 Feb 2010 13:17:34 +0000 (14:17 +0100)]
error: Convert do_device_add() to QError

Conversion to QObject is still missing.

14 years agoRevert "qdev: Use QError for 'device not found' error"
Markus Armbruster [Fri, 19 Feb 2010 09:03:13 +0000 (10:03 +0100)]
Revert "qdev: Use QError for 'device not found' error"

This reverts commit 3ced9f7a36189aed94d8bf86f3f5087a53012455.

The next commit will convert all of qdev_device_add() to QError, and
it'll be clearer with this partial conversion reverted.

14 years agoerror: New QERR_NO_BUS_FOR_DEVICE
Markus Armbruster [Fri, 19 Feb 2010 18:54:06 +0000 (19:54 +0100)]
error: New QERR_NO_BUS_FOR_DEVICE

14 years agoerror: New QERR_DEVICE_INIT_FAILED
Markus Armbruster [Fri, 19 Feb 2010 18:53:54 +0000 (19:53 +0100)]
error: New QERR_DEVICE_INIT_FAILED

14 years agoerror: New QERR_BUS_NO_HOTPLUG
Markus Armbruster [Fri, 19 Feb 2010 18:53:36 +0000 (19:53 +0100)]
error: New QERR_BUS_NO_HOTPLUG

14 years agoerror: New QERR_BAD_BUS_FOR_DEVICE
Markus Armbruster [Fri, 19 Feb 2010 18:52:45 +0000 (19:52 +0100)]
error: New QERR_BAD_BUS_FOR_DEVICE

14 years agoerror: New error_printf_unless_qmp()
Markus Armbruster [Fri, 19 Feb 2010 09:30:05 +0000 (10:30 +0100)]
error: New error_printf_unless_qmp()

14 years agoqdev: Convert qbus_find() to QError
Markus Armbruster [Fri, 19 Feb 2010 17:09:33 +0000 (18:09 +0100)]
qdev: Convert qbus_find() to QError

14 years agoerror: New QERR_DEVICE_NO_BUS
Markus Armbruster [Fri, 19 Feb 2010 17:06:18 +0000 (18:06 +0100)]
error: New QERR_DEVICE_NO_BUS

14 years agoerror: New QERR_DEVICE_MULTIPLE_BUSSES
Markus Armbruster [Fri, 19 Feb 2010 17:05:59 +0000 (18:05 +0100)]
error: New QERR_DEVICE_MULTIPLE_BUSSES

14 years agoerror: New QERR_BUS_NOT_FOUND
Markus Armbruster [Fri, 19 Feb 2010 17:05:39 +0000 (18:05 +0100)]
error: New QERR_BUS_NOT_FOUND

14 years agoqdev: Relax parsing of bus option
Markus Armbruster [Fri, 19 Feb 2010 15:09:25 +0000 (16:09 +0100)]
qdev: Relax parsing of bus option

Treat multiple successive slashes as a one slash.  Ignore trailing
slashes.  This is how POSIX pathnames work.

14 years agoqdev: convert setting device properties to QError
Markus Armbruster [Fri, 19 Feb 2010 12:20:23 +0000 (13:20 +0100)]
qdev: convert setting device properties to QError

14 years agoerror: New QERR_PROPERTY_VALUE_NOT_FOUND
Markus Armbruster [Tue, 16 Mar 2010 16:44:38 +0000 (17:44 +0100)]
error: New QERR_PROPERTY_VALUE_NOT_FOUND

14 years agoerror: New QERR_PROPERTY_VALUE_IN_USE
Markus Armbruster [Tue, 16 Mar 2010 16:40:48 +0000 (17:40 +0100)]
error: New QERR_PROPERTY_VALUE_IN_USE

14 years agoerror: New QERR_PROPERTY_VALUE_BAD
Markus Armbruster [Fri, 19 Feb 2010 12:17:58 +0000 (13:17 +0100)]
error: New QERR_PROPERTY_VALUE_BAD

14 years agoerror: New QERR_PROPERTY_NOT_FOUND
Markus Armbruster [Fri, 19 Feb 2010 12:11:41 +0000 (13:11 +0100)]
error: New QERR_PROPERTY_NOT_FOUND

14 years agoerror: Polish human-readable error descriptions
Markus Armbruster [Fri, 19 Feb 2010 16:42:46 +0000 (17:42 +0100)]
error: Polish human-readable error descriptions

Also put error definitions in alphabetical order

14 years agoerror: Let converted handlers print in human monitor
Markus Armbruster [Tue, 2 Mar 2010 13:56:34 +0000 (14:56 +0100)]
error: Let converted handlers print in human monitor

While fully converted handlers are not supposed to print anything when
running in a QMP monitor, they are free to print in a human monitor.
For instance, device_add (not yet converted) prints help, and will
continue to do so after conversion.

Moreover, utility functions converted to QError should remain usable
from unconverted handlers.

Two problems:

* handler_audit() complains when a converted handler prints.  Limit
  that to QMP monitors.

* With QMP, handlers need to pass the error object by way of
  monitor_set_error().  However, we do that both for QMP and for the
  human monitor.  The human monitor prints the error object after the
  handler returns.  If the handler prints anything else, that output
  "overtakes" the error message.

  Limit use of monitor_set_error() to QMP monitors.  Update
  handler_audit() accordingly.

14 years agomonitor: New monitor_cur_is_qmp()
Markus Armbruster [Thu, 11 Feb 2010 16:05:43 +0000 (17:05 +0100)]
monitor: New monitor_cur_is_qmp()

14 years agoqdev: Hide "ptr" properties from users
Markus Armbruster [Fri, 19 Feb 2010 10:47:06 +0000 (11:47 +0100)]
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.

14 years agoqdev: Hide "no_user" devices from users
Markus Armbruster [Fri, 19 Feb 2010 12:31:49 +0000 (13:31 +0100)]
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.

14 years agoqdev: Factor qdev_create_from_info() out of qdev_create()
Markus Armbruster [Fri, 19 Feb 2010 18:12:18 +0000 (19:12 +0100)]
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().

14 years agoqdev: Fix -device and device_add to handle unsuitable bus gracefully
Markus Armbruster [Fri, 19 Feb 2010 18:08:45 +0000 (19:08 +0100)]
qdev: Fix -device and device_add to handle unsuitable bus gracefully

"device_add isa-serial,bus=pci.0" kills QEMU.  Not good.

14 years agoerror: Track locations on command line
Markus Armbruster [Thu, 18 Feb 2010 19:13:51 +0000 (20:13 +0100)]
error: Track locations on command line

New LOC_CMDLINE.  Use it for tracking option with argument in
lookup_opt().  We now report errors like this

    qemu: -device smbus-eeprom: Did not find I2C bus for smbus-eeprom

14 years agoQemuOpts: Fix qemu_config_parse() to catch file read errors
Markus Armbruster [Thu, 18 Feb 2010 18:56:01 +0000 (19:56 +0100)]
QemuOpts: Fix qemu_config_parse() to catch file read errors

14 years agoerror: Track locations in configuration files
Markus Armbruster [Thu, 18 Feb 2010 18:48:33 +0000 (19:48 +0100)]
error: Track locations in configuration files

New LOC_FILE.  Use it for tracking file name and line number in
qemu_config_parse().  We now report errors like

    qemu:foo.conf:42: Did not find I2C bus for smbus-eeprom

In particular, gems like this message:

    -device: no driver specified

become almost nice now:

    qemu:foo.conf:44: -device: no driver specified

(A later commit will get rid of the bogus -device:)

14 years agoerror: Include the program name in error messages to stderr
Markus Armbruster [Wed, 24 Feb 2010 13:37:14 +0000 (14:37 +0100)]
error: Include the program name in error messages to stderr

14 years agoerror: Infrastructure to track locations for error reporting
Markus Armbruster [Thu, 18 Feb 2010 18:46:49 +0000 (19:46 +0100)]
error: Infrastructure to track locations for error reporting

New struct Location holds a location.  So far, the only location is
LOC_NONE, so this doesn't do anything useful yet.

Passing the current location all over the place would be too
cumbersome.  Hide it away in static cur_loc instead, and provide
accessors.  Print it in error_report().

Store it in QError, and print it in qerror_print().

Store it in QemuOpt, for use by qemu_opts_foreach().  This makes
error_report() do the right thing when it runs within
qemu_opts_foreach().

We may still have to store it in other data structures holding user
input for better error messages.  Left for another day.

14 years agoerror: Rename qemu_error_new() to qerror_report()
Markus Armbruster [Tue, 2 Mar 2010 17:15:09 +0000 (18:15 +0100)]
error: Rename qemu_error_new() to qerror_report()

14 years agoerror: Replace qemu_error() by error_report()
Markus Armbruster [Thu, 18 Feb 2010 16:25:24 +0000 (17:25 +0100)]
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.

14 years agoerror: Don't abuse qemu_error() for non-error in scsi_hot_add()
Markus Armbruster [Thu, 18 Feb 2010 17:41:52 +0000 (18:41 +0100)]
error: Don't abuse qemu_error() for non-error in scsi_hot_add()

Commit 30d335d6 converted an informational message from
monitor_printf() to qemu_error(), probably because the latter doesn't
need a mon argument.  A later commit will make qemu_error() print
additional stuff that is only appropriate for proper errors, and then
this will break.  Clean it up.

14 years agoerror: Don't abuse qemu_error() for non-error in qbus_find()
Markus Armbruster [Thu, 18 Feb 2010 17:55:59 +0000 (18:55 +0100)]
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.

14 years agoerror: Don't abuse qemu_error() for non-error in qdev_device_help()
Markus Armbruster [Thu, 18 Feb 2010 17:44:15 +0000 (18:44 +0100)]
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.

14 years agoerror: New error_printf() and error_vprintf()
Markus Armbruster [Thu, 18 Feb 2010 16:14:17 +0000 (17:14 +0100)]
error: New error_printf() and error_vprintf()

14 years agoerror: Move qemu_error & friends into their own header
Markus Armbruster [Thu, 18 Feb 2010 15:24:31 +0000 (16:24 +0100)]
error: Move qemu_error & friends into their own header

14 years agoerror: Simplify error sink setup
Markus Armbruster [Thu, 18 Feb 2010 12:16:02 +0000 (13:16 +0100)]
error: Simplify error sink setup

qemu_error_sink can either point to a monitor or a file.  In practice,
it always points to the current monitor if we have one, else to
stderr.  Simply route errors to the current monitor or else to stderr,
and remove qemu_error_sink along with the functions to control it.

Actually, the old code switches the sink slightly later, in
handle_user_command() and handle_qmp_command(), than it gets switched
now, implicitly, by setting the current monitor in monitor_read() and
monitor_control_read().  Likewise, it switches back slightly earlier
(same places).  Doesn't make a difference, because there are no calls
of qemu_error() in between.

14 years agoerror: Move qemu_error() & friends from monitor.c to own file
Markus Armbruster [Wed, 17 Feb 2010 09:55:46 +0000 (10:55 +0100)]
error: Move qemu_error() & friends from monitor.c to own file

They're about reporting errors, not about the monitor.

14 years agomonitor: Factor monitor_set_error() out of qemu_error_internal()
Markus Armbruster [Wed, 17 Feb 2010 09:52:26 +0000 (10:52 +0100)]
monitor: Factor monitor_set_error() out of qemu_error_internal()

This separates the monitor part from the QError part.