OSDN Git Service

qmiga/qemu.git
5 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2019-01-24' into staging
Peter Maydell [Fri, 25 Jan 2019 11:52:12 +0000 (11:52 +0000)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2019-01-24' into staging

QAPI patches for 2019-01-24

# gpg: Signature made Thu 24 Jan 2019 14:25:19 GMT
# gpg:                using RSA key 3870B400EB918653
# 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

* remotes/armbru/tags/pull-qapi-2019-01-24:
  json: Fix % handling when not interpolating
  qmp: Add examples to qom list, get, and set commands
  qapi: Eliminate indirection through qmp_event_get_func_emit()
  qapi: Belatedly update docs for commit 9c2f56e9f9d

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/kraxel/tags/audio-20190124-pull-request' into...
Peter Maydell [Fri, 25 Jan 2019 10:38:03 +0000 (10:38 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/audio-20190124-pull-request' into staging

audio: pc speaker init fix, rework driver probing

# gpg: Signature made Thu 24 Jan 2019 13:19:52 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# 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

* remotes/kraxel/tags/audio-20190124-pull-request:
  audio: probe audio drivers by default
  audio: error message tweak
  audio: check for pulseaudio daemon pidfile
  audio: use try-sdl for openbsd
  audio: allow optional audio drivers.
  audio: use pkg-config
  audio: fix pc speaker init

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/vivier2/tags/trivial-patches-pull-request'...
Peter Maydell [Fri, 25 Jan 2019 09:54:47 +0000 (09:54 +0000)]
Merge remote-tracking branch 'remotes/vivier2/tags/trivial-patches-pull-request' into staging

- Some typo and UTF-8 fixes
- a ppc e6500 fix to remove duplicate SPR registering

# gpg: Signature made Thu 24 Jan 2019 12:48:05 GMT
# gpg:                using RSA key F30C38BD3F2FBE3C
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>"
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>"
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>"
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/trivial-patches-pull-request:
  hw/i386/pc.c: fix one typo in function name
  virtio-net: Fix a typo
  ppc: e6500 registers SPR 604 twice
  contrib/gitdm: Fix a typo
  MAINTAINERS: Fix utf-8 mangling

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/berrange/tags/qio-next-pull-request' into staging
Peter Maydell [Fri, 25 Jan 2019 09:26:33 +0000 (09:26 +0000)]
Merge remote-tracking branch 'remotes/berrange/tags/qio-next-pull-request' into staging

Merge qio 2010/01/24

Fixes accidental deletion of VNC server UNIX listener socket

# gpg: Signature made Thu 24 Jan 2019 12:24:43 GMT
# gpg:                using RSA key BE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E  8E3F BE86 EBB4 1510 4FDF

* remotes/berrange/tags/qio-next-pull-request:
  io: ensure UNIX client doesn't unlink server socket

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/kraxel/tags/ui-20190124-pull-request' into...
Peter Maydell [Thu, 24 Jan 2019 15:38:47 +0000 (15:38 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190124-pull-request' into staging

input-linux: customizable grab toggle keys

# gpg: Signature made Thu 24 Jan 2019 10:35:29 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# 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

* remotes/kraxel/tags/ui-20190124-pull-request:
  input-linux: customizable grab toggle keys

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Peter Maydell [Thu, 24 Jan 2019 15:04:47 +0000 (15:04 +0000)]
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

Pull request

Changelog: No user-visible changes.

# gpg: Signature made Thu 24 Jan 2019 10:28:53 GMT
# gpg:                using RSA key 9CA4ABB381AB73C8
# 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

* remotes/stefanha/tags/block-pull-request:
  qemu-coroutine-sleep: drop CoSleepCB
  iotests: add 238 for throttling tgm unregister iothread segfault
  throttle-groups: fix restart coroutine iothread race

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agojson: Fix % handling when not interpolating
Christophe Fergeau [Wed, 2 Jan 2019 14:05:35 +0000 (15:05 +0100)]
json: Fix % handling when not interpolating

Commit 8bca4613 added support for %% in json strings when interpolating,
but in doing so broke handling of % when not interpolating.

When parse_string() is fed a string token containing '%', it skips the
'%' regardless of ctxt->ap, i.e. even it's not interpolating.  If the
'%' is the string's last character, it fails an assertion.  Else, it
"merely" swallows the '%'.

Fix parse_string() to handle '%' specially only when interpolating.

To gauge the bug's impact, let's review non-interpolating users of this
parser, i.e. code passing NULL context to json_message_parser_init():

* tests/check-qjson.c, tests/test-qobject-input-visitor.c,
  tests/test-visitor-serialization.c

  Plenty of tests, but we still failed to cover the buggy case.

* monitor.c: QMP input

* qga/main.c: QGA input

* qobject_from_json():

  - qobject-input-visitor.c: JSON command line option arguments of
    -display and -blockdev

    Reproducer: -blockdev '{"%"}'

  - block.c: JSON pseudo-filenames starting with "json:"

    Reproducer: https://bugzilla.redhat.com/show_bug.cgi?id=1668244#c3

  - block/rbd.c: JSON key pairs

    Pseudo-filenames starting with "rbd:".

Command line, QMP and QGA input are trusted.

Filenames are trusted when they come from command line, QMP or HMP.
They are untrusted when they come from from image file headers.
Example: QCOW2 backing file name.  Note that this is *not* the security
boundary between host and guest.  It's the boundary between host and an
image file from an untrusted source.

Neither failing an assertion nor skipping a character in a filename of
your choice looks exploitable.  Note that we don't support compiling
with NDEBUG.

Fixes: 8bca4613e6cddd948895b8db3def05950463495b
Cc: qemu-stable@nongnu.org
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Message-Id: <20190102140535.11512-1-cfergeau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
[Commit message extended to discuss impact]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
5 years agoMerge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190123a' into...
Peter Maydell [Thu, 24 Jan 2019 13:28:26 +0000 (13:28 +0000)]
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190123a' into staging

Migration pull 2019-01-23

New pages-per-second stat, a new test, and a bunch
of fixes and tidy ups.

# gpg: Signature made Wed 23 Jan 2019 15:54:48 GMT
# gpg:                using RSA key 0516331EBC5BFDE7
# gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>"
# Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A  9FA9 0516 331E BC5B FDE7

* remotes/dgilbert/tags/pull-migration-20190123a:
  migration: introduce pages-per-second
  vmstate: constify SaveVMHandlers
  tests: add /vmstate/simple/array
  migration/rdma: unregister fd handler
  migration: unify error handling for process_incoming_migration_co
  migration: add more error handling for postcopy_ram_enable_notify
  migration: multifd_save_cleanup() can't fail, simplify
  migration: fix the multifd code when receiving less channels
  Fix segmentation fault when qemu_signal_init fails

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agohw/i386/pc.c: fix one typo in function name
Wei Yang [Thu, 24 Jan 2019 07:36:26 +0000 (15:36 +0800)]
hw/i386/pc.c: fix one typo in function name

Rename pc_get_hotpug_handler to pc_get_hotplug_handler.

No functional change.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20190124073626.20534-1-richardw.yang@linux.intel.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agovirtio-net: Fix a typo
Philippe Mathieu-Daudé [Mon, 21 Jan 2019 18:13:35 +0000 (19:13 +0100)]
virtio-net: Fix a typo

Fixes: 2974e916df8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20190121181335.3326-1-philmd@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agoppc: e6500 registers SPR 604 twice
Jon Diekema [Tue, 25 Dec 2018 09:50:24 +0000 (04:50 -0500)]
ppc: e6500 registers SPR 604 twice

When using the e6500 CPU, QEMU generates a fatal error after
complaining about registering SPR 604 twice.

Building and testing with commit
9b2e891ec5ccdb4a7d583b77988848282606fdea shows the issue:

qemu-system-ppc64 --version
QEMU emulator version 3.1.50 (v3.1.0-456-g9b2e891ec5-dirty)
Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers

qemu-system-ppc64 -M none -cpu e6500
Error: Trying to register SPR 604 (25c) twice !

Signed-off-by: Jon Diekema <jon.diekema@ge.com>
Message-Id: <CALvuzg43uSodseEHjNaRcPFBKKPTY2mcppUbYgiLL=QO9RxX_Q@mail.gmail.com>
[removed duplicated mail header in the commit message]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agocontrib/gitdm: Fix a typo
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 15:55:55 +0000 (16:55 +0100)]
contrib/gitdm: Fix a typo

Typo comes from upstream git://git.lwn.net/gitdm.git.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Message-Id: <20190111155555.8270-1-philmd@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agoMAINTAINERS: Fix utf-8 mangling
Philippe Mathieu-Daudé [Thu, 17 Jan 2019 16:13:55 +0000 (17:13 +0100)]
MAINTAINERS: Fix utf-8 mangling

Patch incorrectly applied as 15ffb43cbf4.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190117161355.18204-1-philmd@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agoio: ensure UNIX client doesn't unlink server socket
Daniel P. Berrangé [Mon, 14 Jan 2019 11:33:18 +0000 (11:33 +0000)]
io: ensure UNIX client doesn't unlink server socket

The qio_channel_socket_close method for was mistakenly unlinking the
UNIX server socket, even if the channel was a client connection. This
was not noticed with chardevs, since they never call close, but with the
VNC server, this caused the VNC server socket to be deleted after the
first client quit.

The qio_channel_socket_close method also needlessly reimplemented the
logic that already exists in socket_listen_cleanup(). Just call that
method directly, for listen sockets only.

This fixes a regression introduced in QEMU 3.0.0 with

  commit d66f78e1eaa832f73c771d9df1b606fe75d52a50
  Author: Pavel Balaev <mail@void.so>
  Date:   Mon May 21 19:17:35 2018 +0300

    Delete AF_UNIX socket after close

Fixes launchpad #1795100

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoaudio: probe audio drivers by default
Gerd Hoffmann [Thu, 24 Jan 2019 11:20:55 +0000 (12:20 +0100)]
audio: probe audio drivers by default

Add the drivers listed in audio_possible_drivers to audio_drv_list,
using the try-* variants.  That way the probable drivers are compiled by
default if possible.

Additioal tweaks:
  linux: reorder to: pa alsa sdl oss.
  *bsd: drop pa.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20190124112055.547-7-kraxel@redhat.com

5 years agoaudio: error message tweak
Gerd Hoffmann [Thu, 24 Jan 2019 11:20:54 +0000 (12:20 +0100)]
audio: error message tweak

Only print a message about the failed driver initialization in case it
was the driver explicitly requested by the user via QEMU_AUDIO_DRV=$drv.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190124112055.547-6-kraxel@redhat.com

5 years agoaudio: check for pulseaudio daemon pidfile
Gerd Hoffmann [Thu, 24 Jan 2019 11:20:53 +0000 (12:20 +0100)]
audio: check for pulseaudio daemon pidfile

Check whenever the pulseaudio daemon pidfile is present before trying to
initialize the pulseaudio backend.  Just return NULL if that is not the
case, so qemu will check the next backend in line.

In case the user explicitly configured a non-default pulseaudio server
skip the check.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20190124112055.547-5-kraxel@redhat.com

5 years agoaudio: use try-sdl for openbsd
Gerd Hoffmann [Thu, 24 Jan 2019 11:20:52 +0000 (12:20 +0100)]
audio: use try-sdl for openbsd

Fixes the openbsd build failure with SDL disabled.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20190124112055.547-4-kraxel@redhat.com

5 years agoaudio: allow optional audio drivers.
Gerd Hoffmann [Thu, 24 Jan 2019 11:20:51 +0000 (12:20 +0100)]
audio: allow optional audio drivers.

For those audio drivers which can be probed (sdl, alsa, pulse) add a
try-$name variants.  Unlike the variants without try- prefix they will
not error out on probe failure, the driver will be dropped from the list
instead.  Mainly useful for the audio_drv_list default values.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20190124112055.547-3-kraxel@redhat.com

5 years agoaudio: use pkg-config
Gerd Hoffmann [Thu, 24 Jan 2019 11:20:50 +0000 (12:20 +0100)]
audio: use pkg-config

Use pkg-config to probe for alsa and pulseaudio.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190124112055.547-2-kraxel@redhat.com

5 years agoaudio: fix pc speaker init
Gerd Hoffmann [Thu, 24 Jan 2019 11:08:10 +0000 (12:08 +0100)]
audio: fix pc speaker init

Get rid of the pcspk_state global, allow pc speaker
be added using "-device isa-pcspk".

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190124110810.1040-1-kraxel@redhat.com

5 years agoMerge remote-tracking branch 'remotes/stsquad/tags/pull-fpu-next-230119-2' into staging
Peter Maydell [Thu, 24 Jan 2019 12:01:02 +0000 (12:01 +0000)]
Merge remote-tracking branch 'remotes/stsquad/tags/pull-fpu-next-230119-2' into staging

Some more softfloat/fpu fixes

   - make check-softfloat
   - fixes for fp-bench
   - workaround broken host fma
   - compile fix for s390x/clang
   - fixed for bigendian (v2)
   - minor makefile tweaks (v2)

# gpg: Signature made Wed 23 Jan 2019 11:37:53 GMT
# gpg:                using RSA key FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>"
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-fpu-next-230119-2:
  tests/Makefile: add check-softfloat rule
  scripts/archive-source: include softfloat tests
  tests/Makefile: add floating point tests
  include/fpu/softfloat: Fix compilation with Clang on s390x
  softfloat: enforce softfloat if the host's FMA is broken
  tests/fp/platform.h: include config-host.h
  fp-test: fix signature of slow_clear_flags and qemu_clear_flags
  tests/fp/Makefile: do not use gcc-only -W flags
  berkeley-testfloat-3: pull changes
  fp-bench: remove wrong exponent raise in fill_random
  fp-bench: fix update_random_ops

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoqemu-coroutine-sleep: drop CoSleepCB
Vladimir Sementsov-Ogievskiy [Tue, 22 Jan 2019 14:31:13 +0000 (17:31 +0300)]
qemu-coroutine-sleep: drop CoSleepCB

Drop CoSleepCB structure. It's actually unused.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-id: 20190122143113.20331-1-vsementsov@virtuozzo.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5 years agoiotests: add 238 for throttling tgm unregister iothread segfault
Stefan Hajnoczi [Mon, 14 Jan 2019 13:32:57 +0000 (13:32 +0000)]
iotests: add 238 for throttling tgm unregister iothread segfault

Hot-unplug a scsi-hd using an iothread.  The previous patch fixes a
segfault in this scenario.

This patch adds a regression test.

Suggested-by: Alberto Garcia <berto@igalia.com>
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-id: 20190114133257.30299-3-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5 years agothrottle-groups: fix restart coroutine iothread race
Stefan Hajnoczi [Mon, 14 Jan 2019 13:32:56 +0000 (13:32 +0000)]
throttle-groups: fix restart coroutine iothread race

The following QMP command leads to a crash when iothreads are used:

  { 'execute': 'device_del', 'arguments': {'id': 'data'} }

The backtrace involves the queue restart coroutine where
tgm->throttle_state is a NULL pointer because
throttle_group_unregister_tgm() has already been called:

  (gdb) bt full
  #0  0x00005585a7a3b378 in qemu_mutex_lock_impl (mutex=0xffffffffffffffd0, file=0x5585a7bb3d54 "block/throttle-groups.c", line=412) at util/qemu-thread-posix.c:64
        err = <optimized out>
        __PRETTY_FUNCTION__ = "qemu_mutex_lock_impl"
        __func__ = "qemu_mutex_lock_impl"
  #1  0x00005585a79be074 in throttle_group_restart_queue_entry (opaque=0x5585a9de4eb0) at block/throttle-groups.c:412
        _f = <optimized out>
        data = 0x5585a9de4eb0
        tgm = 0x5585a9079440
        ts = 0x0
        tg = 0xffffffffffffff98
        is_write = false
        empty_queue = 255

This coroutine should not execute in the iothread after the throttle
group member has been unregistered!

The root cause is that the device_del code path schedules the restart
coroutine in the iothread while holding the AioContext lock.  Therefore
the iothread cannot execute the coroutine until after device_del
releases the lock - by this time it's too late.

This patch adds a reference count to ThrottleGroupMember so we can
synchronously wait for restart coroutines to complete.  Once they are
done it is safe to unregister the ThrottleGroupMember.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-id: 20190114133257.30299-2-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5 years agoinput-linux: customizable grab toggle keys
Ryan El Kochta [Wed, 23 Jan 2019 21:45:55 +0000 (16:45 -0500)]
input-linux: customizable grab toggle keys

This patch adds a new option to the input-linux object:

grab-toggle=[key-combo]

The key combination can be one of the following:

* ctrl-ctrl
* alt-alt
* meta-meta
* scrolllock
* ctrl-scrolllock

The user can pick any of these key combinations. The VM's grab
of the evdev device will be toggled when the key combination is
pressed.

Any invalid setting will result in an error. No setting will
result in the current default of ctrl-ctrl.

The right and left ctrl key both work for Ctrl-Scrolllock.

If scrolllock is selected as one of the grab-toggle keys, it
will be entirely disabled and not passed to the guest at all.
This is to prevent enabling it while attempting to leave or enter
the VM. On the host, scrolllock can be disabled using xmodmap.

First, find the modifier that Scroll_Lock is bound to:

$ xmodmap -pm

Then, remove Scroll_Lock from it, replacing modX with the modifier:

$ xmodmap -e 'remove modX = Scroll_Lock'

If Scroll_Lock is not bound to any modifier, it is already disabled.

To save the changes, add them to your xinitrc.

Ryan El Kochta (1):
  input-linux: customizable grab toggle keys v5

Signed-off-by: Ryan El Kochta <relkochta@gmail.com>
Message-id: 20190123214555.12712-2-relkochta@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5 years agoqmp: Add examples to qom list, get, and set commands
Wainer dos Santos Moschetta [Fri, 28 Dec 2018 19:44:42 +0000 (14:44 -0500)]
qmp: Add examples to qom list, get, and set commands

Added examples for the qom-list, qom-get, and qom-set
commands in qapi misc JSON file.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Message-Id: <20181228194442.3506-1-wainersm@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
5 years agoqapi: Eliminate indirection through qmp_event_get_func_emit()
Markus Armbruster [Tue, 18 Dec 2018 18:22:21 +0000 (19:22 +0100)]
qapi: Eliminate indirection through qmp_event_get_func_emit()

The qapi_event_send_FOO() functions emit events like this:

    QMPEventFuncEmit emit;

    emit = qmp_event_get_func_emit();
    if (!emit) {
        return;
    }

    qmp = qmp_event_build_dict("FOO");
    [put event arguments into @qmp...]

    emit(QAPI_EVENT_FOO, qmp);

The value of qmp_event_get_func_emit() depends only on the program:

* In qemu-system-FOO, it's always monitor_qapi_event_queue.

* In tests/test-qmp-event, it's always event_test_emit.

* In all other programs, it's always null.

This is exactly the kind of dependence the linker is supposed to
resolve; we don't actually need an indirection.

Note that things would fall apart if we linked more than one QAPI
schema into a single program: each set of qapi_event_send_FOO() uses
its own event enumeration, yet they share a single emit function.
Which takes the event enumeration as an argument.  Which one if
there's more than one?

More seriously: how does this work even now?  qemu-system-FOO wants
QAPIEvent, and passes a function taking that to
qmp_event_set_func_emit().  test-qmp-event wants test_QAPIEvent, and
passes a function taking that to qmp_event_set_func_emit().

It works by type trickery, of course:

    typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict);

    void qmp_event_set_func_emit(QMPEventFuncEmit emit);

    QMPEventFuncEmit qmp_event_get_func_emit(void);

We use unsigned instead of the enumeration type.  Relies on both
enumerations boiling down to unsigned, which happens to be true for
the compilers we use.

Clean this up as follows:

* Generate qapi_event_send_FOO() that call PREFIX_qapi_event_emit()
  instead of the value of qmp_event_set_func_emit().

* Generate a prototype for PREFIX_qapi_event_emit() into
  qapi-events.h.

* PREFIX_ is empty for qapi/qapi-schema.json, and test_ for
  tests/qapi-schema/qapi-schema-test.json.  It's qga_ for
  qga/qapi-schema.json, and doc-good- for
  tests/qapi-schema/doc-good.json, but those don't define any events.

* Rename monitor_qapi_event_queue() to qapi_event_emit() instead of
  passing it to qmp_event_set_func_emit().  This takes care of
  qemu-system-FOO.

* Rename event_test_emit() to test_qapi_event_emit() instead of
  passing it to qmp_event_set_func_emit().  This takes care of
  tests/test-qmp-event.

* Add a qapi_event_emit() that does nothing to stubs/monitor.c.  This
  takes care of all other programs that link code emitting QMP events.

* Drop qmp_event_set_func_emit(), qmp_event_get_func_emit().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20181218182234.28876-3-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[Commit message typos fixed]

5 years agoqapi: Belatedly update docs for commit 9c2f56e9f9d
Markus Armbruster [Tue, 18 Dec 2018 18:22:20 +0000 (19:22 +0100)]
qapi: Belatedly update docs for commit 9c2f56e9f9d

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20181218182234.28876-2-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5 years agoMerge remote-tracking branch 'remotes/xtensa/tags/20190122-xtensa' into staging
Peter Maydell [Wed, 23 Jan 2019 21:50:49 +0000 (21:50 +0000)]
Merge remote-tracking branch 'remotes/xtensa/tags/20190122-xtensa' into staging

target/xtensa: zero overhead loops rework/helpers split

- change xtensa zero overhead loops implementation to avoid invalidation
  of TBs corresponding to previous loop body when a new loop is
  encountered;
- extract helper function groups from op_helper.c and move them into
  separate source files: exc_helper.c (exception helpers), win_helper.c
  (windowed registers helpers), fpu_helper.c (floating point helpers),
  mmu_helper.c (memory management helpers) and dbg_helper.c (native debug
  helpers).

# gpg: Signature made Tue 22 Jan 2019 18:44:17 GMT
# gpg:                using RSA key 51F9CC91F83FA044
# gpg: Good signature from "Max Filippov <filippov@cadence.com>"
# gpg:                 aka "Max Filippov <max.filippov@cogentembedded.com>"
# gpg:                 aka "Max Filippov <jcmvbkbc@gmail.com>"
# Primary key fingerprint: 2B67 854B 98E5 327D CDEB  17D8 51F9 CC91 F83F A044

* remotes/xtensa/tags/20190122-xtensa:
  target/xtensa: move non-HELPER functions to helper.c
  target/xtensa: drop dump_state helper
  target/xtensa: extract interrupt and exception helpers
  target/xtensa: extract debug helpers
  target/xtensa: extract MMU helpers
  target/xtensa: extract windowed registers helpers
  target/xtensa: extract FPU helpers
  target/xtensa: rework zero overhead loops implementation

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/kraxel/tags/ui-20190121-pull-request' into...
Peter Maydell [Wed, 23 Jan 2019 17:57:47 +0000 (17:57 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190121-pull-request' into staging

ui: highres logo for sdl and gtk, bugfixes for vnc and egl.

# gpg: Signature made Mon 21 Jan 2019 14:11:39 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# 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

* remotes/kraxel/tags/ui-20190121-pull-request:
  egl-helpers.h: do not depend on X11 Window type, use EGLNativeWindowType
  vnc: detect and optimize pageflips
  sdl: add support for high resolution window icon
  ui: fix icon display for GTK frontend under GNOME Shell with Wayland
  ui: install logo icons to $prefix/share/icons

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agomigration: introduce pages-per-second
Xiao Guangrong [Fri, 11 Jan 2019 06:37:30 +0000 (14:37 +0800)]
migration: introduce pages-per-second

It introduces a new statistic, pages-per-second, as bandwidth or mbps is
not enough to measure the performance of posting pages out as we have
compression, xbzrle, which can significantly reduce the amount of the
data size, instead, pages-per-second is the one we want

Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
Message-Id: <20190111063732.10484-2-xiaoguangrong@tencent.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
  With typo's Eric spotted fixed

5 years agovmstate: constify SaveVMHandlers
Marc-André Lureau [Wed, 14 Nov 2018 13:31:39 +0000 (17:31 +0400)]
vmstate: constify SaveVMHandlers

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20181114133139.27346-1-marcandre.lureau@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agotests: add /vmstate/simple/array
Marc-André Lureau [Wed, 14 Nov 2018 13:21:30 +0000 (17:21 +0400)]
tests: add /vmstate/simple/array

A very simple test to show VMSTATE_*_ARRAY usage and result. It could
be systematically extended to other primitives, but I leave that as an
exercise for others :).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20181114132130.27141-1-marcandre.lureau@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agomigration/rdma: unregister fd handler
Dr. David Alan Gilbert [Tue, 22 Jan 2019 17:31:11 +0000 (17:31 +0000)]
migration/rdma: unregister fd handler

Unregister the fd handler before we destroy the channel,
otherwise we've got a race where we might land in the
fd handler just as we're closing the device.

(The race is quite data dependent, you just have to have
the right set of devices for it to trigger).

Corresponds to RH bz: https://bugzilla.redhat.com/show_bug.cgi?id=1666601

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190122173111.29821-1-dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agomigration: unify error handling for process_incoming_migration_co
Fei Li [Sun, 13 Jan 2019 14:08:49 +0000 (22:08 +0800)]
migration: unify error handling for process_incoming_migration_co

In the current code, if process_incoming_migration_co() fails we do
the same error handing: set the error state, close the source file,
do the cleanup for multifd, and then exit(EXIT_FAILURE). To make the
code clearer, add a "goto fail" to unify the error handling.

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Fei Li <fli@suse.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190113140849.38339-6-lifei1214@126.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agomigration: add more error handling for postcopy_ram_enable_notify
Fei Li [Sun, 13 Jan 2019 14:08:48 +0000 (22:08 +0800)]
migration: add more error handling for postcopy_ram_enable_notify

Call postcopy_ram_incoming_cleanup() to do the cleanup when
postcopy_ram_enable_notify fails. Besides, report the error
message when qemu_ram_foreach_migratable_block() fails.

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Fei Li <fli@suse.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190113140849.38339-5-lifei1214@126.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agomigration: multifd_save_cleanup() can't fail, simplify
Fei Li [Sun, 13 Jan 2019 14:08:47 +0000 (22:08 +0800)]
migration: multifd_save_cleanup() can't fail, simplify

multifd_save_cleanup() takes an Error ** argument and returns an
error code even though it can't actually fail.  Its callers
dutifully check for failure.  Remove the useless argument and return
value, and simplify the callers.

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Fei Li <fli@suse.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20190113140849.38339-4-lifei1214@126.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agomigration: fix the multifd code when receiving less channels
Fei Li [Sun, 13 Jan 2019 14:08:46 +0000 (22:08 +0800)]
migration: fix the multifd code when receiving less channels

In our current code, when multifd is used during migration, if there
is an error before the destination receives all new channels, the
source keeps running, however the destination does not exit but keeps
waiting until the source is killed deliberately.

Fix this by dumping the specific error and let users decide whether
to quit from the destination side when failing to receive packet via
some channel. And update the comment for multifd_recv_new_channel().

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Fei Li <fli@suse.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-Id: <20190113140849.38339-3-lifei1214@126.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agoFix segmentation fault when qemu_signal_init fails
Fei Li [Sun, 13 Jan 2019 14:08:45 +0000 (22:08 +0800)]
Fix segmentation fault when qemu_signal_init fails

When qemu_signal_init() fails in qemu_init_main_loop(), we return
without setting an error.  Its callers crash then when they try to
report the error with error_report_err().

To avoid such segmentation fault, add a new Error parameter to make
the call trace to propagate the err to the final caller.

Fixes: 2f78e491d7b46542158ce0b8132ee4e05bc0ade4
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fei Li <fli@suse.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190113140849.38339-2-lifei1214@126.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agoMerge remote-tracking branch 'remotes/edgar/tags/edgar/xilinx-next-2019-01-22.for...
Peter Maydell [Wed, 23 Jan 2019 11:59:42 +0000 (11:59 +0000)]
Merge remote-tracking branch 'remotes/edgar/tags/edgar/xilinx-next-2019-01-22.for-upstream' into staging

Pullreq 2019-01-22

# gpg: Signature made Tue 22 Jan 2019 11:42:41 GMT
# gpg:                using RSA key 29C596780F6BCA83
# gpg: Good signature from "Edgar E. Iglesias (Xilinx key) <edgar.iglesias@xilinx.com>"
# gpg:                 aka "Edgar E. Iglesias <edgar.iglesias@gmail.com>"
# Primary key fingerprint: AC44 FEDC 14F7 F1EB EDBF  4151 29C5 9678 0F6B CA83

* remotes/edgar/tags/edgar/xilinx-next-2019-01-22.for-upstream:
  target/microblaze: Add props enabling exceptions on failed bus accesses
  hw/microblaze: s3adsp1800: Create an unimplemented GPIO area
  target/microblaze: Switch to transaction_failed hook

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agotests/Makefile: add check-softfloat rule
Alex Bennée [Mon, 7 Jan 2019 17:25:44 +0000 (17:25 +0000)]
tests/Makefile: add check-softfloat rule

This adds a rule to run all of our softfloat tests. It is included as
a pre-requisite to check-tcg and check-unit as well.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Emilio G. Cota <cota@braap.org>
5 years agoscripts/archive-source: include softfloat tests
Alex Bennée [Tue, 8 Jan 2019 11:51:53 +0000 (11:51 +0000)]
scripts/archive-source: include softfloat tests

We need these if we want to run unit/softfloat tests in our docker
containers.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotests/Makefile: add floating point tests
Alex Bennée [Mon, 7 Jan 2019 17:22:19 +0000 (17:22 +0000)]
tests/Makefile: add floating point tests

Wire up test/fp-test into the main testing Makefile. Currently we skip
some of the extF80 and f128 related tests. Once we re-factor and fix
these tests the plumbing should get simpler.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5 years agoinclude/fpu/softfloat: Fix compilation with Clang on s390x
Thomas Huth [Mon, 14 Jan 2019 12:12:35 +0000 (13:12 +0100)]
include/fpu/softfloat: Fix compilation with Clang on s390x

Clang v7.0.1 does not like the __int128 variable type for inline
assembly on s390x:

In file included from fpu/softfloat.c:97:
include/fpu/softfloat-macros.h:647:9: error: inline asm error:
 This value type register class is not natively supported!
    asm("dlgr %0, %1" : "+r"(n) : "r"(d));
        ^

Disable this code part there now when compiling with Clang, so that
the generic code gets used instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5 years agosoftfloat: enforce softfloat if the host's FMA is broken
Emilio G. Cota [Tue, 25 Dec 2018 07:03:05 +0000 (02:03 -0500)]
softfloat: enforce softfloat if the host's FMA is broken

The added branch to the FMA ops is marked as unlikely and therefore
its impact on performance (measured with fp-bench) is within noise range
when measured on an Intel(R) Xeon(R) Gold 6142 CPU @ 2.60GHz.

Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5 years agotests/fp/platform.h: include config-host.h
Emilio G. Cota [Tue, 22 Jan 2019 20:10:42 +0000 (15:10 -0500)]
tests/fp/platform.h: include config-host.h

We get HOST_WORDS_BIGENDIAN from config-host.h, but the include
is missing. Fix it.

This fixes `make check-softfloat' on big endian hosts.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5 years agofp-test: fix signature of slow_clear_flags and qemu_clear_flags
Emilio G. Cota [Thu, 17 Jan 2019 18:22:12 +0000 (13:22 -0500)]
fp-test: fix signature of slow_clear_flags and qemu_clear_flags

To match the type in testfloat.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5 years agotests/fp/Makefile: do not use gcc-only -W flags
Emilio G. Cota [Thu, 17 Jan 2019 18:18:46 +0000 (13:18 -0500)]
tests/fp/Makefile: do not use gcc-only -W flags

The build now completes in both gcc and clang.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5 years agoberkeley-testfloat-3: pull changes
Emilio G. Cota [Thu, 17 Jan 2019 18:17:48 +0000 (13:17 -0500)]
berkeley-testfloat-3: pull changes

- fail: constify fail_programName

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5 years agofp-bench: remove wrong exponent raise in fill_random
Emilio G. Cota [Fri, 21 Dec 2018 19:52:00 +0000 (14:52 -0500)]
fp-bench: remove wrong exponent raise in fill_random

At this point random_ops[] only contains normals, so there's
no need to do anything to them. In fact, raising the exponent
here can make the output !normal, which is precisely
what the comment says we want to avoid.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5 years agofp-bench: fix update_random_ops
Emilio G. Cota [Fri, 21 Dec 2018 19:51:59 +0000 (14:51 -0500)]
fp-bench: fix update_random_ops

The second test in the branches is wrong; fix while converting
to a switch statement, which is easier to get right.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/kraxel/tags/ipxe-20190122-pull-request' into...
Peter Maydell [Tue, 22 Jan 2019 19:24:10 +0000 (19:24 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/ipxe-20190122-pull-request' into staging

ipxe: update to latest git master

# gpg: Signature made Tue 22 Jan 2019 06:33:53 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# 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

* remotes/kraxel/tags/ipxe-20190122-pull-request:
  ipxe: update to latest git master

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2019-01-21' into staging
Peter Maydell [Tue, 22 Jan 2019 17:56:21 +0000 (17:56 +0000)]
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2019-01-21' into staging

nbd patches for 2019-01-21

Add 'qemu-nbd --list' for probing a remote NBD server's advertisements.

- Eric Blake: 0/21 nbd: add qemu-nbd --list

# gpg: Signature made Mon 21 Jan 2019 22:44:27 GMT
# gpg:                using RSA key A7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>"
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>"
# gpg:                 aka "[jpeg image of size 6874]"
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-nbd-2019-01-21: (21 commits)
  iotests: Enhance 223, 233 to cover 'qemu-nbd --list'
  nbd/client: Work around 3.0 bug for listing meta contexts
  qemu-nbd: Add --list option
  nbd/client: Add meta contexts to nbd_receive_export_list()
  nbd/client: Add nbd_receive_export_list()
  nbd/client: Refactor nbd_opt_go() to support NBD_OPT_INFO
  nbd/client: Pull out oldstyle size determination
  nbd/client: Split handshake into two functions
  nbd/client: Refactor return of nbd_receive_negotiate()
  nbd/client: Split out nbd_receive_one_meta_context()
  nbd/client: Split out nbd_send_meta_query()
  nbd/client: Change signature of nbd_negotiate_simple_meta_context()
  nbd/client: Move export name into NBDExportInfo
  nbd/client: Refactor nbd_receive_list()
  qemu-nbd: Avoid strtol open-coding
  nbd/server: Favor [u]int64_t over off_t
  nbd/server: Hoist length check to qmp_nbd_server_add
  qemu-nbd: Sanity check partition bounds
  qemu-nbd: Enhance man page
  maint: Allow for EXAMPLES in texi2pod
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agotarget/microblaze: Add props enabling exceptions on failed bus accesses
Edgar E. Iglesias [Fri, 4 Jan 2019 14:05:10 +0000 (15:05 +0100)]
target/microblaze: Add props enabling exceptions on failed bus accesses

Add MicroBlaze CPU properties to enable exceptions on failed
bus accesses.

Reviewed-by: Luc Michel <luc.michel@greensocs.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
5 years agohw/microblaze: s3adsp1800: Create an unimplemented GPIO area
Edgar E. Iglesias [Fri, 4 Jan 2019 13:39:06 +0000 (14:39 +0100)]
hw/microblaze: s3adsp1800: Create an unimplemented GPIO area

Create an unimplemented GPIO area instead of leaving it unassigned.

Reviewed-by: Luc Michel <luc.michel@greensocs.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
5 years agotarget/microblaze: Switch to transaction_failed hook
Peter Maydell [Mon, 10 Dec 2018 17:56:30 +0000 (17:56 +0000)]
target/microblaze: Switch to transaction_failed hook

Switch the microblaze target from the old unassigned_access hook
to the transaction_failed hook.

The notable difference is that rather than it being called
for all physical memory accesses which fail (including
those made by DMA devices or by the gdbstub), it is only
called for those made by the CPU via its MMU. For
microblaze this makes no difference because none of the
target CPU code needs to make loads or stores by physical
address.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
[EI: Add space in qemu_log()]
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
5 years agoMerge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-01-22' into...
Peter Maydell [Tue, 22 Jan 2019 09:48:40 +0000 (09:48 +0000)]
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-01-22' into staging

- Use more CONFIG Makefile switches for qtests
- Get rid of global_qtests in some more qtests
- typedef cleanups
- Fixes for compiling with Clang
- Force C standard to gnu99
- Don't use -nographic in qtests

# gpg: Signature made Tue 22 Jan 2019 06:18:41 GMT
# gpg:                using RSA key 2ED9D774FE702DB5
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>"
# gpg:                 aka "Thomas Huth <thuth@redhat.com>"
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>"
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>"
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* remotes/huth-gitlab/tags/pull-request-2019-01-22: (26 commits)
  tests: remove rule for nonexisting qdev-monitor-test
  tests/hexloader-test: Don't pass -nographic to the QEMU under test
  configure: Force the C standard to gnu99
  seccomp: Work-around GCC 4.x bug in gnu99 mode
  block: Work-around a bug in libiscsi 1.9.0 when used in gnu99 mode
  linux-user: Fix compilation with clang 3.4
  virtio-net: Fix VirtIONet typedef redefinition
  ppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode
  ppc: Move spapr-related prototypes from xics.h into a seperate header file
  ui/console: Remove PixelFormat from qemu/typedefs.h
  ui/console: Remove MouseTransformInfo from qemu/typedefs.h
  ui/console: Remove DisplayState/DisplaySurface from "qemu/typedefs.h"
  ui/console: Remove QemuDmaBuf from "qemu/typedefs.h"
  audio: Remove AudioState from "qemu/typedefs.h"
  hw/i386: Remove PCMachineClass from "qemu/typedefs.h"
  hw/char/serial: Remove SerialState from "qemu/typedefs.h"
  hw/bt: Remove HCIInfo from "qemu/typedefs.h"
  hw/i2c/smbus: Remove SMBusDevice from "qemu/typedefs.h"
  hw/ide/ahci: Remove AllwinnerAHCIState from "qemu/typedefs.h"
  hw/pcmcia: Remove PCMCIACardState from "qemu/typedefs.h"
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoipxe: update to latest git master
Gerd Hoffmann [Tue, 22 Jan 2019 06:27:59 +0000 (07:27 +0100)]
ipxe: update to latest git master

git shortlog ipxe-qemu-20170717-0600d3ae94-0..ipxe-qemu-20190122-de4565cbe7-0
-----------------------------------------------------------------------------

Aaron Young (1):
      [libc] Fix strcmp()/strncmp() to return proper values

Ameer Mahagneh (1):
      [golan] Set log_max_qp to 1

Bruce Rogers (1):
      [build] Disable gcc stringop-truncation warnings

Christian Hesse (1):
      [build] Handle R_X86_64_PLT32 from binutils 2.31

Hannes Reinecke (1):
      [iscsi] Parse IPv6 address in root path

Heinrich Schuchardt (2):
      [efi] Accept (and ignore) R_ARM_V4BX relocations
      [efi] Add support for R_ARM_REL32 relocations

Ignat Korchagin (1):
      [efi] Fix error handling path in efi_snp_probe

Janos Mattyasovszky (1):
      [intel] Add PCI device ID for X550-T2

Joseph Wong (1):
      [tg3] Add support for SerDes PHY initialization

Ladi Prosek (1):
      [crypto] Fail fast if cross-certificate source is empty

Laurent Gourvénec (1):
      [acpi] Compute and check checksum for ACPI tables

Martin Habets (2):
      [netdevice] Make netdev_irq_enabled() independent of netdev_irq_supported()
      [sfc] Add support for X25xx adapters

Michael Brown (88):
      [efi] Enumerate PCI BARs in same order as SnpDxe
      [build] Conditionalise use of -mabi=lp64 for ARM64 builds
      [build] Fix use of inline assembly on GCC 4.8 ARM64 builds
      [build] Fix ARM32 EFI builds with current EDK2 headers
      [acpi] Fix spurious uninitialised-variable warning on some gcc versions
      [hyperv] Do not steal ownership from the Gen 2 UEFI firmware
      [shell] Enable "shell" command even when BANNER_TIMEOUT is zero
      [romprefix] Avoid unaligned accesses within ROM headers
      [malloc] Avoid false positive warnings from valgrind
      [linux] Impose receive quota on tap driver
      [efi] Raise TPL when calling UNDI entry point
      [netdevice] Cancel all pending transmissions on any transmit error
      [monojob] Check for job progress only once per timer tick
      [job] Allow jobs to report an arbitrary status message
      [downloader] Allow underlying downloads to provide detailed job progress
      [monojob] Display job status message, if present
      [peerdist] Gather and report peer statistics during download
      [netdevice] Add "hwaddr" setting
      [resolv] Use pass-through interfaces for name resolution multiplexer
      [dns] Report current DNS query as job progress status message
      [efi] Check buffer length for packets retrieved via our SNP protocol
      [efi] Match behaviour of SnpDxe for truncated received packets
      [dns] Ensure DNS names are NUL-terminated when used as diagnostic strings
      [efi] Continue to connect remaining handles after connection errors
      [build] Exclude selected directories from Secure Boot builds
      [efi] Inhibit our driver Start() method during disconnection attempts
      [efi] Allow for building with older versions of elf.h system header
      [crypto] Fix endianness typo in comment
      [crypto] Eliminate repetitions in MD5 round constant table
      [crypto] Add MD4 message digest algorithm
      [ntlm] Add support for NTLM authentication mechanism
      [http] Gracefully handle offers of multiple authentication schemes
      [http] Handle parsing of WWW-Authenticate header within authentication scheme
      [http] Add support for NTLM authentication
      [xen] Skip probing of any unsupported device types
      [http] Include error messages for 4xx and 5xx response codes
      [http] Report unsuccessful response status lines at DBGVL_LOG
      [image] Omit URI query string and fragment from download progress messages
      [legal] Add missing FILE_LICENCE declarations
      [legal] Add missing FILE_LICENCE declarations
      [build] Avoid use of "ld --oformat binary"
      [ena] Add driver for Amazon ENA virtual function NIC
      [skel] Remove MII interface
      [ena] Fix spurious uninitialised variable warning on older versions of gcc
      [xhci] Assume an invalid PSI table if any invalid PSI value is observed
      [intel] Work around broken reset mechanism in i219 devices
      [http] Allow for domain names within NTLM user names
      [xhci] Consume event TRB before reporting completion to USB core
      [efi] Run at TPL_CALLBACK to protect against UEFI timers
      [efi] Raise TPL within EFI_SIMPLE_NETWORK_PROTOCOL entry points
      [efi] Raise TPL within EFI_USB_IO_PROTOCOL entry points
      [process] Include process name in debug messages
      [efi] Drop to TPL_APPLICATION when gathering entropy
      [efi] Raise TPL within EFI_DRIVER_BINDING_PROTOCOL entry points
      [librm] Add facility to provide register and stack dump for CPU exceptions
      [golan] Do not assume all devices are identical
      [lacp] Mark link as blocked if partner is not yet up and running
      [lacp] Fix debug message to match documentation
      [tftp] Prevent potential division by zero
      [profile] Prevent potential division by zero
      [ocsp] Centralise test for whether or not an OCSP check is required
      [ocsp] Allow OCSP checks to be disabled
      [lacp] Check the partner's own state when checking for blocked links
      [efi] Provide Map_Mem() and associated UNDI callbacks
      [time] Add support for the ACPI power management timer
      [rng] Use fixed-point calculations for min-entropy quantities
      [build] Prevent use of MMX and SSE registers
      [undi] Treat invalid IRQ numbers as non-fatal errors
      [librm] Provide symbols for inline code placed into other sections
      [librm] Ensure that inline code symbols are unique
      [tls] Ensure received data list is initialised before calling tls_free()
      [list] Add list_is_first_entry() and list_is_last_entry()
      [tls] Rename tls_session to tls_connection
      [tls] Ensure that window change is propagated to plainstream interface
      [efi] Release SNP devices before starting SAN boot image
      [efi] Do not raise TPL within EFI_DRIVER_BINDING_PROTOCOL.Supported()
      [undi] Include subsystem IDs in broken interrupt device check
      [rhine] Fix usage of mii_read()
      [velocity] Fix usage of mii_read() and mii_write()
      [mii] Separate concepts of MII interface and MII device
      [tcp] Add missing packed attribute on struct tcp_header
      [mii] Fix typo in parameter name
      [http] Work around stateful authentication schemes
      [build] Use positive-form tests when checking for supported warnings
      [rndis] Clean up error handling path in register_rndis()
      [ethernet] Use standard 1500 byte MTU unless explicitly overridden
      [intelxl] Add driver for Intel 40 Gigabit Ethernet NICs
      [zbin] Fix compiler warning with GCC 9

Peter von Konigsmark (2):
      [exanic] Power up optical PHYs (if present)
      [exanic] Add PCI device ID for another X40 variant

Petr Borsodi (3):
      [pci] Correct invalid base-class/sub-class/prog-if order in PCIR
      [util] Improve processing of ROM images in Option::ROM
      [util] Add support for EFI ROM images

Richard Moore (1):
      [intel] Add various PCI device IDs

Rob Taglang (3):
      [intel] Add PCI_ROM entry for Intel i354 NIC
      [intelx] Add PCI_ROM entry for Intel X553 NIC
      [efi] Exclude link-layer header length from MaxPacketSize

Robin Smidsrød (1):
      [util] Support reversed sort ordering when generating NIC list

Roman Kagan (2):
      [rndis] Register netdev with MAC filled
      [vmbus] Do not expect version in version_response

Steven Haber (1):
      [intelx] Add support for Intel X552 NIC

Sylvie Barlow (3):
      [mii] Add mii_find()
      [mii] Add bit-bashing interface
      [icplus] Add driver for IC+ network card

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5 years agotests: remove rule for nonexisting qdev-monitor-test
Paolo Bonzini [Tue, 15 Jan 2019 18:19:07 +0000 (19:19 +0100)]
tests: remove rule for nonexisting qdev-monitor-test

This test was merged into drive_del-test in 2014.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Fixes: e2f3f221885a90de766ce9a3 ("Merge of qdev-monitor-test, blockdev-test")
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agotests/hexloader-test: Don't pass -nographic to the QEMU under test
Peter Maydell [Fri, 4 Jan 2019 14:50:18 +0000 (14:50 +0000)]
tests/hexloader-test: Don't pass -nographic to the QEMU under test

The hexloader test invokes QEMU with the -nographic argument. This
is unnecessary, because the qtest_initf() function will pass it
-display none, which suffices to disable the graphical window.
It also means that the QEMU process will make the stdin/stdout
O_NONBLOCK. Since O_NONBLOCK is not per-file descriptor but per
"file description", this non-blocking behaviour is then shared
with any other process that's using the stdin/stdout of the
'make check' run, including make itself. This can result in make
falling over with "make: write error: stdout" because it got
an unexpected EINTR trying to write output messages to the terminal.
This is particularly noticable if running 'make check' in a loop with
  while make check; do true; done
(It does not affect single make check runs so much because the
shell will remove the O_NONBLOCK status before it reads the
terminal for interactive input.)

Remove the unwanted -nographic argument.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoconfigure: Force the C standard to gnu99
Thomas Huth [Mon, 7 Jan 2019 10:25:22 +0000 (11:25 +0100)]
configure: Force the C standard to gnu99

Different versions of GCC and Clang use different versions of the C standard.
This repeatedly caused problems already, e.g. with duplicated typedefs:

 https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05829.html

or with for-loop variable initializers:

 https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg00237.html

To avoid these problems, we should enforce the C language version to the
same level for all compilers. Since our minimum compiler versions is
GCC v4.8, our best option is "gnu99" for C code right now ("gnu17" is not
available there yet, and "gnu11" is marked as "experimental"), and "gnu++98"
for the few C++ code that we have in the repository.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoseccomp: Work-around GCC 4.x bug in gnu99 mode
Thomas Huth [Tue, 15 Jan 2019 17:23:57 +0000 (18:23 +0100)]
seccomp: Work-around GCC 4.x bug in gnu99 mode

We'd like to compile QEMU with -std=gnu99, but GCC 4.8 currently
fails to compile qemu-seccomp.c in this mode:

qemu-seccomp.c:45:1: error: initializer element is not constant
 };
 ^
qemu-seccomp.c:45:1: error: (near initialization for ‘sched_setscheduler_arg[0]’)

This is due to a compiler bug which has just been fixed in GCC 5.0:

 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567

Since we still want to support GCC 4.8 for a while and also want to use
gnu99 mode, work-around the issue by expanding the macro manually.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Eduardo Otubo <otubo@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoblock: Work-around a bug in libiscsi 1.9.0 when used in gnu99 mode
Thomas Huth [Mon, 14 Jan 2019 13:37:20 +0000 (14:37 +0100)]
block: Work-around a bug in libiscsi 1.9.0 when used in gnu99 mode

The header "scsi-lowlevel.h" of libiscsi 1.9.0 contains some bad
"inline" prototype definitions which GCC refuses to compile in its
gnu99 mode:

In file included from block/iscsi.c:52:0:
/usr/include/iscsi/scsi-lowlevel.h:810:13: error: inline function
‘scsi_set_uint16’ declared but never defined [-Werror]
 inline void scsi_set_uint16(unsigned char *c, uint16_t val);
             ^
/usr/include/iscsi/scsi-lowlevel.h:809:13: error: inline function
‘scsi_set_uint32’ declared but never defined [-Werror]
 inline void scsi_set_uint32(unsigned char *c, uint32_t val);
             ^
[...]

This has been fixed by upstream libiscsi in version 1.10.0 (see
https://github.com/sahlberg/libiscsi/commit/7692027d6c11 ), but
since we still want to support 1.9.0 for CentOS 7 / RHEL7, we
have to work-around the issue by redefining the "inline" keyword
to use the old "gnu89" mode behavior via "gnu_inline" instead.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agolinux-user: Fix compilation with clang 3.4
Thomas Huth [Fri, 30 Nov 2018 08:23:16 +0000 (09:23 +0100)]
linux-user: Fix compilation with clang 3.4

Clang version 3.4.2 does not know the -Wpragmas option yet and bails
out with an error when we try to disable it in linux-user/qemu.h.
Fortunately, clang has a __has_warning() macro which allows us to add
an explicit check for the option that we want to ignore. With that we
can check for the availability of "-Waddress-of-packed-member" properly
and do not need the "-Wpragmas" at all here.

Fixes: 850d5e330a9c68cc998cecc02caf8a3c8d1ee8a3
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agovirtio-net: Fix VirtIONet typedef redefinition
Philippe Mathieu-Daudé [Mon, 21 Jan 2019 18:10:30 +0000 (19:10 +0100)]
virtio-net: Fix VirtIONet typedef redefinition

Commit 2974e916df8 introduced the VirtioNetRscChain structure which
refer to a VirtIONet, declared later, thus required VirtIONet typedef
to use a forward declaration.
However, when compiling with Clang in -std=gnu99 mode, this triggers
the following warning/error:

    CC      hw/net/virtio-net.o
  In file included from qemu/hw/net/virtio-net.c:22:
  include/hw/virtio/virtio-net.h:189:3: error: redefinition of typedef 'VirtIONet' is a C11 feature [-Werror,-Wtypedef-redefinition]
  } VirtIONet;
    ^
  include/hw/virtio/virtio-net.h:110:26: note: previous definition is here
  typedef struct VirtIONet VirtIONet;
                           ^
  1 error generated.
  make: *** [rules.mak:69: hw/net/virtio-net.o] Error 1

Fix it by removing the duplicate typedef definition.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode
Thomas Huth [Thu, 10 Jan 2019 07:09:13 +0000 (08:09 +0100)]
ppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode

When compiling the ppc code with clang and -std=gnu99, there are a
couple of warnings/errors like this one:

  CC      ppc64-softmmu/hw/intc/xics.o
In file included from hw/intc/xics.c:35:
include/hw/ppc/xics.h:43:25: error: redefinition of typedef 'ICPState' is a C11 feature
      [-Werror,-Wtypedef-redefinition]
typedef struct ICPState ICPState;
                        ^
target/ppc/cpu.h:1181:25: note: previous definition is here
typedef struct ICPState ICPState;
                        ^
Work around the problems by including the proper headers in spapr.h
and by using struct forward declarations in cpu.h.

Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoppc: Move spapr-related prototypes from xics.h into a seperate header file
Thomas Huth [Thu, 10 Jan 2019 08:18:47 +0000 (09:18 +0100)]
ppc: Move spapr-related prototypes from xics.h into a seperate header file

When compiling with Clang in -std=gnu99 mode, there is a warning/error:

  CC      ppc64-softmmu/hw/intc/xics_spapr.o
In file included from /home/thuth/devel/qemu/hw/intc/xics_spapr.c:34:
/home/thuth/devel/qemu/include/hw/ppc/xics.h:203:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
      [-Werror,-Wtypedef-redefinition]
typedef struct sPAPRMachineState sPAPRMachineState;
                                 ^
/home/thuth/devel/qemu/include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here
typedef struct sPAPRMachineState sPAPRMachineState;
                                 ^

We have to remove the duplicated typedef here and include "spapr.h" instead.
But "spapr.h" should not be included for the pnv machine files. So move
the spapr-related prototypes into a new file called "xics_spapr.h" instead.

Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoui/console: Remove PixelFormat from qemu/typedefs.h
Philippe Mathieu-Daudé [Mon, 14 Jan 2019 13:08:29 +0000 (14:08 +0100)]
ui/console: Remove PixelFormat from qemu/typedefs.h

Header files requiring PixelFormat already include "ui/qemu-pixman.h".

To clean "qemu/typedefs.h", move the declaration to "ui/qemu-pixman.h"
(removing the forward declaration).

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoui/console: Remove MouseTransformInfo from qemu/typedefs.h
Philippe Mathieu-Daudé [Mon, 14 Jan 2019 13:08:28 +0000 (14:08 +0100)]
ui/console: Remove MouseTransformInfo from qemu/typedefs.h

Header files requiring MouseTransformInfo already include "ui/console.h".

To clean "qemu/typedefs.h", move the declaration to "ui/console.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoui/console: Remove DisplayState/DisplaySurface from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:56 +0000 (15:08 +0100)]
ui/console: Remove DisplayState/DisplaySurface from "qemu/typedefs.h"

Files requiring DisplayState/DisplaySurface already include "ui/console.h".

To clean "qemu/typedefs.h", move the declarations to "ui/console.h"
(removing DisplaySurface forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoui/console: Remove QemuDmaBuf from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:55 +0000 (15:08 +0100)]
ui/console: Remove QemuDmaBuf from "qemu/typedefs.h"

Files requiring QemuDmaBuf already include "ui/console.h".

To clean "qemu/typedefs.h", move the declaration to "ui/console.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoaudio: Remove AudioState from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:53 +0000 (15:08 +0100)]
audio: Remove AudioState from "qemu/typedefs.h"

Files requiring AudioState already include "audio_int.h".

To clean "qemu/typedefs.h", move the declaration to "audio_int.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agohw/i386: Remove PCMachineClass from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:51 +0000 (15:08 +0100)]
hw/i386: Remove PCMachineClass from "qemu/typedefs.h"

Files requiring PCMachineClass already include "hw/i386/pc.h".

To clean "qemu/typedefs.h", move the declaration to "hw/i386/pc.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agohw/char/serial: Remove SerialState from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:50 +0000 (15:08 +0100)]
hw/char/serial: Remove SerialState from "qemu/typedefs.h"

Files requiring SerialState already include "hw/char/serial.h".

To clean "qemu/typedefs.h", move the declaration to "hw/char/serial.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agohw/bt: Remove HCIInfo from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:49 +0000 (15:08 +0100)]
hw/bt: Remove HCIInfo from "qemu/typedefs.h"

Files requiring HCIInfo already include "sysemu/bt.h".

To clean "qemu/typedefs.h", move the declaration to "sysemu/bt.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agohw/i2c/smbus: Remove SMBusDevice from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:48 +0000 (15:08 +0100)]
hw/i2c/smbus: Remove SMBusDevice from "qemu/typedefs.h"

Files requiring SMBusDevice already include "hw/i2c/smbus.h".

To clean "qemu/typedefs.h", move the forward declaration
to "hw/i2c/smbus.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agohw/ide/ahci: Remove AllwinnerAHCIState from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:46 +0000 (15:08 +0100)]
hw/ide/ahci: Remove AllwinnerAHCIState from "qemu/typedefs.h"

Files requiring AllwinnerAHCIState already include "hw/ide/ahci.h".

To clean "qemu/typedefs.h", move the declaration to "hw/ide/ahci.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agohw/pcmcia: Remove PCMCIACardState from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:44 +0000 (15:08 +0100)]
hw/pcmcia: Remove PCMCIACardState from "qemu/typedefs.h"

There is only one header file requiring this typedef (hw/arm/pxa.h),
let it include "hw/pcmcia.h" directly to simplify "qemu/typedefs.h".

To clean "qemu/typedefs.h", move the declaration to "hw/pcmcia.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
[thuth: slightly tweaked commit message]
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agohw/input/ps2: Remove PS2State from "qemu/typedefs.h"
Philippe Mathieu-Daudé [Fri, 11 Jan 2019 14:08:43 +0000 (15:08 +0100)]
hw/input/ps2: Remove PS2State from "qemu/typedefs.h"

PS2State is only used in "hw/input/ps2.h", there is no
need to expose it via "qemu/typedefs.h".

To clean "qemu/typedefs.h", move the forward declaration
to "hw/input/ps2.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agotests/pnv-xscom: Make test independent of global_qtest
Thomas Huth [Thu, 3 Jan 2019 11:09:52 +0000 (12:09 +0100)]
tests/pnv-xscom: Make test independent of global_qtest

Pass around the QTestState, so that we can finally get rid of the
out-of-favor global_qtest variable in this file, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agotests/boot-order: Make test independent of global_qtest
Thomas Huth [Thu, 3 Jan 2019 11:09:51 +0000 (12:09 +0100)]
tests/boot-order: Make test independent of global_qtest

Pass around the QTestState from function to function, so that we can finally
get rid of the out-of-favor global_qtest variable in this file, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agotests/endianesss: Make test independent of global_qtest
Thomas Huth [Thu, 3 Jan 2019 11:09:50 +0000 (12:09 +0100)]
tests/endianesss: Make test independent of global_qtest

Pass around the test state explicitly, to be able to use the qtest_in*()
and qtest_out*() function in this test.

Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agotests/Makefile: Use some more CONFIG switches for ppc tests
Thomas Huth [Thu, 29 Nov 2018 10:32:11 +0000 (11:32 +0100)]
tests/Makefile: Use some more CONFIG switches for ppc tests

To be able to build and test QEMU binaries where certain devices or machines
are disabled, we have to use the right CONFIG_* switches to run certain tests
only if the corresponding device or machine really has been compiled into
the binary.

Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agotests/Makefile: Use some more CONFIG switches for x86 tests
Thomas Huth [Thu, 29 Nov 2018 10:20:25 +0000 (11:20 +0100)]
tests/Makefile: Use some more CONFIG switches for x86 tests

To be able to build and test QEMU binaries where certain devices are
disabled, we have to use the right CONFIG_* switches to run certain
tests only if the corresponding device really has been compiled into
the binary.

Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoiotests: Enhance 223, 233 to cover 'qemu-nbd --list'
Eric Blake [Thu, 17 Jan 2019 19:36:58 +0000 (13:36 -0600)]
iotests: Enhance 223, 233 to cover 'qemu-nbd --list'

Any good new feature deserves some regression testing :)
Coverage includes:
- 223: what happens when there are 0 or more than 1 export,
proof that we can see multiple contexts including qemu:dirty-bitmap
- 233: proof that we can list over TLS, and that mix-and-match of
plain/TLS listings will behave sanely

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190117193658.16413-22-eblake@redhat.com>

5 years agonbd/client: Work around 3.0 bug for listing meta contexts
Eric Blake [Thu, 17 Jan 2019 19:36:57 +0000 (13:36 -0600)]
nbd/client: Work around 3.0 bug for listing meta contexts

Commit 3d068aff forgot to advertise available qemu: contexts
when the client requests a list with 0 queries. Furthermore,
3.0 shipped with a qemu-img hack of x-dirty-bitmap (commit
216ee365) that _silently_ acts as though the entire image is
clean if a requested bitmap is not present.  Both bugs have
been recently fixed, so that a modern qemu server gives full
context output right away, and the client refuses a
connection if a requested x-dirty-bitmap was not found.

Still, it is likely that there will be users that have to
work with a mix of old and new qemu versions, depending on
which features get backported where, at which point being
able to rely on 'qemu-img --list' output to know for sure
whether a given NBD export has the desired dirty bitmap is
much nicer than blindly connecting and risking that the
entire image may appear clean.  We can make our --list code
smart enough to work around buggy servers by tracking
whether we've seen any qemu: replies in the original 0-query
list; if not, repeat with a single query on "qemu:" (which
may still have no replies, but then we know for sure we
didn't trip up on the server bug).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190117193658.16413-21-eblake@redhat.com>

5 years agoqemu-nbd: Add --list option
Eric Blake [Thu, 17 Jan 2019 19:36:56 +0000 (13:36 -0600)]
qemu-nbd: Add --list option

We want to be able to detect whether a given qemu NBD server is
exposing the right export(s) and dirty bitmaps, at least for
regression testing.  We could use 'nbd-client -l' from the upstream
NBD project to list exports, but it's annoying to rely on
out-of-tree binaries; furthermore, nbd-client doesn't necessarily
know about all of the qemu NBD extensions.  Thus, it is time to add
a new mode to qemu-nbd that merely sniffs all possible information
from the server during handshake phase, then disconnects and dumps
the information.

This patch actually implements --list/-L, while reusing other
options such as --tls-creds for now designating how to connect
as the client (rather than their non-list usage of how to operate
as the server).

I debated about adding this functionality to something akin to
'qemu-img info' - but that tool does not readily lend itself
to connecting to an arbitrary NBD server without also tying to
a specific export (I may, however, still add ImageInfoSpecificNBD
for reporting the bitmaps available when connecting to a single
export).  And, while it may feel a bit odd that normally
qemu-nbd is a server but 'qemu-nbd -L' is a client, we are not
really making the qemu-nbd binary that much larger, because
'qemu-nbd -c' has to operate as both server and client
simultaneously across two threads when feeding the kernel module
for /dev/nbdN access.

Sample output:
$ qemu-nbd -L
exports available: 1
 export: ''
  size:  65536
  flags: 0x4ed ( flush fua trim zeroes df cache )
  min block: 512
  opt block: 4096
  max block: 33554432
  available meta contexts: 1
   base:allocation

Note that the output only lists sizes if the server sent
NBD_FLAG_HAS_FLAGS, because a newstyle server does not give
the size otherwise.  It has the side effect that for really
old servers that did not send any flags, the size is not
output even though it was available.  However, I'm not too
concerned about that - oldstyle servers are (rightfully)
getting less common to encounter (qemu 3.0 was the last
version where we even serve it), and most existing servers
that still even offer oldstyle negotiation (such as nbdkit)
still send flags (since that was added to the NBD protocol
in 2007 to permit read-only connections).

Not done here, but maybe worth future experiments: capture
the meat of NBDExportInfo into a QAPI struct, and use the
generated QAPI pretty-printers instead of hand-rolling our
output loop.  It would also permit us to add a JSON output
mode for machine parsing.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20190117193658.16413-20-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
5 years agonbd/client: Add meta contexts to nbd_receive_export_list()
Eric Blake [Thu, 17 Jan 2019 19:36:55 +0000 (13:36 -0600)]
nbd/client: Add meta contexts to nbd_receive_export_list()

We want to be able to detect whether a given qemu NBD server is
exposing the right export(s) and dirty bitmaps, at least for
regression testing.  We could use 'nbd-client -l' from the upstream
NBD project to list exports, but it's annoying to rely on
out-of-tree binaries; furthermore, nbd-client doesn't necessarily
know about all of the qemu NBD extensions.  Thus, we plan on adding
a new mode to qemu-nbd that merely sniffs all possible information
from the server during handshake phase, then disconnects and dumps
the information.

This patch continues the work of the previous patch, by adding the
ability to track the list of available meta contexts into
NBDExportInfo.  It benefits from the recent refactoring patches
with a new nbd_list_meta_contexts() that reuses much of the same
framework as setting a meta context.

Note: a malicious server could exhaust memory of a client by feeding
an unending loop of contexts; perhaps we could place a limit on how
many we are willing to receive. But this is no different from our
earlier analysis on a server sending an unending list of exports,
and the death of a client due to memory exhaustion when the client
was going to exit soon anyways is not really a denial of service
attack.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190117193658.16413-19-eblake@redhat.com>

5 years agonbd/client: Add nbd_receive_export_list()
Eric Blake [Thu, 17 Jan 2019 19:36:54 +0000 (13:36 -0600)]
nbd/client: Add nbd_receive_export_list()

We want to be able to detect whether a given qemu NBD server is
exposing the right export(s) and dirty bitmaps, at least for
regression testing.  We could use 'nbd-client -l' from the upstream
NBD project to list exports, but it's annoying to rely on
out-of-tree binaries; furthermore, nbd-client doesn't necessarily
know about all of the qemu NBD extensions.  Thus, we plan on adding
a new mode to qemu-nbd that merely sniffs all possible information
from the server during handshake phase, then disconnects and dumps
the information.

This patch adds the low-level client code for grabbing the list
of exports.  It benefits from the recent refactoring patches, in
order to share as much code as possible when it comes to doing
validation of server replies.  The resulting information is stored
in an array of NBDExportInfo which has been expanded to any
description string, along with a convenience function for freeing
the list.

Note: a malicious server could exhaust memory of a client by feeding
an unending loop of exports; perhaps we should place a limit on how
many we are willing to receive. But note that a server could
reasonably be serving an export for every file in a large directory,
where an arbitrary limit in the client means we can't list anything
from such a server; the same happens if we just run until the client
fails to malloc() and thus dies by an abort(), where the limit is
no longer arbitrary but determined by available memory.  Since the
client is already planning on being short-lived, it's hard to call
this a denial of service attack that would starve off other uses,
so it does not appear to be a security issue.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20190117193658.16413-18-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
5 years agonbd/client: Refactor nbd_opt_go() to support NBD_OPT_INFO
Eric Blake [Thu, 17 Jan 2019 19:36:53 +0000 (13:36 -0600)]
nbd/client: Refactor nbd_opt_go() to support NBD_OPT_INFO

Rename the function to nbd_opt_info_or_go() with an added parameter
and slight changes to comments and trace messages, in order to
reuse the function for NBD_OPT_INFO.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190117193658.16413-17-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
5 years agonbd/client: Pull out oldstyle size determination
Eric Blake [Thu, 17 Jan 2019 19:36:52 +0000 (13:36 -0600)]
nbd/client: Pull out oldstyle size determination

Another refactoring creating nbd_negotiate_finish_oldstyle()
for further reuse during 'qemu-nbd --list'.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20190117193658.16413-16-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
5 years agonbd/client: Split handshake into two functions
Eric Blake [Thu, 17 Jan 2019 19:36:51 +0000 (13:36 -0600)]
nbd/client: Split handshake into two functions

An upcoming patch will add the ability for qemu-nbd to list
the services provided by an NBD server.  Share the common
code of the TLS handshake by splitting the initial exchange
into a separate function, leaving only the export handling
in the original function.  Functionally, there should be no
change in behavior in this patch, although some of the code
motion may be difficult to follow due to indentation changes
(view with 'git diff -w' for a smaller changeset).

I considered an enum for the return code coordinating state
between the two functions, but in the end just settled with
ample comments.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190117193658.16413-15-eblake@redhat.com>

5 years agonbd/client: Refactor return of nbd_receive_negotiate()
Eric Blake [Thu, 17 Jan 2019 19:36:50 +0000 (13:36 -0600)]
nbd/client: Refactor return of nbd_receive_negotiate()

The function could only ever return 0 or -EINVAL; make this
clearer by dropping a useless 'fail:' label.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190117193658.16413-14-eblake@redhat.com>

5 years agonbd/client: Split out nbd_receive_one_meta_context()
Eric Blake [Thu, 17 Jan 2019 19:36:49 +0000 (13:36 -0600)]
nbd/client: Split out nbd_receive_one_meta_context()

Extract portions of nbd_negotiate_simple_meta_context() to
a new function nbd_receive_one_meta_context() that copies the
pattern of nbd_receive_list() for performing the argument
validation of one reply.  The error message when the server
replies with more than one context changes slightly, but
that shouldn't happen in the common case.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190117193658.16413-13-eblake@redhat.com>

5 years agonbd/client: Split out nbd_send_meta_query()
Eric Blake [Thu, 17 Jan 2019 19:36:48 +0000 (13:36 -0600)]
nbd/client: Split out nbd_send_meta_query()

Refactor nbd_negotiate_simple_meta_context() to pull out the
code that can be reused to send a LIST request for 0 or 1 query.
No semantic change.  The old comment about 'sizeof(uint32_t)'
being equivalent to '/* number of queries */' is no longer
needed, now that we are computing 'sizeof(queries)' instead.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20190117193658.16413-12-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
5 years agonbd/client: Change signature of nbd_negotiate_simple_meta_context()
Eric Blake [Thu, 17 Jan 2019 19:36:47 +0000 (13:36 -0600)]
nbd/client: Change signature of nbd_negotiate_simple_meta_context()

Pass 'info' instead of three separate parameters related to info,
when requesting the server to set the meta context.  Update the
NBDExportInfo struct to rename the received id field to match the
fact that we are currently overloading the field to match whatever
context the user supplied through the x-dirty-bitmap hack, as well
as adding a TODO comment to remind future patches about a desire
to request two contexts at once.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190117193658.16413-11-eblake@redhat.com>

5 years agonbd/client: Move export name into NBDExportInfo
Eric Blake [Thu, 17 Jan 2019 19:36:46 +0000 (13:36 -0600)]
nbd/client: Move export name into NBDExportInfo

Refactor the 'name' parameter of nbd_receive_negotiate() from
being a separate parameter into being part of the in-out 'info'.
This also spills over to a simplification of nbd_opt_go().

The main driver for this refactoring is that an upcoming patch
would like to add support to qemu-nbd to list information about
all exports available on a server, where the name(s) will be
provided by the server instead of the client.  But another benefit
is that we can now allow the client to explicitly specify the
empty export name "" even when connecting to an oldstyle server
(even if qemu is no longer such a server after commit 7f7dfe2a).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190117193658.16413-10-eblake@redhat.com>

5 years agonbd/client: Refactor nbd_receive_list()
Eric Blake [Thu, 17 Jan 2019 19:36:45 +0000 (13:36 -0600)]
nbd/client: Refactor nbd_receive_list()

Right now, nbd_receive_list() is only called by
nbd_receive_query_exports(), which in turn is only called if the
server lacks NBD_OPT_GO but has working option negotiation, and is
merely used as a quality-of-implementation trick since servers
can't give decent errors for NBD_OPT_EXPORT_NAME.  However, servers
that lack NBD_OPT_GO are becoming increasingly rare (nbdkit was a
latecomer, in Aug 2018, but qemu has been such a server since commit
f37708f6 in July 2017 and released in 2.10), so it no longer makes
sense to micro-optimize that function for performance.

Furthermore, when debugging a server's implementation, tracing the
full reply (both names and descriptions) is useful, not to mention
that upcoming patches adding 'qemu-nbd --list' will want to collect
that data.  And when you consider that a server can send an export
name up to the NBD protocol length limit of 4k; but our current
NBD_MAX_NAME_SIZE is only 256, we can't trace all valid server
names without more storage, but 4k is large enough that the heap
is better than the stack for long names.

Thus, I'm changing the division of labor, with nbd_receive_list()
now always malloc'ing a result on success (the malloc is bounded
by the fact that we reject servers with a reply length larger
than 32M), and moving the comparison to 'wantname' to the caller.

There is a minor change in behavior where a server with 0 exports
(an immediate NBD_REP_ACK reply) is now no longer distinguished
from a server without LIST support (NBD_REP_ERR_UNSUP); this
information could be preserved with a complication to the calling
contract to provide a bit more information, but I didn't see the
point.  After all, the worst that can happen if our guess at a
match is wrong is that the caller will get a cryptic disconnect
when NBD_OPT_EXPORT_NAME fails (which is no different from what
would happen if we had not tried LIST), while treating an empty
list as immediate failure would prevent connecting to really old
servers that really did lack LIST.  Besides, NBD servers with 0
exports are rare (qemu can do it when using QMP nbd-server-start
without nbd-server-add - but qemu understands NBD_OPT_GO and
thus won't tickle this change in behavior).

Fix the spelling of foundExport to match coding standards while
in the area.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190117193658.16413-9-eblake@redhat.com>

5 years agoqemu-nbd: Avoid strtol open-coding
Eric Blake [Thu, 17 Jan 2019 19:36:44 +0000 (13:36 -0600)]
qemu-nbd: Avoid strtol open-coding

Our copy-and-pasted open-coding of strtol handling forgot to
handle overflow conditions.  Use qemu_strto*() instead.

In the case of --partition, since we insist on a user-supplied
partition to be non-zero, we can use 0 rather than -1 for our
initial value to distinguish when a partition is not being
served, for slightly more optimal code.

The error messages for out-of-bounds values are less specific,
but should not be a terrible loss in quality.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20190117193658.16413-8-eblake@redhat.com>