]> git.ipfire.org Git - thirdparty/qemu.git/log
thirdparty/qemu.git
7 years agoqemu-io: Switch 'alloc' command to byte-based length
Eric Blake [Sat, 29 Apr 2017 19:14:12 +0000 (14:14 -0500)] 
qemu-io: Switch 'alloc' command to byte-based length

For the 'alloc' command, accepting an offset in bytes but a length
in sectors, and reporting output in sectors, is confusing.  Do
everything in bytes, and adjust the expected output accordingly.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-id: 20170429191419.30051-3-eblake@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
7 years agoqemu-io: Improve alignment checks
Eric Blake [Sat, 29 Apr 2017 19:14:11 +0000 (14:14 -0500)] 
qemu-io: Improve alignment checks

Several copy-and-pasted alignment checks exist in qemu-io, which
could use some minor improvements:

- Manual comparison against 0x1ff is not as clean as using our
alignment macros (QEMU_IS_ALIGNED) from osdep.h.

- The error messages aren't quite grammatically correct.

Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-id: 20170429191419.30051-2-eblake@redhat.com
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
7 years agoblockdev: use drained_begin/end for qmp_block_resize
John Snow [Wed, 10 May 2017 17:39:45 +0000 (13:39 -0400)] 
blockdev: use drained_begin/end for qmp_block_resize

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1447551
If one tries to issue a block_resize while a guest is busy
accessing the disk, it is possible that qemu may deadlock
when invoking aio_poll from both the main loop and the iothread.

Replace another instance of bdrv_drain_all that doesn't
quite belong.

Cc: qemu-stable@nongnu.org
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agonvme: Implement Write Zeroes
Christoph Hellwig [Fri, 5 May 2017 09:58:07 +0000 (11:58 +0200)] 
nvme: Implement Write Zeroes

Signed-off-by: Keith Busch <keith.busch@intel.com>
[hch: ported over from qemu-nvme.git to mainline]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoqemu-img: wait for convert coroutines to complete
Anton Nefedov [Wed, 26 Apr 2017 08:33:15 +0000 (11:33 +0300)] 
qemu-img: wait for convert coroutines to complete

On error path (like i/o error in one of the coroutines), it's required to
  - wait for coroutines completion before cleaning the common structures
  - reenter dependent coroutines so they ever finish

Introduced in 2d9187bc65.

Cc: qemu-stable@nongnu.org
Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
Reviewed-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agofile-posix: Remove .bdrv_inactivate/invalidate_cache
Kevin Wolf [Thu, 4 May 2017 16:52:41 +0000 (18:52 +0200)] 
file-posix: Remove .bdrv_inactivate/invalidate_cache

Now that the block layer takes care to request a lot less permissions
for inactive nodes, the special-casing in file-posix isn't necessary any
more.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoblock: Fix write/resize permissions for inactive images
Kevin Wolf [Thu, 4 May 2017 16:52:40 +0000 (18:52 +0200)] 
block: Fix write/resize permissions for inactive images

Format drivers for inactive nodes don't need write/resize permissions on
their bs->file and can share write/resize with another VM (in fact, this
is the whole point of keeping images inactive). Represent this fact in
the op blocker system, so that image locking does the right thing
without special-casing inactive images.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoblock: Inactivate parents before children
Kevin Wolf [Thu, 4 May 2017 16:52:39 +0000 (18:52 +0200)] 
block: Inactivate parents before children

The proper order for inactivating block nodes is that first the parents
get inactivated and then the children. If we do things in this order, we
can assert that we didn't accidentally leave a parent activated when one
of its child nodes is inactive.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoblock: Drop permissions when migration completes
Kevin Wolf [Thu, 4 May 2017 16:52:38 +0000 (18:52 +0200)] 
block: Drop permissions when migration completes

With image locking, permissions affect other qemu processes as well. We
want to be sure that the destination can run, so let's drop permissions
on the source when migration completes.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoblock: New BdrvChildRole.activate() for blk_resume_after_migration()
Kevin Wolf [Thu, 4 May 2017 16:52:37 +0000 (18:52 +0200)] 
block: New BdrvChildRole.activate() for blk_resume_after_migration()

Instead of manually calling blk_resume_after_migration() in migration
code after doing bdrv_invalidate_cache_all(), integrate the BlockBackend
activation with cache invalidation into a single function. This is
achieved with a new callback in BdrvChildRole that is called by
bdrv_invalidate_cache_all().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agomigration: Unify block node activation error handling
Kevin Wolf [Thu, 4 May 2017 16:52:36 +0000 (18:52 +0200)] 
migration: Unify block node activation error handling

Migration code activates all block driver nodes on the destination when
the migration completes. It does so by calling
bdrv_invalidate_cache_all() and blk_resume_after_migration(). There is
one code path for precopy and one for postcopy migration, resulting in
four function calls, which used to have three different failure modes.

This patch unifies the behaviour so that failure to activate all block
nodes is non-fatal, but the error message is logged and the VM isn't
automatically started. 'cont' will retry activating the block nodes.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoiotests: Extend test 066
Max Reitz [Wed, 3 May 2017 23:11:20 +0000 (01:11 +0200)] 
iotests: Extend test 066

066 was supposed to be a test "for discarding preallocated zero
clusters", but it did so incompletely: While it did check the image
file's integrity after the operation, it did not confirm that the
clusters are indeed freed. This patch adds this test.

In addition, new cases for writing to preallocated zero clusters are
added.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoqcow2: Discard preallocated zero clusters
Max Reitz [Wed, 3 May 2017 23:11:19 +0000 (01:11 +0200)] 
qcow2: Discard preallocated zero clusters

In discard_single_l2(), we completely discard normal clusters instead of
simply turning them into preallocated zero clusters. That means we
should probably do the same with such preallocated zero clusters:
Discard them instead of keeping them allocated.

Reported-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoqcow2: Reuse preallocated zero clusters
Max Reitz [Wed, 3 May 2017 23:11:18 +0000 (01:11 +0200)] 
qcow2: Reuse preallocated zero clusters

Instead of just freeing preallocated zero clusters and completely
allocating them from scratch, reuse them.

We cannot do this in handle_copied(), however, since this is a COW
operation. Therefore, we have to add the new logic to handle_alloc() and
simply return the existing offset if it exists. The only catch is that
we have to convince qcow2_alloc_cluster_link_l2() not to free the old
clusters (because we have reused them).

Reported-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoqcow2: Fix preallocation size formula
Max Reitz [Wed, 3 May 2017 23:11:17 +0000 (01:11 +0200)] 
qcow2: Fix preallocation size formula

When calculating the number of reftable entries, we should actually use
the number of refblocks and not (wrongly[1]) re-calculate it.

[1] "Wrongly" means: Dividing the number of clusters by the number of
    entries per refblock and rounding down instead of up.

Reported-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agotests: Add POSIX image locking test case 182
Fam Zheng [Tue, 2 May 2017 16:35:58 +0000 (00:35 +0800)] 
tests: Add POSIX image locking test case 182

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoqemu-iotests: Add test case 153 for image locking
Fam Zheng [Tue, 2 May 2017 16:35:57 +0000 (00:35 +0800)] 
qemu-iotests: Add test case 153 for image locking

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agofile-posix: Add image locking to perm operations
Fam Zheng [Tue, 2 May 2017 16:35:56 +0000 (00:35 +0800)] 
file-posix: Add image locking to perm operations

This extends the permission bits of op blocker API to external using
Linux OFD locks.

Each permission in @perm and @shared_perm is represented by a locked
byte in the image file.  Requesting a permission in @perm is translated
to a shared lock of the corresponding byte; rejecting to share the same
permission is translated to a shared lock of a separate byte. With that,
we use 2x number of bytes of distinct permission types.

virtlockd in libvirt locks the first byte, so we do locking from a
higher offset.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoosdep: Fall back to posix lock when OFD lock is unavailable
Fam Zheng [Tue, 2 May 2017 16:35:55 +0000 (00:35 +0800)] 
osdep: Fall back to posix lock when OFD lock is unavailable

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoosdep: Add qemu_lock_fd and qemu_unlock_fd
Fam Zheng [Tue, 2 May 2017 16:35:54 +0000 (00:35 +0800)] 
osdep: Add qemu_lock_fd and qemu_unlock_fd

They are wrappers of POSIX fcntl "file private locking", with a
convenient "try lock" wrapper implemented with F_OFD_GETLK.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblock: Reuse bs as backing hd for drive-backup sync=none
Fam Zheng [Tue, 2 May 2017 16:35:53 +0000 (00:35 +0800)] 
block: Reuse bs as backing hd for drive-backup sync=none

Opening the backing image for the second time is bad, especially here
when it is also in use as the active image as the source. The
drive-backup job itself doesn't read from target->backing for COW,
instead it gets data from the write notifier, so it's not a big problem.
However, exporting the target to NBD etc. won't work, because of the
likely stale metadata cache.

Use BDRV_O_NO_BACKING in this case and manually set up the backing
BdrvChild.

Cc: qemu-stable@nongnu.org
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agotests: Disable image lock in test-replication
Fam Zheng [Tue, 2 May 2017 16:35:52 +0000 (00:35 +0800)] 
tests: Disable image lock in test-replication

The COLO block replication architecture requires one disk to be shared
between primary and secondary, in the test both processes use posix file
protocol (instead of over NBD) so it is affected by image locking.
Disable the lock.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agofile-win32: Error out if locking=on
Fam Zheng [Tue, 2 May 2017 16:35:51 +0000 (00:35 +0800)] 
file-win32: Error out if locking=on

We share the same set of QAPI options with file-posix, but locking is
not supported here. So error out if it is specified as 'on' for now.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agofile-posix: Add 'locking' option
Fam Zheng [Tue, 2 May 2017 16:35:50 +0000 (00:35 +0800)] 
file-posix: Add 'locking' option

Making this option available even before implementing it will let
converting tests easier: in coming patches they can specify the option
already when necessary, before we actually write code to lock the
images.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agotests: Use null-co:// instead of /dev/null as the dummy image
Fam Zheng [Tue, 2 May 2017 16:35:49 +0000 (00:35 +0800)] 
tests: Use null-co:// instead of /dev/null as the dummy image

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoiotests: 172: Use separate images for multiple devices
Fam Zheng [Tue, 2 May 2017 16:35:48 +0000 (00:35 +0800)] 
iotests: 172: Use separate images for multiple devices

To avoid image lock failures.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoiotests: 091: Quit QEMU before checking image
Fam Zheng [Tue, 2 May 2017 16:35:47 +0000 (00:35 +0800)] 
iotests: 091: Quit QEMU before checking image

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoiotests: 087: Don't attach test image twice
Fam Zheng [Tue, 2 May 2017 16:35:46 +0000 (00:35 +0800)] 
iotests: 087: Don't attach test image twice

The test scenario doesn't require the same image, instead it focuses on
the duplicated node-name, so use null-co to avoid locking conflict.

Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoiotests: 085: Avoid image locking conflict
Fam Zheng [Tue, 2 May 2017 16:35:45 +0000 (00:35 +0800)] 
iotests: 085: Avoid image locking conflict

In the case where we test the expected error when a blockdev-snapshot
target already has a backing image, the backing chain is opened multiple
times. This will be a problem when we use image locking, so use a
different backing file that is not already open.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoiotests: 055: Don't attach the target image already for drive-backup
Fam Zheng [Tue, 2 May 2017 16:35:44 +0000 (00:35 +0800)] 
iotests: 055: Don't attach the target image already for drive-backup

Double attach is not a valid usage of the target image, drive-backup
will open the blockdev itself so skip the add_drive call in this case.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoiotests: 046: Prepare for image locking
Fam Zheng [Tue, 2 May 2017 16:35:43 +0000 (00:35 +0800)] 
iotests: 046: Prepare for image locking

The qemu-img info command is executed while VM is running, add -U option
to avoid the image locking error.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoiotests: 030: Prepare for image locking
Fam Zheng [Tue, 2 May 2017 16:35:42 +0000 (00:35 +0800)] 
iotests: 030: Prepare for image locking

qemu-img and qemu-io commands when guest is running need "-U" option,
add it.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoqemu-io: Add --force-share option
Fam Zheng [Tue, 2 May 2017 16:35:41 +0000 (00:35 +0800)] 
qemu-io: Add --force-share option

Add --force-share/-U to program options and -U to open subcommand.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoqemu-img: Update documentation for -U
Fam Zheng [Tue, 2 May 2017 16:35:40 +0000 (00:35 +0800)] 
qemu-img: Update documentation for -U

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoqemu-img: Add --force-share option to subcommands
Fam Zheng [Tue, 2 May 2017 16:35:39 +0000 (00:35 +0800)] 
qemu-img: Add --force-share option to subcommands

This will force the opened images to allow sharing all permissions with other
programs.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblock: Respect "force-share" in perm propagating
Fam Zheng [Tue, 2 May 2017 16:35:38 +0000 (00:35 +0800)] 
block: Respect "force-share" in perm propagating

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblock: Add, parse and store "force-share" option
Fam Zheng [Tue, 2 May 2017 16:35:37 +0000 (00:35 +0800)] 
block: Add, parse and store "force-share" option

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblock: Make bdrv_perm_names public
Fam Zheng [Tue, 2 May 2017 16:35:36 +0000 (00:35 +0800)] 
block: Make bdrv_perm_names public

It can be used outside of block.c for making user friendly messages.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoMerge remote-tracking branch 'armbru/tags/pull-qapi-2017-05-04-v3' into staging
Stefan Hajnoczi [Tue, 9 May 2017 19:49:08 +0000 (15:49 -0400)] 
Merge remote-tracking branch 'armbru/tags/pull-qapi-2017-05-04-v3' into staging

QAPI patches for 2017-05-04

# gpg: Signature made Tue 09 May 2017 03:16:12 AM EDT
# gpg:                using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* armbru/tags/pull-qapi-2017-05-04-v3: (28 commits)
  qmp-shell: improve help
  qmp-shell: don't show version greeting if unavailable
  qmp-shell: Cope with query-commands error
  qmp-shell: add -N option to skip negotiate
  qmp-shell: add persistent command history
  qobject-input-visitor: Catch misuse of end_struct vs. end_list
  qapi: Document intended use of @name within alternate visits
  qobject-input-visitor: Document full_name_nth()
  qmp: Improve QMP dispatch error messages
  sockets: Delete unused helper socket_address_crumple()
  sockets: Limit SocketAddressLegacy to external interfaces
  sockets: Rename SocketAddressFlat to SocketAddress
  sockets: Rename SocketAddress to SocketAddressLegacy
  qapi: New QAPI_CLONE_MEMBERS()
  sockets: Prepare inet_parse() for flattened SocketAddress
  sockets: Prepare vsock_parse() for flattened SocketAddress
  test-qga: Actually test 0xff sync bytes
  fdc-test: Avoid deprecated 'change' command
  QemuOpts: Simplify qemu_opts_to_qdict()
  block: Simplify bdrv_append_temp_snapshot() logic
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoqmp-shell: improve help
Marc-André Lureau [Thu, 4 May 2017 12:54:32 +0000 (16:54 +0400)] 
qmp-shell: improve help

Describe the arguments & fix the tool name.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170504125432.21653-5-marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoqmp-shell: don't show version greeting if unavailable
Marc-André Lureau [Thu, 4 May 2017 12:54:31 +0000 (16:54 +0400)] 
qmp-shell: don't show version greeting if unavailable

qemu-ga doesn't have greeting.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170504125432.21653-4-marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoqmp-shell: Cope with query-commands error
Marc-André Lureau [Thu, 4 May 2017 12:54:30 +0000 (16:54 +0400)] 
qmp-shell: Cope with query-commands error

qemu-ga doesn't implement it.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170504125432.21653-3-marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoqmp-shell: add -N option to skip negotiate
Marc-André Lureau [Thu, 4 May 2017 12:54:29 +0000 (16:54 +0400)] 
qmp-shell: add -N option to skip negotiate

qemu-ga doesn't have negotiate phase.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170504125432.21653-2-marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoqmp-shell: add persistent command history
John Snow [Thu, 27 Apr 2017 22:36:28 +0000 (18:36 -0400)] 
qmp-shell: add persistent command history

Use the existing readline history function we are utilizing
to provide persistent command history across instances of qmp-shell.

This assists entering debug commands across sessions that may be
interrupted by QEMU sessions terminating, where the qmp-shell has
to be relaunched.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20170427223628.20893-1-jsnow@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoqobject-input-visitor: Catch misuse of end_struct vs. end_list
Markus Armbruster [Thu, 27 Apr 2017 08:41:26 +0000 (10:41 +0200)] 
qobject-input-visitor: Catch misuse of end_struct vs. end_list

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493282486-28338-5-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[More elaborate assertions for clarity]

7 years agoqapi: Document intended use of @name within alternate visits
Markus Armbruster [Thu, 27 Apr 2017 08:41:25 +0000 (10:41 +0200)] 
qapi: Document intended use of @name within alternate visits

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493282486-28338-4-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7 years agoqobject-input-visitor: Document full_name_nth()
Markus Armbruster [Thu, 27 Apr 2017 08:41:24 +0000 (10:41 +0200)] 
qobject-input-visitor: Document full_name_nth()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493282486-28338-3-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7 years agoqmp: Improve QMP dispatch error messages
Markus Armbruster [Thu, 27 Apr 2017 08:41:23 +0000 (10:41 +0200)] 
qmp: Improve QMP dispatch error messages

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1493282486-28338-2-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7 years agosockets: Delete unused helper socket_address_crumple()
Markus Armbruster [Wed, 26 Apr 2017 07:36:42 +0000 (09:36 +0200)] 
sockets: Delete unused helper socket_address_crumple()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493192202-3184-8-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Commit message typo fixed]

7 years agosockets: Limit SocketAddressLegacy to external interfaces
Markus Armbruster [Wed, 26 Apr 2017 07:36:41 +0000 (09:36 +0200)] 
sockets: Limit SocketAddressLegacy to external interfaces

SocketAddressLegacy is a simple union, and simple unions are awkward:
they have their variant members wrapped in a "data" object on the
wire, and require additional indirections in C.  SocketAddress is the
equivalent flat union.  Convert all users of SocketAddressLegacy to
SocketAddress, except for existing external interfaces.

See also commit fce5d53..9445673 and 85a82e8..c5f1ae3.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493192202-3184-7-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Minor editing accident fixed, commit message and a comment tweaked]

Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agosockets: Rename SocketAddressFlat to SocketAddress
Markus Armbruster [Wed, 26 Apr 2017 07:36:40 +0000 (09:36 +0200)] 
sockets: Rename SocketAddressFlat to SocketAddress

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493192202-3184-6-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
7 years agosockets: Rename SocketAddress to SocketAddressLegacy
Markus Armbruster [Wed, 26 Apr 2017 07:36:39 +0000 (09:36 +0200)] 
sockets: Rename SocketAddress to SocketAddressLegacy

The next commit will rename SocketAddressFlat to SocketAddress, and
the commit after that will replace most uses of SocketAddressLegacy by
SocketAddress, replacing most of this commit's renames right back.

Note that checkpatch emits a few "line over 80 characters" warnings.
The long lines are all temporary; the SocketAddressLegacy replacement
will shorten them again.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493192202-3184-5-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoqapi: New QAPI_CLONE_MEMBERS()
Markus Armbruster [Wed, 26 Apr 2017 07:36:38 +0000 (09:36 +0200)] 
qapi: New QAPI_CLONE_MEMBERS()

QAPI_CLONE() returns a newly allocated QAPI object.  Inconvenient when
we want to clone into an existing object.  QAPI_CLONE_MEMBERS() does
exactly that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493192202-3184-4-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agosockets: Prepare inet_parse() for flattened SocketAddress
Markus Armbruster [Wed, 26 Apr 2017 07:36:37 +0000 (09:36 +0200)] 
sockets: Prepare inet_parse() for flattened SocketAddress

I'm going to flatten SocketAddress: rename SocketAddress to
SocketAddressLegacy, SocketAddressFlat to SocketAddress, eliminate
SocketAddressLegacy except in external interfaces.

inet_parse() returns a newly allocated InetSocketAddress.  Lift the
allocation from inet_parse() into its caller socket_parse() to prepare
for flattening SocketAddress.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493192202-3184-3-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Straightforward rebase]

7 years agosockets: Prepare vsock_parse() for flattened SocketAddress
Markus Armbruster [Wed, 26 Apr 2017 07:36:36 +0000 (09:36 +0200)] 
sockets: Prepare vsock_parse() for flattened SocketAddress

I'm going to flatten SocketAddress: rename SocketAddress to
SocketAddressLegacy, SocketAddressFlat to SocketAddress, eliminate
SocketAddressLegacy except in external interfaces.

vsock_parse() returns a newly allocated VsockSocketAddress.  Lift the
allocation from vsock_parse() into its caller socket_parse() to
prepare for flattening SocketAddress.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1493192202-3184-2-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotest-qga: Actually test 0xff sync bytes
Eric Blake [Thu, 27 Apr 2017 21:58:21 +0000 (16:58 -0500)] 
test-qga: Actually test 0xff sync bytes

Commit 62c39b3 introduced test-qga, and at face value, appears
to be testing the 'guest-sync' behavior that is recommended for
guests in sending 0xff to QGA to force the parser to reset.  But
this aspect of the test has never actually done anything: the
qmp_fd() call chain converts its string argument into QObject,
then converts that QObject back to the actual string that is
sent over the wire - and the conversion process silently drops
the 0xff byte from the string sent to QGA, thus never resetting
the QGA parser.

An upcoming patch will get rid of the wasteful round trip
through QObject, at which point the string in test-qga will be
directly sent over the wire.

But fixing qmp_fd() to actually send 0xff over the wire is not
all we have to do - the actual QMP parser loudly complains that
0xff is not valid JSON, and sends an error message _prior_ to
actually parsing the 'guest-sync' or 'guest-sync-delimited'
command.  With 'guest-sync', we cannot easily tell if this error
message is a result of our command - which is WHY we invented
the 'guest-sync-delimited' command.  So for the testsuite, fix
things to only check 0xff behavior on 'guest-sync-delimited',
and to loop until we've consumed all garbage prior to the
requested delimiter, which is compatible with the documented actions
that a real QGA client is supposed to do.

Ideally, we'd fix the QGA JSON parser to silently ignore 0xff
rather than sending an error message back, at which point we
could enhance this test for 'guest-sync' as well as for
'guest-sync-delimited'.  But for the sake of this patch, our
testing of 'guest-sync' is no worse than it was pre-patch,
because we have never been sending 0xff over the wire in the
first place.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-11-eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
[Additional comment squashed in, along with matching commit message
update]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agofdc-test: Avoid deprecated 'change' command
Eric Blake [Thu, 27 Apr 2017 21:58:20 +0000 (16:58 -0500)] 
fdc-test: Avoid deprecated 'change' command

Use the preferred blockdev-change-medium command instead.

Also, use of 'device' is deprecated; adding an explicit id on
the command line lets us use 'id' for both blockdev-change-medium
and eject.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-10-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoQemuOpts: Simplify qemu_opts_to_qdict()
Eric Blake [Thu, 27 Apr 2017 21:58:19 +0000 (16:58 -0500)] 
QemuOpts: Simplify qemu_opts_to_qdict()

Noticed while investigating Coccinelle cleanups. There is no need
for a temporary variable when we can use the new macro to do the
same thing with less typing.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-9-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoblock: Simplify bdrv_append_temp_snapshot() logic
Eric Blake [Thu, 27 Apr 2017 21:58:18 +0000 (16:58 -0500)] 
block: Simplify bdrv_append_temp_snapshot() logic

Noticed while checking Coccinelle results. Naming a label 'out:'
when it is only used on error paths is weird.  Also, we had some
dead stores to 'ret'.  Meanwhile we know that snapshot_options
is NULL on success and that QDECREF(NULL) is safe.  So merge the
two exit paths into one by careful control over bs_snapshot.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-8-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoqobject: Use simpler QDict/QList scalar insertion macros
Eric Blake [Thu, 27 Apr 2017 21:58:17 +0000 (16:58 -0500)] 
qobject: Use simpler QDict/QList scalar insertion macros

We now have macros in place to make it less verbose to add a scalar
to QDict and QList, so use them.

Patch created mechanically via:
  spatch --sp-file scripts/coccinelle/qobject.cocci \
    --macro-file scripts/cocci-macro-file.h --dir . --in-place
then touched up manually to fix a couple of '?:' back to original
spacing, as well as avoiding a long line in monitor.c.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-7-eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoqobject: Add helper macros for common scalar insertions
Eric Blake [Thu, 27 Apr 2017 21:58:16 +0000 (16:58 -0500)] 
qobject: Add helper macros for common scalar insertions

Rather than making lots of callers wrap a scalar in a QInt, QString,
or QBool, provide helper macros that do the wrapping automatically.

Update the Coccinelle script to make mass conversions easy, although
the conversion itself will be done as a separate patches to ease
review and backport efforts.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-6-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoqobject: Drop useless QObject casts
Eric Blake [Thu, 27 Apr 2017 21:58:15 +0000 (16:58 -0500)] 
qobject: Drop useless QObject casts

We have macros in place to make it less verbose to add a subtype
of QObject to both QDict and QList. While we have made cleanups
like this in the past (see commit fcfcd8ffc, for example), having
it be automated by Coccinelle makes it easier to maintain.

Patch created mechanically via:
  spatch --sp-file scripts/coccinelle/qobject.cocci \
    --macro-file scripts/cocci-macro-file.h --dir . --in-place
then I verified that no manual touchups were required.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-5-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agococcinelle: Add script to remove useless QObject casts
Eric Blake [Thu, 27 Apr 2017 21:58:14 +0000 (16:58 -0500)] 
coccinelle: Add script to remove useless QObject casts

We have macros in place to make it less verbose to add a subtype
of QObject to both QDict and QList. While we have made cleanups
like this in the past (see commit fcfcd8ffc, for example), having
it be automated by Coccinelle makes it easier to maintain.

The script is separate from the cleanups, for ease of review and
backporting.  A later patch will then add further possible cleanups.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-4-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agopci: Reduce scope of error injection
Eric Blake [Thu, 27 Apr 2017 21:58:13 +0000 (16:58 -0500)] 
pci: Reduce scope of error injection

No one outside of pcie_aer.h was using error injection; mark them
static for internal use.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-3-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agopci: Use struct instead of QDict to pass back parameters
Eric Blake [Thu, 27 Apr 2017 21:58:12 +0000 (16:58 -0500)] 
pci: Use struct instead of QDict to pass back parameters

It's simpler to just use a C struct than it is to bundle things
into a QDict in one function just to pull them back out in the
caller.  Plus, doing this gets rid of one more user of dynamic
JSON through qobject_from_jsonf(), as well as a memory leak of
the QDict.

While cleaning the code, fix things to report all errors (the
code was previously silently ignoring a failure of
pcie_aer_inject_error(), at a distance).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-2-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agotest-keyval: fix leaks
Marc-André Lureau [Wed, 3 May 2017 22:38:42 +0000 (02:38 +0400)] 
test-keyval: fix leaks

Spotted by ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170503223846.6559-2-marcandre.lureau@redhat.com>
Reviewed-by: Eric blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agotests/check-qdict: Fix missing brackets
Dr. David Alan Gilbert [Thu, 6 Apr 2017 15:41:07 +0000 (16:41 +0100)] 
tests/check-qdict: Fix missing brackets

Gcc 7 (on Fedora 26) spotted odd use of integers instead of a
boolean; it's got a point.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20170406154107.9178-1-dgilbert@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7 years agoMerge remote-tracking branch 'aurel32/tags/pull-tcg-mips-20170506' into staging
Stefan Hajnoczi [Mon, 8 May 2017 17:29:50 +0000 (13:29 -0400)] 
Merge remote-tracking branch 'aurel32/tags/pull-tcg-mips-20170506' into staging

Fix MIPS R2 hosts support

# gpg: Signature made Sat 06 May 2017 06:56:28 AM EDT
# gpg:                using RSA key 0xBA9C78061DDD8C9B
# gpg: Good signature from "Aurelien Jarno <aurelien@aurel32.net>"
# gpg:                 aka "Aurelien Jarno <aurelien@jarno.fr>"
# gpg:                 aka "Aurelien Jarno <aurel32@debian.org>"
# Primary key fingerprint: 7746 2642 A9EF 94FD 0F77  196D BA9C 7806 1DDD 8C9B

* aurel32/tags/pull-tcg-mips-20170506:
  tcg/mips: fix field extraction opcode

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'bonzini/tags/for-upstream' into staging
Stefan Hajnoczi [Mon, 8 May 2017 17:29:40 +0000 (13:29 -0400)] 
Merge remote-tracking branch 'bonzini/tags/for-upstream' into staging

A large set of small patches.  I have not included yet vhost-user-scsi,
but it'll come in the next pull request.

* use GDB XML register description for x86
* use _Static_assert in QEMU_BUILD_BUG_ON
* add "R:" to MAINTAINERS and get_maintainers
* checkpatch improvements
* dump threading fixes
* first part of vhost-user-scsi support
* QemuMutex tracing
* vmw_pvscsi and megasas fixes
* sgabios module update
* use Rev3 (ACPI 2.0) FADT
* deprecate -hdachs
* improve -accel documentation
* hax fix
* qemu-char GSource bugfix

# gpg: Signature made Fri 05 May 2017 06:10:40 AM EDT
# gpg:                using RSA key 0xBFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>"
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* bonzini/tags/for-upstream: (21 commits)
  vhost-scsi: create a vhost-scsi-common abstraction
  libvhost-user: replace vasprintf() to fix build
  get_maintainer: add subsystem to reviewer output
  get_maintainer: --r (list reviewer) is on by default
  get_maintainer: it's '--pattern-depth', not '-pattern-depth'
  get_maintainer: Teach get_maintainer.pl about the new "R:" tag
  MAINTAINERS: Add "R:" tag for self-appointed reviewers
  Fix the -accel parameter and the documentation for 'hax'
  dump: Acquire BQL around vm_start() in dump thread
  hax: Fix memory mapping de-duplication logic
  checkpatch: Disallow glib asserts in main code
  trace: add qemu mutex lock and unlock trace events
  vmw_pvscsi: check message ring page count at initialisation
  sgabios: update for "fix wrong video attrs for int 10h,ah==13h"
  scsi: avoid an off-by-one error in megasas_mmio_write
  vl: deprecate the "-hdachs" option
  use _Static_assert in QEMU_BUILD_BUG_ON
  target/i386: Add GDB XML register description support
  char: Fix removing wrong GSource that be found by fd_in_tag
  hw/i386: Build-time assertion on pc/q35 reset register being identical.
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'mcayland/tags/qemu-sparc-signed' into staging
Stefan Hajnoczi [Mon, 8 May 2017 16:43:15 +0000 (12:43 -0400)] 
Merge remote-tracking branch 'mcayland/tags/qemu-sparc-signed' into staging

qemu-sparc update

# gpg: Signature made Fri 05 May 2017 04:51:46 AM EDT
# gpg:                using RSA key 0x5BC2C56FAE0F321F
# gpg: Good signature from "Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>"
# Primary key fingerprint: CC62 1AB9 8E82 200D 915C  C9C4 5BC2 C56F AE0F 321F

* mcayland/tags/qemu-sparc-signed:
  cg3: add explicit ram_addr_t cast to scanline page variable
  tcx: fix cut/paste error in update_palette_entries()

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agomaintainers: add maintainer for replay* files
Pavel Dovgalyuk [Wed, 3 May 2017 11:33:04 +0000 (14:33 +0300)] 
maintainers: add maintainer for replay* files

Updating MAINTAINERS to set Pavel Dovgalyuk as record/replay maintainer
and Paolo Bonzini as a reviewer.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Message-id: 20170503113304.8704.13997.stgit@PASHA-ISP
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge tag 'tracing-pull-request' into staging
Stefan Hajnoczi [Mon, 8 May 2017 13:39:48 +0000 (09:39 -0400)] 
Merge tag 'tracing-pull-request' into staging

# gpg: Signature made Mon 08 May 2017 09:39:00 AM EDT
# gpg:                using RSA key 0x9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* tag 'tracing-pull-request':
  trace: disallow more than 10 arguments per trace event

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agotrace: disallow more than 10 arguments per trace event
Daniel P. Berrange [Wed, 26 Apr 2017 15:39:00 +0000 (16:39 +0100)] 
trace: disallow more than 10 arguments per trace event

The UST trace backend can only cope with upto 10 arguments. To ensure we
don't exceed the limit when UST is not compiled in, disallow more than
10 arguments upfront.

This prevents the case where:

  commit 0fc8aec7de64f2bf83a274a2a38b938ce03425d2
  Author: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
  Date:   Tue Apr 18 10:20:20 2017 +0800

    COLO-compare: Optimize tcp compare trace event

    Optimize two trace events as one, adjust print format make
    it easy to read. rename trace_colo_compare_pkt_info_src/dst
    to trace_colo_compare_tcp_info.

regressed the fix done in

  commit 2dfe5113b11ce0ddb08176ebb54ab7ac4104b413
  Author: Alex Bennée <alex.bennee@linaro.org>
  Date:   Fri Oct 28 14:25:59 2016 +0100

    net: split colo_compare_pkt_info into two trace events

    It seems there is a limit to the number of arguments a UST trace event
    can take and at 11 the previous trace command broke the build. Split the
    trace into a src pkt and dst pkt trace to fix this.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
    Message-id: 20161028132559.8324-1-alex.bennee@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Now we get an immediate fail even when UST is disabled:

  GEN     net/trace.h
Traceback (most recent call last):
  File "/home/berrange/src/virt/qemu/scripts/tracetool.py", line 154, in <module>
    main(sys.argv)
  File "/home/berrange/src/virt/qemu/scripts/tracetool.py", line 145, in main
    events.extend(tracetool.read_events(fh))
  File "/home/berrange/src/virt/qemu/scripts/tracetool/__init__.py", line 307, in read_events
    event = Event.build(line)
  File "/home/berrange/src/virt/qemu/scripts/tracetool/__init__.py", line 244, in build
    event = Event(name, props, fmt, args)
  File "/home/berrange/src/virt/qemu/scripts/tracetool/__init__.py", line 196, in __init__
    "argument count" % name)
ValueError: Event 'colo_compare_tcp_info' has more than maximum permitted argument count
Makefile:96: recipe for target 'net/trace.h-timestamp' failed

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 20170426153900.21066-1-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agogdbstub: implement remote debugging protocol escapes for command receive
Doug Gale [Mon, 1 May 2017 16:22:10 +0000 (12:22 -0400)] 
gdbstub: implement remote debugging protocol escapes for command receive

- decode escape sequences
- decompress run-length encoding escape sequences
- report command parsing problems to output when debug output is enabled
- reject packet checksums that are not valid hex digits
- compute the checksum based on the packet stream, not based on the
  decoded packet

Tested with GDB and QtCreator integrated debugger on SMP QEMU instance.
Works for me.

Signed-off-by: Doug Gale <doug16k@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agotcg/mips: fix field extraction opcode
Aurelien Jarno [Sun, 30 Apr 2017 14:46:20 +0000 (16:46 +0200)] 
tcg/mips: fix field extraction opcode

The "msb" argument should correspond to (len - 1).

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
7 years agoMerge remote-tracking branch 'elmarco/tags/chr-tests-pull-request' into staging
Stefan Hajnoczi [Fri, 5 May 2017 16:04:07 +0000 (17:04 +0100)] 
Merge remote-tracking branch 'elmarco/tags/chr-tests-pull-request' into staging

# gpg: Signature made Thu 04 May 2017 12:42:10 PM BST
# gpg:                using RSA key 0xDAE8E10975969CE5
# gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>"
# gpg:                 aka "Marc-André Lureau <marcandre.lureau@gmail.com>"
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* elmarco/tags/chr-tests-pull-request: (21 commits)
  tests: add /char/console test
  tests: add /char/udp test
  tests: add /char/socket test
  tests: add /char/file test
  tests: add /char/pipe test
  tests: add alias check in /char/ringbuf
  char-udp: flush as much buffer as possible
  char-socket: add 'connected' property
  char-socket: add 'addr' property
  char-socket: update local address after listen
  char-socket: introduce update_disconnected_filename()
  char: useless NULL check
  char: remove chardevs list
  char: remove qemu_chardev_add
  char: use /chardevs container instead of chardevs list
  vl: add todo note about root container cleanup
  char: add a /chardevs container
  container: don't leak container reference
  xen: use a better chardev type check
  mux: simplfy muxes_realize_done
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'cohuck/tags/s390x-3270-20170504' into staging
Stefan Hajnoczi [Fri, 5 May 2017 15:56:23 +0000 (16:56 +0100)] 
Merge remote-tracking branch 'cohuck/tags/s390x-3270-20170504' into staging

Basic support for using channel-attached 3270 'green-screen'
devices via tn3270. Actual handling of the data stream is
delegated to x3270; more info at http://wiki.qemu.org/Features/3270

# gpg: Signature made Thu 04 May 2017 11:36:51 AM BST
# gpg:                using RSA key 0xDECF6B93C6F02FAF
# gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>"
# gpg:                 aka "Cornelia Huck <cohuck@kernel.org>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"
# gpg:                 aka "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* cohuck/tags/s390x-3270-20170504:
  s390x/3270: Mark non-migratable and enable the device
  s390x/3270: Detect for continued presence of a 3270 client
  s390x/3270: Add the TCP socket events handler for 3270
  s390x/3270: 3270 data stream handling
  s390x/3270: Add emulated terminal3270 device
  s390x/3270: Add abstract emulated ccw-attached 3270 device
  s390x/css: Add an algorithm to find a free chpid
  chardev: Basic support for TN3270

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'quintela/tags/migration/20170504' into staging
Stefan Hajnoczi [Fri, 5 May 2017 15:52:12 +0000 (16:52 +0100)] 
Merge remote-tracking branch 'quintela/tags/migration/20170504' into staging

migration/next for 20170504

# gpg: Signature made Thu 04 May 2017 10:35:41 AM BST
# gpg:                using RSA key 0xF487EF185872D723
# gpg: Good signature from "Juan Quintela <quintela@redhat.com>"
# gpg:                 aka "Juan Quintela <quintela@trasno.org>"
# Primary key fingerprint: 1899 FF8E DEBF 58CC EE03  4B82 F487 EF18 5872 D723

* quintela/tags/migration/20170504:
  migration: Extra tracing
  migration: Move postcopy-ram.h to migration/
  monitor: Move hmp_info_snapshots from savevm.c to hmp.c
  monitor: Move hmp_delvm from savevm.c to hmp.c
  monitor: Move hmp_savevm from savevm.c to hmp.c
  monitor: Move hmp_loadvm from monitor.c to hmp.c
  monitor: Remove monitor parameter from save_vmstate
  migration: to_dst_file at that point is NULL
  migration: setup bi-directional I/O channel for exec: protocol
  ram: Split dirty bitmap by RAMBlock

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'kraxel/tags/pull-audio-20170504-1' into staging
Stefan Hajnoczi [Fri, 5 May 2017 15:46:51 +0000 (16:46 +0100)] 
Merge remote-tracking branch 'kraxel/tags/pull-audio-20170504-1' into staging

audio: cleanups, bugfixes (memory leaks).

# gpg: Signature made Thu 04 May 2017 08:16:50 AM BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* kraxel/tags/pull-audio-20170504-1: (30 commits)
  audio: Use ARRAY_SIZE from qemu/osdep.h
  audio: un-export OPLResetChip
  audio: Remove unused typedefs
  audio: UpdateHandler is not used anymore
  audio: IRQHandler is not used anymore
  audio: OPLSetUpdateHandler is not used anywhere
  audio: OPLSetIRQHandler is not used anywhere
  audio: GUSsample is int16_t
  audio: GUSword is uint16_t
  audio: GUSword is uint16_t
  audio: remove GUSchar
  audio: GUSbyte is uint8_t
  audio: Remove unused fields
  audio: Remove type field
  audio: Remove Unused OPL_TYPE_*
  audio: Unfold OPLSAMPLE
  audio: Remove INT32
  audio: remove INT16
  audio: Remove INT8
  audio: remove UINT32
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'kraxel/tags/pull-input-20170504-1' into staging
Stefan Hajnoczi [Fri, 5 May 2017 15:30:59 +0000 (16:30 +0100)] 
Merge remote-tracking branch 'kraxel/tags/pull-input-20170504-1' into staging

input: limit kbd queue depth
input: don't queue delay if paused
input: Add trace event for empty keyboard queue

# gpg: Signature made Thu 04 May 2017 06:48:37 AM BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* kraxel/tags/pull-input-20170504-1:
  input: Add trace event for empty keyboard queue
  input: don't queue delay if paused
  input: limit kbd queue depth

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'shorne/tags/pull-or-20170504' into staging
Stefan Hajnoczi [Fri, 5 May 2017 15:21:00 +0000 (16:21 +0100)] 
Merge remote-tracking branch 'shorne/tags/pull-or-20170504' into staging

Openrisc Features and Fixes for qemu 2.10

# gpg: Signature made Thu 04 May 2017 01:41:45 AM BST
# gpg:                using RSA key 0xC3B31C2D5E6627E4
# gpg: Good signature from "Stafford Horne <shorne@gmail.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: D9C4 7354 AEF8 6C10 3A25  EFF1 C3B3 1C2D 5E66 27E4

* shorne/tags/pull-or-20170504:
  target/openrisc: Support non-busy idle state using PMR SPR
  target/openrisc: Remove duplicate features property
  target/openrisc: Implement full vmstate serialization
  migration: Add VMSTATE_STRUCT_2DARRAY()
  target/openrisc: implement shadow registers
  migration: Add VMSTATE_UINTTL_2DARRAY()
  target/openrisc: add numcores and coreid support
  target/openrisc: Fixes for memory debugging
  target/openrisc: Implement EPH bit
  target/openrisc: Implement EVBAR register
  MAINTAINERS: Add myself as openrisc maintainer

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'awilliam/tags/vfio-updates-20170503.0' into staging
Stefan Hajnoczi [Fri, 5 May 2017 15:14:08 +0000 (16:14 +0100)] 
Merge remote-tracking branch 'awilliam/tags/vfio-updates-20170503.0' into staging

VFIO fixes 2017-05-03

 - Enable 8-byte memory region accesses (Jose Ricardo Ziviani)
 - Fix vfio-pci error message (Dong Jia Shi)

# gpg: Signature made Wed 03 May 2017 10:28:55 PM BST
# gpg:                using RSA key 0x239B9B6E3BB08B22
# gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>"
# gpg:                 aka "Alex Williamson <alex@shazbot.org>"
# gpg:                 aka "Alex Williamson <alwillia@redhat.com>"
# gpg:                 aka "Alex Williamson <alex.l.williamson@gmail.com>"
# Primary key fingerprint: 42F6 C04E 540B D1A9 9E7B  8A90 239B 9B6E 3BB0 8B22

* awilliam/tags/vfio-updates-20170503.0:
  vfio/pci: Fix incorrect error message
  vfio: enable 8-byte reads/writes to vfio
  vfio: Set MemoryRegionOps:max_access_size and min_access_size

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'cohuck/tags/s390x-20170502' into staging
Stefan Hajnoczi [Fri, 5 May 2017 14:59:56 +0000 (15:59 +0100)] 
Merge remote-tracking branch 'cohuck/tags/s390x-20170502' into staging

More s390x patches, this time boot related:
- LOADPARM machine property, exposed to the guest via SCLP and
  diagnose 308
- Use LOADPARM in the s390-ccw bios to select a boot entry
- Fix a crash in the ipl device code when a virtio-scsi-pci device
  has been specified

# gpg: Signature made Tue 02 May 2017 02:29:26 PM BST
# gpg:                using RSA key 0xDECF6B93C6F02FAF
# gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>"
# gpg:                 aka "Cornelia Huck <cohuck@kernel.org>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"
# gpg:                 aka "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* cohuck/tags/s390x-20170502:
  hw/s390x/ipl: Fix crash with virtio-scsi-pci device
  pc-bios/s390-ccw.img: update image
  pc-bios/s390-ccw: add boot entry selection to El Torito routine
  pc-bios/s390-ccw: add boot entry selection for ECKD DASD
  pc-bios/s390-ccw: provide entry selection on LOADPARM for SCSI disk
  pc-bios/s390-ccw: provide a function to interpret LOADPARM value
  pc-bios/s390-ccw: get LOADPARM stored in SCP Read Info
  pc-bios/s390-ccw: Make ebcdic/ascii conversion public
  util/qemu-config: Add loadparm to qemu machine_opts
  hw/s390x/sclp: update LOADPARM in SCP Info
  hw/s390x/ipl: enable LOADPARM in IPIB for a boot device
  hw/s390x: provide loadparm property for the machine

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agovhost-scsi: create a vhost-scsi-common abstraction
Felipe Franciosi [Thu, 2 Mar 2017 18:25:51 +0000 (10:25 -0800)] 
vhost-scsi: create a vhost-scsi-common abstraction

In order to introduce a new vhost-user-scsi host device type, it makes
sense to abstract part of vhost-scsi into a common parent class. This
commit does exactly that.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
Message-Id: <1488479153-21203-3-git-send-email-felipe@nutanix.com>

7 years agolibvhost-user: replace vasprintf() to fix build
Felipe Franciosi [Thu, 2 Mar 2017 18:25:50 +0000 (10:25 -0800)] 
libvhost-user: replace vasprintf() to fix build

On gcc 3.4 and newer, simply using (void) in front of WUR functions is
not sufficient to ignore the return value. That prevents a build when
handling warnings as errors.

libvhost-user had a usage of (void)vasprintf() which triggered such a
condition. This fixes it by replacing this call with g_strdup_vprintf()
which aborts on OOM.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
Message-Id: <1488479153-21203-2-git-send-email-felipe@nutanix.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoget_maintainer: add subsystem to reviewer output
Joe Perches [Sat, 7 Nov 2015 00:30:52 +0000 (16:30 -0800)] 
get_maintainer: add subsystem to reviewer output

Reviewer output currently does not include the subsystem
that matched.  Add it.

Miscellanea:

o Add a get_subsystem_name routine to centralize this

Cherry picked from Linux commit 2a7cb1dc82fc2a52e747b4c496c13f6575fb1790.

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoget_maintainer: --r (list reviewer) is on by default
Brian Norris [Sat, 7 Nov 2015 00:30:49 +0000 (16:30 -0800)] 
get_maintainer: --r (list reviewer) is on by default

We don't consistenly document the default value next to the option
listing, but we do have a list of defaults here, so let's keep it up to
date.

Cherry picked from Linux commit 4f07510df2e8c47fd65b8ffaaf6c5d334d59d598.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoget_maintainer: it's '--pattern-depth', not '-pattern-depth'
Brian Norris [Wed, 3 May 2017 09:16:44 +0000 (11:16 +0200)] 
get_maintainer: it's '--pattern-depth', not '-pattern-depth'

Though it appears that Perl's GetOptions will take either, the latter is
not documented in the options listing.

Cherry picked from Linux commit cc7ff0ef6eca3deeea4a424ca47a67c8450d5424.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoget_maintainer: Teach get_maintainer.pl about the new "R:" tag
Joe Perches [Mon, 2 Jun 2014 19:05:17 +0000 (12:05 -0700)] 
get_maintainer: Teach get_maintainer.pl about the new "R:" tag

We can now designate reviewers in the MAINTAINERS file with the new
"R:" tag, so this commit teaches get_maintainers.pl to add their
email addresses.

Cherry picked from Linux commit c1c3f2c906e35bcb6e4cdf5b8e077660fead14fe,
with fixes to avoid \C as in QEMU commit ba10f729f1 ("get_maintainer.pl:
\C is deprecated", 2015-09-25).

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoMAINTAINERS: Add "R:" tag for self-appointed reviewers
Paul E. McKenney [Mon, 2 Jun 2014 16:06:37 +0000 (09:06 -0700)] 
MAINTAINERS: Add "R:" tag for self-appointed reviewers

Some people are not content with the amount of mail they get, and would
like to be CCed on patches for areas they do not maintain.  Let them
satisfy their own appetite for qemu-devel messages.

Seriously: the purpose here is a bit different from the Linux kernel.
While Linux uses "R" to designate non-maintainers for reviewing patches
in a given area, in QEMU I would also like to use "R" so that people can
delegate sending pull requests while keeping some degree of oversight.

Based on Linux commit eafbaac3093760d1fd3b2a5b9f016362dd68af36.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoFix the -accel parameter and the documentation for 'hax'
Thomas Huth [Thu, 4 May 2017 05:24:41 +0000 (07:24 +0200)] 
Fix the -accel parameter and the documentation for 'hax'

Since 'hax' is a possible accelerator nowadays, too, the '-accel'
option should support it and we should mention this accelerator
in the documentation, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1493875481-16388-1-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agodump: Acquire BQL around vm_start() in dump thread
Fam Zheng [Wed, 3 May 2017 07:28:19 +0000 (15:28 +0800)] 
dump: Acquire BQL around vm_start() in dump thread

This fixes an assertion failure in the following backtrace:

    __GI___assert_fail
    memory_region_transaction_commit
    memory_region_add_eventfd
    virtio_pci_ioeventfd_assign
    virtio_bus_set_host_notifier
    virtio_blk_data_plane_start
    virtio_bus_start_ioeventfd
    virtio_vmstate_change
    vm_state_notify
    vm_prepare_start
    vm_start
    dump_cleanup
    dump_process
    dump_thread
    start_thread
    clone

vm_start need BQL, acquire it if doing cleaning up from main thread.

Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170503072819.14462-1-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agohax: Fix memory mapping de-duplication logic
Yu Ning [Fri, 28 Apr 2017 07:27:23 +0000 (15:27 +0800)] 
hax: Fix memory mapping de-duplication logic

hax_update_mapping() avoids unnecessary and potentially expensive
calls to HAX_VM_IOCTL_SET_RAM by computing the net result (i.e.
effective mapping changes) of each MemoryRegion transaction, with
the help of a linked list of HAXMapping objects.

However, when processing a new mapping that overlaps with an
existing mapping in the list, it fails to handle the case where the
start address of the new mapping is above that of the existing
mapping in the guest physical address space. This happens when QEMU
is launched with "-machine q35 -enable-hax", which involves the
following MemoryRegion transaction for digging the VGA hole:

 region_del: 0x00000000->0x08000000 VA 05fa0000 ('pc.ram')
 region_add: 0x00000000->0x000a0000 VA 05fa0000 ('pc.ram')
 region_add: 0x000a0000->0x000c0000 VA 00000000 ('vga-lowmem')
 region_add: 0x000c0000->0x08000000 VA 06060000 ('pc.ram')

where the third MemoryRegion is MMIO and is ignored. The current
de-duplication logic handles the last MemoryRegion incorrectly and
produces the following result:

 hax_mapping_dump_list updates:
         + 0x000c0000->0x08000000 VA 0x06060000
         - 0x07fe0000->0x08000000 VA 0x0df80000

which is why VGA emulation does not work for Q35.

With this patch, one can see VGA output as Q35 boots up. Note that
Q35 support also requires a change to HAXM kernel module, which is
not available in the current HAXM release (6.1.2).

+ Add a warning if the input MemoryRegion is a ROM device, which is
  not supported by HAXM kernel module at this time.

Signed-off-by: Yu Ning <yu.ning@linux.intel.com>
Message-Id: <20170428072723.7036-1-yu.ning@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agocheckpatch: Disallow glib asserts in main code
Dr. David Alan Gilbert [Thu, 27 Apr 2017 16:55:26 +0000 (17:55 +0100)] 
checkpatch: Disallow glib asserts in main code

Glib commit a6a875068779 (from 2013) made many of the glib assert
macros non-fatal if a flag is set.
This causes two problems:
  a) Compilers moan that your code is unsafe even though you've
     put an assert in before the point of use.
  b) Someone evil could, in a library, call
     g_test_set_nonfatal_assertions() and cause our assertions in
     important places not to fail and potentially allow memory overruns.

Ban most of the glib assertion functions (basically everything except
g_assert and g_assert_not_reached) except in tests/

This makes checkpatch gives an error such as:

  ERROR: Use g_assert or g_assert_not_reached
  #77: FILE: vl.c:4725:
  +    g_assert_cmpstr("Chocolate", >, "Cheese");

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20170427165526.19836-1-dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agotrace: add qemu mutex lock and unlock trace events
Jose Ricardo Ziviani [Mon, 24 Apr 2017 17:19:58 +0000 (14:19 -0300)] 
trace: add qemu mutex lock and unlock trace events

These trace events were very useful to help me to understand and find a
reordering issue in vfio, for example:

qemu_mutex_lock locked mutex 0x10905ad8
  vfio_region_write  (0001:03:00.0:region1+0xc0, 0x2020c, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
qemu_mutex_lock locked mutex 0x10905ad8
  vfio_region_write  (0001:03:00.0:region1+0xc4, 0xa0000, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8

that also helped me to see the desired result after the fix:

qemu_mutex_lock locked mutex 0x10905ad8
  vfio_region_write  (0001:03:00.0:region1+0xc0, 0x2000c, 4)
  vfio_region_write  (0001:03:00.0:region1+0xc4, 0xb0000, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8

So it could be a good idea to have these traces implemented. It's worth
mentioning that they should be surgically enabled during the debugging,
otherwise it can flood the trace logs with lock/unlock messages.

How to use it:
trace-event qemu_mutex_lock on|off
trace-event qemu_mutex_unlock on|off
or
trace-event qemu_mutex* on|off

Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Message-Id: <1493054398-26013-1-git-send-email-joserz@linux.vnet.ibm.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
[Also handle trylock, cond_wait and win32; trace "unlocked" while still
 in the critical section, so that "unlocked" always comes before the
 next "locked" tracepoint. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agovmw_pvscsi: check message ring page count at initialisation
P J P [Tue, 25 Apr 2017 13:06:23 +0000 (18:36 +0530)] 
vmw_pvscsi: check message ring page count at initialisation

A guest could set the message ring page count to zero, resulting in
infinite loop. Add check to avoid it.

Reported-by: YY Z <bigbird475958471@gmail.com>
Signed-off-by: P J P <ppandit@redhat.com>
Message-Id: <20170425130623.3649-1-ppandit@redhat.com>
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agosgabios: update for "fix wrong video attrs for int 10h,ah==13h"
Paolo Bonzini [Thu, 27 Apr 2017 08:39:14 +0000 (10:39 +0200)] 
sgabios: update for "fix wrong video attrs for int 10h,ah==13h"

Update the submodule and rebuild the binary.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoscsi: avoid an off-by-one error in megasas_mmio_write
Prasad J Pandit [Mon, 24 Apr 2017 12:06:34 +0000 (17:36 +0530)] 
scsi: avoid an off-by-one error in megasas_mmio_write

While reading magic sequence(MFI_SEQ) in megasas_mmio_write,
an off-by-one error could occur as 's->adp_reset' index is not
reset after reading the last sequence.

Reported-by: YY Z <bigbird475958471@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Message-Id: <20170424120634.12268-1-ppandit@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agovl: deprecate the "-hdachs" option
Thomas Huth [Thu, 27 Apr 2017 05:20:54 +0000 (07:20 +0200)] 
vl: deprecate the "-hdachs" option

If the user needs to specify the disk geometry, the corresponding
parameters of the "-device ide-hd" option should be used instead.
"-hdachs" is considered as deprecated and might be removed soon.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1493270454-1448-1-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agouse _Static_assert in QEMU_BUILD_BUG_ON
Andreas Grapentin [Tue, 14 Mar 2017 16:59:53 +0000 (17:59 +0100)] 
use _Static_assert in QEMU_BUILD_BUG_ON

QEMU_BUILD_BUG_ON should use C11's _Static_assert, if the compiler supports it,
to provide more readable messages on failure.

We check for _Static_assert in configure, and set CONFIG_STATIC_ASSERT
accordingly. QEMU_BUILD_BUG_ON invokes _Static_assert if CONFIG_STATIC_ASSERT
is defined, and reverts to the old way otherwise.

That way, systems without C11 conforming compiler will still have the old
messages, as verified by intentionally breaking the configure check.

the following example output was generated by inverting the condition in
QEMU_BUILD_BUG_ON:

without _Static_assert:

> In file included from /qemu/include/qemu/osdep.h:36:0,
>                  from /qemu/qga/commands.c:13:
> /qemu/qga/commands.c: In function â€˜qmp_guest_exec_status’:
> /qemu/include/qemu/compiler.h:89:12: error: negative width in bit-field â€˜<anonymous>’
>      struct { \
>             ^
> /qemu/include/qemu/compiler.h:96:38: note: in expansion of macro  QEMU_BUILD_BUG_ON_STRUCT’
>  #define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
>                                       ^~~~~~~~~~~~~~~~~~~~~~~~
> /qemu/include/qemu/atomic.h:146:5: note: in expansion of macro â€˜QEMU_BUILD_BUG_ON’
>      QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *));   \
>      ^~~~~~~~~~~~~~~~~
> /qemu/include/qemu/atomic.h:417:5: note: in expansion of macro â€˜atomic_load_acquire’
>      atomic_load_acquire(ptr)
>      ^~~~~~~~~~~~~~~~~~~
> /qemu/qga/commands.c:160:21: note: in expansion of macro â€˜atomic_mb_read’
>      bool finished = atomic_mb_read(&gei->finished);
>                      ^~~~~~~~~~~~~~

with _Static_assert:

> In file included from /qemu/include/qemu/osdep.h:36:0,
>                  from /qemu/qga/commands.c:13:
> /qemu/qga/commands.c: In function â€˜qmp_guest_exec_status’:
> /qemu/include/qemu/compiler.h:94:30: error: static assertion failed: "not expecting: sizeof(*&gei->finished) > sizeof(void *)"
>  #define QEMU_BUILD_BUG_ON(x) _Static_assert((x), #x)
>                               ^
> /qemu/include/qemu/atomic.h:146:5: note: in expansion of macro â€˜QEMU_BUILD_BUG_ON’
>      QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *));   \
>      ^~~~~~~~~~~~~~~~~
> /qemu/include/qemu/atomic.h:417:5: note: in expansion of macro â€˜atomic_load_acquire’
>      atomic_load_acquire(ptr)
>      ^~~~~~~~~~~~~~~~~~~
> /qemu/qga/commands.c:160:21: note: in expansion of macro â€˜atomic_mb_read’
>      bool finished = atomic_mb_read(&gei->finished);
>                      ^~~~~~~~~~~~~~

Signed-off-by: Andreas Grapentin <andreas@grapentin.org>
Message-Id: <20170314165953.18506-1-andreas@grapentin.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>