]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
7 years agoMerge remote-tracking branch 'sthibault/tags/samuel-thibault' into staging
Stefan Hajnoczi [Tue, 15 Nov 2016 11:50:04 +0000 (11:50 +0000)]
Merge remote-tracking branch 'sthibault/tags/samuel-thibault' into staging

slirp updates

# gpg: Signature made Mon 14 Nov 2016 08:19:16 PM GMT
# gpg:                using RSA key 0xA003196827414880
# gpg: Good signature from "Samuel Thibault <samuel.thibault@u-bordeaux.fr>"
# gpg:                 aka "Samuel Thibault <sthibault@debian.org>"
# gpg:                 aka "Samuel Thibault <samuel.thibault@gnu.org>"
# gpg:                 aka "Samuel Thibault <samuel.thibault@inria.fr>"
# gpg:                 aka "Samuel Thibault <samuel.thibault@labri.fr>"
# gpg:                 aka "Samuel Thibault <samuel.thibault@ens-lyon.org>"
# Primary key fingerprint: 900C B024 B679 31D4 0F82  304B D017 8C76 7D06 9EE6
#      Subkey fingerprint: 6B0F AC21 8566 46E9 4AA2  D200 A003 1968 2741 4880

* sthibault/tags/samuel-thibault:
  slirp: Fix access to freed memory

Message-id: 20161114202030.17685-1-samuel.thibault@ens-lyon.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'quintela/tags/migration/20161114' into staging
Stefan Hajnoczi [Tue, 15 Nov 2016 11:49:46 +0000 (11:49 +0000)]
Merge remote-tracking branch 'quintela/tags/migration/20161114' into staging

migration/next for 20161114

# gpg: Signature made Mon 14 Nov 2016 07:55:42 PM GMT
# 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/20161114:
  migration: Fix return code of ram_save_iterate()
  tests/test-vmstate.c: add array of pointer to struct
  tests/test-vmstate.c: add save_buffer util func
  migration: fix missing assignment for has_x_checkpoint_delay

Message-id: 1479153474-2401-1-git-send-email-quintela@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agomigration: Fix return code of ram_save_iterate()
Thomas Huth [Fri, 4 Nov 2016 13:10:17 +0000 (14:10 +0100)]
migration: Fix return code of ram_save_iterate()

qemu_savevm_state_iterate() expects the iterators to return 1
when they are done, and 0 if there is still something left to do.
However, ram_save_iterate() does not obey this rule and returns
the number of saved pages instead. This causes a fatal hang with
ppc64 guests when you run QEMU like this (also works with TCG):

 qemu-img create -f qcow2  /tmp/test.qcow2 1M
 qemu-system-ppc64 -nographic -nodefaults -m 256 \
                   -hda /tmp/test.qcow2 -serial mon:stdio

... then switch to the monitor by pressing CTRL-a c and try to
save a snapshot with "savevm test1" for example.

After the first iteration, ram_save_iterate() always returns 0 here,
so that qemu_savevm_state_iterate() hangs in an endless loop and you
can only "kill -9" the QEMU process.
Fix it by using proper return values in ram_save_iterate().

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agoMerge remote-tracking branch 'jsnow/tags/ide-pull-request' into staging
Stefan Hajnoczi [Mon, 14 Nov 2016 17:07:15 +0000 (17:07 +0000)]
Merge remote-tracking branch 'jsnow/tags/ide-pull-request' into staging

# gpg: Signature made Mon 14 Nov 2016 04:16:48 PM GMT
# gpg:                using RSA key 0x7DEF8106AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>"
# Primary key fingerprint: FAEB 9711 A12C F475 812F  18F2 88A9 064D 1835 61EB
#      Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76  CBD0 7DEF 8106 AAFC 390E

* jsnow/tags/ide-pull-request:
  ahci-test: add QMP tray test for ATAPI
  libqos/ahci: Add get_sense and test_ready
  libqos/ahci: Add ATAPI tray macros
  libqos/ahci: Support expected errors
  libqtest: add qmp_eventwait_ref
  block-backend: Always notify on blk_eject
  ahci-test: test atapi read_cd with bcl, nb_sectors = 0
  ahci-test: Create smaller test ISO images
  atapi: classify read_cd as conditionally returning data

Message-id: 1479140746-22142-1-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoslirp: Fix access to freed memory
Samuel Thibault [Sun, 13 Nov 2016 22:54:27 +0000 (23:54 +0100)]
slirp: Fix access to freed memory

if_start() goes through the slirp->if_fastq and slirp->if_batchq
list of pending messages, and accesses ifm->ifq_so->so_nqueued of its
elements if ifm->ifq_so != NULL.  When freeing a socket, we thus need
to make sure that any pending message for this socket does not refer
to the socket any more.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Tested-by: Brian Candler <b.candler@pobox.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoahci-test: add QMP tray test for ATAPI
John Snow [Mon, 14 Nov 2016 16:15:55 +0000 (11:15 -0500)]
ahci-test: add QMP tray test for ATAPI

Test QMP events for a CDROM device with or without a media inserted,
including both guest-initiated and hw-initiated eject/load requests.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1478553214-497-7-git-send-email-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
7 years agolibqos/ahci: Add get_sense and test_ready
John Snow [Mon, 14 Nov 2016 16:15:55 +0000 (11:15 -0500)]
libqos/ahci: Add get_sense and test_ready

Required for tray tests once a medium may have changed.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1478553214-497-6-git-send-email-jsnow@redhat.com
[Line length edit --js]
Signed-off-by: John Snow <jsnow@redhat.com>
7 years agolibqos/ahci: Add ATAPI tray macros
John Snow [Mon, 14 Nov 2016 16:15:55 +0000 (11:15 -0500)]
libqos/ahci: Add ATAPI tray macros

(1) Add START_STOP_UNIT command to ahci-test suite
(2) Add eject/start macro commands; this is not a data transfer
    command so it is not well-served by the existing generic pipeline.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1478553214-497-5-git-send-email-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
7 years agolibqos/ahci: Support expected errors
John Snow [Mon, 14 Nov 2016 16:15:54 +0000 (11:15 -0500)]
libqos/ahci: Support expected errors

Sometimes we know we'll get back an error, so let's have the
test framework understand that.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1478553214-497-4-git-send-email-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
7 years agolibqtest: add qmp_eventwait_ref
John Snow [Mon, 14 Nov 2016 16:15:54 +0000 (11:15 -0500)]
libqtest: add qmp_eventwait_ref

Wait for an event, but return a copy so we can investigate parameters.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1478553214-497-3-git-send-email-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
7 years agoblock-backend: Always notify on blk_eject
John Snow [Mon, 14 Nov 2016 16:15:54 +0000 (11:15 -0500)]
block-backend: Always notify on blk_eject

blk_eject is only used by scsi-disk and atapi, and in both cases we
only attempt to invoke blk_eject if we have a bona-fide change in
tray state.

The "issue" here is that the tray state does not generate a QMP event
unless there is a medium/BDS attached to the device, so if libvirt et al
are waiting for a tray event to occur from an empty-but-closed drive,
software opening that drive will not emit an event and libvirt will
wait forever.

Change this by modifying blk_eject to always emit an event, instead of
conditionally on a "real" backend eject.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1373264
Reported-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1478553214-497-2-git-send-email-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
7 years agoahci-test: test atapi read_cd with bcl, nb_sectors = 0
John Snow [Mon, 14 Nov 2016 16:15:54 +0000 (11:15 -0500)]
ahci-test: test atapi read_cd with bcl, nb_sectors = 0

Commit 9ef2e93f introduced the concept of tagging ATAPI commands as
NONDATA, but this introduced a regression for certain commands better
described as CONDDATA. read_cd is such a command that both requires
a non-zero BCL if a transfer size is set, but is perfectly content to
accept a zero BCL if the transfer size is 0.

This test adds a regression test for the case where BCL and nb_sectors
are both 0.

Flesh out the CDROM tests by:

(1) Allowing the test to specify a BCL
(2) Allowing the buffer comparison test to compare a 0-size buffer
(3) Fix the BCL specification in libqos (It is LE, not BE)
(4) Add a nice human-readable message for future SCSI command additions

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1477970211-25754-4-git-send-email-jsnow@redhat.com
[Line length edit --js]
Signed-off-by: John Snow <jsnow@redhat.com>
7 years agoahci-test: Create smaller test ISO images
John Snow [Mon, 14 Nov 2016 16:15:54 +0000 (11:15 -0500)]
ahci-test: Create smaller test ISO images

These can simply be the size of the number of sectors we're reading,
plus one for a buffer. We don't need them to be any larger.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1477970211-25754-3-git-send-email-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
7 years agoatapi: classify read_cd as conditionally returning data
John Snow [Mon, 14 Nov 2016 16:15:54 +0000 (11:15 -0500)]
atapi: classify read_cd as conditionally returning data

For the purposes of byte_count_limit verification, add a new flag that
identifies read_cd as sometimes returning data, then check the BCL in
its command handler after we know that it will indeed return data.

Reported-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1477970211-25754-2-git-send-email-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
7 years agoMerge remote-tracking branch 'kwolf/tags/for-upstream' into staging
Stefan Hajnoczi [Mon, 14 Nov 2016 15:42:22 +0000 (15:42 +0000)]
Merge remote-tracking branch 'kwolf/tags/for-upstream' into staging

Block layer patches for 2.8.0-rc0

# gpg: Signature made Fri 11 Nov 2016 03:46:12 PM GMT
# gpg:                using RSA key 0x7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* kwolf/tags/for-upstream:
  raw-posix: Rename 'raw_s' to 'rs'
  iotests: Always use -machine accel=qtest
  iotests: Skip test 162 if there is no SSH support
  block: Emit modules in bdrv_iterate_format()
  block: Fix bdrv_iterate_format() sorting
  nfs: Fix memory leak in nfs_file_create()
  qcow2: Remove stale FIXME comment
  raw_bsd: don't check size alignment when only offset is set
  raw_bsd: move check to prevent overflow
  hmp: Make block_stream set an explicit job ID
  block/ssh: Code cleanup for unused parameter
  block/nbd: Fix the leaked visitor

Message-id: 1478883311-24052-1-git-send-email-kwolf@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'remotes/fam/tags/for-upstream' into staging
Stefan Hajnoczi [Mon, 14 Nov 2016 15:35:57 +0000 (15:35 +0000)]
Merge remote-tracking branch 'remotes/fam/tags/for-upstream' into staging

* remotes/fam/tags/for-upstream:
  test-uuid: fix leak

Message-id: 20161111131818.GC12800@lemon
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agotests/test-vmstate.c: add array of pointer to struct
Halil Pasic [Fri, 21 Oct 2016 14:37:39 +0000 (16:37 +0200)]
tests/test-vmstate.c: add array of pointer to struct

Increase test coverage by adding tests for the macro
VMSTATE_ARRAY_OF_POINTER_TO_STRUCT.

Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Reviewed-by: Guenther Hutzl <hutzl@linux.vnet.ibm.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agotests/test-vmstate.c: add save_buffer util func
Halil Pasic [Fri, 21 Oct 2016 14:37:38 +0000 (16:37 +0200)]
tests/test-vmstate.c: add save_buffer util func

Let us de-duplicate some code by introducing an utility function for
saving a chunk of bytes (used when testing load based on wire).

Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Reviewed-by: Guenther Hutzl <hutzl@linux.vnet.ibm.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agomigration: fix missing assignment for has_x_checkpoint_delay
zhanghailiang [Wed, 2 Nov 2016 07:42:09 +0000 (15:42 +0800)]
migration: fix missing assignment for has_x_checkpoint_delay

We forgot to assign true to params->has_x_checkpoint_delay parameter
in qmp_query_migrate_parameters.

Without this, qmp command 'query-migrate-parameters' doesn't show the
default value for x-checkpoint-delay option.

This also fixes the fact that HMP was relying on unspecified behavior by
reading x_checkpoint_delay without checking has_x_checkpoint_delay.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agoMerge remote-tracking branch 'mreitz/tags/pull-block-2016-11-11' into queue-block
Kevin Wolf [Fri, 11 Nov 2016 14:58:12 +0000 (15:58 +0100)]
Merge remote-tracking branch 'mreitz/tags/pull-block-2016-11-11' into queue-block

Block patches for qemu 2.8

# gpg: Signature made Fri Nov 11 15:56:59 2016 CET
# gpg:                using RSA key 0xF407DB0061D5CF40
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>"
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* mreitz/tags/pull-block-2016-11-11:
  raw-posix: Rename 'raw_s' to 'rs'
  iotests: Always use -machine accel=qtest
  iotests: Skip test 162 if there is no SSH support
  block: Emit modules in bdrv_iterate_format()
  block: Fix bdrv_iterate_format() sorting

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoraw-posix: Rename 'raw_s' to 'rs'
Fam Zheng [Thu, 27 Oct 2016 10:45:17 +0000 (18:45 +0800)]
raw-posix: Rename 'raw_s' to 'rs'

It is too confusing because it sounds like a BDRVRawState variable.

Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-id: 1477565117-17230-1-git-send-email-famz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
7 years agoiotests: Always use -machine accel=qtest
Max Reitz [Mon, 17 Oct 2016 18:39:17 +0000 (20:39 +0200)]
iotests: Always use -machine accel=qtest

Currently, we only use -machine accel=qtest when qemu is invoked through
the common.qemu functions. However, we always want to use it, so move it
from common.qemu directly into QEMU_OPTIONS.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20161017183917.8837-1-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
7 years agoiotests: Skip test 162 if there is no SSH support
Max Reitz [Wed, 12 Oct 2016 20:49:07 +0000 (22:49 +0200)]
iotests: Skip test 162 if there is no SSH support

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20161012204907.25941-4-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
7 years agoblock: Emit modules in bdrv_iterate_format()
Max Reitz [Wed, 12 Oct 2016 20:49:06 +0000 (22:49 +0200)]
block: Emit modules in bdrv_iterate_format()

Some block drivers may not be loaded yet, but qemu supports them
nonetheless. bdrv_iterate_format() should report them, too.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20161012204907.25941-3-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
7 years agoblock: Fix bdrv_iterate_format() sorting
Max Reitz [Wed, 12 Oct 2016 20:49:05 +0000 (22:49 +0200)]
block: Fix bdrv_iterate_format() sorting

bdrv_iterate_format() did not actually sort the formats by name but by
"pointer interpreted as string". That is probably not what we intended
to do, so fix it (by changing qsort_strcmp() so it matches the example
from qsort()'s manual page).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20161012204907.25941-2-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
7 years agonfs: Fix memory leak in nfs_file_create()
Kevin Wolf [Mon, 7 Nov 2016 09:27:51 +0000 (10:27 +0100)]
nfs: Fix memory leak in nfs_file_create()

The leak was introduced in commit 94d6a7a7.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoqcow2: Remove stale FIXME comment
Alberto Garcia [Fri, 4 Nov 2016 15:00:48 +0000 (17:00 +0200)]
qcow2: Remove stale FIXME comment

It was from the time when none of the global functions had a qcow2_
prefix.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoraw_bsd: don't check size alignment when only offset is set
Tomáš Golembiovský [Thu, 3 Nov 2016 13:47:49 +0000 (14:47 +0100)]
raw_bsd: don't check size alignment when only offset is set

We make sure that the size is aligned to sector length to prevent any
round ups. Otherwise we could end up reading/writing data outside the
area specified by user. This is only needed when user supplies the size
option to avoid any surprises. It is not necessary when only offset is
set.

More over, the check made it difficult to use the offset option without
size option. The check puts unneeded restriction on the offset which had
to be aligned too. Because bdrv_getlength() returns aligned value having
unaligned offset would make the check fail.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoraw_bsd: move check to prevent overflow
Tomáš Golembiovský [Thu, 3 Nov 2016 13:47:48 +0000 (14:47 +0100)]
raw_bsd: move check to prevent overflow

When only offset is specified but no size and the offset is greater than
the real size of the containing device an overflow occurs when parsing
the options. This overflow is harmless because we do check for this
exact situation little bit later, but it leads to an error message with
weird values. It is better to do the check is sooner and prevent the
overflow.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agohmp: Make block_stream set an explicit job ID
Alberto Garcia [Fri, 4 Nov 2016 13:44:43 +0000 (15:44 +0200)]
hmp: Make block_stream set an explicit job ID

A job ID is always required in order to create a block job on a
non-root node. The default ID (obtained with bdrv_get_device_name())
is otherwise empty in this scenario and the job cannot be created.

The HMP block_stream command doesn't set a job ID and therefore it
doesn't allow streaming to intermediate nodes. One solution is to add
an extra parameter to set a job ID. The other solution is to simply
use the node name passed to block_stream as job ID. This won't work
if it's automatically generated (because it contains a '#') but is
otherwise simple enough for all other cases.

This way 'block_stream node3' will create a job with the ID 'node3'
and the good old 'block_stream virtio0' will keep the previous
behaviour and use 'virtio0' for the job ID.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblock/ssh: Code cleanup for unused parameter
Ashijeet Acharya [Wed, 2 Nov 2016 10:53:46 +0000 (16:23 +0530)]
block/ssh: Code cleanup for unused parameter

This patch drops the unused parameter "BDRVSSHState" being passed into
the ssh_config() function and does code cleanup. The unused parameter
was introduced by the commit c322712.

Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblock/nbd: Fix the leaked visitor
Ashijeet Acharya [Wed, 2 Nov 2016 10:40:03 +0000 (16:10 +0530)]
block/nbd: Fix the leaked visitor

This patch frees the leaked visitor in nbd_refresh_filename() and uses
visit_free() to fix it. The leak was introduced by the commit 491d6c7.

Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agotest-uuid: fix leak
Marc-André Lureau [Wed, 9 Nov 2016 11:02:10 +0000 (15:02 +0400)]
test-uuid: fix leak

ASAN spotted:
SUMMARY: AddressSanitizer: 74 byte(s) leaked in 2 allocation(s).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20161109110210.25925-1-marcandre.lureau@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
7 years agoMerge remote-tracking branch 'bonzini/tags/for-upstream' into staging
Stefan Hajnoczi [Fri, 11 Nov 2016 12:51:50 +0000 (12:51 +0000)]
Merge remote-tracking branch 'bonzini/tags/for-upstream' into staging

Small fixes for hard freeze.

# gpg: Signature made Thu 10 Nov 2016 03:34:24 PM GMT
# 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:
  nbd: Don't inf-loop on early EOF
  target-i386: document how x86 gdb_num_core_regs is computed.
  qdev: fix use-after-free regression from becdfa00cfa
  target-i386/machine: fix migrate faile because of Hyper-V HV_X64_MSR_VP_RUNTIME
  vl.c: move pidfile creation up the line
  target-i386: fix typo

Message-id: 1478800362-18138-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMAINTAINERS: Remove obsolete stable branches
Thomas Huth [Wed, 9 Nov 2016 18:30:48 +0000 (19:30 +0100)]
MAINTAINERS: Remove obsolete stable branches

There are only very old and orphaned stable branches listed
in the MAINTAINERS file - so this section is pretty useless
nowadays. Let's remove it.

Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
7 years agoMAINTAINERS: Add Fam and Jsnow for Bitmap support
John Snow [Thu, 4 Aug 2016 18:18:51 +0000 (14:18 -0400)]
MAINTAINERS: Add Fam and Jsnow for Bitmap support

These files are currently unmaintained.

I'm proposing that Fam and I co-maintain them; under the model that
whomever between us isn't authoring a given series will be responsible
for reviewing it.

Signed-off-by: John Snow <jsnow@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
Acked-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
7 years agoMAINTAINERS: Add an entry for the CHRP NVRAM files
Thomas Huth [Tue, 8 Nov 2016 11:46:22 +0000 (12:46 +0100)]
MAINTAINERS: Add an entry for the CHRP NVRAM files

I recently added new files to the source tree that are not
covered by any maintainer yet -- and since every new source
file should have a maintainer nowadays, I volunteer to look
after these files now, too.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
7 years agom68k: Update the 68k sections in the MAINTAINERS file
Thomas Huth [Wed, 2 Nov 2016 08:39:33 +0000 (09:39 +0100)]
m68k: Update the 68k sections in the MAINTAINERS file

disas/m68k.c obviously belong to the m68k CPU section in
the MAINTAINERS file, but remove the hw/m68k/ directory
here since it only contains machine (not CPU) related
files, as requested by Laurent. Add the machine related
files to the right machine sections instead.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
7 years agosparc: Add slavio_misc.c and eccmemctl.c to the MAINTAINERS file
Thomas Huth [Fri, 23 Sep 2016 12:27:25 +0000 (14:27 +0200)]
sparc: Add slavio_misc.c and eccmemctl.c to the MAINTAINERS file

Both files seem to belong to the Sun4m machine.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
7 years agoMAINTAINERS: Add some ARM related files to the corresponding sections
Thomas Huth [Fri, 23 Sep 2016 12:14:18 +0000 (14:14 +0200)]
MAINTAINERS: Add some ARM related files to the corresponding sections

The files w/cpu/a*mpcore.c are already assigned to the ARM CPU
section, but the corresponding headers include/hw/cpu/a*mpcore.h
are still missing.

The file hw/*/imx* are already assigned to the i.MX31 machine, but
the corresponding header files include/hw/*/imx* are still missing.

The file hw/misc/arm_integrator_debug.c seems to belong to Integrator
CP, hw/cpu/realview_mpcore.c seems to belong to Real View, and
hw/misc/mst_fpga.c seems to belong to PXA2XX.

And the files hw/misc/zynq* and include/hw/misc/zynq* seem to belong
to the Xilinx Zynq machine.

Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
7 years agoFix cursesw detection
Samuel Thibault [Wed, 9 Nov 2016 10:27:52 +0000 (11:27 +0100)]
Fix cursesw detection

On systems which do not provide ncursesw.pc and whose /usr/include/curses.h
does not include wide support, we should not only try with no -I, i.e.
/usr/include, but also with -I/usr/include/ncursesw.

To properly detect for wide support with and without -Werror, we need to
check for the presence of e.g. the WACS_DEGREE macro.

We also want to stop at the first curses_inc_list configuration which works,
and make sure to set IFS to : at each new loop.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Message-id: 20161109102752.13255-1-samuel.thibault@ens-lyon.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agohw/input/hid: support alternative sysrq/break scancodes for gtk-vnc
Peter Korsgaard [Fri, 28 Oct 2016 14:51:32 +0000 (16:51 +0200)]
hw/input/hid: support alternative sysrq/break scancodes for gtk-vnc

The printscreen/sysrq and pause/break keys currently don't work for guests
using -usbdevice keyboard when accessed through vnc with a gtk-vnc based
client.

The reason for this is a mismatch between gtk-vnc and qemu in how these keys
should be mapped to XT keycodes.

On the original IBM XT these keys behaved differently than other keys.

Quoting from https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html:

The keys PrtSc/SysRq and Pause/Break are special. The former produces
scancode e0 2a e0 37 when no modifier key is pressed simultaneously, e0 37
together with Shift or Ctrl, but 54 together with (left or right) Alt.  (And
one gets the expected sequences upon release.  But see below.) The latter
produces scancode sequence e1 1d 45 e1 9d c5 when pressed (without modifier)
and nothing at all upon release.  However, together with (left or right)
Ctrl, one gets e0 46 e0 c6, and again nothing at release.  It does not
repeat.

Gtk-vnc supports the 'QEMU Extended Key Event Message' RFB extension to send
raw XT keycodes directly to qemu, but the specification doesn't explicitly
specify how to map such long/complicated keycode sequences.  From the spec
(https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#qemu-extended-key-event-message)

The keycode is the XT keycode that produced the keysym. An XT keycode is an
XT make scancode sequence encoded to fit in a single U32 quantity.  Single
byte XT scancodes with a byte value less than 0x7f are encoded as is.
2-byte XT scancodes whose first byte is 0xe0 and second byte is less than
0x7f are encoded with the high bit of the first byte set

hid.c currently expects the keycode sequence with shift/ctl for sysrq (e0 37
-> 0xb7 in RFB), whereas gtk-vnc uses the sequence with alt (0x54).
Likewise, hid.c expects the code without modifiers (e1 1d 45 -> 0xc5 in
RFB), whereas gtk-vnc sends the keycode sequence with ctrl for pause (e0 46
-> 0xc6 in RFB).

See keymaps.cvs in gtk-vnc for the mapping used:
https://git.gnome.org/browse/gtk-vnc/tree/src/keymaps.csv#n150

Now, it isn't obvious to me which sequence is really "right", but as the
0x54/0xc6 keycodes are currently unused in hid.c, supporting both seems like
the pragmatic solution to me.  The USB HID keyboard boot protocol used by
hid.c doesn't have any other mapping applicable to these keys.

The other guest keyboard interfaces (ps/2, virtio, ..) are not affected,
because they handle these keys differently.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Message-id: 20161028145132.1702-1-peter@korsgaard.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agoui/gtk: Fix build with older versions of gtk
Thomas Huth [Wed, 2 Nov 2016 10:08:48 +0000 (11:08 +0100)]
ui/gtk: Fix build with older versions of gtk

GDK_KEY_Delete is only defined with gtk version 2.22 and newer,
on older versions this key was called GDK_Delete instead.
Since this is the case for all GDK_KEY_* defines, change the
already existing preprocessor check there to test for version 2.22,
so we know that we can remove this code block in case we require
that version as a minimum one day.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1478081328-25515-1-git-send-email-thuth@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agousbredir: free vm_change_state_handler in usbredir destroy dispatch
Li Qiang [Tue, 8 Nov 2016 05:57:46 +0000 (21:57 -0800)]
usbredir: free vm_change_state_handler in usbredir destroy dispatch

In usbredir destroy dispatch function, it doesn't free the vm change
state handler once registered in usbredir_realize function. This will
lead a memory leak issue. This patch avoid this.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 58216976.d0236b0a.77b99.bcd6@mx.google.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agousb: ehci: fix memory leak in ehci_init_transfer
Li Qiang [Tue, 8 Nov 2016 12:11:10 +0000 (04:11 -0800)]
usb: ehci: fix memory leak in ehci_init_transfer

In ehci_init_transfer function, if the 'cpage' is bigger than 4,
it doesn't free the 'p->sgl' once allocated previously thus leading
a memory leak issue. This patch avoid this.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Message-id: 5821c0f4.091c6b0a.e0c92.e811@mx.google.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agoipxe: update to 20161108 snapshot
Gerd Hoffmann [Wed, 9 Nov 2016 08:48:44 +0000 (09:48 +0100)]
ipxe: update to 20161108 snapshot

git shortlog 04186319..b991c67c
===============================

Laszlo Ersek (3):
      [efi] Install the HII config access protocol on a child of the SNP handle
      [librm] Conditionalize the workaround for the Tivoli VMM's SSE garbling
      [build] Disable TIVOLI_VMM_WORKAROUND in the qemu configuration

Lukas Grossar (1):
      [intel] Add PCI device ID for I219-V/LM

Michael Brown (57):
      [efi] Fix uninitialised data in HII IFR structures
      [bios] Do not enable interrupts when printing to the console
      [pxe] Disable interrupts on the PIC before starting NBP
      [dhcp] Allow for variable encapsulation of architecture-specific options
      [dhcpv6] Include RFC5970 client architecture options in DHCPv6 requests
      [dhcpv6] Include vendor class identifier option in DHCPv6 requests
      [dhcp] Automatically generate vendor class identifier string
      [xfer] Send intf_close() if redirection fails
      [downloader] Treat redirection failures as fatal
      [iscsi] Treat redirection failures as fatal
      [debug] Allow per-object runtime enabling/disabling of debug messages
      [debug] Allow debug messages to be initially disabled at runtime
      [libc] Allow assertions to be globally enabled or disabled
      [profile] Allow profiling to be globally enabled or disabled
      [rng] Check for functioning RTC interrupt
      [acpi] Add support for ACPI power off
      [acpi] Allow time for ACPI power off to take effect
      [ipv4] Send gratuitous ARPs whenever a new IPv4 address is applied
      [intel] Strip spurious VLAN tags received by virtual function NICs
      [intel] Remove duplicate intelvf_mbox_queues() function
      [ipv6] Perform SLAAC only during autoconfiguration
      [settings] Create space for IPv6 in settings display order
      [ipv6] Rename ipv6_scope to dhcpv6_scope
      [settings] Correctly mortalise autovivified child settings blocks
      [ipv6] Allow settings to comprise arbitrary subsets of NDP options
      [ipv6] Expose IPv6 settings acquired through NDP
      [dhcpv6] Expose IPv6 address setting acquired through DHCPv6
      [ipv6] Expose IPv6 link-local address settings
      [settings] Allow settings blocks to specify a sibling ordering
      [ipv6] Match user expectations for IPv6 settings priorities
      [ipv6] Create routing table based on IPv6 settings
      [ipv6] Rename ipv6_scope to ipv6_settings_scope
      [test] Update IPv6 tests to use okx()
      [ipv6] Allow for multiple routers
      [hyperv] Use instance UUID in device name
      [crypto] Remove obsolete extern declaration for asn1_invalidate_cursor()
      [crypto] Allow for parsing of partial ASN.1 cursors
      [image] Add image_asn1() to extract ASN.1 objects from image
      [crypto] Add DER image format
      [crypto] Add PEM image format
      [image] Use image_asn1() to extract data from CMS signature images
      [build] Remove obsolete explicit object requirements
      [crypto] Enable both DER and PEM formats by default
      [build] Remove more obsolete explicit object requirements
      [pixbuf] Enable PNG format by default
      [crypto] Add image_x509() to extract X.509 certificates from image
      [crypto] Generalise X.509 "valid" field to a "flags" field
      [list] Add list_next_entry() and list_prev_entry()
      [crypto] Expose certstore_del() to explicitly remove stored certificates
      [crypto] Allow certificates to be marked as having been added explicitly
      [crypto] Add certstat() to display basic certificate information
      [cmdline] Add certificate management commands
      [crypto] Mark permanent certificates as permanent
      [efi] Mark AppleNetBoot.h as a native iPXE header
      [efi] Update to current EDK2 headers
      [efi] Add EFI_BLOCK_IO2_PROTOCOL header and GUID definition
      [bzimage] Fix page alignment of initrd images

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agonbd: Don't inf-loop on early EOF
Eric Blake [Mon, 7 Nov 2016 20:38:13 +0000 (14:38 -0600)]
nbd: Don't inf-loop on early EOF

Commit 7d3123e converted a single read_sync() into a while loop
that assumed that read_sync() would either make progress or give
an error. But when the server hangs up early, the client sees
EOF (a read_sync() of 0) and never makes progress, which in turn
caused qemu-iotest './check -nbd 83' to go into an infinite loop.

Rework the loop to accomodate reads cut short by EOF.

Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1478551093-32757-1-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agotarget-i386: document how x86 gdb_num_core_regs is computed.
Doug Evans [Thu, 3 Nov 2016 21:48:56 +0000 (21:48 +0000)]
target-i386: document how x86 gdb_num_core_regs is computed.

It helps when reading the code to see how the number is arrived at.

Signed-off-by: Doug Evans <dje@google.com>
Message-Id: <94eb2c187eda43dba005406c86f7@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoqdev: fix use-after-free regression from becdfa00cfa
Marc-André Lureau [Mon, 7 Nov 2016 09:59:22 +0000 (13:59 +0400)]
qdev: fix use-after-free regression from becdfa00cfa

Spotted by Coverity, CID 1365383.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20161107095922.31676-1-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agotarget-i386/machine: fix migrate faile because of Hyper-V HV_X64_MSR_VP_RUNTIME
ZhuangYanying [Fri, 4 Nov 2016 08:16:38 +0000 (16:16 +0800)]
target-i386/machine: fix migrate faile because of Hyper-V HV_X64_MSR_VP_RUNTIME

Hyper-V HV_X64_MSR_VP_RUNTIME was introduced in linux-4.4 + qemu-2.5.

As long as the KVM module supports, qemu will save / load the
vmstate_msr_hyperv_runtime register during the migration.

Regardless of whether the hyperv_runtime configuration of x86_cpu_properties is
enabled.

The qemu-2.3 does not support this feature, of course, failed to migrate.

    linux-BGSfqC:/home/qemu # ./x86_64-softmmu/qemu-system-x86_64 --enable-kvm \
        -nodefaults -machine pc-i440fx-2.3,accel=kvm,usb=off -smp 4 -m 4096 -drive \
        file=/work/suse/sles11sp3.img.bak,format=raw,if=none,id=drive-virtio-disk0,cache=none \
        -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0 \
        -vnc :99 -device cirrus-vga,id=video0,vgamem_mb=8,bus=pci.0,addr=0x2 -monitor vc

    save_section_header:se->section_id=3,se->idstr:ram,se->instance_id=0,se->version_id=4
    save_section_header:se->section_id=0,se->idstr:timer,se->instance_id=0,se->version_id=2
    save_section_header:se->section_id=4,se->idstr:cpu_common,se->instance_id=0,se->version_id=1
    save_section_header:se->section_id=5,se->idstr:cpu,se->instance_id=0,se->version_id=12
    vmstate_subsection_save:vmsd->name:cpu/async_pf_msr
    hyperv_runtime_enable_needed:env->msr_hv_runtime=128902811
    vmstate_subsection_save:vmsd->name:cpu/msr_hyperv_runtime

Since hyperv_runtime is false, vm will not use hv->runtime_offset, then
vmstate_msr_hyperv_runtime is no need to transfer while migrating.

Signed-off-by: ann.zhuangyanying@huawei.com
Message-Id: <1478247398-5016-1-git-send-email-ann.zhuangyanying@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agovl.c: move pidfile creation up the line
Michael Tokarev [Wed, 2 Nov 2016 14:18:50 +0000 (17:18 +0300)]
vl.c: move pidfile creation up the line

With current code, pid file is open after various
sockets, chardevs, fsdevs and the like.  This causes
interesting effects, for example when monitor is a
unix-socket, and another qemu instance is already
running, new qemu first "damages" the socket and
next complain that it can't acquire the pid file and
exits, making running qemu unreachable.

Move pid file creation earlier, right after the call
to os_daemonize(), where we know our process id (pid).

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <1478096330-18081-1-git-send-email-mjt@msgid.tls.msk.ru>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agotarget-i386: fix typo
Paolo Bonzini [Wed, 2 Nov 2016 19:58:25 +0000 (20:58 +0100)]
target-i386: fix typo

The impact is small because kvm_get_vcpu_events fixes env->hflags, but
it is wrong and could cause INITs to be delayed arbitrarily with
-machine kernel_irqchip=off.

Reported-by: Achille Fouilleul <achille.fouilleul@gadz.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoMerge remote-tracking branch 'public/tags/tracing-pull-request' into staging
Stefan Hajnoczi [Wed, 9 Nov 2016 12:44:16 +0000 (12:44 +0000)]
Merge remote-tracking branch 'public/tags/tracing-pull-request' into staging

# gpg: Signature made Tue 08 Nov 2016 06:17:13 PM GMT
# 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

* public/tags/tracing-pull-request:
  docs/tracing.txt: Update documentation of default backend

Message-id: 1478629053-31709-1-git-send-email-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'public/tags/block-pull-request' into staging
Stefan Hajnoczi [Wed, 9 Nov 2016 12:43:50 +0000 (12:43 +0000)]
Merge remote-tracking branch 'public/tags/block-pull-request' into staging

# gpg: Signature made Tue 08 Nov 2016 06:12:29 PM GMT
# 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

* public/tags/block-pull-request:
  aio-posix: simplify aio_epoll_update
  aio-posix: avoid NULL pointer dereference in aio_epoll_update
  block: Don't mark node clean after failed flush

Message-id: 1478628762-31050-1-git-send-email-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agodocs/tracing.txt: Update documentation of default backend
Peter Maydell [Fri, 4 Nov 2016 16:27:17 +0000 (16:27 +0000)]
docs/tracing.txt: Update documentation of default backend

In commit baf86d6b3c we switched the default trace backend from "nop"
to "log". Update the documentation to match.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1478276837-31780-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoaio-posix: simplify aio_epoll_update
Paolo Bonzini [Tue, 8 Nov 2016 13:55:24 +0000 (14:55 +0100)]
aio-posix: simplify aio_epoll_update

Extract common code out of the "if".

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 20161108135524.25927-3-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoaio-posix: avoid NULL pointer dereference in aio_epoll_update
Paolo Bonzini [Tue, 8 Nov 2016 13:55:23 +0000 (14:55 +0100)]
aio-posix: avoid NULL pointer dereference in aio_epoll_update

aio_epoll_update dereferences parameter "node", but it could have been NULL
if deleting an fd handler that was not registered in the first place.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-id: 20161108135524.25927-2-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoblock: Don't mark node clean after failed flush
Kevin Wolf [Fri, 4 Nov 2016 23:03:15 +0000 (00:03 +0100)]
block: Don't mark node clean after failed flush

Commit 3ff2f67a changed bdrv_co_flush() so that no flush is issues if
the image hasn't been dirtied since the last flush. This is not quite
correct: The condition should be that the image hasn't been dirtied
since the last _successful_ flush. This patch changes the logic
accordingly.

Without this fix, subsequent bdrv_co_flush() calls would return success
without actually doing anything even though the image is still dirty.
The difference is visible in some blkdebug test cases where error
messages incorrectly disappeared after commit 3ff2f67a.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-id: 1478300595-10090-1-git-send-email-kwolf@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'pm215/tags/pull-target-arm-20161107' into staging
Stefan Hajnoczi [Mon, 7 Nov 2016 14:02:15 +0000 (14:02 +0000)]
Merge remote-tracking branch 'pm215/tags/pull-target-arm-20161107' into staging

target-arm queue:
 * bitbang_i2c: Handle NACKs from devices
 * Fix corruption of CPSR when SCTLR.EE is set
 * nvic: set pending status for not active interrupts
 * char: cadence: check baud rate generator and divider values

# gpg: Signature made Mon 07 Nov 2016 10:43:07 AM GMT
# gpg:                using RSA key 0x3C2525ED14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>"
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>"
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* pm215/tags/pull-target-arm-20161107:
  hw/i2c/bitbang_i2c: Handle NACKs from devices
  Fix corruption of CPSR when SCTLR.EE is set
  nvic: set pending status for not active interrupts
  char: cadence: check baud rate generator and divider values

Message-id: 1478515653-6361-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agos390x/kvm: fix run_on_cpu sigp conversions
Cornelia Huck [Wed, 2 Nov 2016 16:21:03 +0000 (17:21 +0100)]
s390x/kvm: fix run_on_cpu sigp conversions

Commit 14e6fe12a ("*_run_on_cpu: introduce run_on_cpu_data type")
attempted to convert all users of run_on_cpu to use the new
run_on_cpu_data type. It missed to change the called sigp_* routines,
however. Fix that.

Fixes: 14e6fe12a ("*_run_on_cpu: introduce run_on_cpu_data type")
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-id: 20161102162103.66480-1-cornelia.huck@de.ibm.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agohw/i2c/bitbang_i2c: Handle NACKs from devices
Peter Maydell [Mon, 24 Oct 2016 18:12:29 +0000 (19:12 +0100)]
hw/i2c/bitbang_i2c: Handle NACKs from devices

If the guest attempts to talk to a nonexistent device over i2c,
the i2c_start_transfer() function will return non-zero, indicating
that the bus is signalling a NACK. Similarly, if the i2c_send()
function returns nonzero then the target device returned a NACK.
Handle this possibility in the bitbang_i2c code, by returning
the state machine to the STOPPED state and returning the NACK
bit to the guest.

This bit of missing functionality was spotted by Coverity
(it noticed that we weren't checking the return value from
i2c_start_transfer()).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1477332749-27098-1-git-send-email-peter.maydell@linaro.org

7 years agoFix corruption of CPSR when SCTLR.EE is set
Julian Brown [Mon, 7 Nov 2016 10:00:24 +0000 (10:00 +0000)]
Fix corruption of CPSR when SCTLR.EE is set

Fix a typo in arm_cpu_do_interrupt_aarch32 (OR'ing with ~CPSR_E
instead of CPSR_E) which meant that when we took an interrupt with
SCTLR.EE set we would corrupt the CPSR.

Signed-off-by: Julian Brown <julian@codesourcery.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agonvic: set pending status for not active interrupts
Marcin Krzeminski [Mon, 7 Nov 2016 10:00:24 +0000 (10:00 +0000)]
nvic: set pending status for not active interrupts

According to ARM DUI 0552A 4.2.10. NVIC set pending status
also for disabled interrupts. Correct the logic for
when interrupts are marked pending both on input level
transition and when interrupts are dismissed, to match
the NVIC behaviour rather than the 11MPCore GIC.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agochar: cadence: check baud rate generator and divider values
Prasad J Pandit [Mon, 7 Nov 2016 10:00:24 +0000 (10:00 +0000)]
char: cadence: check baud rate generator and divider values

The Cadence UART device emulator calculates speed by dividing the
baud rate by a 'baud rate generator' & 'baud rate divider' value.
The device specification defines these register values to be
non-zero and within certain limits. Add checks for these limits
to avoid errors like divide by zero.

Reported-by: Huawei PSIRT <psirt@huawei.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
Message-id: 1477596278-1470-1-git-send-email-ppandit@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoMerge remote-tracking branch 'sstabellini/tags/xen-20161102-tag' into staging
Stefan Hajnoczi [Fri, 4 Nov 2016 09:26:24 +0000 (09:26 +0000)]
Merge remote-tracking branch 'sstabellini/tags/xen-20161102-tag' into staging

Xen 2016/11/02

# gpg: Signature made Wed 02 Nov 2016 07:28:40 PM GMT
# gpg:                using RSA key 0x894F8F4870E1AE90
# gpg: Good signature from "Stefano Stabellini <sstabellini@kernel.org>"
# gpg:                 aka "Stefano Stabellini <stefano.stabellini@eu.citrix.com>"
# Primary key fingerprint: D04E 33AB A51F 67BA 07D3  0AEA 894F 8F48 70E1 AE90

* sstabellini/tags/xen-20161102-tag:
  PCMachineState: introduce acpi_build_enabled field
  hw/xen/xen_pvdev: Include qemu/log.h for qemu_log_vprintf()

Message-id: alpine.DEB.2.10.1611021227530.19454@sstabellini-ThinkPad-X260
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
Stefan Hajnoczi [Thu, 3 Nov 2016 16:32:30 +0000 (16:32 +0000)]
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging

* NBD bugfix (Changlong)
* NBD write zeroes support (Eric)
* Memory backend fixes (Haozhong)
* Atomics fix (Alex)
* New AVX512 features (Luwei)
* "make check" logging fix (Paolo)
* Chardev refactoring fallout (Paolo)
* Small checkpatch improvements (Paolo, Jeff)

# gpg: Signature made Wed 02 Nov 2016 08:31:11 AM GMT
# 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

* remotes/bonzini/tags/for-upstream: (30 commits)
  main-loop: Suppress I/O thread warning under qtest
  docs/rcu.txt: Fix minor typo
  vl: exit qemu on guest panic if -no-shutdown is not set
  checkpatch: allow spaces before parenthesis for 'coroutine_fn'
  x86: add AVX512_4VNNIW and AVX512_4FMAPS features
  slirp: fix CharDriver breakage
  qemu-char: do not forward events through the mux until QEMU has started
  nbd: Implement NBD_CMD_WRITE_ZEROES on client
  nbd: Implement NBD_CMD_WRITE_ZEROES on server
  nbd: Improve server handling of shutdown requests
  nbd: Refactor conversion to errno to silence checkpatch
  nbd: Support shorter handshake
  nbd: Less allocation during NBD_OPT_LIST
  nbd: Let client skip portions of server reply
  nbd: Let server know when client gives up negotiation
  nbd: Share common option-sending code in client
  nbd: Send message along with server NBD_REP_ERR errors
  nbd: Share common reply-sending code in server
  nbd: Rename struct nbd_request and nbd_reply
  nbd: Rename NbdClientSession to NBDClientSession
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoMerge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
Stefan Hajnoczi [Thu, 3 Nov 2016 14:41:53 +0000 (14:41 +0000)]
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

virtio, pc: fixes and features

nvdimm hotplug support
virtio migration and ioeventfd rework
virtio crypto device
ipmi fixes

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# gpg: Signature made Tue 01 Nov 2016 05:23:40 PM GMT
# gpg:                using RSA key 0x281F0DB8D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
#      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469

* remotes/mst/tags/for_upstream: (47 commits)
  acpi: fix assert failure caused by commit 35c5a52d
  acpi/ipmi: Initialize the fwinfo before fetching it
  ipmi: Add graceful shutdown handling to the external BMC
  ipmi: fix build config variable name for ipmi_bmc_extern.o
  ipmi: Implement shutdown via ACPI overtemp
  ipmi: chassis poweroff should use qemu_system_shutdown_request()
  ipmi_bmc_sim: Remove an unnecessary mutex
  ipmi: Remove hotplug from IPMI BMCs
  pc: memhp: enable nvdimm device hotplug
  nvdimm acpi: introduce _FIT
  nvdimm acpi: introduce fit buffer
  nvdimm acpi: prebuild nvdimm devices for available slots
  nvdimm acpi: use common macros instead of magic names
  acpi nvdimm: rename result_size to dsm_out_buf_siz
  nvdimm acpi: compile nvdimm acpi code arch-independently
  acpi nvdimm: fix Arg6 usage
  acpi nvdimm: fix ARG3 conflict
  acpi nvdimm: fix device physical address base
  acpi nvdimm: fix OperationRegion definition
  acpi nvdimm: fix wrong buffer size returned by DSM method
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agoPCMachineState: introduce acpi_build_enabled field
Wei Liu [Tue, 1 Nov 2016 17:44:16 +0000 (17:44 +0000)]
PCMachineState: introduce acpi_build_enabled field

Introduce this field to control whether ACPI build is enabled by a
particular machine or accelerator.

It defaults to true if the machine itself supports ACPI build. Xen
accelerator will disable it because Xen is in charge of building ACPI
tables for the guest.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Tested-by: Sander Eikelenboom <linux@eikelenboom.it>
7 years agohw/xen/xen_pvdev: Include qemu/log.h for qemu_log_vprintf()
Thomas Huth [Wed, 2 Nov 2016 10:19:18 +0000 (11:19 +0100)]
hw/xen/xen_pvdev: Include qemu/log.h for qemu_log_vprintf()

Olaf Hering reported a build failure due to an undefined reference
to 'qemu_log_vprintf'. Explicitely including qemu/log.h seems to
fix the issue.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Tested-by: Olaf Hering <olaf@aepfle.de>
7 years agomain-loop: Suppress I/O thread warning under qtest
Max Reitz [Mon, 17 Oct 2016 18:09:39 +0000 (20:09 +0200)]
main-loop: Suppress I/O thread warning under qtest

We do not want to display the "I/O thread spun" warning for test cases
that run under qtest. The first attempt for this (commit
01c22f2cdd4fcf02276ea10f48253850a5fd7259) tested whether qtest_enabled()
was true.

Commit 21a24302e85024dd7b2a151158adbc1f5dc5c4dd correctly recognized
that just testing qtest_enabled() is not sufficient since there are some
tests that do not use the qtest accelerator but just the qtest character
device, and thus replaced qtest_enabled() by qtest_driver().

However, there are also some tests that only use the qtest accelerator
and not the qtest chardev; perhaps most notably the bash iotests.
Therefore, we have to check both qtest_enabled() and qtest_driver().

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20161017180939.27912-1-mreitz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agodocs/rcu.txt: Fix minor typo
Pranith Kumar [Tue, 18 Oct 2016 05:04:18 +0000 (01:04 -0400)]
docs/rcu.txt: Fix minor typo

s/presented/prevented/

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
Message-Id: <20161018050418.4912-1-bobby.prani@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agovl: exit qemu on guest panic if -no-shutdown is not set
Christian Borntraeger [Tue, 18 Oct 2016 07:29:54 +0000 (09:29 +0200)]
vl: exit qemu on guest panic if -no-shutdown is not set

For automated testing purposes it can be helpful to exit qemu
(poweroff) when the guest panics. Make this the default unless
-no-shutdown is specified.

For internal-errors like errors from KVM_RUN the behaviour is
not changed, in other words QEMU does not exit to allow debugging
in the QEMU monitor.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-Id: <1476775794-108012-1-git-send-email-borntraeger@de.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agocheckpatch: allow spaces before parenthesis for 'coroutine_fn'
Jeff Cody [Tue, 1 Nov 2016 14:38:35 +0000 (10:38 -0400)]
checkpatch: allow spaces before parenthesis for 'coroutine_fn'

Signed-off-by: Jeff Cody <jcody@redhat.com>
Message-Id: <83b0fae0728906e18849c971d22d077d7fc0f179.1478010883.git.jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agox86: add AVX512_4VNNIW and AVX512_4FMAPS features
Luwei Kang [Mon, 31 Oct 2016 08:27:26 +0000 (16:27 +0800)]
x86: add AVX512_4VNNIW and AVX512_4FMAPS features

The spec can be found in Intel Software Developer Manual or in
Instruction Set Extensions Programming Reference.

Signed-off-by: Piotr Luc <piotr.luc@intel.com>
Signed-off-by: Luwei Kang <luwei.kang@intel.com>
Message-Id: <1477902446-5932-1-git-send-email-he.chen@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoslirp: fix CharDriver breakage
Paolo Bonzini [Thu, 27 Oct 2016 20:04:58 +0000 (22:04 +0200)]
slirp: fix CharDriver breakage

SLIRP expects a CharBackend as the third argument to slirp_add_exec,
but net/slirp.c was passing a CharDriverState.  Fix this to restore
guestfwd functionality.

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoqemu-char: do not forward events through the mux until QEMU has started
Paolo Bonzini [Thu, 27 Oct 2016 13:38:19 +0000 (15:38 +0200)]
qemu-char: do not forward events through the mux until QEMU has started

Otherwise, the CHR_EVENT_OPENED event is sent twice: first when the
backend (for example "stdio") is opened, and second after processing
the command line.

The incorrect sending of the event prints the monitor banner when
QEMU is started with "-serial mon:stdio".  This includes the "(qemu)"
prompt; thus the monitor seems to be dead, whereas actually the
active front-end is the serial port.

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Tested-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Implement NBD_CMD_WRITE_ZEROES on client
Eric Blake [Fri, 14 Oct 2016 18:33:18 +0000 (13:33 -0500)]
nbd: Implement NBD_CMD_WRITE_ZEROES on client

Upstream NBD protocol recently added the ability to efficiently
write zeroes without having to send the zeroes over the wire,
along with a flag to control whether the client wants a hole.

The generic block code takes care of falling back to the obvious
write of lots of zeroes if we return -ENOTSUP because the server
does not have WRITE_ZEROES.

Ideally, since NBD_CMD_WRITE_ZEROES does not involve any data
over the wire, we want to support transactions that are much
larger than the normal 32M limit imposed on NBD_CMD_WRITE.  But
the server may still have a limit smaller than UINT_MAX, so
until experimental NBD protocol additions for advertising various
command sizes is finalized (see [1], [2]), for now we just stick to
the same limits as normal writes.

[1] https://github.com/yoe/nbd/blob/extension-info/doc/proto.md
[2] https://sourceforge.net/p/nbd/mailman/message/35081223/

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-17-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Implement NBD_CMD_WRITE_ZEROES on server
Eric Blake [Fri, 14 Oct 2016 18:33:17 +0000 (13:33 -0500)]
nbd: Implement NBD_CMD_WRITE_ZEROES on server

Upstream NBD protocol recently added the ability to efficiently
write zeroes without having to send the zeroes over the wire,
along with a flag to control whether the client wants to allow
a hole.

Note that when it comes to requiring full allocation, vs.
permitting optimizations, the NBD spec intentionally picked a
different sense for the flag; the rules in qemu are:
MAY_UNMAP == 0: must write zeroes
MAY_UNMAP == 1: may use holes if reads will see zeroes

while in NBD, the rules are:
FLAG_NO_HOLE == 1: must write zeroes
FLAG_NO_HOLE == 0: may use holes if reads will see zeroes

In all cases, the 'may use holes' scenario is optional (the
server need not use a hole, and must not use a hole if
subsequent reads would not see zeroes).

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-16-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Improve server handling of shutdown requests
Eric Blake [Fri, 14 Oct 2016 18:33:16 +0000 (13:33 -0500)]
nbd: Improve server handling of shutdown requests

NBD commit 6d34500b clarified how clients and servers are supposed
to behave before closing a connection. It added NBD_REP_ERR_SHUTDOWN
(for the server to announce it is about to go away during option
haggling, so the client should quit sending NBD_OPT_* other than
NBD_OPT_ABORT) and ESHUTDOWN (for the server to announce it is about
to go away during transmission, so the client should quit sending
NBD_CMD_* other than NBD_CMD_DISC).  It also clarified that
NBD_OPT_ABORT gets a reply, while NBD_CMD_DISC does not.

This patch merely adds the missing reply to NBD_OPT_ABORT and teaches
the client to recognize server errors.  Actually teaching the server
to send NBD_REP_ERR_SHUTDOWN or ESHUTDOWN would require knowing that
the server has been requested to shut down soon (maybe we could do
that by installing a SIGINT handler in qemu-nbd, which transitions
from RUNNING to a new state that waits for the client to react,
rather than just out-right quitting - but that's a bigger task for
another day).

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-15-git-send-email-eblake@redhat.com>
[Move dummy ESHUTDOWN to include/qemu/osdep.h. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Refactor conversion to errno to silence checkpatch
Eric Blake [Fri, 14 Oct 2016 18:33:15 +0000 (13:33 -0500)]
nbd: Refactor conversion to errno to silence checkpatch

Checkpatch complains that 'return EINVAL' is usually wrong
(since we tend to favor 'return -EINVAL').  But it is a
false positive for nbd_errno_to_system_errno().  Since NBD
may add future defined wire values, refactor the code to
keep checkpatch happy.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-14-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Support shorter handshake
Eric Blake [Fri, 14 Oct 2016 18:33:14 +0000 (13:33 -0500)]
nbd: Support shorter handshake

The NBD Protocol allows the server and client to mutually agree
on a shorter handshake (omit the 124 bytes of reserved 0), via
the server advertising NBD_FLAG_NO_ZEROES and the client
acknowledging with NBD_FLAG_C_NO_ZEROES (only possible in
newstyle, whether or not it is fixed newstyle).  It doesn't
shave much off the wire, but we might as well implement it.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alex Bligh <alex@alex.org.uk>
Message-Id: <1476469998-28592-13-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Less allocation during NBD_OPT_LIST
Eric Blake [Fri, 14 Oct 2016 18:33:13 +0000 (13:33 -0500)]
nbd: Less allocation during NBD_OPT_LIST

Since we know that the maximum name we are willing to accept
is small enough to stack-allocate, rework the iteration over
NBD_OPT_LIST responses to reuse a stack buffer rather than
allocating every time.  Furthermore, we don't even have to
allocate if we know the server's length doesn't match what
we are searching for.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-12-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Let client skip portions of server reply
Eric Blake [Fri, 14 Oct 2016 18:33:12 +0000 (13:33 -0500)]
nbd: Let client skip portions of server reply

The server has a nice helper function nbd_negotiate_drop_sync()
which lets it easily ignore fluff from the client (such as the
payload to an unknown option request).  We can't quite make it
common, since it depends on nbd_negotiate_read() which handles
coroutine magic, but we can copy the idea into the client where
we have places where we want to ignore data (such as the
description tacked on the end of NBD_REP_SERVER).

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-11-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Let server know when client gives up negotiation
Eric Blake [Fri, 14 Oct 2016 18:33:11 +0000 (13:33 -0500)]
nbd: Let server know when client gives up negotiation

The NBD spec says that a client should send NBD_OPT_ABORT
rather than just dropping the connection, if the client doesn't
like something the server sent during option negotiation.  This
is a best-effort attempt only, and can only be done in places
where we know the server is still in sync with what we've sent,
whether or not we've read everything the server has sent.
Technically, the server then has to reply with NBD_REP_ACK, but
it's not worth complicating the client to wait around for that
reply.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-10-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Share common option-sending code in client
Eric Blake [Fri, 14 Oct 2016 18:33:10 +0000 (13:33 -0500)]
nbd: Share common option-sending code in client

Rather than open-coding each option request, it's easier to
have common helper functions do the work.  That in turn requires
having convenient packed types for handling option requests
and replies.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-9-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Send message along with server NBD_REP_ERR errors
Eric Blake [Fri, 14 Oct 2016 18:33:09 +0000 (13:33 -0500)]
nbd: Send message along with server NBD_REP_ERR errors

The NBD Protocol allows us to send human-readable messages
along with any NBD_REP_ERR error during option negotiation;
make use of this fact for clients that know what to do with
our message.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-8-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Share common reply-sending code in server
Eric Blake [Fri, 14 Oct 2016 18:33:08 +0000 (13:33 -0500)]
nbd: Share common reply-sending code in server

Rather than open-coding NBD_REP_SERVER, reuse the code we
already have by adding a length parameter.  Additionally,
the refactoring will make adding NBD_OPT_GO in a later patch
easier.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-7-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Rename struct nbd_request and nbd_reply
Eric Blake [Fri, 14 Oct 2016 18:33:07 +0000 (13:33 -0500)]
nbd: Rename struct nbd_request and nbd_reply

Our coding convention prefers CamelCase names, and we already
have other existing structs with NBDFoo naming.  Let's be
consistent, before later patches add even more structs.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-6-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Rename NbdClientSession to NBDClientSession
Eric Blake [Fri, 14 Oct 2016 18:33:06 +0000 (13:33 -0500)]
nbd: Rename NbdClientSession to NBDClientSession

It's better to use consistent capitalization of the namespace
used for NBD functions; we have more instances of NBD* than
Nbd*.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-5-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Rename NBDRequest to NBDRequestData
Eric Blake [Fri, 14 Oct 2016 18:33:05 +0000 (13:33 -0500)]
nbd: Rename NBDRequest to NBDRequestData

We have both 'struct NBDRequest' and 'struct nbd_request'; making
it confusing to see which does what.  Furthermore, we want to
rename nbd_request to align with our normal CamelCase naming
conventions.  So, rename the struct which is used to associate
the data received during request callbacks, while leaving the
shorter name for the description of the request sent over the
wire in the NBD protocol.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-4-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Treat flags vs. command type as separate fields
Eric Blake [Fri, 14 Oct 2016 18:33:04 +0000 (13:33 -0500)]
nbd: Treat flags vs. command type as separate fields

Current upstream NBD documents that requests have a 16-bit flags,
followed by a 16-bit type integer; although older versions mentioned
only a 32-bit field with masking to find flags.  Since the protocol
is in network order (big-endian over the wire), the ABI is unchanged;
but dealing with the flags as a separate field rather than masking
will make it easier to add support for upcoming NBD extensions that
increase the number of both flags and commands.

Improve some comments in nbd.h based on the current upstream
NBD protocol (https://github.com/yoe/nbd/blob/master/doc/proto.md),
and touch some nearby code to keep checkpatch.pl happy.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-3-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agonbd: Add qemu-nbd -D for human-readable description
Eric Blake [Fri, 14 Oct 2016 18:33:03 +0000 (13:33 -0500)]
nbd: Add qemu-nbd -D for human-readable description

The NBD protocol allows servers to advertise a human-readable
description alongside an export name during NBD_OPT_LIST.  Add
an option to pass through the user's string to the NBD client.

Doing this also makes it easier to test commit 200650d4, which
is the client counterpart of receiving the description.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-2-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoexec.c: check memory backend file size with 'size' option
Haozhong Zhang [Wed, 2 Nov 2016 01:05:51 +0000 (09:05 +0800)]
exec.c: check memory backend file size with 'size' option

If the memory backend file is not large enough to hold the required 'size',
Qemu will report error and exit.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Message-Id: <20161027042300.5929-3-haozhong.zhang@intel.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20161102010551.2723-1-haozhong.zhang@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoacpi: fix assert failure caused by commit 35c5a52d
Haozhong Zhang [Wed, 19 Oct 2016 09:19:25 +0000 (17:19 +0800)]
acpi: fix assert failure caused by commit 35c5a52d

Commit 35c5a52d "acpi: do not use TARGET_PAGE_SIZE" changed struct
NvdimmDsmIn from a variable-size structure to a fixed-size structure of
4096 bytes. It forgot to adjust an assert in
nvdimm_dsm_set_label_data(..., NvdimmDsmIn *in, ...):
    assert(sizeof(*in) + sizeof(*set_label_data) + set_label_data->length <=
           4096);
which could crash QEMU when guest writes NVDIMM labels.

Fix it by replacing sizeof(*in) by offsetof(NvdimmDsmIn, arg3).

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reported-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agoacpi/ipmi: Initialize the fwinfo before fetching it
Corey Minyard [Mon, 24 Oct 2016 20:10:21 +0000 (15:10 -0500)]
acpi/ipmi: Initialize the fwinfo before fetching it

The initialization was missed before, resulting in some
bad data in the smbus case.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: qemu-stable@nongnu.org
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agoipmi: Add graceful shutdown handling to the external BMC
Corey Minyard [Mon, 24 Oct 2016 20:10:20 +0000 (15:10 -0500)]
ipmi: Add graceful shutdown handling to the external BMC

I misunderstood the workings of the power settings, the power off
is a force off operation and there needs to be a separate graceful
shutdown operation.  So replace the force off operation with a
graceful shutdown.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agoipmi: fix build config variable name for ipmi_bmc_extern.o
Daniel P. Berrange [Mon, 24 Oct 2016 20:10:19 +0000 (15:10 -0500)]
ipmi: fix build config variable name for ipmi_bmc_extern.o

The original commit:

  commit 67aa56fc03bea44ccf384ea400515a8a58844a50
  Author: Corey Minyard <cminyard@mvista.com>
  Date:   Thu Dec 17 12:50:06 2015 -0600

    ipmi: Add an external connection simulation interface

defined a new variable CONFIG_IPMI_EXTERN, but then went
on to mistakely use the pre-existing CONFIG_IPMI_LOCAL
variable.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agoipmi: Implement shutdown via ACPI overtemp
Corey Minyard [Mon, 24 Oct 2016 20:10:18 +0000 (15:10 -0500)]
ipmi: Implement shutdown via ACPI overtemp

This is allowed by the IPMI specification for graceful shutdown,
so implement it.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agoipmi: chassis poweroff should use qemu_system_shutdown_request()
Cédric Le Goater [Mon, 24 Oct 2016 20:10:17 +0000 (15:10 -0500)]
ipmi: chassis poweroff should use qemu_system_shutdown_request()

When issuing a chassis 'powerdown' control command, the routine
qemu_system_shutdown_request() should be used to exit the guest.
qemu_system_powerdown_request() will initiate a soft shutdown which is
not what is required by the IPMI (28.3 Chassis Control Command):

    0h = power down. Force system into soft off (S4/S45) state. This
    is for 'emergency' management power down actions. The command does
    not initiate a clean shut-down of the operating system prior to
    powering down the system

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agoipmi_bmc_sim: Remove an unnecessary mutex
Corey Minyard [Mon, 24 Oct 2016 20:10:16 +0000 (15:10 -0500)]
ipmi_bmc_sim: Remove an unnecessary mutex

Get rid of the unnecessary mutex, it was a vestige
of something else that was not done.  That way we don't
have to free it.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>