sdk/emulator/qemu.git
12 years agoqemu-ga: align versioning with QEMU_VERSION
Michael Roth [Mon, 14 May 2012 14:33:48 +0000 (09:33 -0500)]
qemu-ga: align versioning with QEMU_VERSION

Previously qemu-ga version was defined seperately. Since it is aligned
with QEMU releases, use QEMU_VERSION instead. This also implies the
version bump for 1.1[-rcN] release of qemu-ga.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: fix segv after failure to open log file
Michael Roth [Mon, 14 May 2012 21:42:35 +0000 (16:42 -0500)]
qemu-ga: fix segv after failure to open log file

Currently, if we fail to open the specified log file (generally due to a
permissions issue), we'll assign NULL to the logfile handle (stderr,
initially) used by the logging routines, which can cause a segfault to
occur when we attempt to report the error before exiting.

Instead, only re-assign if the open() was successful.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: guest-shutdown: use only async-signal-safe functions
Luiz Capitulino [Mon, 14 May 2012 18:25:20 +0000 (15:25 -0300)]
qemu-ga: guest-shutdown: use only async-signal-safe functions

POSIX mandates[1] that a child process of a multi-thread program uses
only async-signal-safe functions before exec(). We consider qemu-ga
to be multi-thread, because it uses glib.

However, qmp_guest_shutdown() uses functions that are not
async-signal-safe. Fix it the following way:

- fclose() -> reopen_fd_to_null()
- execl() -> execle()
- exit() -> _exit()
- drop slog() usage (which is not safe)

  [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/fork.html

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: guest-shutdown: become synchronous
Luiz Capitulino [Fri, 11 May 2012 19:19:47 +0000 (16:19 -0300)]
qemu-ga: guest-shutdown: become synchronous

Last commit dropped qemu-ga's SIGCHLD handler, used to automatically
reap terminated children processes. This introduced a bug to
qmp_guest_shutdown(): it will generate zombies.

This problem probably doesn't matter in the success case, as the VM
will shutdown anyway, but let's do the right thing and reap the
created process. This ultimately means that guest-shutdown is now a
synchronous command.

An interesting side effect is that guest-shutdown is now able to
report an error to the client if shutting down fails.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: guest-suspend: make the API synchronous
Luiz Capitulino [Fri, 11 May 2012 19:19:46 +0000 (16:19 -0300)]
qemu-ga: guest-suspend: make the API synchronous

Currently, qemu-ga has a SIGCHLD handler that automatically reaps terminated
children processes. The idea is to avoid having qemu-ga commands blocked
waiting for children to terminate.

That approach has two problems:

 1. qemu-ga is unable to detect errors in the child, meaning that qemu-ga
    returns success even if the child fails to perform its task

 2. if a command does depend on the child exit status, the command has to
    play tricks to bypass the automatic reaper

Case 2 impacts the guest-suspend-* API, because it has to execute an external
program to check for suspend support. Today, to bypass the automatic reaper,
suspend code has to double fork and pass exit status information through a
pipe. Besides being complex, this is prone to race condition bugs. Indeed,
the current code does have such bugs.

Making the guest-suspend-* API synchronous (ie. by dropping the SIGCHLD
handler and calling waitpid() from commands) is a much simpler approach,
which fixes current race conditions bugs and enables commands to detect
errors in the child.

This commit does just that. There's a side effect though, guest-shutdown
will generate zombies if shutting down fails. This will be fixed by the
next commit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: become_daemon(): reopen standard fds to /dev/null
Luiz Capitulino [Thu, 10 May 2012 19:50:42 +0000 (16:50 -0300)]
qemu-ga: become_daemon(): reopen standard fds to /dev/null

This fixes a bug where qemu-ga doesn't suspend the guest because it
fails to detect suspend support even when the guest does support
suspend. This happens because of the way qemu-ga fds are managed in
daemon mode.

When starting qemu-ga with --daemon, become_daemon() will close all
standard fds. This will cause qemu-ga to end up with the following
fds (if started with 'qemu-ga --daemon'):

    0 -> /dev/vport0p1
    3 -> /run/qemu-ga.pid

Then a guest-suspend-* function is issued. They call bios_supports_mode(),
which will call pipe(), and qemu-ga's fd will be:

    0 -> /dev/vport0p1
    1 -> pipe:[16247]
    2 -> pipe:[16247]
    3 -> /run/qemu-ga.pid

bios_supports_mode() forks off a child and blocks waiting for the child
to write something to the pipe. The child, however, closes its reading
end of the pipe _and_ reopen all standard fds to /dev/null. This will
cause the child's fds to be:

    0 -> /dev/null
    1 -> /dev/null
    2 -> /dev/null
    3 -> /run/qemu-ga.pid

In other words, the child's writing end of the pipe is now /dev/null.
It writes there and exits. The parent process (blocked on read()) will
get an EOF and interpret this as "something unexpected happened in
the child, let's assume the guest doesn't support suspend". And suspend
will fail.

To solve this problem we have to reopen standard fds to /dev/null
in become_daemon(), instead of closing them.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: make reopen_fd_to_null() public
Luiz Capitulino [Thu, 10 May 2012 19:50:41 +0000 (16:50 -0300)]
qemu-ga: make reopen_fd_to_null() public

The next commit wants to use it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: guest-suspend-hybrid: don't emit a success response
Luiz Capitulino [Tue, 8 May 2012 17:24:49 +0000 (14:24 -0300)]
qemu-ga: guest-suspend-hybrid: don't emit a success response

Today, qemu-ga may not be able to emit a success response when
guest-suspend-hybrid completes. This happens because the VM may
suspend before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if
they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-suspend-hybrid to
never emit a success response and suggests in the documentation
what clients should do to check for success.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: guest-suspend-ram: don't emit a success response
Luiz Capitulino [Tue, 8 May 2012 17:24:48 +0000 (14:24 -0300)]
qemu-ga: guest-suspend-ram: don't emit a success response

Today, qemu-ga may not be able to emit a success response when
guest-suspend-ram completes. This happens because the VM may
suspend before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if
they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-suspend-ram to
never emit a success response and suggests in the documentation
what clients should do to check for success.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: guest-suspend-disk: don't emit a success response
Luiz Capitulino [Tue, 8 May 2012 17:24:47 +0000 (14:24 -0300)]
qemu-ga: guest-suspend-disk: don't emit a success response

Today, qemu-ga may not be able to emit a success response when
guest-suspend-disk completes. This happens because the VM may
vanish before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if
they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-suspend-disk to
never emit a success response and suggests in the documentation
what clients could do to check for success.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: guest-shutdown: don't emit a success response
Luiz Capitulino [Tue, 8 May 2012 17:24:46 +0000 (14:24 -0300)]
qemu-ga: guest-shutdown: don't emit a success response

Today, qemu-ga may not be able to emit a success response when
guest-shutdown completes. This happens because the VM may vanish
before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if
they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-shutdown to never
emit a success response and suggests in the documentation what
clients could do to check for success.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: don't warn on no command return
Luiz Capitulino [Tue, 8 May 2012 17:24:45 +0000 (14:24 -0300)]
qemu-ga: don't warn on no command return

This is a valid condition when a command chooses to not emit a
success response.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqapi: add support for command options
Luiz Capitulino [Tue, 8 May 2012 17:24:44 +0000 (14:24 -0300)]
qapi: add support for command options

Options allow for changes in commands behavior. This commit introduces
the QCO_NO_SUCCESS_RESP option, which causes a command to not emit a
success response.

This is needed by commands such as qemu-ga's guest-shutdown, which
may not be able to complete before the VM vanishes. In this case, it's
useful and simpler not to bother sending a success response.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoUpdate version to 1.1.0-rc2
Anthony Liguori [Mon, 14 May 2012 22:56:50 +0000 (17:56 -0500)]
Update version to 1.1.0-rc2

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotcg/ppc64: Fix CONFIG_TCG_PASS_AREG0
Andreas Färber [Sat, 12 May 2012 01:16:58 +0000 (03:16 +0200)]
tcg/ppc64: Fix CONFIG_TCG_PASS_AREG0

In qemu_ld/st load the registers for the helper calls directly rather
than rotating them around afterwards for AREG0.

Also clobber the additional register.

Signed-off-by: Andreas F?rber <afaerber@suse.de>
Signed-off-by: malc <av1474@comtv.ru>
12 years agotcg/ppc64: Don't hardcode register numbers for qemu_ld/st
Andreas Färber [Sat, 12 May 2012 01:16:57 +0000 (03:16 +0200)]
tcg/ppc64: Don't hardcode register numbers for qemu_ld/st

Facilitates using r3 for prepended AREG0.

Signed-off-by: Andreas F?rber <afaerber@suse.de>
Signed-off-by: malc <av1474@comtv.ru>
12 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 14 May 2012 17:45:01 +0000 (12:45 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

* kwolf/for-anthony:
  qemu-img: Fix segmentation fault
  qcow2: Don't ignore failure to clear autoclear flags
  coroutine: Fix setup of sigaltstack coroutines

12 years agoMerge remote-tracking branch 'qmp/queue/qmp' into staging
Anthony Liguori [Mon, 14 May 2012 15:18:06 +0000 (10:18 -0500)]
Merge remote-tracking branch 'qmp/queue/qmp' into staging

* qmp/queue/qmp:
  qapi: QMP input visitor, handle floats parsed as ints

12 years agoMerge remote-tracking branch 'afaerber-or/qom-1.1' into staging
Anthony Liguori [Mon, 14 May 2012 15:15:52 +0000 (10:15 -0500)]
Merge remote-tracking branch 'afaerber-or/qom-1.1' into staging

* afaerber-or/qom-1.1:
  mips_fulong2e: Don't register "cpu" VMState twice
  pc: Add back PCI.rombar compat property
  qdev: Fix adding of ptr properties
  qdev: Use object_property_print() in info qtree
  target-i386: Defer MCE init
  qom: Documentation addition for object_class_by_name()
  target-mips: Remove commented-out function declaration

12 years agoMerge remote-tracking branch 'kraxel/usb.50' into staging
Anthony Liguori [Mon, 14 May 2012 15:07:23 +0000 (10:07 -0500)]
Merge remote-tracking branch 'kraxel/usb.50' into staging

* kraxel/usb.50:
  usb-host: handle guest-issued clear halt

12 years agoMerge remote-tracking branch 'spice/spice.v55' into staging
Anthony Liguori [Mon, 14 May 2012 15:07:06 +0000 (10:07 -0500)]
Merge remote-tracking branch 'spice/spice.v55' into staging

* spice/spice.v55:
  qxl: set size of PCI IO BAR correctly (16) for revision 2

12 years agoMerge remote-tracking branch 'sweil/for-1.1' into staging
Anthony Liguori [Mon, 14 May 2012 15:06:50 +0000 (10:06 -0500)]
Merge remote-tracking branch 'sweil/for-1.1' into staging

* sweil/for-1.1:
  qemu-doc: Use QEMU instead of qemu for product name
  qemu-doc: Fix executable name in examples
  qemu-doc: Add missing parameter in description of -D option
  configure: Use QEMU instead of Qemu
  fix some common typos
  qemu-timer: Fix wrong error message

12 years agoqdev: fix -device foo,?
Paolo Bonzini [Wed, 2 May 2012 11:30:59 +0000 (13:30 +0200)]
qdev: fix -device foo,?

Since most property types do not have a parse property now, this was
broken.  Fix it by looking at the setter instead.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Acked-by: Andreas F=E4rber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqemu-img: Fix segmentation fault
Charles Arnold [Fri, 11 May 2012 16:57:54 +0000 (10:57 -0600)]
qemu-img: Fix segmentation fault

The following command generates a segmentation fault.
qemu-img convert -O vpc -o ? test test2
This is because the 'goto out;' statement calls qemu_progress_end
before qemu_progress_init is called resulting in a NULL pointer
invocation.

Signed-off-by: Charles Arnold <carnold@suse.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow2: Don't ignore failure to clear autoclear flags
Kevin Wolf [Fri, 11 May 2012 13:33:03 +0000 (15:33 +0200)]
qcow2: Don't ignore failure to clear autoclear flags

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agocoroutine: Fix setup of sigaltstack coroutines
Jan Kiszka [Wed, 9 May 2012 17:23:27 +0000 (14:23 -0300)]
coroutine: Fix setup of sigaltstack coroutines

Use pthread_kill instead of process-wide kill to invoke the signal
handler used for stack switching. This may fix spurious lock-ups with
this backend, easily triggerable by extending the time window between
kill and sigsuspend.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoMerge remote-tracking branch 'origin/master' into staging
Anthony Liguori [Mon, 14 May 2012 13:44:32 +0000 (08:44 -0500)]
Merge remote-tracking branch 'origin/master' into staging

* origin/master:
  sun4u: implement interrupt clearing registers
  sun4u: initialize OBIO interrupt mappings
  fix block loads broken in commit 30038fd818
  Implement address masking for SPARC v9 CPUs
  vga: disable default VGA if appropriate -device is used
  cputlb: fix watchpoints handling

12 years agoqapi: QMP input visitor, handle floats parsed as ints
Michael Roth [Fri, 11 May 2012 17:43:24 +0000 (12:43 -0500)]
qapi: QMP input visitor, handle floats parsed as ints

JSON numbers can be interpreted as either integers or floating point
values depending on their representation. As a result, QMP input visitor
might visit a QInt when it was expecting a QFloat, so add handling to
account for this.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Acked-by: Andreas Färber <afaerber@suse.de>
12 years agousb-host: handle guest-issued clear halt
Gerd Hoffmann [Tue, 8 May 2012 11:54:45 +0000 (13:54 +0200)]
usb-host: handle guest-issued clear halt

Most important here is to update our internal endpoint state so we know
the endpoint isn't in halted state any more.  Without this usb-host
tries to clear halt again with the next data transfer submitted.  Doing
this twice is (a) not correct and (b) confuses some usb devices,
rendering them non-functional in the guest.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoqxl: set size of PCI IO BAR correctly (16) for revision 2
Uri Lublin [Thu, 10 May 2012 13:24:53 +0000 (16:24 +0300)]
qxl: set size of PCI IO BAR correctly (16) for revision 2

Also move it up into switch(qxl->revision) block

Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoqemu-doc: Use QEMU instead of qemu for product name
Stefan Weil [Fri, 11 May 2012 20:25:50 +0000 (22:25 +0200)]
qemu-doc: Use QEMU instead of qemu for product name

When 'qemu' was used as a product name or as a generic process name,
it is now replaced by the official upper case 'QEMU'.

v2:
Added missing period (hint from Andreas Färber).

Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agoqemu-doc: Fix executable name in examples
Stefan Weil [Fri, 11 May 2012 20:21:50 +0000 (22:21 +0200)]
qemu-doc: Fix executable name in examples

The executable name qemu was replaced some time ago by qemu-system-i386.
Fix all examples accordingly.

Some examples will only work with qemu-system-i386 or qemu-system-x86_64
for obvious reasons ("dos.img").

To keep things simple, I did not vary the executable name.
Place holders like qemu-system-TARGET were also only used once
in the enhanced description for QEMU launches using Wine.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agoqemu-doc: Add missing parameter in description of -D option
Stefan Weil [Fri, 11 May 2012 20:40:50 +0000 (22:40 +0200)]
qemu-doc: Add missing parameter in description of -D option

'logfile' is a place holder for a non optional parameter.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agoconfigure: Use QEMU instead of Qemu
Stefan Weil [Fri, 11 May 2012 19:14:47 +0000 (21:14 +0200)]
configure: Use QEMU instead of Qemu

This new 'Qemu' was recently added.
Replace it by the official all upper case 'QEMU'.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agofix some common typos
Jim Meyering [Wed, 9 May 2012 05:12:04 +0000 (05:12 +0000)]
fix some common typos

These were identified using: http://github.com/lyda/misspell-check
and run like this to create a bourne shell script using GNU sed's
-i option:

git ls-files|grep -vF .bin | misspellings -f - |grep -v '^ERROR:' |perl \
-pe 's/^(.*?)\[(\d+)\]: (\w+) -> "(.*?)"$/sed -i '\''${2}s!$3!$4!'\'' $1/'

Manually eliding the FP, "rela->real" and resolving "addres" to
address (not "adders") we get this:

  sed -i '450s!thru!through!' Changelog
  sed -i '260s!neccessary!necessary!' coroutine-sigaltstack.c
  sed -i '54s!miniscule!minuscule!' disas.c
  sed -i '1094s!thru!through!' hw/usb/hcd-ehci.c
  sed -i '1095s!thru!through!' hw/usb/hcd-ehci.c
  sed -i '21s!unecessary!unnecessary!' qapi-schema-guest.json
  sed -i '307s!explictly!explicitly!' qemu-ga.c
  sed -i '490s!preceeding!preceding!' qga/commands-posix.c
  sed -i '792s!addres!address!' qga/commands-posix.c
  sed -i '6s!beeing!being!' tests/tcg/test-mmap.c

Also, manually fix "arithmentic", spotted by Peter Maydell:

  sed -i 's!arithmentic!arithmetic!' coroutine-sigaltstack.c

Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12 years agoqemu-timer: Fix wrong error message
Stefan Weil [Tue, 8 May 2012 17:14:43 +0000 (19:14 +0200)]
qemu-timer: Fix wrong error message

Function timeSetEvent returns 0 when it fails, but it does not set
an error code which can be retrieved by GetLastError.

Therefore calling GetLastError is useless.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agomips_fulong2e: Don't register "cpu" VMState twice
Juan Quintela [Sun, 13 May 2012 17:32:54 +0000 (19:32 +0200)]
mips_fulong2e: Don't register "cpu" VMState twice

We have the following simplified callgraph in mips_fulong2e_init():

  cpu_init() => cpu_mips_init()
    object_new()
      mips_cpu_initfn()
        cpu_exec_init()
          register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
                          cpu_save, cpu_load, env)
  register_savevm(NULL, "cpu", 0, 3, cpu_save, cpu_load, env)

CPU_SAVE_VERSION is defined as 3 in target-mips/cpu.h.
fulong2e instantiates one CPU, so its cpu_index is 0.
Thus the two are fully identical.

Therefore just remove the second call in fulong2e.

Signed-off-by: Juan Quintela <quintela@redhat.com>
[AF: Extend explanation in commit message]
Signed-off-by: Andreas Färber <afaerber@suse.de>
12 years agopc: Add back PCI.rombar compat property
Paolo Bonzini [Wed, 2 May 2012 11:31:04 +0000 (13:31 +0200)]
pc: Add back PCI.rombar compat property

This was erroneously dropped in d6c730086cbf24382eb8cff25551798769edfd84
(pc: reduce duplication in compat machine types).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
12 years agoqdev: Fix adding of ptr properties
Anthony Liguori [Wed, 2 May 2012 11:31:07 +0000 (13:31 +0200)]
qdev: Fix adding of ptr properties

ptr properties have neither a get/set or a print/parse which means that when
they're added they aren't treated as static or legacy properties.

Just assume properties like this are legacy properties and treat them as such.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
12 years agoqdev: Use object_property_print() in info qtree
Paolo Bonzini [Wed, 2 May 2012 11:31:00 +0000 (13:31 +0200)]
qdev: Use object_property_print() in info qtree

Otherwise, non-string properties without a legacy counterpart are missed.
Also fix error propagation in object_property_print() itself.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
12 years agotarget-i386: Defer MCE init
Andreas Färber [Wed, 9 May 2012 21:15:32 +0000 (23:15 +0200)]
target-i386: Defer MCE init

Commit de024815e3b523addf58f1f79846b7fe74643678 (target-i386: QOM'ify
CPU init) moved mce_init() call from helper.c:cpu_x86_init() into
X86CPU's cpu.c:x86_cpu_initfn().
mce_init() checks for a family >= 6 though, so we could end up with a
sequence such as for -cpu somecpu,family=6:

  x86_cpu_initfn => X86CPU::family == 5
    mce_init => no-op
  cpu_x86_register => X86CPU::family = 6
  => MCE unexpectedly not init'ed

or for -cpu someothercpu,family=5:

  x86_cpu_initfn => X86CPU::family == 6
    mce_init => init'ed
  cpu_x86_register => X86CPU::family = 5
  => MCE unexpectedly init'ed

Therefore partially revert the above commit. To avoid moving
mce_init() back into helper.c, foresightedly move it into a
new x86_cpu_realize() function and, in lack of ObjectClass::realize,
call it directly from cpu_x86_init().

While at it, move the qemu_init_vcpu() call that used to follow
mce_init() in cpu_x86_init() into the new realizefn as well.

Reported-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
12 years agoqom: Documentation addition for object_class_by_name()
Paolo Bonzini [Wed, 2 May 2012 11:30:53 +0000 (13:30 +0200)]
qom: Documentation addition for object_class_by_name()

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[AF: Document the possible NULL return value]
Signed-off-by: Andreas Färber <afaerber@suse.de>
12 years agotarget-mips: Remove commented-out function declaration
Andreas Färber [Sat, 5 May 2012 11:35:40 +0000 (13:35 +0200)]
target-mips: Remove commented-out function declaration

There is no function cpu_mips_get_clock(), so drop it.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Stefan Weil <sw@weilnetz.de>
12 years agosun4u: implement interrupt clearing registers
Artyom Tarasenko [Sat, 12 May 2012 09:15:23 +0000 (11:15 +0200)]
sun4u: implement interrupt clearing registers

Implement registers for clearing OBIO and PCI interrupts

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agosun4u: initialize OBIO interrupt mappings
Artyom Tarasenko [Sat, 12 May 2012 09:15:22 +0000 (11:15 +0200)]
sun4u: initialize OBIO interrupt mappings

Similarly to PCI interrupt mappings, the OBIO ones have to be initialized.

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agofix block loads broken in commit 30038fd818
Artyom Tarasenko [Sat, 12 May 2012 09:15:21 +0000 (11:15 +0200)]
fix block loads broken in commit 30038fd818

Fix UltraSPARC/JPS1/UA2007 VIS block load instructions broken in
30038fd81808f7c3bca92be2369e74c8ca7b3d69.

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
[blauwirbel@gmail.com: trimmed unwanted part of patch]
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoImplement address masking for SPARC v9 CPUs
Artyom Tarasenko [Sat, 12 May 2012 09:15:20 +0000 (11:15 +0200)]
Implement address masking for SPARC v9 CPUs

According to UltraSPARC - IIi User's manual:

14.1.11 Address Masking (Impdep #125)
When PSTATE.AM=1, the CALL, JMPL, and RDPC instructions and all traps
transmit zero in the high-order 32-bits of the PC to their specified
destination registers.

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agovga: disable default VGA if appropriate -device is used
Paolo Bonzini [Thu, 10 May 2012 07:39:17 +0000 (09:39 +0200)]
vga: disable default VGA if appropriate -device is used

This is a partial revert of commits a369da5 (vga: improve VGA logic,
committed 2012-01-22) and c5bd4f3 (vga: fix -nodefaults -device VGA,
2012-01-24) which broke command-line option parsing in different ways.

Since commit a369da5 it has become impossible to specify a VGA device
entirely with QemuOpts-enabled options, i.e. without needing an explicit
"-vga none".

In addition, until commit c5bd4f3 -nodefaults would not disable the device
you specified with the legacy "-vga" option, independent of the order.
Since commit c5bd4f3 QEMU -nodefaults will override a previous -vga
option.

I did not reintroduce machine->no_vga.  Boards can simply ignore the
vga_interface_type variable, and most will indeed do so.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agocputlb: fix watchpoints handling
Max Filippov [Sat, 5 May 2012 21:44:31 +0000 (01:44 +0400)]
cputlb: fix watchpoints handling

Cleanup commit e554861766d9ae84dd5720baa4869f4ed711506f have changed
code_address calculation in the tlb_set_page function in case of access
to a page with a watchpoint. This caused QEMU segfault in the xtensa
test_break unit test. Fix it by moving code_address assignment above
memory_region_section_get_iotlb call.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agouse inet_listen()/inet_connect() to support ipv6 migration
Amos Kong [Thu, 10 May 2012 16:28:35 +0000 (00:28 +0800)]
use inet_listen()/inet_connect() to support ipv6 migration

Use help functions in qemu-socket.c for tcp migration,
which already support ipv6 addresses.

Currently errp will be set to UNDEFINED_ERROR when migration fails,
qemu would output "migration failed: ...", and current user can
see a message("An undefined error has occurred") in monitor.

This patch changed tcp_start_outgoing_migration()/inet_connect()
/inet_connect_opts(), socket error would be passed back,
then current user can see a meaningful err message in monitor.

Qemu will exit if listening fails, so output socket error
to qemu stderr.

For IPv6 brackets must be mandatory if you require a port.
Referencing to RFC5952, the recommended format is:
  [2312::8274]:5200

test status: Successed
listen side: qemu-kvm .... -incoming tcp:[2312::8274]:5200
client side: qemu-kvm ...
             (qemu) migrate -d tcp:[2312::8274]:5200

Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agosockets: use error class to pass listen error
Amos Kong [Thu, 10 May 2012 16:28:26 +0000 (00:28 +0800)]
sockets: use error class to pass listen error

Add a new argument in inet_listen()/inet_listen_opts()
to pass back listen error.

Change nbd, qemu-char, vnc to use new interface.

Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agosockets: change inet_connect() to support nonblock socket
Amos Kong [Thu, 10 May 2012 16:28:16 +0000 (00:28 +0800)]
sockets: change inet_connect() to support nonblock socket

Add a bool argument to inet_connect() to assign if set socket
to block/nonblock, and delete original argument 'socktype'
that is unused.
Add a new argument to inet_connect()/inet_connect_opts(),
to pass back connect error by error class.

Retry to connect when -EINTR is got. Connect's successful
for nonblock socket when following errors are got, user
should wait for connecting by select():
  -EINPROGRESS
  -EWOULDBLOCK (win32)
  -WSAEALREADY (win32)

Change nbd, vnc to use new interface.

Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqerror: add five qerror strings
Amos Kong [Thu, 10 May 2012 16:28:08 +0000 (00:28 +0800)]
qerror: add five qerror strings

Add five new qerror strings, they are about listen/connect socket:
  QERR_SOCKET_CONNECT_IN_PROGRESS
  QERR_SOCKET_CONNECT_FAILED
  QERR_SOCKET_LISTEN_FAILED
  QERR_SOCKET_BIND_FAILED
  QERR_SOCKET_CREATE_FAILED

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomove CPU definitions to /usr/share/qemu/cpus-x86_64.conf (v2)
Eduardo Habkost [Wed, 2 May 2012 16:07:30 +0000 (13:07 -0300)]
move CPU definitions to /usr/share/qemu/cpus-x86_64.conf (v2)

Changes v1 -> v2:
 - userconfig variable is now bool, not int

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoimplement -no-user-config command-line option (v3)
Eduardo Habkost [Wed, 2 May 2012 16:07:29 +0000 (13:07 -0300)]
implement -no-user-config command-line option (v3)

Changes v2 -> v3:
 - Rebase against latest qemu.git

Changes v1 -> v2:
 - Change 'userconfig' field/variables to bool instead of int
 - Coding style change

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agovl.c: change 'defconfig' variable to bool (v2)
Eduardo Habkost [Wed, 2 May 2012 16:07:28 +0000 (13:07 -0300)]
vl.c: change 'defconfig' variable to bool (v2)

Changes v1 -> v2:
 - Actually change the variable type declaration to 'bool'

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomove list of default config files to an array
Eduardo Habkost [Wed, 2 May 2012 16:07:27 +0000 (13:07 -0300)]
move list of default config files to an array

More files will be added to the list, with additional attributes, later.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoeliminate arch_config_name variable
Eduardo Habkost [Wed, 2 May 2012 16:07:26 +0000 (13:07 -0300)]
eliminate arch_config_name variable

Not needed anymore, as the code that uses the variable is already inside
arch_init.c.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomove code to read default config files to a separate function (v2)
Eduardo Habkost [Wed, 2 May 2012 16:07:25 +0000 (13:07 -0300)]
move code to read default config files to a separate function (v2)

Function added to arch_init.c because it depends on arch-specific
settings.

Changes v1 -> v2:
 - Move qemu_read_default_config_file() prototype to qemu-config.h

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoblock: fix warning introduced in efcc7a23
Anthony Liguori [Thu, 10 May 2012 14:10:42 +0000 (09:10 -0500)]
block: fix warning introduced in efcc7a23

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoSwitch SIG_IPI to SIGUSR1
Jan Kiszka [Wed, 9 May 2012 22:14:25 +0000 (19:14 -0300)]
Switch SIG_IPI to SIGUSR1

Use SIGUSR1 unconditionally as SIG_IPI. First, ucontext coroutines tend
to corrupt RT signal masks due to a 32-on-64-bit Linux kernel bug. And,
second, there appears to be no advantage in using RT signals for VCPU
kicking.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'pmaydell/target-arm.for-upstream' into staging
Anthony Liguori [Thu, 10 May 2012 13:30:55 +0000 (08:30 -0500)]
Merge remote-tracking branch 'pmaydell/target-arm.for-upstream' into staging

* pmaydell/target-arm.for-upstream:
  target-arm/cpu.h: Make cpu_init("nonexistent cpu") return NULL
  target-arm: When setting FPSCR.QC, don't clear other FPSCR bits

12 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Thu, 10 May 2012 13:30:34 +0000 (08:30 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

* kwolf/for-anthony: (30 commits)
  declare ECANCELED on all machines
  tests/Makefile: Add missing $(EXESUF)
  stream: do not copy unallocated sectors from the base
  stream: fix ratelimiting corner case
  stream: fix HMP block_job_set_speed
  stream: pass new base image format to bdrv_change_backing_file
  stream: add testcase for partial streaming
  stream: fix sectors not allocated test
  qemu-io: fix the alloc command
  qemu-io: correctly print non-integer values as decimals
  qemu-img: make "info" backing file output correct and easier to use
  block: move field reset from bdrv_open_common to bdrv_close
  block: protect path_has_protocol from filenames with colons
  block: simplify path_is_absolute
  block: wait for job callback in block_job_cancel_sync
  block: add block_job_sleep_ns
  block: fully delete bs->file when closing
  block: do not reuse the backing file across bdrv_close/bdrv_open
  block: another bdrv_append fix
  block: fix snapshot on QED
  ...

12 years agoMerge remote-tracking branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Thu, 10 May 2012 13:08:31 +0000 (08:08 -0500)]
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging

* qemu-kvm/uq/master:
  kvm: Fix dirty tracking with large kernel page size

12 years agotarget-arm/cpu.h: Make cpu_init("nonexistent cpu") return NULL
Peter Maydell [Thu, 10 May 2012 12:56:09 +0000 (12:56 +0000)]
target-arm/cpu.h: Make cpu_init("nonexistent cpu") return NULL

The macro definition of cpu_init meant that if cpu_arm_init()
returned NULL this wouldn't result in cpu_init() itself returning
NULL. This had the effect that "-cpu foo" for some unknown CPU
name 'foo' would cause ARM targets to segfault rather than
generating a useful error message. Fix this by making cpu_init
a simple inline function.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Andreas Färber <afaerber@suse.de>
12 years agotarget-arm: When setting FPSCR.QC, don't clear other FPSCR bits
Matt Craighead [Thu, 10 May 2012 12:56:08 +0000 (12:56 +0000)]
target-arm: When setting FPSCR.QC, don't clear other FPSCR bits

This patch fixes a bug affecting a variety of Neon instructions, such as
VQADD.

Signed-off-by: Matt Craighead <mjcraighead@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agokvm: Fix dirty tracking with large kernel page size
David Gibson [Wed, 4 Apr 2012 01:15:54 +0000 (11:15 +1000)]
kvm: Fix dirty tracking with large kernel page size

If the kernel page size is larger than TARGET_PAGE_SIZE, which
happens for example on ppc64 with kernels compiled for 64K pages,
the dirty tracking doesn't work.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agodeclare ECANCELED on all machines
Paolo Bonzini [Thu, 10 May 2012 07:27:50 +0000 (09:27 +0200)]
declare ECANCELED on all machines

This is needed in particular on Win32.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agotests/Makefile: Add missing $(EXESUF)
Kevin Wolf [Thu, 10 May 2012 07:46:18 +0000 (09:46 +0200)]
tests/Makefile: Add missing $(EXESUF)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agostream: do not copy unallocated sectors from the base
Paolo Bonzini [Tue, 8 May 2012 14:51:58 +0000 (16:51 +0200)]
stream: do not copy unallocated sectors from the base

Unallocated sectors should really never be accessed by the guest,
so there's no need to copy them during the streaming process.
If they are read by the guest during streaming, guest-initiated
copy-on-read will copy them (we're in the base == NULL case, which
enables copy on read).  If they are read after we disconnect the
image from the base, they will read as zeroes anyway.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agostream: fix ratelimiting corner case
Paolo Bonzini [Tue, 8 May 2012 14:51:57 +0000 (16:51 +0200)]
stream: fix ratelimiting corner case

This fixes inability to make progress in streaming if the quota is set
to less than the amount of data that an I/O operation has to write.

In this case, limit->dispatched + n will always be above the quota and,
due to the "goto retry" to recheck cancellation and allocation, streaming
will livelock.

This can be reproduced with "block_job_set_speed ide0-hd0 1b".  Of course,
with this patch the requested limit will not be obeyed.  That could be
done with another patch that caps is_allocated's n argument by the slice
quota.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agostream: fix HMP block_job_set_speed
Paolo Bonzini [Tue, 8 May 2012 14:51:56 +0000 (16:51 +0200)]
stream: fix HMP block_job_set_speed

The change of the argument name from value to speed was not propagated there.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agostream: pass new base image format to bdrv_change_backing_file
Paolo Bonzini [Tue, 8 May 2012 14:51:55 +0000 (16:51 +0200)]
stream: pass new base image format to bdrv_change_backing_file

When an image is modified to point to the new backing file, the backing
file format is set to NULL, which means auto-probe.  This is wrong, in
fact it is a small security problem.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agostream: add testcase for partial streaming
Paolo Bonzini [Wed, 9 May 2012 13:05:03 +0000 (15:05 +0200)]
stream: add testcase for partial streaming

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agostream: fix sectors not allocated test
Paolo Bonzini [Tue, 8 May 2012 14:51:53 +0000 (16:51 +0200)]
stream: fix sectors not allocated test

The test on sectors not allocated can fail if the L1/L2 tables are
not on disk yet.  Allow tests to shutdown the VM early.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-io: fix the alloc command
Paolo Bonzini [Tue, 8 May 2012 14:51:52 +0000 (16:51 +0200)]
qemu-io: fix the alloc command

Because sector_num is not updated, the loop would either go on
forever or return garbage.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-io: correctly print non-integer values as decimals
Paolo Bonzini [Tue, 8 May 2012 14:51:51 +0000 (16:51 +0200)]
qemu-io: correctly print non-integer values as decimals

qemu-io's cvtstr function sometimes will incorrectly omit the
decimal part of the number, and sometimes will incorrectly include
it.  This patch fixes both.  The former is more serious, and can
be seen in the patches to 027.out and 033.out.

The changes to all other files were scripted with sed, so there were
no "surprises" beyond 027.out and 033.out.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-img: make "info" backing file output correct and easier to use
Paolo Bonzini [Tue, 8 May 2012 14:51:50 +0000 (16:51 +0200)]
qemu-img: make "info" backing file output correct and easier to use

qemu-img info should use the same logic as qemu when printing the
backing file path, or debugging becomes quite tricky.  We can also
simplify the output in case the backing file has an absolute path
or a protocol.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: move field reset from bdrv_open_common to bdrv_close
Paolo Bonzini [Tue, 8 May 2012 14:51:49 +0000 (16:51 +0200)]
block: move field reset from bdrv_open_common to bdrv_close

bdrv_close should leave fields in the same state as bdrv_new.  It is
not up to bdrv_open_common to fix the mess.

Also, backing_format was not being re-initialized.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: protect path_has_protocol from filenames with colons
Paolo Bonzini [Tue, 8 May 2012 14:51:48 +0000 (16:51 +0200)]
block: protect path_has_protocol from filenames with colons

path_has_protocol will erroneously return "true" if the colon is part
of a filename.  These names are common with stable device names produced
by udev.  We cannot fully protect against this in case the filename
does not have a path component (e.g. if the current directory is
/dev/disk/by-path), but in the common case there will be a slash before
and path_has_protocol can easily detect that and return false.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: simplify path_is_absolute
Paolo Bonzini [Tue, 8 May 2012 14:51:47 +0000 (16:51 +0200)]
block: simplify path_is_absolute

On Windows, all the logic is already in is_windows_drive and
is_windows_drive_prefix.  On POSIX, there is no need to look
out for colons.

The win32 code changes the behaviour in some cases, we could have
something like "d:foo.img". The old code would treat it as relative
path, the new one as absolute. Now the path is absolute, because to
go from c:/program files/blah to d:foo.img you cannot say c:/program
files/blah/d:foo.img.  You have to say d:foo.img.  But you could also
say it's relative because (I think, at least it was like that in DOS
15 years ago) d:foo.img is relative to the current path of drive D.
Considering how path_is_absolute is used by path_combine, I think it's
better to treat it as absolute.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: wait for job callback in block_job_cancel_sync
Paolo Bonzini [Tue, 8 May 2012 14:51:46 +0000 (16:51 +0200)]
block: wait for job callback in block_job_cancel_sync

The limitation on not having I/O after cancellation cannot really be
kept.  Even streaming has a very small race window where you could
cancel a job and have it report completion.  If this window is hit,
bdrv_change_backing_file() will yield and possibly cause accesses to
dangling pointers etc.

So, let's just assume that we cannot know exactly what will happen
after the coroutine has set busy to false.  We can set a very lax
condition:

- if we cancel the job, the coroutine won't set it to false again
(and hence will not call co_sleep_ns again).

- block_job_cancel_sync will wait for the coroutine to exit, which
pretty much ensures no race.

Instead, we track the coroutine that executes the job and put very
strict conditions on what to do while it is quiescent (busy = false).
First of all, the coroutine must never set busy = false while the job
has been cancelled.  Second, the coroutine can be reentered arbitrarily
while it is quiescent, so you cannot really do anything but co_sleep_ns at
that time.  This condition is obeyed by the block_job_sleep_ns function.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: add block_job_sleep_ns
Paolo Bonzini [Tue, 8 May 2012 14:51:45 +0000 (16:51 +0200)]
block: add block_job_sleep_ns

This function abstracts the pretty complex semantics of the "busy"
member of BlockJob.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: fully delete bs->file when closing
Paolo Bonzini [Tue, 8 May 2012 14:51:44 +0000 (16:51 +0200)]
block: fully delete bs->file when closing

We are reusing bs->file across close/open, which may not cause any
known bugs but is a recipe for trouble.  Prefer bdrv_delete, and
enjoy the new invariant in the implementation of bdrv_delete.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: do not reuse the backing file across bdrv_close/bdrv_open
Paolo Bonzini [Tue, 8 May 2012 14:51:43 +0000 (16:51 +0200)]
block: do not reuse the backing file across bdrv_close/bdrv_open

This is another bug caused by not doing a full cleanup of the BDS
across close/open.  This was found with mirroring by Shaolong Hu,
but it can probably be reproduced also with eject or change.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: another bdrv_append fix
Paolo Bonzini [Tue, 8 May 2012 14:51:42 +0000 (16:51 +0200)]
block: another bdrv_append fix

bdrv_append must also copy open_flags to the top, because the snapshot
has BDRV_O_NO_BACKING set.  This causes interesting results if you
later use drive-reopen (not upstream) to reopen the image, and lose
the backing file in the process.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: fix snapshot on QED
Paolo Bonzini [Tue, 8 May 2012 14:51:41 +0000 (16:51 +0200)]
block: fix snapshot on QED

QED's opaque data includes a pointer back to the BlockDriverState.
This breaks when bdrv_append shuffles data between bs_new and bs_top.
To avoid this, add a "rebind" function that tells the driver about
the new relationship between the BlockDriverState and its opaque.

The patch also adds rebind to VVFAT for completeness, even though
it is not used with live snapshots.

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqtest: Add floppy test
Kevin Wolf [Tue, 8 May 2012 14:38:37 +0000 (16:38 +0200)]
qtest: Add floppy test

Let's start with testing media change.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqtest: Add function to send QMP commands
Kevin Wolf [Thu, 26 Apr 2012 17:07:55 +0000 (19:07 +0200)]
qtest: Add function to send QMP commands

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-iotests: strip spaces from qemu-img/qemu-io/qemu command lines
Paolo Bonzini [Thu, 12 Apr 2012 12:01:05 +0000 (14:01 +0200)]
qemu-iotests: strip spaces from qemu-img/qemu-io/qemu command lines

A trailing space is left when qemu-img has no arguments, for example if
-nocache is not used.  This becomes an empty argument after split()
and causes qemu-io to fail.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: fix allocation size for dirty bitmap
Paolo Bonzini [Thu, 12 Apr 2012 12:01:04 +0000 (14:01 +0200)]
block: fix allocation size for dirty bitmap

Also reuse elsewhere the new constant for sizeof(unsigned long) * 8.

The dirty bitmap is allocated in bits but declared as unsigned long.
Thus, its memory block is accessed beyond its end unless the image
is a multiple of 64 chunks (i.e. a multiple of 64 MB).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: open backing file as read-only when probing for size
Paolo Bonzini [Thu, 12 Apr 2012 12:01:03 +0000 (14:01 +0200)]
block: open backing file as read-only when probing for size

bdrv_img_create will temporarily open the backing file to probe its size.
However, this could be done with a read-write open if the wrong flags are
passed to bdrv_img_create.  Since there is really no documentation on
what flags can be passed, assume that bdrv_img_create receives the flags
with which the new image will be opened; sanitize them when opening
the backing file.

Reported-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: update in-memory backing file and format
Paolo Bonzini [Thu, 12 Apr 2012 12:01:02 +0000 (14:01 +0200)]
block: update in-memory backing file and format

These are needed to print "info block" output correctly.  QCOW2 does this
because it needs it to write the header, but QED does not, and common code
is the right place to do it.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: push bdrv_change_backing_file error checking up from drivers
Paolo Bonzini [Thu, 12 Apr 2012 12:01:01 +0000 (14:01 +0200)]
block: push bdrv_change_backing_file error checking up from drivers

This check applies to all drivers, but QED lacks it.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: fail live snapshot if disk has no medium
Paolo Bonzini [Thu, 12 Apr 2012 12:00:59 +0000 (14:00 +0200)]
block: fail live snapshot if disk has no medium

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: add mode argument to blockdev-snapshot-sync
Paolo Bonzini [Thu, 12 Apr 2012 12:00:58 +0000 (14:00 +0200)]
block: add mode argument to blockdev-snapshot-sync

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: add the support to drain throttled requests
Zhi Yong Wu [Thu, 12 Apr 2012 12:00:57 +0000 (14:00 +0200)]
block: add the support to drain throttled requests

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
[ Iterate until all block devices have processed all requests,
  add comments. - Paolo ]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoUpdate version for 1.1.0-rc0 release
Anthony Liguori [Wed, 9 May 2012 21:39:57 +0000 (16:39 -0500)]
Update version for 1.1.0-rc0 release

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode
Andreas Färber [Wed, 9 May 2012 17:26:59 +0000 (19:26 +0200)]
tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode

Adjust the tcg_out_qemu_{ld,st}() slow paths to pass AREG0 in r3,
based on patches by malc.

Also adjust the registers clobbered, based on patch by Alex.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Alexander Graf <agraf@suse.de>
[AF: Do not hardcode r3 for AREG0, requested by Alex]
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotcg/ppc: Clobber r5 for 64-bit qemu_ld
Andreas Färber [Wed, 9 May 2012 17:26:58 +0000 (19:26 +0200)]
tcg/ppc: Clobber r5 for 64-bit qemu_ld

This accounts for the additional addr_reg2 register.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>