Compare commits

..

135 Commits

Author SHA1 Message Date
Gerd Hoffmann
496eacaa67 update pci-bridge-seat section in docs/multiseat.txt
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-07-03 12:21:11 +02:00
Gerd Hoffmann
5cce173323 virtio-input: add input routing support
Add display and head properties for input routing to
virtio-input devices, update multiseat documentation.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-07-03 12:21:11 +02:00
Peter Maydell
6686ce3f16 Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
# gpg: Signature made Thu Jul  2 10:10:39 2015 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request:
  block: remove redundant check before g_slist_find()
  block/nfs: limit maximum readahead size to 1MB
  block/iscsi: restore compatiblity with libiscsi 1.9.0
  iotests: Use event_wait in wait_ready
  qemu-iotests: Add test case for mirror with unmap
  qemu-iotests: Make block job methods common
  block: Remove bdrv_reset_dirty
  block: Fix dirty bitmap in bdrv_co_discard
  mirror: Do zero write on target if sectors not allocated
  qmp: Add optional bool "unmap" to drive-mirror
  block: Add bdrv_get_block_status_above
  timer: Use a single definition of NSEC_PER_SEC for the whole codebase
  timer: Move NANOSECONDS_PER_SECONDS to timer.h
  blockdev: no need to drain+flush in hmp_drive_del
  qapi: Rename 'dirty-bitmap' mode to 'incremental'
  qcow2: Handle EAGAIN returned from update_refcount
  block/iscsi: add support for request timeouts

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-07-02 10:44:34 +01:00
Alberto Garcia
764ba3ae51 block: remove redundant check before g_slist_find()
An empty GSList is represented by a NULL pointer, therefore it's a
perfectly valid argument for g_slist_find() and there's no need to
make any additional check.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: 1435583533-5758-1-git-send-email-berto@igalia.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Peter Lieven
29c838cdc9 block/nfs: limit maximum readahead size to 1MB
a malicious caller could otherwise specify a very
large value via the URI and force libnfs to allocate
a large amount of memory for the readahead buffer.

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
Message-id: 1435317241-25585-1-git-send-email-pl@kamp.de
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Peter Lieven
9049736ec7 block/iscsi: restore compatiblity with libiscsi 1.9.0
RHEL7 and others are stuck with libiscsi 1.9.0 since there
unfortunately was an ABI breakage after that release.

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1435313881-19366-1-git-send-email-pl@kamp.de
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Fam Zheng
d7b2529792 iotests: Use event_wait in wait_ready
Only poll the specific type of event we are interested in, to avoid
stealing events that should be consumed by someone else.

Suggested-by: John Snow <jsnow@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Fam Zheng
c615091793 qemu-iotests: Add test case for mirror with unmap
This checks that the discard on mirror source that effectively zeroes
data is also reflected by the data of target.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Fam Zheng
866323f39d qemu-iotests: Make block job methods common
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Fam Zheng
6e82e4bce1 block: Remove bdrv_reset_dirty
Using this function would always be wrong because a dirty bitmap must
have a specific owner that consumes the dirty bits and calls
bdrv_reset_dirty_bitmap().

Remove the unused function to avoid future misuse.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Fam Zheng
508249952c block: Fix dirty bitmap in bdrv_co_discard
Unsetting dirty globally with discard is not very correct. The discard may zero
out sectors (depending on can_write_zeroes_with_unmap), we should replicate
this change to destination side to make sure that the guest sees the same data.

Calling bdrv_reset_dirty also troubles mirror job because the hbitmap iterator
doesn't expect unsetting of bits after current position.

So let's do it the opposite way which fixes both problems: set the dirty bits
if we are to discard it.

Reported-by: wangxiaolong@ucloud.cn
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Fam Zheng
dcfb3beb51 mirror: Do zero write on target if sectors not allocated
If guest discards a source cluster, mirroring with bdrv_aio_readv is overkill.
Some protocols do zero upon discard, where it's best to use
bdrv_aio_write_zeroes, otherwise, bdrv_aio_discard will be enough.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Fam Zheng
0fc9f8ea28 qmp: Add optional bool "unmap" to drive-mirror
If specified as "true", it allows discarding on target sectors where source is
not allocated.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:06:23 +01:00
Fam Zheng
ba3f0e2545 block: Add bdrv_get_block_status_above
Like bdrv_is_allocated_above, this function follows the backing chain until seeing
BDRV_BLOCK_ALLOCATED.  Base is not included.

Reimplement bdrv_is_allocated on top.

[Initialized bdrv_co_get_block_status_above() ret to 0 to silence
mingw64 compiler warning about the unitialized variable.  assert(bs !=
base) prevents that case but I suppose the program could be compiled
with -DNDEBUG.
--Stefan]

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 10:03:50 +01:00
Alberto Garcia
e0cf11f31c timer: Use a single definition of NSEC_PER_SEC for the whole codebase
Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: c6e55468856ba0b8f95913c4da111cc0ef266541.1434113783.git.berto@igalia.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 09:20:18 +01:00
Alberto Garcia
471fae3c98 timer: Move NANOSECONDS_PER_SECONDS to timer.h
We want to be able to reuse this define by making it common to
multiple QEMU modules.

This also makes it an integer since there's no need for it to be a
float.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: 6375912849da2ab561046dd013684535ccecca44.1434113783.git.berto@igalia.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 09:20:18 +01:00
Paolo Bonzini
126b8bbdfe blockdev: no need to drain+flush in hmp_drive_del
bdrv_close already does that, and in fact hmp_drive_del would need
another drain after the flush (which bdrv_close does).  So remove
the duplication.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1432822629-25401-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 09:20:18 +01:00
John Snow
4b80ab2b7d qapi: Rename 'dirty-bitmap' mode to 'incremental'
If we wish to make differential backups a feature that's easy to access,
it might be pertinent to rename the "dirty-bitmap" mode to "incremental"
to make it clear what /type/ of backup the dirty-bitmap is helping us
perform.

This is an API breaking change, but 2.4 has not yet gone live,
so we have this flexibility.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1433463642-21840-2-git-send-email-jsnow@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 09:20:18 +01:00
Jindřich Makovička
3e5feb6202 qcow2: Handle EAGAIN returned from update_refcount
Fixes a crash during image compression

Signed-off-by: Jindřich Makovička <makovick@gmail.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 09:20:18 +01:00
Peter Lieven
5dd7a535b7 block/iscsi: add support for request timeouts
libiscsi starting with 1.15 will properly support timeout of iscsi
commands. The default will remain no timeout, but this can
be changed via cmdline parameters, e.g.:

qemu -iscsi timeout=30 -drive file=iscsi://...

If a timeout occurs a reconnect is scheduled and the timed out command
will be requeued for processing after a successful reconnect.

The required API call iscsi_set_timeout is present since libiscsi
1.10 which was released in October 2013. However, due to some bugs
in the libiscsi code the use is not recommended before version 1.15.

Please note that this patch bumps the libiscsi requirement to 1.10
to have all function and macros defined. The patch fixes also a
off-by-one error in the NOP timeout calculation which was fixed
while touching these code parts.

Signed-off-by: Peter Lieven <pl@kamp.de>
Message-id: 1434455107-19328-1-git-send-email-pl@kamp.de
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-07-02 09:20:18 +01:00
Peter Maydell
d2966f804d Merge remote-tracking branch 'remotes/vivier/tags/pull-m68k-20150629' into staging
Trivial m68k cleanup

# gpg: Signature made Mon Jun 29 16:38:40 2015 BST using DSA key ID ABF36C53
# gpg: Good signature from "Laurent Vivier <laurent@vivier.eu>"
# gpg:                 aka "Laurent Vivier <Laurent@vivier.eu>"
# gpg:                 aka "Laurent Vivier <Laurent@lvivier.info>"
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>"
# gpg:                 aka "[jpeg image of size 3881]"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 9EC7 B78A C0AC E697 5E4B  BDE3 34A4 F6C9 ABF3 6C53

* remotes/vivier/tags/pull-m68k-20150629:
  m68k: remove useless parameter op_size from gen_lea_indexed()
  m68k: remove useless file m68k-qreg.h
  m68k: is_mem is useless

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-29 17:03:20 +01:00
Laurent Vivier
a435612616 m68k: remove useless parameter op_size from gen_lea_indexed()
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <huth@tuxfamily.org>
2015-06-29 17:11:57 +02:00
Laurent Vivier
bb337ac978 m68k: remove useless file m68k-qreg.h
Unused since:

    commit e1f3808e03
    Author: pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>
    Date:   Sat May 24 22:29:16 2008 +0000

        Convert m68k target to TCG.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <huth@tuxfamily.org>
2015-06-29 17:10:25 +02:00
Laurent Vivier
805167adcb m68k: is_mem is useless
Remove is_mem as it is never tested anymore since:

    commit bfa50bc263
    Author: aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
    Date:   Tue Nov 18 20:26:41 2008 +0000

        Remove premature memop TB terminations (Jan Kiszka)

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <huth@tuxfamily.org>
2015-06-29 17:09:38 +02:00
Peter Maydell
2b464e13f0 Merge remote-tracking branch 'remotes/bkoppelmann/tags/pull-tricore-20150629' into staging
TriCore bugfixes

# gpg: Signature made Mon Jun 29 13:08:17 2015 BST using RSA key ID 6B69CA14
# gpg: Good signature from "Bastian Koppelmann <kbastian@mail.uni-paderborn.de>"

* remotes/bkoppelmann/tags/pull-tricore-20150629:
  target-tricore: fix depositing bits from PCXI into ICR

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-29 13:26:43 +01:00
Paolo Bonzini
5f37fd8e29 target-tricore: fix depositing bits from PCXI into ICR
Spotted by Coverity, because (env->PCXI & MASK_PCXI_PCPN) >> 24
is always zero.  The immediately preceding assignment is also
wrong though.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Message-Id: <1435147270-1040-1-git-send-email-pbonzini@redhat.com>
2015-06-29 14:02:58 +02:00
Peter Maydell
dc1e1350f8 Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
virtio, pci fixes, enhancements

Almost exclusively bugfixes, though in this case,
we are adding functionality to the pxb in order
to make OVMF work on it.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

# gpg: Signature made Fri Jun 26 14:43:27 2015 BST using RSA key ID D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"

* remotes/mst/tags/for_upstream:
  Fix glib_subprocess test
  hw/pci-bridge: format special OFW unit address for PXB host
  hw/core: explicit OFW unit address callback for SysBusDeviceClass
  hw/pci-bridge: disable SHPC in PXB
  hw/pci-bridge: introduce "shpc" property
  hw/pci: introduce shpc_present() helper function
  hw/pci-bridge: add macro for "msi" property
  hw/pci-bridge: add macro for "chassis_nr" property
  hw/pci-bridge: expose _test parameter in SHPC_VMSTATE()
  migration: introduce VMSTATE_BUFFER_UNSAFE_INFO_TEST()
  add pci-bridge-seat
  pc: cleanup and convert TMP ACPI device description to AML API
  MAINTAINERS: add ACPI entry
  vhost: correctly pass error to caller in vhost_dev_enable_notifiers()
  balloon: add a feature bit to let Guest OS deflate balloon on oom
  qdev: fix OVERFLOW_BEFORE_WIDEN
  virito-pci: fix OVERRUN problem

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-26 15:57:43 +01:00
Peter Maydell
d14b9d79be Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20150626' into staging
target-arm queue:
 * Change the virt board's default interface type for block devices to virtio
 * Improve some error messages that will now be triggered by some incorrect
   but previously worked-by-accident command lines
 * Print ELR if we're doing debug logging of AArch64 exception entry
 * Handle the "completely empty semihosting commandline" correctly for
   softmmu (we already did for linux-user)
 * Add GICv2m description to ACPI tables for virt board
 * Fix some incorrect table revision entries in virt board ACPI tables

# gpg: Signature made Fri Jun 26 14:29:39 2015 BST using RSA key ID 14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"

* remotes/pmaydell/tags/pull-target-arm-20150626:
  hw/arm/virt: Make block devices default to virtio
  qdev-properties-system: Improve error message for drive assignment conflict
  qdev-properties-system: Change set_pointer's parse callback to use Error
  target-arm: A64: Print ELR when taking exceptions
  target-arm: default empty semihosting cmdline
  hw/arm/virt-acpi-build: Add GICv2m description in ACPI MADT table
  hw/arm/virt-acpi-build: Fix table revision and some comments

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-26 14:40:47 +01:00
Peter Maydell
4e2c0b2a4a hw/arm/virt: Make block devices default to virtio
Now we have virtio-pci, we can make the virt board's default block
device type be IF_VIRTIO. This allows users to use simplified
command lines that don't have to explicitly create virtio-pci-blk
devices; the -hda &c very short options now also work.

This means we also need to set no_cdrom to avoid getting a
default cdrom device -- this is needed because the virtio-blk
device will fail if it is connected to a block backend with
no media, which is what the default cdrom device typically is.
Providing a cdrom with media via -cdrom will succeed, but silently
create a device with non-removable medium. this is probably
not really what the user wants, but is the best we can do now.

Note that this change means that some command lines which used
to work (by accident) will stop working. Where a drive was connected
manually to a device but without 'if=none' being specified, we
used to treat this as an IDE drive, which we would then not autoplug
because the board doesn't support IDE. Now we will treat it as a
virtio disk and autoplug it, which means the attempt to use the
drive manually will fail:
  qemu-system-arm: -drive file=img.qcow2,id=foo: Drive 'foo' is already
  in use because it has been automatically connected to another device
  (did you need 'if=none' in the drive options?)
The command line will have to be changed to include 'if=none', as the
error message suggests.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1435068107-12594-4-git-send-email-peter.maydell@linaro.org
2015-06-26 14:22:37 +01:00
Peter Maydell
62f7dbde4c qdev-properties-system: Improve error message for drive assignment conflict
If the user forgot if=none on their drive specification they're likely
to get an error message because the drive is assigned once automatically
by QEMU and once by the manual id=/drive= user command line specification.
Improve the error message produced in this case to explicitly guide the
user towards if=none.

We rephrase the "drive conflict but not for an if=something" error as
well to keep the wording in line.

The two cases that change are:

(1) Drive specified as to be auto-connected and also manually connected
(and the board does handle this if= type):

  qemu-system-x86_64 -nodefaults -display none \
     -drive if=scsi,file=tmp.qcow2,id=foo -device ide-hd,drive=foo

Previously:
  qemu-system-x86_64: -device ide-hd,drive=foo: Property 'ide-hd.drive'
  can't take value 'foo', it's in use

Now:
  qemu-system-x86_64: -device ide-hd,drive=foo: Drive 'foo' is already in
  use because it has been automatically connected to another device (did
  you need 'if=none' in the drive options?)

(2) Drive specified to be manually connected in two different ways:

  qemu-system-x86_64 -nodefaults -display none \
   -drive if=none,file=tmp.qcow2,id=foo -device ide-hd,drive=foo \
   -device ide-hd,drive=foo

Previously:
  qemu-system-x86_64: -device ide-hd,drive=foo: Property 'ide-hd.drive'
  can't take value 'foo', it's in use

Now:
  qemu-system-x86_64: -device ide-hd,drive=foo: Drive 'foo' is already in
  use by another device

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1435068107-12594-3-git-send-email-peter.maydell@linaro.org
2015-06-26 14:22:36 +01:00
Peter Maydell
f1fb9f0dc0 qdev-properties-system: Change set_pointer's parse callback to use Error
Instead of having set_pointer() call a parse callback which returns
an error number that we then convert to an Error string with
error_set_from_qdev_prop_error(), make the parse callback take an
Error** and set the error itself. This will allow parse routines
to provide more helpful error messages than the generic ones.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1435068107-12594-2-git-send-email-peter.maydell@linaro.org
2015-06-26 14:22:36 +01:00
Soren Brinkmann
b21ab1fc21 target-arm: A64: Print ELR when taking exceptions
When taking an exception print the content of the exception link
register. This is useful especially for synchronous exceptions because
in that case this registers holds the address of the instruction that
generated the exception.

Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Message-id: 1435036655-16132-1-git-send-email-soren.brinkmann@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-26 14:22:36 +01:00
Liviu Ionescu
f3c2bda216 target-arm: default empty semihosting cmdline
If neither explicit semihosting args nor -kernel are used,
make SYS_GET_CMDLINE return an empty string.

Signed-off-by: Liviu Ionescu <ilg@livius.net>
Message-id: AC7B5AFC-06AE-4FAD-9852-B65708E80E09@livius.net
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-26 14:22:36 +01:00
Shannon Zhao
ca79373653 hw/arm/virt-acpi-build: Add GICv2m description in ACPI MADT table
Add GICv2m description in ACPI MADT table, so guest can use MSI when
booting with ACPI.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Message-id: 1434676210-2276-1-git-send-email-shannon.zhao@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-26 14:22:36 +01:00
Shannon Zhao
d0652b5765 hw/arm/virt-acpi-build: Fix table revision and some comments
The table revision is not the ACPI spec version. Fix the wrong revision
and also some comments.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-id: 1433820378-8336-1-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-26 14:22:36 +01:00
Peter Maydell
ccb0c7e122 Merge remote-tracking branch 'remotes/lalrae/tags/mips-20150626' into staging
MIPS patches 2015-06-26

Changes:
* MIPS UHI semihosting support
* microMIPS32 R6 support

# gpg: Signature made Fri Jun 26 10:42:33 2015 BST using RSA key ID 0B29DA6B
# gpg: Good signature from "Leon Alrae <leon.alrae@imgtec.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8DD3 2F98 5495 9D66 35D4  4FC0 5211 8E3C 0B29 DA6B

* remotes/lalrae/tags/mips-20150626:
  target-mips: add mips32r6-generic CPU definition
  target-mips: microMIPS32 R6 POOL16{A, C} instructions
  target-mips: microMIPS32 R6 Major instructions
  target-mips: microMIPS32 R6 POOL32{I, C} instructions
  target-mips: microMIPS32 R6 POOL32F instructions
  target-mips: microMIPS32 R6 POOL32A{XF} instructions
  target-mips: microMIPS32 R6 branches and jumps
  target-mips: add microMIPS32 R6 opcode enum
  target-mips: signal RI for removed instructions in microMIPS R6
  target-mips: raise RI exceptions when FIR.PS = 0
  target-mips: rearrange gen_compute_compact_branch
  target-mips: refactor {D}LSA, {D}ALIGN, {D}BITSWAP
  target-mips: remove an unused argument
  target-mips: add microMIPS TLBINV, TLBINVF
  target-mips: fix {RD, WR}PGPR in microMIPS
  target-mips: convert host to MIPS errno values when required
  target-mips: add Unified Hosting Interface (UHI) support
  target-mips: remove identical code in different branch
  hw/mips: Do not clear BEV for MIPS malta kernel load
  include/softmmu-semi.h: Make semihosting support 64-bit clean

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-26 11:32:58 +01:00
Yongbok Kim
4b3bcd016d target-mips: add mips32r6-generic CPU definition
Define a new CPU definition supporting MIPS32 Release 6 ISA and
microMIPS32 Release 6 ISA.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:26 +01:00
Yongbok Kim
ed7ce6c0f9 target-mips: microMIPS32 R6 POOL16{A, C} instructions
microMIPS32 Release 6 POOL16A/ POOL16C instructions

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:26 +01:00
Yongbok Kim
ab39ee452d target-mips: microMIPS32 R6 Major instructions
Add new microMIPS32 Release 6 Major opcode instructions

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:25 +01:00
Yongbok Kim
3b4a548944 target-mips: microMIPS32 R6 POOL32{I, C} instructions
Add new microMIPS32 Release 6 POOL32I/POOL32C type instructions

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:25 +01:00
Yongbok Kim
2a24a7bade target-mips: microMIPS32 R6 POOL32F instructions
Add new microMIPS32 Release 6 POOL32F instructions

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:25 +01:00
Yongbok Kim
e033209583 target-mips: microMIPS32 R6 POOL32A{XF} instructions
Add new microMIPS32 Release 6 pool32a/pool32axf instructions.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:25 +01:00
Yongbok Kim
65935f070a target-mips: microMIPS32 R6 branches and jumps
Add new microMIPS32 Release 6 branch and jump instructions.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:25 +01:00
Yongbok Kim
3a1f426828 target-mips: add microMIPS32 R6 opcode enum
Add microMIPS32 Release 6 opcode enum.
Remove RI checking for pre-R6 reserved opcode.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:25 +01:00
Yongbok Kim
9e8f441a7e target-mips: signal RI for removed instructions in microMIPS R6
Signal a Reserved Instruction exception for removed instruction encoding
in microMIPS Release 6.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:25 +01:00
Yongbok Kim
e29c962804 target-mips: raise RI exceptions when FIR.PS = 0
64-bit paired-single (PS) floating point data type is optional in the
pre-Release 6.
It has to raise RI exception when PS type is not implemented. (FIR.PS = 0)
(The PS data type is removed in the Release 6.)
Loongson-2E and Loongson-2F don't have any implementation field in
FCSR0(FIR) but do support PS data format, therefore for these cores RI will
not be signalled regardless of PS bit.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:22:05 +01:00
Yongbok Kim
6893f07466 target-mips: rearrange gen_compute_compact_branch
The function will be also used for microMIPS Release 6.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:09:42 +01:00
Yongbok Kim
1f1b4c008e target-mips: refactor {D}LSA, {D}ALIGN, {D}BITSWAP
Refactor those instructions in order to reuse them for microMIPS32
Release 6.
Rearrange gen_move_low32().

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:09:42 +01:00
Yongbok Kim
f60eeb0c5d target-mips: remove an unused argument
Remove an unused argument from decode_micromips32_opc()

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:09:42 +01:00
Yongbok Kim
e60ec06357 target-mips: add microMIPS TLBINV, TLBINVF
Add microMIPS TLBINV, TLBINVF

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:09:42 +01:00
Yongbok Kim
1bf5902de0 target-mips: fix {RD, WR}PGPR in microMIPS
rt, rs were swapped

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:09:42 +01:00
Leon Alrae
2c44b19c19 target-mips: convert host to MIPS errno values when required
Convert only errno values which can be returned by system calls in
mips-semi.c and are not generic to all archs.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
2015-06-26 09:08:50 +01:00
Leon Alrae
3b3c1694cf target-mips: add Unified Hosting Interface (UHI) support
Add UHI semihosting support for MIPS. QEMU run with "-semihosting" option
will alter the behaviour of SDBBP 1 instruction -- UHI operation will be
called instead of generating a debug exception.

Also tweak Malta's pseudo-bootloader. On CPU reset the $4 register is set
to -1 if semihosting arguments are passed to indicate that the UHI
operations should be used to obtain input arguments.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
2015-06-26 09:08:50 +01:00
Leon Alrae
ff33476772 target-mips: remove identical code in different branch
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
2015-06-26 09:08:50 +01:00
Matthew Fortune
d6ca4277ee hw/mips: Do not clear BEV for MIPS malta kernel load
The BEV flag controls whether the boot exception vector is still
in place when starting a kernel.  When cleared the exception vector
at EBASE (or hard coded address of 0x80000000) is used instead.

The early stages of the linux kernel would benefit from BEV still
being set to ensure any faults get handled by the boot rom exception
handlers.  This is a moot point for system qemu as there aren't really
any BEV handlers, but there are other good reasons to change this...

The UHI (semi-hosting interface) defines special behaviours depending
on whether an application starts in an environment with BEV set or
cleared. When BEV is set then UHI assumes that a bootloader is
relatively dumb and has no advanced exception handling logic.
However, when BEV is cleared then UHI assumes that the bootloader
has the ability to handle UHI exceptions with its exception handlers
and will unwind and forward UHI SYSCALL exceptions to the exception
vector that was installed prior to running the application.

Signed-off-by: Matthew Fortune <matthew.fortune@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2015-06-26 09:08:50 +01:00
Maciej W. Rozycki
9f6f7ca149 include/softmmu-semi.h: Make semihosting support 64-bit clean
Correct addresses passed around in semihosting to use a data type suitable
for both 32-bit and 64-bit targets.

Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
2015-06-26 09:08:50 +01:00
Peter Maydell
0a4a0312bf Merge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging
# gpg: Signature made Wed Jun 24 16:37:23 2015 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/net-pull-request:
  net: simplify net_client_init1()
  net: drop if expression that is always true
  net: raise an error if -net type is invalid
  net: replace net_client_init1() netdev whitelist with blacklist
  net: add missing "netmap" to host_net_devices[]

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-25 14:03:55 +01:00
Peter Maydell
58e8b33518 Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
# gpg: Signature made Wed Jun 24 16:27:53 2015 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request:
  virito-blk: drop duplicate check
  qemu-iotests: fix 051.out after qdev error message change
  iov: don't touch iov in iov_send_recv()
  raw-posix: Introduce hdev_is_sg()
  raw-posix: Use DPRINTF for DEBUG_FLOPPY
  raw-posix: DPRINTF instead of DEBUG_BLOCK_PRINT
  Fix migration in case of scsi-generic
  block: Use bdrv_is_sg() everywhere
  nvme: Fix memleak in nvme_dma_read_prp
  vvfat: add a label option
  util/hbitmap: Add an API to reset all set bits in hbitmap
  virtio-blk: Use blk_drain() to drain IO requests
  block-backend: Introduce blk_drain()
  throttle: Check current timers before updating any_timer_armed[]
  block: Let bdrv_drain_all() to call aio_poll() for each AioContext

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-25 11:19:46 +01:00
Stefan Hajnoczi
1e81aba5ac net: simplify net_client_init1()
Drop the union and move the hubport creation into the !is_netdev case.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-id: 1432743412-15943-6-git-send-email-stefanha@redhat.com
2015-06-24 16:33:42 +01:00
Stefan Hajnoczi
4ef0defbad net: drop if expression that is always true
Both is_netdev and !is_netdev paths already check that
net_client_init_func[opts->kind] is non-NULL so there is no need for the
if statement.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-id: 1432743412-15943-5-git-send-email-stefanha@redhat.com
2015-06-24 16:33:27 +01:00
Stefan Hajnoczi
d139e9a6cf net: raise an error if -net type is invalid
When a -net type is used that was not compiled into the binary there
should be an error message.

Note the special case for -net none, which is a no-op.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-id: 1432743412-15943-4-git-send-email-stefanha@redhat.com
2015-06-24 16:33:20 +01:00
Stefan Hajnoczi
1322629b4f net: replace net_client_init1() netdev whitelist with blacklist
It's cumbersome to keep the whitelist up-to-date.  New netdev backends
should most likely be allowed so a blacklist makes more sense than a
whitelist.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-id: 1432743412-15943-3-git-send-email-stefanha@redhat.com
2015-06-24 16:30:29 +01:00
Stefan Hajnoczi
027a247bbf net: add missing "netmap" to host_net_devices[]
Although hmp-commands.hx lists "netmap" as a valid host_net_add type,
the command rejects it because it's missing from the list.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1432743412-15943-2-git-send-email-stefanha@redhat.com
2015-06-24 16:29:07 +01:00
Gonglei
1204854501 virito-blk: drop duplicate check
in_num = req->elem.in_num, and req->elem.in_num is
checked in line 489, so the check about in_num variable
is superflous, let's drop it.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-id: 1435138164-11728-1-git-send-email-arei.gonglei@huawei.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-24 16:16:04 +01:00
Stefan Hajnoczi
a30c4eb2ce qemu-iotests: fix 051.out after qdev error message change
Commit f006cf7fa9 ("qdev-monitor:
Propagate errors through qdev_device_add()") dropped a meaningless error
message.  This change in output caused qemu-iotests 051 to fail:

   QEMU_PROG: -device ide-drive,drive=disk: Device initialization failed.
  -QEMU_PROG: -device ide-drive,drive=disk: Device 'ide-drive' could not be initialized

Update 051.out so the test passes again.

Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-id: 1435071369-30936-1-git-send-email-stefanha@redhat.com
2015-06-24 15:23:20 +01:00
Peter Maydell
355df30554 Merge remote-tracking branch 'remotes/mjt/tags/pull-trivial-patches-2015-06-23' into staging
trivial patches for 2015-06-23

# gpg: Signature made Tue Jun 23 18:23:45 2015 BST using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>"
# gpg:                 aka "Michael Tokarev <mjt@debian.org>"

* remotes/mjt/tags/pull-trivial-patches-2015-06-23: (21 commits)
  util/qemu-sockets: improve ai_flag hints for ipv6 hosts
  hw/display/tcx.c: Fix memory leak
  hw/display/cg3.c: Fix memory leak
  Makefile: Add "make ctags"
  Makefile: Fix "make cscope TAGS"
  qemu-options: Use @itemx where appropriate
  qemu-options: Improve -global documentation
  throttle: Fix typo in the documentation of block_set_io_throttle
  hw/display/qxl-logger.c: Constify some variable
  configure: rearrange --help and consolidate enable/disable together
  libcacard: pkgconfig: tidy dependent libs
  vt82c686: QOMify
  xen_pt: QOMify
  wdt_i6300esb: QOMify
  piix4: QOMify
  piix: piix3 QOMify
  pci-assign: QOMify
  Print error when failing to load PCI config data
  Grammar: 'as to'->'as for'
  remove libdecnumber/dpd/decimal128Local.h
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-23 18:25:55 +01:00
Wolfgang Bumiller
3de3d698d9 util/qemu-sockets: improve ai_flag hints for ipv6 hosts
*) Do not use AI_ADDRCONFIG on listening sockets, because this flag
makes it impossible to explicitly listen on '127.0.0.1' if no global
ipv4 address is configured additionally, making this a very
uncomfortable option.
*) Add AI_V4MAPPED hint for connecting sockets.

If your system is globally only connected via ipv6 you often still want
to be able to use '127.0.0.1' and 'localhost' (even if localhost doesn't
also have an ipv6 entry).
For example, PVE - unless explicitly asking for insecure mode - uses
ipv4 loopback addresses with QEMU for live migrations tunneled over SSH.
These fail to start because AI_ADDRCONFIG makes getaddrinfo refuse to
work with '127.0.0.1'.

As for the AI_V4MAPPED flag: glibc uses it by default, and providing
non-0 flags removes it. I think it makes sense to use it.

I also want to point out that glibc explicitly sidesteps POSIX standards
when passing 0 as hints by then assuming both AI_V4MAPPED and
AI_ADDRCONFIG (the latter being a rather weird choice IMO), while
according to POSIX.1-2001 it should be assumed 0. (glibc considers its
choice an improvement.)
Since either AI_CANONNAME or AI_PASSIVE are passed in our cases, glibc's
default flags in turn are disabled again unless explicitly added, which
I do with this patch.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:39 +03:00
Shannon Zhao
8684e85ca9 hw/display/tcx.c: Fix memory leak
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:39 +03:00
Shannon Zhao
22b2aeb82c hw/display/cg3.c: Fix memory leak
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:39 +03:00
Fam Zheng
ae5fdc81a1 Makefile: Add "make ctags"
This generates ctags file

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:39 +03:00
Fam Zheng
eaa2ddbb76 Makefile: Fix "make cscope TAGS"
Cscope and TAGS files work in source directory rather than the build
directory, also, don't ask users to run configure first, because they
may have an out of tree build.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:39 +03:00
Markus Armbruster
f9cfd6555a qemu-options: Use @itemx where appropriate
Doesn't appear to make a difference, but let's use it consistently.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:39 +03:00
Markus Armbruster
ae08fd5a36 qemu-options: Improve -global documentation
Recent commit 3751d7c "vl: allow full-blown QemuOpts syntax for
-global" overloaded its existing argument syntax DRIVER.PROP=VALUE
with QemuOpts syntax.  Unambigious as long as no DRIVER contains '='.

Its documentation claims that "the two syntaxes are equivalent."
Improve it to spell out how exactly the old syntax gets desugared into
the new one.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:39 +03:00
Alberto Garcia
6b932c0a5f throttle: Fix typo in the documentation of block_set_io_throttle
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:39 +03:00
Frediano Ziglio
a91e21186f hw/display/qxl-logger.c: Constify some variable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:39 +03:00
Michael Tokarev
c23f23b970 configure: rearrange --help and consolidate enable/disable together
This is an attempt to rearrange configure --help output a bit
and consolidate pairs of --enable/disable into its own section.

After this, help text is easier to sort, manage and read.
More descriptive text can be added as well, since we now have
more space.

While at it, mention en/dis-able-vte.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 20:23:33 +03:00
Michael Tokarev
1e4db05957 libcacard: pkgconfig: tidy dependent libs
libcacard.pc file lists only one package in Requires
field, which is nss, while glib-2.0 is also a requiriment.
Furthermore, for libraries used internally by the library
(this is the way nss and glib are used by libcacard),
Requires.private shold be used instead of Requires.

Fix both issues.

This does not affect linking of qemu because it links
with objects from libcacard directly.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:28 +03:00
Gonglei
417349e6e9 vt82c686: QOMify
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:28 +03:00
Gonglei
f9b9d292af xen_pt: QOMify
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Tested-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:28 +03:00
Gonglei
41fc9050fe wdt_i6300esb: QOMify
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:28 +03:00
Gonglei
acff3e48b7 piix4: QOMify
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:28 +03:00
Gonglei
b7c69719d2 piix: piix3 QOMify
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:28 +03:00
Gonglei
1ea6305a83 pci-assign: QOMify
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:28 +03:00
Dr. David Alan Gilbert
7c59364d03 Print error when failing to load PCI config data
When loading migration fails due to a disagreement about
PCI config data we don't currently get any errors explaining
that was the cause of the problem or which byte in the config
data was at fault.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:27 +03:00
Dr. David Alan Gilbert
4aab6282f8 Grammar: 'as to'->'as for'
Fixup migrate-incoming text as requested by Eric in:

 http://lists.nongnu.org/archive/html/qemu-devel/2015-03/msg03362.html

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:27 +03:00
Michael Tokarev
bfa3ab6197 remove libdecnumber/dpd/decimal128Local.h
Commit 72ac97cdfc added two equivalent versions of decimal128Local.h,
one in libdecnumber/dpd/ and another in include/libdecnumber/dpd/.
Being identical by the code, the two files however differs in the
licensing terms.  The one in libdecnumber/dpd/ (which is being
removed by this patch) is licensed as GPL3.1 (plus gcc runtime
exception), which, as far as I know, is not compatible with GPL-2.
This file is not used (it is included from
include/libdecnumber/dpd/decimal128.h, so version in include/ is
used).

More, the version in include/ can also be removed, since none
of the 3 defines from that file are actually used by the code.
Even more, one of the defines from there, decimal128SetSign,
is redefined (to equivalent value) in libdecnumber/dpd/decimal128.c,
but again, never used.

What a mess...

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-23 19:57:27 +03:00
Alex Bennée
a4969e90b8 configure: append --extra-ldflags to LDFLAGS
The help text says --extra-ldflags is appended to LDFLAGS so make it so.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-06-23 19:57:27 +03:00
Peter Maydell
000d6042da Merge remote-tracking branch 'remotes/sstabellini/tags/xen-220615-3' into staging
xen-220615, more SOB lines

# gpg: Signature made Tue Jun 23 17:19:08 2015 BST using RSA key ID 70E1AE90
# gpg: Good signature from "Stefano Stabellini <stefano.stabellini@eu.citrix.com>"

* remotes/sstabellini/tags/xen-220615-3:
  Revert "xen-hvm: increase maxmem before calling xc_domain_populate_physmap"
  xen/pass-through: constify some static data
  xen/pass-through: log errno values rather than function return ones
  xen/pass-through: ROM BAR handling adjustments
  xen/pass-through: fold host PCI command register writes

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-23 17:46:20 +01:00
Stefano Stabellini
ffffbb369f Revert "xen-hvm: increase maxmem before calling xc_domain_populate_physmap"
This reverts commit c1d322e604.

The original commit fixes a bug when assigning a large number of
devices which require option roms to a guest.  (One known
configuration that needs extra memory is having more than 4 emulated
NICs assigned.  Three or fewer NICs seems to work without this
functionality.)

However, by unilaterally increasing maxmem, it introduces two
problems.

First, now libxl's calculation of the required maxmem during migration
is broken -- any guest which exercised this functionality will fail on
migration.  (Guests which have the default number of devices are not
affected.)

Secondly, it makes it impossible for a higher-level toolstack or
administer to predict how much memory a VM will actually use, making
it much more difficult to effectively use all of the memory on a
machine.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2015-06-23 16:18:38 +00:00
Jan Beulich
74526eb018 xen/pass-through: constify some static data
This is done indirectly by adjusting two typedefs and helps emphasizing
that the respective tables aren't supposed to be modified at runtime
(as they may be shared between devices).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2015-06-23 16:18:37 +00:00
Jan Beulich
3782f60d20 xen/pass-through: log errno values rather than function return ones
Functions setting errno commonly return just -1, which is of no
particular use in the log file.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2015-06-23 16:18:31 +00:00
Jan Beulich
69976894c1 xen/pass-through: ROM BAR handling adjustments
Expecting the ROM BAR to be written with an all ones value when sizing
the region is wrong - the low bit has another meaning (enable/disable)
and bits 1..10 are reserved. The PCI spec also mandates writing all
ones to just the address portion of the register.

Use suitable constants also for initializing the ROM BAR register field
description.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
2015-06-23 16:18:29 +00:00
Jan Beulich
950fe0aa3f xen/pass-through: fold host PCI command register writes
The code introduced to address XSA-126 allows simplification of other
code in xen_pt_initfn(): All we need to do is update "cmd" suitably,
as it'll be written back to the host register near the end of the
function anyway.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
2015-06-23 16:18:24 +00:00
Wen Congyang
6b64640dd2 iov: don't touch iov in iov_send_recv()
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Message-id: 555D39D2.4000705@cn.fujitsu.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 16:05:34 +01:00
Dimitris Aragiorgis
3307ed7b3f raw-posix: Introduce hdev_is_sg()
Until now, an SG device was identified only by checking if its path
started with "/dev/sg". Then, hdev_open() would set the bs->sg flag
accordingly. The patch relies on the actual properties of the device
instead of the specified file path.

To this end, test for an SG device (e.g. /dev/sg0) by ensuring that
all of the following holds:

 - The specified file name corresponds to a character device
 - The device supports the SG_GET_VERSION_NUM ioctl
 - The device supports the SG_GET_SCSI_ID ioctl

Signed-off-by: Dimitris Aragiorgis <dimara@arrikto.com>
Message-id: 1435056300-14924-6-git-send-email-dimara@arrikto.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:08:52 +01:00
Dimitris Aragiorgis
a93a3982a6 raw-posix: Use DPRINTF for DEBUG_FLOPPY
Get rid of several #ifdef DEBUG_FLOPPY and substitute them with
DPRINTF.

Signed-off-by: Dimitris Aragiorgis <dimara@arrikto.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1435056300-14924-5-git-send-email-dimara@arrikto.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:08:52 +01:00
Dimitris Aragiorgis
bcb225550d raw-posix: DPRINTF instead of DEBUG_BLOCK_PRINT
Building the QEMU tools fails if we #define DEBUG_BLOCK inside
block/raw-posix.c. Here instead of adding qemu-log.o in block-obj-y
so that DEBUG_BLOCK_PRINT can be used, we substitute the latter with
a simple DPRINTF() (that does not cause bit-rot).

Signed-off-by: Dimitris Aragiorgis <dimara@arrikto.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1435056300-14924-4-git-send-email-dimara@arrikto.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:08:52 +01:00
Dimitris Aragiorgis
1b6bc94d5d Fix migration in case of scsi-generic
During migration, QEMU uses fsync()/fdatasync() on the open file
descriptor for read-write block devices to flush data just before
stopping the VM.

However, fsync() on a scsi-generic device returns -EINVAL which
causes the migration to fail. This patch skips flushing data in case
of an SG device, since submitting SCSI commands directly via an SG
character device (e.g. /dev/sg0) bypasses the page cache completely,
anyway.

Note that fsync() not only flushes the page cache but also the disk
cache. The scsi-generic device never sends flushes, and for
migration it assumes that the same SCSI device is used by the
destination host, so it does not issue any SCSI SYNCHRONIZE CACHE
(10) command.

Finally, remove the bdrv_is_sg() test from iscsi_co_flush() since
this is now redundant (we flush the underlying protocol at the end
of bdrv_co_flush() which, with this patch, we never reach).

Signed-off-by: Dimitris Aragiorgis <dimara@arrikto.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1435056300-14924-3-git-send-email-dimara@arrikto.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:08:52 +01:00
Dimitris Aragiorgis
b192af8acc block: Use bdrv_is_sg() everywhere
Instead of checking bs->sg use bdrv_is_sg() consistently throughout
the code.

Signed-off-by: Dimitris Aragiorgis <dimara@arrikto.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1435056300-14924-2-git-send-email-dimara@arrikto.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:08:52 +01:00
Lu Lina
25940fa7e5 nvme: Fix memleak in nvme_dma_read_prp
Signed-off-by: Lu Lina <lina.lulina@huawei.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Message-id: 1434695254-69808-1-git-send-email-kathy.wangting@huawei.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:06:17 +01:00
Wolfgang Bumiller
d5941ddae8 vvfat: add a label option
Until now the vvfat volume label was hardcoded to be
"QEMU VVFAT", now you can pass a file.label=labelname option
to the -drive to change it.

The FAT structure defines the volume label to be limited to
11 bytes and is filled up spaces when shorter than that. The
trailing spaces however aren't exposed to the user by
operating systems.

[Added missing comment '#' characters in block-core.json to fix build
errors.
--Stefan]

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Message-id: 1434706529-13895-2-git-send-email-w.bumiller@proxmox.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:06:17 +01:00
Wen Congyang
c6a8c3283f util/hbitmap: Add an API to reset all set bits in hbitmap
The function bdrv_clear_dirty_bitmap() is updated to use
faster hbitmap_reset_all() call.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-id: 555E868A.60506@cn.fujitsu.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:06:16 +01:00
Alexander Yarygin
6e40b3bfc7 virtio-blk: Use blk_drain() to drain IO requests
Each call of the virtio_blk_reset() function calls blk_drain_all(),
which works for all existing BlockDriverStates, while draining only
one is needed.

This patch replaces blk_drain_all() by blk_drain() in
virtio_blk_reset(). virtio_blk_data_plane_stop() should be called
after draining because it restores vblk->complete_request.

Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Message-id: 1434537440-28236-3-git-send-email-yarygin@linux.vnet.ibm.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:06:16 +01:00
Alexander Yarygin
97b0385a34 block-backend: Introduce blk_drain()
This patch introduces the blk_drain() function which allows to replace
blk_drain_all() when only one BlockDriverState needs to be drained.

Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1434537440-28236-2-git-send-email-yarygin@linux.vnet.ibm.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:06:16 +01:00
Alberto Garcia
2f388b93a1 throttle: Check current timers before updating any_timer_armed[]
Calling throttle_group_config() cancels all timers from a particular
BlockDriverState, so any_timer_armed[] should be updated accordingly.

However, with the current code it may happen that a timer is armed in
a different BlockDriverState from the same group, so any_timer_armed[]
would be set to false in a situation where there is still a timer
armed.

The consequence is that we might end up with two timers armed. This
should not have any noticeable impact however, since all accesses to
the ThrottleGroup are protected by a lock, and the situation would
become normal again shortly thereafter as soon as all timers have been
fired.

The correct way to solve this is to check that we're actually
cancelling a timer before updating any_timer_armed[].

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: 1434382875-3998-1-git-send-email-berto@igalia.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:06:16 +01:00
Alexander Yarygin
f406c03c09 block: Let bdrv_drain_all() to call aio_poll() for each AioContext
After the commit 9b536adc ("block: acquire AioContext in
bdrv_drain_all()") the aio_poll() function got called for every
BlockDriverState, in assumption that every device may have its own
AioContext. If we have thousands of disks attached, there are a lot of
BlockDriverStates but only a few AioContexts, leading to tons of
unnecessary aio_poll() calls.

This patch changes the bdrv_drain_all() function allowing it find shared
AioContexts and to call aio_poll() only for unique ones.

Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-id: 1433936297-7098-4-git-send-email-yarygin@linux.vnet.ibm.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-06-23 15:06:16 +01:00
Peter Maydell
6966b2a071 Merge remote-tracking branch 'remotes/kraxel/tags/pull-input-20150623-1' into staging
virtio-input: property fixes, add evdev passthrough

# gpg: Signature made Tue Jun 23 09:33:29 2015 BST using RSA key ID D3E87138
# 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>"

* remotes/kraxel/tags/pull-input-20150623-1:
  Add MAINTAINERS entry for virtio-input
  virtio-input: evdev passthrough
  virtio-input: move properties, use virtio_instance_init_common

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-23 13:32:50 +01:00
Peter Maydell
a3206972a9 Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2015-06-22' into staging
Monitor patches

# gpg: Signature made Mon Jun 22 18:56:18 2015 BST using RSA key ID EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"

* remotes/armbru/tags/pull-monitor-2015-06-22: (24 commits)
  Include monitor/monitor.h exactly where needed
  Include qapi/qmp/qerror.h exactly where needed
  qerror: Move #include out of qerror.h
  qerror: Finally unused, clean up
  qmp: Wean off qerror_report()
  tpm: Avoid qerror_report() outside QMP command handlers
  qerror: Clean up QERR_ macros to expand into a single string
  qerror: Eliminate QERR_DEVICE_NOT_FOUND
  vl: Use error_report() for --display errors
  vl: Avoid qerror_report() outside QMP command handlers
  QemuOpts: Wean off qerror_report_err()
  qdev-monitor: Propagate errors through qdev_device_add()
  qdev-monitor: Propagate errors through set_property()
  qdev-monitor: Convert qbus_find() to Error
  qdev-monitor: Fix check for full bus
  qdev-monitor: Stop error avalanche in qbus_find_recursive()
  disas: Remove uses of CPU env
  monitor: Split mon_get_cpu fn to remove ENV_GET_CPU
  monitor: Fix failure path for "S" argument
  monitor: Point to "help" command on syntax error
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-23 10:38:00 +01:00
Gerd Hoffmann
a5d4d7b580 Add MAINTAINERS entry for virtio-input
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-06-23 10:32:35 +02:00
Gerd Hoffmann
006a5edebe virtio-input: evdev passthrough
This allows to assign host input devices to the guest:

qemu -device virtio-input-host-pci,evdev=/dev/input/event<nr>

The guest gets exclusive access to the input device, so be careful
with assigning the keyboard if you have only one connected to your
machine.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-06-23 10:32:35 +02:00
Gerd Hoffmann
6f2b9a5b24 virtio-input: move properties, use virtio_instance_init_common
Move properties from virtio-*-pci to virtio-*-device.
Also make better use of QOM and attach common properties
to the abstract parent classes (virtio-input-device and
virtio-input-pci-device).

Switch the hid device instance init functions over to use
virtio_instance_init_common, so we get the properties of the
virtio device aliased properly to the virtio pci proxy.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-06-23 10:32:35 +02:00
Markus Armbruster
a0b1a66ea3 Include monitor/monitor.h exactly where needed
In particular, don't include it into headers.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:41 +02:00
Markus Armbruster
cc7a8ea740 Include qapi/qmp/qerror.h exactly where needed
In particular, don't include it into headers.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:41 +02:00
Markus Armbruster
d49b683644 qerror: Move #include out of qerror.h
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:40 +02:00
Markus Armbruster
4629ed1e98 qerror: Finally unused, clean up
Remove it except for two things in qerror.h:

* Two #include to be cleaned up separately to avoid cluttering this
  patch.

* The QERR_ macros.  Mark as obsolete.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:40 +02:00
Markus Armbruster
485febc6d1 qmp: Wean off qerror_report()
The traditional QMP command handler interface

    int qmp_FOO(Monitor *mon, const QDict *params, QObject **ret_data);

doesn't provide for returning an Error object.  Instead, the handler
is expected to stash it in the monitor with qerror_report().

When we rebased QMP on top of QAPI, we didn't change this interface.
Instead, commit 776574d introduced "middle mode" as a temporary aid
for converting existing QMP commands to QAPI one by one.  More than
three years later, we're still using it.

Middle mode has two effects:

* Instead of the native input marshallers

      static void qmp_marshal_input_FOO(QDict *, QObject **, Error **)

  it generates input marshallers conforming to the traditional QMP
  command handler interface.

* It suppresses generation of code to register them with
  qmp_register_command()

  This permits giving them internal linkage.

As long as we need qmp-commands.hx, we can't use the registry behind
qmp_register_command(), so the latter has to stay for now.

The former has to go to get rid of qerror_report().  Changing all QMP
commands to fit the QAPI mold in one go was impractical back when we
started, but by now there are just a few stragglers left:
do_qmp_capabilities(), qmp_qom_set(), qmp_qom_get(), qmp_object_add(),
qmp_netdev_add(), do_device_add().

Switch middle mode to generate native input marshallers, and adapt the
stragglers.  Simplifies both the monitor code and the stragglers.

Rename do_qmp_capabilities() to qmp_capabilities(), and
do_device_add() to qmp_device_add, because that's how QMP command
handlers are named today.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:40 +02:00
Markus Armbruster
8b53a19675 tpm: Avoid qerror_report() outside QMP command handlers
qerror_report() is a transitional interface to help with converting
existing monitor commands to QMP.  It should not be used elsewhere.
Replace by error_report().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:40 +02:00
Markus Armbruster
c6bd8c706a qerror: Clean up QERR_ macros to expand into a single string
These macros expand into error class enumeration constant, comma,
string.  Unclean.  Has been that way since commit 13f59ae.

The error class is always ERROR_CLASS_GENERIC_ERROR since the previous
commit.

Clean up as follows:

* Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and
  delete it from the QERR_ macro.  No change after preprocessing.

* Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into
  error_setg(...).  Again, no change after preprocessing.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:40 +02:00
Markus Armbruster
75158ebbe2 qerror: Eliminate QERR_DEVICE_NOT_FOUND
Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
Fortunately, there's just one such macro left.  Eliminate it with this
coccinelle semantic patch:

    @@
    expression EP, E;
    @@
    -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
    +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:39 +02:00
Markus Armbruster
c6bf0f7ffa vl: Use error_report() for --display errors
Results in nicer error messages.  Before this patch:

    Invalid GTK option string: gtk,lirum-larum

After:

    qemu-system-x86_64: -display gtk,lirum-larum: Invalid GTK option string

Of course, the thing ought to use QemuOpts instead of parsing by hand.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:39 +02:00
Markus Armbruster
1459407e88 vl: Avoid qerror_report() outside QMP command handlers
qerror_report() is a transitional interface to help with converting
existing monitor commands to QMP.  It should not be used elsewhere.
Replace by error_report() in initial startup helpers parse_sandbox()
and parse_add_fd().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:39 +02:00
Markus Armbruster
70b9433109 QemuOpts: Wean off qerror_report_err()
qerror_report_err() is a transitional interface to help with
converting existing monitor commands to QMP.  It should not be used
elsewhere.

The only remaining user in qemu-option.c is qemu_opts_parse().  Is it
used in QMP context?  If not, we can simply replace
qerror_report_err() by error_report_err().

The uses in qemu-img.c, qemu-io.c, qemu-nbd.c and under tests/ are
clearly not in QMP context.

The uses in vl.c aren't either, because the only QMP command handlers
there are qmp_query_status() and qmp_query_machines(), and they don't
call it.

Remaining uses:

* drive_def(): Command line -drive and such, HMP drive_add and pci_add

* hmp_chardev_add(): HMP chardev-add

* monitor_parse_command(): HMP core

* tmp_config_parse(): Command line -tpmdev

* net_host_device_add(): HMP host_net_add

* net_client_parse(): Command line -net and -netdev

* qemu_global_option(): Command line -global

* vnc_parse_func(): Command line -display, -vnc, default display, HMP
  change, QMP change.  Bummer.

* qemu_pci_hot_add_nic(): HMP pci_add

* usb_net_init(): Command line -usbdevice, HMP usb_add

Propagate errors through qemu_opts_parse().  Create a convenience
function qemu_opts_parse_noisily() that passes errors to
error_report_err().  Switch all non-QMP users outside tests to it.

That leaves vnc_parse_func().  Propagate errors through it.  Since I'm
touching it anyway, rename it to vnc_parse().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:39 +02:00
Markus Armbruster
f006cf7fa9 qdev-monitor: Propagate errors through qdev_device_add()
Also polish an error message while I'm touching the line anyway,

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
2015-06-22 18:20:39 +02:00
Markus Armbruster
4caa489d13 qdev-monitor: Propagate errors through set_property()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
2015-06-22 18:20:39 +02:00
Markus Armbruster
d282842999 qdev-monitor: Convert qbus_find() to Error
As usual, the conversion breaks printing explanatory messages after
the error: actual printing of the error gets delayed, so the
explanations precede rather than follow it.

Pity.  Disable them for now.  See also commit 7216ae3.

While there, eliminate QERR_BUS_NOT_FOUND, and clean up unusual
spelling in the error message.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2015-06-22 18:20:39 +02:00
Markus Armbruster
ed238ba2a0 qdev-monitor: Fix check for full bus
Property bus has always been too screwed up to be really usable for
values other than plain bus IDs.  This just fixes a bug that crept in
in commit 1395af6 "qdev: add a maximum device allowed field for the
bus."

It doesn't always fail when it should:

    $ qemu-system-x86_64 -nodefaults -device virtio-serial-pci -device virtio-rng-device,bus=pci.0/virtio-serial-pci/virtio-bus

Happily plugs the virtio-rng-device into the virtio-bus provided by
virtio-serial-pci, even though its only slot is already occupied by a
virtio-serial-device.

And sometimes fails when it shouldn't:

    $ qemu-system-x86_64 -nodefaults -device virtio-serial-pci -device virtserialport,bus=virtio-bus/virtio-serial-device

Yes, the virtio-bus is full, but the virtio-serial-bus provided by
virtio-serial-device isn't, and that's the one we're trying to use.

Root cause: we check "bus full" when we resolve the first element of
the path.  That's the correct one only when it's also the last one.

Fix by moving the "bus full" check to right before we return a bus.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2015-06-22 18:20:39 +02:00
Markus Armbruster
a5ec494e27 qdev-monitor: Stop error avalanche in qbus_find_recursive()
Reproducer:

    $ qemu-system-x86_64 -nodefaults -device virtio-rng-pci -device virtio-rng-pci -device virtio-rng-device,bus=virtio-bus
    qemu-system-x86_64: -device virtio-rng-device,bus=virtio-bus: Bus 'virtio-bus' is full
    qemu-system-x86_64: -device virtio-rng-device,bus=virtio-bus: Bus 'virtio-bus' is full
    qemu-system-x86_64: -device virtio-rng-device,bus=virtio-bus: Bus 'virtio-bus' not found

qbus_find_recursive() reports the "is full" error itself, and leaves
reporting "not found" to its caller.  The result is confusion.  Write
it a function contract that permits leaving all error reporting to the
caller, and implement it.  Update callers to detect and report "is
full".

Screwed up when commit 1395af6 added the max_dev limit and the "is
full" error condition to enforce it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2015-06-22 18:20:39 +02:00
Peter Crosthwaite
d49190c420 disas: Remove uses of CPU env
disas does not need to access the CPU env for any reason. Change the
APIs to accept CPU pointers instead. Small change pattern needs to be
applied to all target translate.c. This brings us closer to making
disas.o a common-obj and less architecture specific in general.

Cc: Richard Henderson <rth@twiddle.net>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Michael Walle <michael@walle.cc>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Cc: Jia Liu <proljc@gmail.com>
Cc: Alexander Graf <agraf@suse.de>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-22 17:40:01 +02:00
Peter Crosthwaite
5bcda5f734 monitor: Split mon_get_cpu fn to remove ENV_GET_CPU
The monitor currently has one helper, mon_get_cpu() which will return
an env pointer. The target specific users of this API want an env, but
all the target agnostic users really just want the cpu pointer. These
users then need to use the target-specifically defined ENV_GET_CPU to
navigate back up to the CPU from the ENV. Split the API for the two
uses cases to remove all need for ENV_GET_CPU.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-22 17:40:00 +02:00
Bandan Das
e549d2aaeb monitor: Fix failure path for "S" argument
Since the "S" argument type is only used with the "?" flag,
the bug can't bite.

Signed-off-by: Bandan Das <bsd@redhat.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-22 17:40:00 +02:00
Bandan Das
dd41eea771 monitor: Point to "help" command on syntax error
When a command fails due to incorrect syntax or input, suggest using
the "help" command to get more information about the command.  This
is only applicable for HMP.

Signed-off-by: Bandan Das <bsd@redhat.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-22 17:40:00 +02:00
Bandan Das
ae50212ff7 monitor: cleanup parsing of cmd name and cmd arguments
There's too much going on in monitor_parse_command().
Split up the arguments parsing bits into a separate function
monitor_parse_arguments(). Let the original function check for
command validity and sub-commands if any and return data (*cmd)
that the newly introduced function can process and return a
QDict. Also, pass a pointer to the cmdline to track current
parser location.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Bandan Das <bsd@redhat.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-22 17:40:00 +02:00
Bandan Das
19f2db5c84 monitor: remove debug prints
The preferred solution is to use tracepoints and there
is good chance of bitrot with the debug prints not being
enabled at compile time. Remove them.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Bandan Das <bsd@redhat.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-22 17:40:00 +02:00
Eric Blake
34acbc9522 qobject: Use 'bool' inside qdict
Now that qbool is fixed, let's fix getting and setting a bool
value to a qdict member to also use C99 bool rather than int.

I audited all callers to ensure that the changed return type
will not cause any changed semantics.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-22 17:40:00 +02:00
Eric Blake
fc48ffc39e qobject: Use 'bool' for qbool
We require a C99 compiler, so let's use 'bool' instead of 'int'
when dealing with boolean values.  There are few enough clients
to fix them all in one pass.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-22 17:40:00 +02:00
248 changed files with 3886 additions and 2346 deletions

View File

@@ -740,6 +740,12 @@ S: Supported
F: hw/s390x/virtio-ccw.[hc] F: hw/s390x/virtio-ccw.[hc]
T: git git://github.com/cohuck/qemu virtio-ccw-upstr T: git git://github.com/cohuck/qemu virtio-ccw-upstr
virtio-input
M: Gerd Hoffmann <kraxel@redhat.com>
S: Maintained
F: hw/input/virtio-input*.c
F: include/hw/virtio/virtio-input.h
virtio-serial virtio-serial
M: Amit Shah <amit.shah@redhat.com> M: Amit Shah <amit.shah@redhat.com>
S: Supported S: Supported

View File

@@ -3,6 +3,11 @@
# Always point to the root of the build tree (needs GNU make). # Always point to the root of the build tree (needs GNU make).
BUILD_DIR=$(CURDIR) BUILD_DIR=$(CURDIR)
# Before including a proper config-host.mak, assume we are in the source tree
SRC_PATH=.
UNCHECKED_GOALS := %clean TAGS cscope ctags
# All following code might depend on configuration variables # All following code might depend on configuration variables
ifneq ($(wildcard config-host.mak),) ifneq ($(wildcard config-host.mak),)
# Put the all: rule here so that config-host.mak can contain dependencies. # Put the all: rule here so that config-host.mak can contain dependencies.
@@ -38,7 +43,7 @@ config-host.mak: $(SRC_PATH)/configure
fi fi
else else
config-host.mak: config-host.mak:
ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
@echo "Please call configure before running make!" @echo "Please call configure before running make!"
@exit 1 @exit 1
endif endif
@@ -449,15 +454,20 @@ endif
test speed: all test speed: all
$(MAKE) -C tests/tcg $@ $(MAKE) -C tests/tcg $@
.PHONY: ctags
ctags:
rm -f $@
find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
.PHONY: TAGS .PHONY: TAGS
TAGS: TAGS:
rm -f $@ rm -f $@
find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} + find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
cscope: cscope:
rm -f ./cscope.* rm -f "$(SRC_PATH)"/cscope.*
find "$(SRC_PATH)" -name "*.[chsS]" -print | sed 's,^\./,,' > ./cscope.files find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
cscope -b cscope -b -i"$(SRC_PATH)/cscope.files"
# opengl shader programs # opengl shader programs
ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
@@ -600,7 +610,7 @@ endif # CONFIG_WIN
# Add a dependency on the generated files, so that they are always # Add a dependency on the generated files, so that they are always
# rebuilt before other object files # rebuilt before other object files
ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
Makefile: $(GENERATED_HEADERS) Makefile: $(GENERATED_HEADERS)
endif endif

View File

@@ -18,6 +18,7 @@
*/ */
#include "hw/hw.h" #include "hw/hw.h"
#include "qemu/error-report.h"
#include "qemu/timer.h" #include "qemu/timer.h"
#include "ui/qemu-spice.h" #include "ui/qemu-spice.h"

View File

@@ -1,5 +1,6 @@
#include "hw/hw.h" #include "hw/hw.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "qemu/error-report.h"
#include "audio.h" #include "audio.h"
typedef struct { typedef struct {

View File

@@ -13,7 +13,6 @@
#include "qapi/visitor.h" #include "qapi/visitor.h"
#include "qapi-types.h" #include "qapi-types.h"
#include "qapi-visit.h" #include "qapi-visit.h"
#include "qapi/qmp/qerror.h"
#include "qemu/config-file.h" #include "qemu/config-file.h"
#include "qom/object_interfaces.h" #include "qom/object_interfaces.h"

View File

@@ -140,19 +140,20 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
RngEgd *s = RNG_EGD(b); RngEgd *s = RNG_EGD(b);
if (s->chr_name == NULL) { if (s->chr_name == NULL) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"chardev", "a valid character device"); "chardev", "a valid character device");
return; return;
} }
s->chr = qemu_chr_find(s->chr_name); s->chr = qemu_chr_find(s->chr_name);
if (s->chr == NULL) { if (s->chr == NULL) {
error_set(errp, QERR_DEVICE_NOT_FOUND, s->chr_name); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", s->chr_name);
return; return;
} }
if (qemu_chr_fe_claim(s->chr) != 0) { if (qemu_chr_fe_claim(s->chr) != 0) {
error_set(errp, QERR_DEVICE_IN_USE, s->chr_name); error_setg(errp, QERR_DEVICE_IN_USE, s->chr_name);
return; return;
} }
@@ -167,7 +168,7 @@ static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
RngEgd *s = RNG_EGD(b); RngEgd *s = RNG_EGD(b);
if (b->opened) { if (b->opened) {
error_set(errp, QERR_PERMISSION_DENIED); error_setg(errp, QERR_PERMISSION_DENIED);
} else { } else {
g_free(s->chr_name); g_free(s->chr_name);
s->chr_name = g_strdup(value); s->chr_name = g_strdup(value);

View File

@@ -74,8 +74,8 @@ static void rng_random_opened(RngBackend *b, Error **errp)
RndRandom *s = RNG_RANDOM(b); RndRandom *s = RNG_RANDOM(b);
if (s->filename == NULL) { if (s->filename == NULL) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"filename", "a valid filename"); "filename", "a valid filename");
} else { } else {
s->fd = qemu_open(s->filename, O_RDONLY | O_NONBLOCK); s->fd = qemu_open(s->filename, O_RDONLY | O_NONBLOCK);
if (s->fd == -1) { if (s->fd == -1) {
@@ -98,7 +98,7 @@ static void rng_random_set_filename(Object *obj, const char *filename,
RndRandom *s = RNG_RANDOM(obj); RndRandom *s = RNG_RANDOM(obj);
if (b->opened) { if (b->opened) {
error_set(errp, QERR_PERMISSION_DENIED); error_setg(errp, QERR_PERMISSION_DENIED);
return; return;
} }

View File

@@ -57,7 +57,7 @@ static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
} }
if (!value && s->opened) { if (!value && s->opened) {
error_set(errp, QERR_PERMISSION_DENIED); error_setg(errp, QERR_PERMISSION_DENIED);
return; return;
} }

View File

@@ -133,7 +133,7 @@ static void tpm_backend_prop_set_opened(Object *obj, bool value, Error **errp)
} }
if (!value && s->opened) { if (!value && s->opened) {
error_set(errp, QERR_PERMISSION_DENIED); error_setg(errp, QERR_PERMISSION_DENIED);
return; return;
} }

View File

@@ -24,12 +24,13 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "monitor/monitor.h" #include "qemu-common.h"
#include "exec/cpu-common.h" #include "exec/cpu-common.h"
#include "sysemu/kvm.h" #include "sysemu/kvm.h"
#include "sysemu/balloon.h" #include "sysemu/balloon.h"
#include "trace.h" #include "trace.h"
#include "qmp-commands.h" #include "qmp-commands.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
static QEMUBalloonEvent *balloon_event_fn; static QEMUBalloonEvent *balloon_event_fn;
@@ -96,7 +97,7 @@ void qmp_balloon(int64_t target, Error **errp)
} }
if (target <= 0) { if (target <= 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size"); error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
return; return;
} }

24
block.c
View File

@@ -26,7 +26,9 @@
#include "trace.h" #include "trace.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "block/blockjob.h" #include "block/blockjob.h"
#include "qemu/error-report.h"
#include "qemu/module.h" #include "qemu/module.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
@@ -583,7 +585,7 @@ static int find_image_format(BlockDriverState *bs, const char *filename,
int ret = 0; int ret = 0;
/* Return the raw BlockDriver * to scsi-generic devices or empty drives */ /* Return the raw BlockDriver * to scsi-generic devices or empty drives */
if (bs->sg || !bdrv_is_inserted(bs) || bdrv_getlength(bs) == 0) { if (bdrv_is_sg(bs) || !bdrv_is_inserted(bs) || bdrv_getlength(bs) == 0) {
*pdrv = &bdrv_raw; *pdrv = &bdrv_raw;
return ret; return ret;
} }
@@ -615,7 +617,7 @@ static int refresh_total_sectors(BlockDriverState *bs, int64_t hint)
BlockDriver *drv = bs->drv; BlockDriver *drv = bs->drv;
/* Do not attempt drv->bdrv_getlength() on scsi-generic devices */ /* Do not attempt drv->bdrv_getlength() on scsi-generic devices */
if (bs->sg) if (bdrv_is_sg(bs))
return 0; return 0;
/* query actual device if possible, otherwise just trust the hint */ /* query actual device if possible, otherwise just trust the hint */
@@ -946,7 +948,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
assert(bdrv_opt_mem_align(bs) != 0); assert(bdrv_opt_mem_align(bs) != 0);
assert(bdrv_min_mem_align(bs) != 0); assert(bdrv_min_mem_align(bs) != 0);
assert((bs->request_alignment != 0) || bs->sg); assert((bs->request_alignment != 0) || bdrv_is_sg(bs));
qemu_opts_del(opts); qemu_opts_del(opts);
return 0; return 0;
@@ -2698,7 +2700,7 @@ void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp)
error_setg(errp, "Node '%s' is not encrypted", error_setg(errp, "Node '%s' is not encrypted",
bdrv_get_device_or_node_name(bs)); bdrv_get_device_or_node_name(bs));
} else if (bdrv_set_key(bs, key) < 0) { } else if (bdrv_set_key(bs, key) < 0) {
error_set(errp, QERR_INVALID_PASSWORD); error_setg(errp, QERR_INVALID_PASSWORD);
} }
} else { } else {
if (bdrv_key_required(bs)) { if (bdrv_key_required(bs)) {
@@ -3511,7 +3513,7 @@ void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap) void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap)
{ {
assert(bdrv_dirty_bitmap_enabled(bitmap)); assert(bdrv_dirty_bitmap_enabled(bitmap));
hbitmap_reset(bitmap->bitmap, 0, bitmap->size); hbitmap_reset_all(bitmap->bitmap);
} }
void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
@@ -3526,18 +3528,6 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
} }
} }
void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector,
int nr_sectors)
{
BdrvDirtyBitmap *bitmap;
QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
if (!bdrv_dirty_bitmap_enabled(bitmap)) {
continue;
}
hbitmap_reset(bitmap->bitmap, cur_sector, nr_sectors);
}
}
/** /**
* Advance an HBitmapIter to an arbitrary offset. * Advance an HBitmapIter to an arbitrary offset.
*/ */

View File

@@ -19,6 +19,7 @@
#include "block/block.h" #include "block/block.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "block/blockjob.h" #include "block/blockjob.h"
#include "qapi/qmp/qerror.h"
#include "qemu/ratelimit.h" #include "qemu/ratelimit.h"
#define BACKUP_CLUSTER_BITS 16 #define BACKUP_CLUSTER_BITS 16
@@ -37,7 +38,7 @@ typedef struct CowRequest {
typedef struct BackupBlockJob { typedef struct BackupBlockJob {
BlockJob common; BlockJob common;
BlockDriverState *target; BlockDriverState *target;
/* bitmap for sync=dirty-bitmap */ /* bitmap for sync=incremental */
BdrvDirtyBitmap *sync_bitmap; BdrvDirtyBitmap *sync_bitmap;
MirrorSyncMode sync_mode; MirrorSyncMode sync_mode;
RateLimit limit; RateLimit limit;
@@ -197,7 +198,7 @@ static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp)
BackupBlockJob *s = container_of(job, BackupBlockJob, common); BackupBlockJob *s = container_of(job, BackupBlockJob, common);
if (speed < 0) { if (speed < 0) {
error_set(errp, QERR_INVALID_PARAMETER, "speed"); error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return; return;
} }
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME); ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
@@ -364,7 +365,7 @@ static void coroutine_fn backup_run(void *opaque)
qemu_coroutine_yield(); qemu_coroutine_yield();
job->common.busy = true; job->common.busy = true;
} }
} else if (job->sync_mode == MIRROR_SYNC_MODE_DIRTY_BITMAP) { } else if (job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
ret = backup_run_incremental(job); ret = backup_run_incremental(job);
} else { } else {
/* Both FULL and TOP SYNC_MODE's require copying.. */ /* Both FULL and TOP SYNC_MODE's require copying.. */
@@ -472,7 +473,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
if ((on_source_error == BLOCKDEV_ON_ERROR_STOP || if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||
on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) && on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) { !bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER, "on-source-error"); error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error");
return; return;
} }
@@ -496,10 +497,10 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
return; return;
} }
if (sync_mode == MIRROR_SYNC_MODE_DIRTY_BITMAP) { if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
if (!sync_bitmap) { if (!sync_bitmap) {
error_setg(errp, "must provide a valid bitmap name for " error_setg(errp, "must provide a valid bitmap name for "
"\"dirty-bitmap\" sync mode"); "\"incremental\" sync mode");
return; return;
} }
@@ -534,7 +535,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
job->on_target_error = on_target_error; job->on_target_error = on_target_error;
job->target = target; job->target = target;
job->sync_mode = sync_mode; job->sync_mode = sync_mode;
job->sync_bitmap = sync_mode == MIRROR_SYNC_MODE_DIRTY_BITMAP ? job->sync_bitmap = sync_mode == MIRROR_SYNC_MODE_INCREMENTAL ?
sync_bitmap : NULL; sync_bitmap : NULL;
job->common.len = len; job->common.len = len;
job->common.co = qemu_coroutine_create(backup_run); job->common.co = qemu_coroutine_create(backup_run);

View File

@@ -700,6 +700,11 @@ int blk_flush_all(void)
return bdrv_flush_all(); return bdrv_flush_all();
} }
void blk_drain(BlockBackend *blk)
{
bdrv_drain(blk->bs);
}
void blk_drain_all(void) void blk_drain_all(void)
{ {
bdrv_drain_all(); bdrv_drain_all();

View File

@@ -15,6 +15,7 @@
#include "trace.h" #include "trace.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "block/blockjob.h" #include "block/blockjob.h"
#include "qapi/qmp/qerror.h"
#include "qemu/ratelimit.h" #include "qemu/ratelimit.h"
enum { enum {
@@ -186,7 +187,7 @@ static void commit_set_speed(BlockJob *job, int64_t speed, Error **errp)
CommitBlockJob *s = container_of(job, CommitBlockJob, common); CommitBlockJob *s = container_of(job, CommitBlockJob, common);
if (speed < 0) { if (speed < 0) {
error_set(errp, QERR_INVALID_PARAMETER, "speed"); error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return; return;
} }
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME); ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);

View File

@@ -24,6 +24,7 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qstring.h"
#include <curl/curl.h> #include <curl/curl.h>
// #define DEBUG_CURL // #define DEBUG_CURL

View File

@@ -24,6 +24,7 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "qemu/bswap.h" #include "qemu/bswap.h"
#include "qemu/error-report.h"
#include "qemu/module.h" #include "qemu/module.h"
#include <zlib.h> #include <zlib.h>
#ifdef CONFIG_BZIP2 #ifdef CONFIG_BZIP2

View File

@@ -26,6 +26,7 @@
#include "block/blockjob.h" #include "block/blockjob.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "block/throttle-groups.h" #include "block/throttle-groups.h"
#include "qemu/error-report.h"
#define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */ #define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
@@ -232,17 +233,6 @@ static bool bdrv_requests_pending(BlockDriverState *bs)
return false; return false;
} }
static bool bdrv_drain_one(BlockDriverState *bs)
{
bool bs_busy;
bdrv_flush_io_queue(bs);
bdrv_start_throttled_reqs(bs);
bs_busy = bdrv_requests_pending(bs);
bs_busy |= aio_poll(bdrv_get_aio_context(bs), bs_busy);
return bs_busy;
}
/* /*
* Wait for pending requests to complete on a single BlockDriverState subtree * Wait for pending requests to complete on a single BlockDriverState subtree
* *
@@ -255,8 +245,13 @@ static bool bdrv_drain_one(BlockDriverState *bs)
*/ */
void bdrv_drain(BlockDriverState *bs) void bdrv_drain(BlockDriverState *bs)
{ {
while (bdrv_drain_one(bs)) { bool busy = true;
while (busy) {
/* Keep iterating */ /* Keep iterating */
bdrv_flush_io_queue(bs);
busy = bdrv_requests_pending(bs);
busy |= aio_poll(bdrv_get_aio_context(bs), busy);
} }
} }
@@ -277,6 +272,7 @@ void bdrv_drain_all(void)
/* Always run first iteration so any pending completion BHs run */ /* Always run first iteration so any pending completion BHs run */
bool busy = true; bool busy = true;
BlockDriverState *bs = NULL; BlockDriverState *bs = NULL;
GSList *aio_ctxs = NULL, *ctx;
while ((bs = bdrv_next(bs))) { while ((bs = bdrv_next(bs))) {
AioContext *aio_context = bdrv_get_aio_context(bs); AioContext *aio_context = bdrv_get_aio_context(bs);
@@ -286,17 +282,30 @@ void bdrv_drain_all(void)
block_job_pause(bs->job); block_job_pause(bs->job);
} }
aio_context_release(aio_context); aio_context_release(aio_context);
if (!g_slist_find(aio_ctxs, aio_context)) {
aio_ctxs = g_slist_prepend(aio_ctxs, aio_context);
}
} }
while (busy) { while (busy) {
busy = false; busy = false;
bs = NULL;
while ((bs = bdrv_next(bs))) { for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) {
AioContext *aio_context = bdrv_get_aio_context(bs); AioContext *aio_context = ctx->data;
bs = NULL;
aio_context_acquire(aio_context); aio_context_acquire(aio_context);
busy |= bdrv_drain_one(bs); while ((bs = bdrv_next(bs))) {
if (aio_context == bdrv_get_aio_context(bs)) {
bdrv_flush_io_queue(bs);
if (bdrv_requests_pending(bs)) {
busy = true;
aio_poll(aio_context, busy);
}
}
}
busy |= aio_poll(aio_context, false);
aio_context_release(aio_context); aio_context_release(aio_context);
} }
} }
@@ -311,6 +320,7 @@ void bdrv_drain_all(void)
} }
aio_context_release(aio_context); aio_context_release(aio_context);
} }
g_slist_free(aio_ctxs);
} }
/** /**
@@ -1521,28 +1531,54 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
return ret; return ret;
} }
/* Coroutine wrapper for bdrv_get_block_status() */ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs,
static void coroutine_fn bdrv_get_block_status_co_entry(void *opaque) BlockDriverState *base,
int64_t sector_num,
int nb_sectors,
int *pnum)
{
BlockDriverState *p;
int64_t ret = 0;
assert(bs != base);
for (p = bs; p != base; p = p->backing_hd) {
ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum);
if (ret < 0 || ret & BDRV_BLOCK_ALLOCATED) {
break;
}
/* [sector_num, pnum] unallocated on this layer, which could be only
* the first part of [sector_num, nb_sectors]. */
nb_sectors = MIN(nb_sectors, *pnum);
}
return ret;
}
/* Coroutine wrapper for bdrv_get_block_status_above() */
static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque)
{ {
BdrvCoGetBlockStatusData *data = opaque; BdrvCoGetBlockStatusData *data = opaque;
BlockDriverState *bs = data->bs;
data->ret = bdrv_co_get_block_status(bs, data->sector_num, data->nb_sectors, data->ret = bdrv_co_get_block_status_above(data->bs, data->base,
data->pnum); data->sector_num,
data->nb_sectors,
data->pnum);
data->done = true; data->done = true;
} }
/* /*
* Synchronous wrapper around bdrv_co_get_block_status(). * Synchronous wrapper around bdrv_co_get_block_status_above().
* *
* See bdrv_co_get_block_status() for details. * See bdrv_co_get_block_status_above() for details.
*/ */
int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num, int64_t bdrv_get_block_status_above(BlockDriverState *bs,
int nb_sectors, int *pnum) BlockDriverState *base,
int64_t sector_num,
int nb_sectors, int *pnum)
{ {
Coroutine *co; Coroutine *co;
BdrvCoGetBlockStatusData data = { BdrvCoGetBlockStatusData data = {
.bs = bs, .bs = bs,
.base = base,
.sector_num = sector_num, .sector_num = sector_num,
.nb_sectors = nb_sectors, .nb_sectors = nb_sectors,
.pnum = pnum, .pnum = pnum,
@@ -1551,11 +1587,11 @@ int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
if (qemu_in_coroutine()) { if (qemu_in_coroutine()) {
/* Fast-path if already in coroutine context */ /* Fast-path if already in coroutine context */
bdrv_get_block_status_co_entry(&data); bdrv_get_block_status_above_co_entry(&data);
} else { } else {
AioContext *aio_context = bdrv_get_aio_context(bs); AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_get_block_status_co_entry); co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry);
qemu_coroutine_enter(co, &data); qemu_coroutine_enter(co, &data);
while (!data.done) { while (!data.done) {
aio_poll(aio_context, true); aio_poll(aio_context, true);
@@ -1564,6 +1600,14 @@ int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
return data.ret; return data.ret;
} }
int64_t bdrv_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum)
{
return bdrv_get_block_status_above(bs, bs->backing_hd,
sector_num, nb_sectors, pnum);
}
int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int *pnum) int nb_sectors, int *pnum)
{ {
@@ -2255,7 +2299,8 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
{ {
int ret; int ret;
if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) { if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs) ||
bdrv_is_sg(bs)) {
return 0; return 0;
} }
@@ -2367,8 +2412,6 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
return -EPERM; return -EPERM;
} }
bdrv_reset_dirty(bs, sector_num, nb_sectors);
/* Do nothing if disabled. */ /* Do nothing if disabled. */
if (!(bs->open_flags & BDRV_O_UNMAP)) { if (!(bs->open_flags & BDRV_O_UNMAP)) {
return 0; return 0;
@@ -2378,6 +2421,8 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
return 0; return 0;
} }
bdrv_set_dirty(bs, sector_num, nb_sectors);
max_discard = MIN_NON_ZERO(bs->bl.max_discard, BDRV_REQUEST_MAX_SECTORS); max_discard = MIN_NON_ZERO(bs->bl.max_discard, BDRV_REQUEST_MAX_SECTORS);
while (nb_sectors > 0) { while (nb_sectors > 0) {
int ret; int ret;
@@ -2561,4 +2606,5 @@ void bdrv_flush_io_queue(BlockDriverState *bs)
} else if (bs->file) { } else if (bs->file) {
bdrv_flush_io_queue(bs->file); bdrv_flush_io_queue(bs->file);
} }
bdrv_start_throttled_reqs(bs);
} }

View File

@@ -38,6 +38,7 @@
#include "qemu/iov.h" #include "qemu/iov.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "qmp-commands.h" #include "qmp-commands.h"
#include "qapi/qmp/qstring.h"
#include <iscsi/iscsi.h> #include <iscsi/iscsi.h>
#include <iscsi/scsi-lowlevel.h> #include <iscsi/scsi-lowlevel.h>
@@ -69,6 +70,7 @@ typedef struct IscsiLun {
bool dpofua; bool dpofua;
bool has_write_same; bool has_write_same;
bool force_next_flush; bool force_next_flush;
bool request_timed_out;
} IscsiLun; } IscsiLun;
typedef struct IscsiTask { typedef struct IscsiTask {
@@ -99,7 +101,8 @@ typedef struct IscsiAIOCB {
#endif #endif
} IscsiAIOCB; } IscsiAIOCB;
#define EVENT_INTERVAL 250 /* libiscsi uses time_t so its enough to process events every second */
#define EVENT_INTERVAL 1000
#define NOP_INTERVAL 5000 #define NOP_INTERVAL 5000
#define MAX_NOP_FAILURES 3 #define MAX_NOP_FAILURES 3
#define ISCSI_CMD_RETRIES ARRAY_SIZE(iscsi_retry_times) #define ISCSI_CMD_RETRIES ARRAY_SIZE(iscsi_retry_times)
@@ -166,6 +169,19 @@ static inline unsigned exp_random(double mean)
return -mean * log((double)rand() / RAND_MAX); return -mean * log((double)rand() / RAND_MAX);
} }
/* SCSI_STATUS_TASK_SET_FULL and SCSI_STATUS_TIMEOUT were introduced
* in libiscsi 1.10.0 as part of an enum. The LIBISCSI_API_VERSION
* macro was introduced in 1.11.0. So use the API_VERSION macro as
* a hint that the macros are defined and define them ourselves
* otherwise to keep the required libiscsi version at 1.9.0 */
#if !defined(LIBISCSI_API_VERSION)
#define QEMU_SCSI_STATUS_TASK_SET_FULL 0x28
#define QEMU_SCSI_STATUS_TIMEOUT 0x0f000002
#else
#define QEMU_SCSI_STATUS_TASK_SET_FULL SCSI_STATUS_TASK_SET_FULL
#define QEMU_SCSI_STATUS_TIMEOUT SCSI_STATUS_TIMEOUT
#endif
static void static void
iscsi_co_generic_cb(struct iscsi_context *iscsi, int status, iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
void *command_data, void *opaque) void *command_data, void *opaque)
@@ -186,13 +202,19 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
iTask->do_retry = 1; iTask->do_retry = 1;
goto out; goto out;
} }
/* status 0x28 is SCSI_TASK_SET_FULL. It was first introduced if (status == SCSI_STATUS_BUSY ||
* in libiscsi 1.10.0. Hardcode this value here to avoid status == QEMU_SCSI_STATUS_TIMEOUT ||
* the need to bump the libiscsi requirement to 1.10.0 */ status == QEMU_SCSI_STATUS_TASK_SET_FULL) {
if (status == SCSI_STATUS_BUSY || status == 0x28) {
unsigned retry_time = unsigned retry_time =
exp_random(iscsi_retry_times[iTask->retries - 1]); exp_random(iscsi_retry_times[iTask->retries - 1]);
error_report("iSCSI Busy/TaskSetFull (retry #%u in %u ms): %s", if (status == QEMU_SCSI_STATUS_TIMEOUT) {
/* make sure the request is rescheduled AFTER the
* reconnect is initiated */
retry_time = EVENT_INTERVAL * 2;
iTask->iscsilun->request_timed_out = true;
}
error_report("iSCSI Busy/TaskSetFull/TimeOut"
" (retry #%u in %u ms): %s",
iTask->retries, retry_time, iTask->retries, retry_time,
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
aio_timer_init(iTask->iscsilun->aio_context, aio_timer_init(iTask->iscsilun->aio_context,
@@ -276,20 +298,26 @@ iscsi_set_events(IscsiLun *iscsilun)
iscsilun); iscsilun);
iscsilun->events = ev; iscsilun->events = ev;
} }
/* newer versions of libiscsi may return zero events. In this
* case start a timer to ensure we are able to return to service
* once this situation changes. */
if (!ev) {
timer_mod(iscsilun->event_timer,
qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + EVENT_INTERVAL);
}
} }
static void iscsi_timed_set_events(void *opaque) static void iscsi_timed_check_events(void *opaque)
{ {
IscsiLun *iscsilun = opaque; IscsiLun *iscsilun = opaque;
/* check for timed out requests */
iscsi_service(iscsilun->iscsi, 0);
if (iscsilun->request_timed_out) {
iscsilun->request_timed_out = false;
iscsi_reconnect(iscsilun->iscsi);
}
/* newer versions of libiscsi may return zero events. Ensure we are able
* to return to service once this situation changes. */
iscsi_set_events(iscsilun); iscsi_set_events(iscsilun);
timer_mod(iscsilun->event_timer,
qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + EVENT_INTERVAL);
} }
static void static void
@@ -627,10 +655,6 @@ static int coroutine_fn iscsi_co_flush(BlockDriverState *bs)
IscsiLun *iscsilun = bs->opaque; IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask; struct IscsiTask iTask;
if (bs->sg) {
return 0;
}
if (!iscsilun->force_next_flush) { if (!iscsilun->force_next_flush) {
return 0; return 0;
} }
@@ -1096,16 +1120,37 @@ static char *parse_initiator_name(const char *target)
return iscsi_name; return iscsi_name;
} }
static int parse_timeout(const char *target)
{
QemuOptsList *list;
QemuOpts *opts;
const char *timeout;
list = qemu_find_opts("iscsi");
if (list) {
opts = qemu_opts_find(list, target);
if (!opts) {
opts = QTAILQ_FIRST(&list->head);
}
if (opts) {
timeout = qemu_opt_get(opts, "timeout");
if (timeout) {
return atoi(timeout);
}
}
}
return 0;
}
static void iscsi_nop_timed_event(void *opaque) static void iscsi_nop_timed_event(void *opaque)
{ {
IscsiLun *iscsilun = opaque; IscsiLun *iscsilun = opaque;
if (iscsi_get_nops_in_flight(iscsilun->iscsi) > MAX_NOP_FAILURES) { if (iscsi_get_nops_in_flight(iscsilun->iscsi) >= MAX_NOP_FAILURES) {
error_report("iSCSI: NOP timeout. Reconnecting..."); error_report("iSCSI: NOP timeout. Reconnecting...");
iscsi_reconnect(iscsilun->iscsi); iscsilun->request_timed_out = true;
} } else if (iscsi_nop_out_async(iscsilun->iscsi, NULL, NULL, 0, NULL) != 0) {
if (iscsi_nop_out_async(iscsilun->iscsi, NULL, NULL, 0, NULL) != 0) {
error_report("iSCSI: failed to sent NOP-Out. Disabling NOP messages."); error_report("iSCSI: failed to sent NOP-Out. Disabling NOP messages.");
return; return;
} }
@@ -1263,10 +1308,13 @@ static void iscsi_attach_aio_context(BlockDriverState *bs,
timer_mod(iscsilun->nop_timer, timer_mod(iscsilun->nop_timer,
qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + NOP_INTERVAL); qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + NOP_INTERVAL);
/* Prepare a timer for a delayed call to iscsi_set_events */ /* Set up a timer for periodic calls to iscsi_set_events and to
* scan for command timeout */
iscsilun->event_timer = aio_timer_new(iscsilun->aio_context, iscsilun->event_timer = aio_timer_new(iscsilun->aio_context,
QEMU_CLOCK_REALTIME, SCALE_MS, QEMU_CLOCK_REALTIME, SCALE_MS,
iscsi_timed_set_events, iscsilun); iscsi_timed_check_events, iscsilun);
timer_mod(iscsilun->event_timer,
qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + EVENT_INTERVAL);
} }
static void iscsi_modesense_sync(IscsiLun *iscsilun) static void iscsi_modesense_sync(IscsiLun *iscsilun)
@@ -1321,7 +1369,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
QemuOpts *opts; QemuOpts *opts;
Error *local_err = NULL; Error *local_err = NULL;
const char *filename; const char *filename;
int i, ret = 0; int i, ret = 0, timeout = 0;
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err); qemu_opts_absorb_qdict(opts, options, &local_err);
@@ -1391,6 +1439,16 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
goto out; goto out;
} }
/* timeout handling is broken in libiscsi before 1.15.0 */
timeout = parse_timeout(iscsi_url->target);
#if defined(LIBISCSI_API_VERSION) && LIBISCSI_API_VERSION >= 20150621
iscsi_set_timeout(iscsi, timeout);
#else
if (timeout) {
error_report("iSCSI: ignoring timeout value for libiscsi <1.15.0");
}
#endif
if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, iscsi_url->lun) != 0) { if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, iscsi_url->lun) != 0) {
error_setg(errp, "iSCSI: Failed to connect to LUN : %s", error_setg(errp, "iSCSI: Failed to connect to LUN : %s",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
@@ -1739,6 +1797,10 @@ static QemuOptsList qemu_iscsi_opts = {
.name = "initiator-name", .name = "initiator-name",
.type = QEMU_OPT_STRING, .type = QEMU_OPT_STRING,
.help = "Initiator iqn name to use when connecting", .help = "Initiator iqn name to use when connecting",
},{
.name = "timeout",
.type = QEMU_OPT_NUMBER,
.help = "Request timeout in seconds (default 0 = no timeout)",
}, },
{ /* end of list */ } { /* end of list */ }
}, },

View File

@@ -14,6 +14,7 @@
#include "trace.h" #include "trace.h"
#include "block/blockjob.h" #include "block/blockjob.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "qapi/qmp/qerror.h"
#include "qemu/ratelimit.h" #include "qemu/ratelimit.h"
#include "qemu/bitmap.h" #include "qemu/bitmap.h"
@@ -57,6 +58,7 @@ typedef struct MirrorBlockJob {
int in_flight; int in_flight;
int sectors_in_flight; int sectors_in_flight;
int ret; int ret;
bool unmap;
} MirrorBlockJob; } MirrorBlockJob;
typedef struct MirrorOp { typedef struct MirrorOp {
@@ -163,6 +165,8 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
int64_t end, sector_num, next_chunk, next_sector, hbitmap_next_sector; int64_t end, sector_num, next_chunk, next_sector, hbitmap_next_sector;
uint64_t delay_ns = 0; uint64_t delay_ns = 0;
MirrorOp *op; MirrorOp *op;
int pnum;
int64_t ret;
s->sector_num = hbitmap_iter_next(&s->hbi); s->sector_num = hbitmap_iter_next(&s->hbi);
if (s->sector_num < 0) { if (s->sector_num < 0) {
@@ -289,8 +293,22 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
s->in_flight++; s->in_flight++;
s->sectors_in_flight += nb_sectors; s->sectors_in_flight += nb_sectors;
trace_mirror_one_iteration(s, sector_num, nb_sectors); trace_mirror_one_iteration(s, sector_num, nb_sectors);
bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors,
mirror_read_complete, op); ret = bdrv_get_block_status_above(source, NULL, sector_num,
nb_sectors, &pnum);
if (ret < 0 || pnum < nb_sectors ||
(ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) {
bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors,
mirror_read_complete, op);
} else if (ret & BDRV_BLOCK_ZERO) {
bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors,
s->unmap ? BDRV_REQ_MAY_UNMAP : 0,
mirror_write_complete, op);
} else {
assert(!(ret & BDRV_BLOCK_DATA));
bdrv_aio_discard(s->target, sector_num, op->nb_sectors,
mirror_write_complete, op);
}
return delay_ns; return delay_ns;
} }
@@ -573,7 +591,7 @@ static void mirror_set_speed(BlockJob *job, int64_t speed, Error **errp)
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);
if (speed < 0) { if (speed < 0) {
error_set(errp, QERR_INVALID_PARAMETER, "speed"); error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return; return;
} }
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME); ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
@@ -598,8 +616,8 @@ static void mirror_complete(BlockJob *job, Error **errp)
return; return;
} }
if (!s->synced) { if (!s->synced) {
error_set(errp, QERR_BLOCK_JOB_NOT_READY, error_setg(errp, QERR_BLOCK_JOB_NOT_READY,
bdrv_get_device_name(job->bs)); bdrv_get_device_name(job->bs));
return; return;
} }
@@ -651,6 +669,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
int64_t buf_size, int64_t buf_size,
BlockdevOnError on_source_error, BlockdevOnError on_source_error,
BlockdevOnError on_target_error, BlockdevOnError on_target_error,
bool unmap,
BlockCompletionFunc *cb, BlockCompletionFunc *cb,
void *opaque, Error **errp, void *opaque, Error **errp,
const BlockJobDriver *driver, const BlockJobDriver *driver,
@@ -667,7 +686,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
if ((on_source_error == BLOCKDEV_ON_ERROR_STOP || if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||
on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) && on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) { !bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER, "on-source-error"); error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error");
return; return;
} }
@@ -685,6 +704,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
s->base = base; s->base = base;
s->granularity = granularity; s->granularity = granularity;
s->buf_size = MAX(buf_size, granularity); s->buf_size = MAX(buf_size, granularity);
s->unmap = unmap;
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp); s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
if (!s->dirty_bitmap) { if (!s->dirty_bitmap) {
@@ -703,21 +723,22 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
int64_t speed, uint32_t granularity, int64_t buf_size, int64_t speed, uint32_t granularity, int64_t buf_size,
MirrorSyncMode mode, BlockdevOnError on_source_error, MirrorSyncMode mode, BlockdevOnError on_source_error,
BlockdevOnError on_target_error, BlockdevOnError on_target_error,
bool unmap,
BlockCompletionFunc *cb, BlockCompletionFunc *cb,
void *opaque, Error **errp) void *opaque, Error **errp)
{ {
bool is_none_mode; bool is_none_mode;
BlockDriverState *base; BlockDriverState *base;
if (mode == MIRROR_SYNC_MODE_DIRTY_BITMAP) { if (mode == MIRROR_SYNC_MODE_INCREMENTAL) {
error_setg(errp, "Sync mode 'dirty-bitmap' not supported"); error_setg(errp, "Sync mode 'incremental' not supported");
return; return;
} }
is_none_mode = mode == MIRROR_SYNC_MODE_NONE; is_none_mode = mode == MIRROR_SYNC_MODE_NONE;
base = mode == MIRROR_SYNC_MODE_TOP ? bs->backing_hd : NULL; base = mode == MIRROR_SYNC_MODE_TOP ? bs->backing_hd : NULL;
mirror_start_job(bs, target, replaces, mirror_start_job(bs, target, replaces,
speed, granularity, buf_size, speed, granularity, buf_size,
on_source_error, on_target_error, cb, opaque, errp, on_source_error, on_target_error, unmap, cb, opaque, errp,
&mirror_job_driver, is_none_mode, base); &mirror_job_driver, is_none_mode, base);
} }
@@ -765,7 +786,7 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
bdrv_ref(base); bdrv_ref(base);
mirror_start_job(bs, base, NULL, speed, 0, 0, mirror_start_job(bs, base, NULL, speed, 0, 0,
on_error, on_error, cb, opaque, &local_err, on_error, on_error, false, cb, opaque, &local_err,
&commit_active_job_driver, false, base); &commit_active_job_driver, false, base);
if (local_err) { if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);

View File

@@ -35,6 +35,8 @@
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include <nfsc/libnfs.h> #include <nfsc/libnfs.h>
#define QEMU_NFS_MAX_READAHEAD_SIZE 1048576
typedef struct NFSClient { typedef struct NFSClient {
struct nfs_context *context; struct nfs_context *context;
struct nfsfh *fh; struct nfsfh *fh;
@@ -327,6 +329,11 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename,
nfs_set_tcp_syncnt(client->context, val); nfs_set_tcp_syncnt(client->context, val);
#ifdef LIBNFS_FEATURE_READAHEAD #ifdef LIBNFS_FEATURE_READAHEAD
} else if (!strcmp(qp->p[i].name, "readahead")) { } else if (!strcmp(qp->p[i].name, "readahead")) {
if (val > QEMU_NFS_MAX_READAHEAD_SIZE) {
error_report("NFS Warning: Truncating NFS readahead"
" size to %d", QEMU_NFS_MAX_READAHEAD_SIZE);
val = QEMU_NFS_MAX_READAHEAD_SIZE;
}
nfs_set_readahead(client->context, val); nfs_set_readahead(client->context, val);
#endif #endif
} else { } else {

View File

@@ -520,13 +520,7 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
} }
case QTYPE_QBOOL: { case QTYPE_QBOOL: {
QBool *value = qobject_to_qbool(obj); QBool *value = qobject_to_qbool(obj);
func_fprintf(f, "%s", qbool_get_int(value) ? "true" : "false"); func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false");
break;
}
case QTYPE_QERROR: {
QString *value = qerror_human((QError *)obj);
func_fprintf(f, "%s", qstring_get_str(value));
QDECREF(value);
break; break;
} }
default: default:

View File

@@ -25,6 +25,7 @@
#include "block/block_int.h" #include "block/block_int.h"
#include "qemu/module.h" #include "qemu/module.h"
#include <zlib.h> #include <zlib.h>
#include "qapi/qmp/qerror.h"
#include "qemu/aes.h" #include "qemu/aes.h"
#include "migration/migration.h" #include "migration/migration.h"
@@ -123,8 +124,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
char version[64]; char version[64];
snprintf(version, sizeof(version), "QCOW version %" PRIu32, snprintf(version, sizeof(version), "QCOW version %" PRIu32,
header.version); header.version);
error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bdrv_get_device_or_node_name(bs), "qcow", version); bdrv_get_device_or_node_name(bs), "qcow", version);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} }

View File

@@ -940,19 +940,21 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
} }
free_in_cluster = s->cluster_size - offset_into_cluster(s, offset); free_in_cluster = s->cluster_size - offset_into_cluster(s, offset);
if (!offset || free_in_cluster < size) { do {
int64_t new_cluster = alloc_clusters_noref(bs, s->cluster_size); if (!offset || free_in_cluster < size) {
if (new_cluster < 0) { int64_t new_cluster = alloc_clusters_noref(bs, s->cluster_size);
return new_cluster; if (new_cluster < 0) {
return new_cluster;
}
if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) {
offset = new_cluster;
}
} }
if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) { assert(offset);
offset = new_cluster; ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER);
} } while (ret == -EAGAIN);
}
assert(offset);
ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }

View File

@@ -25,6 +25,7 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "block/qcow2.h" #include "block/qcow2.h"
#include "qemu/error-report.h"
void qcow2_free_snapshots(BlockDriverState *bs) void qcow2_free_snapshots(BlockDriverState *bs)
{ {

View File

@@ -207,8 +207,8 @@ static void GCC_FMT_ATTR(3, 4) report_unsupported(BlockDriverState *bs,
vsnprintf(msg, sizeof(msg), fmt, ap); vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap); va_end(ap);
error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bdrv_get_device_or_node_name(bs), "qcow2", msg); bdrv_get_device_or_node_name(bs), "qcow2", msg);
} }
static void report_unsupported_feature(BlockDriverState *bs, static void report_unsupported_feature(BlockDriverState *bs,

View File

@@ -407,8 +407,8 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
char buf[64]; char buf[64];
snprintf(buf, sizeof(buf), "%" PRIx64, snprintf(buf, sizeof(buf), "%" PRIx64,
s->header.features & ~QED_FEATURE_MASK); s->header.features & ~QED_FEATURE_MASK);
error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bdrv_get_device_or_node_name(bs), "QED", buf); bdrv_get_device_or_node_name(bs), "QED", buf);
return -ENOTSUP; return -ENOTSUP;
} }
if (!qed_is_cluster_size_valid(s->header.cluster_size)) { if (!qed_is_cluster_size_valid(s->header.cluster_size)) {

View File

@@ -18,6 +18,7 @@
#include "block/block_int.h" #include "block/block_int.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qint.h" #include "qapi/qmp/qint.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "qapi/qmp/qlist.h" #include "qapi/qmp/qlist.h"
@@ -800,8 +801,8 @@ static int quorum_valid_threshold(int threshold, int num_children, Error **errp)
{ {
if (threshold < 1) { if (threshold < 1) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"vote-threshold", "value >= 1"); "vote-threshold", "value >= 1");
return -ERANGE; return -ERANGE;
} }
@@ -1024,9 +1025,9 @@ static void quorum_refresh_filename(BlockDriverState *bs)
qdict_put_obj(opts, QUORUM_OPT_VOTE_THRESHOLD, qdict_put_obj(opts, QUORUM_OPT_VOTE_THRESHOLD,
QOBJECT(qint_from_int(s->threshold))); QOBJECT(qint_from_int(s->threshold)));
qdict_put_obj(opts, QUORUM_OPT_BLKVERIFY, qdict_put_obj(opts, QUORUM_OPT_BLKVERIFY,
QOBJECT(qbool_from_int(s->is_blkverify))); QOBJECT(qbool_from_bool(s->is_blkverify)));
qdict_put_obj(opts, QUORUM_OPT_REWRITE, qdict_put_obj(opts, QUORUM_OPT_REWRITE,
QOBJECT(qbool_from_int(s->rewrite_corrupted))); QOBJECT(qbool_from_bool(s->rewrite_corrupted)));
qdict_put_obj(opts, "children", QOBJECT(children)); qdict_put_obj(opts, "children", QOBJECT(children));
bs->full_open_options = opts; bs->full_open_options = opts;

View File

@@ -22,6 +22,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "qemu-common.h" #include "qemu-common.h"
#include "qemu/error-report.h"
#include "qemu/timer.h" #include "qemu/timer.h"
#include "qemu/log.h" #include "qemu/log.h"
#include "block/block_int.h" #include "block/block_int.h"
@@ -31,6 +32,7 @@
#include "qemu/iov.h" #include "qemu/iov.h"
#include "raw-aio.h" #include "raw-aio.h"
#include "qapi/util.h" #include "qapi/util.h"
#include "qapi/qmp/qstring.h"
#if defined(__APPLE__) && (__MACH__) #if defined(__APPLE__) && (__MACH__)
#include <paths.h> #include <paths.h>
@@ -57,6 +59,7 @@
#include <linux/fd.h> #include <linux/fd.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <scsi/sg.h>
#ifdef __s390__ #ifdef __s390__
#include <asm/dasd.h> #include <asm/dasd.h>
#endif #endif
@@ -94,15 +97,19 @@
#include <xfs/xfs.h> #include <xfs/xfs.h>
#endif #endif
//#define DEBUG_FLOPPY
//#define DEBUG_BLOCK //#define DEBUG_BLOCK
#if defined(DEBUG_BLOCK)
#define DEBUG_BLOCK_PRINT(formatCstr, ...) do { if (qemu_log_enabled()) \ #ifdef DEBUG_BLOCK
{ qemu_log(formatCstr, ## __VA_ARGS__); qemu_log_flush(); } } while (0) # define DEBUG_BLOCK_PRINT 1
#else #else
#define DEBUG_BLOCK_PRINT(formatCstr, ...) # define DEBUG_BLOCK_PRINT 0
#endif #endif
#define DPRINTF(fmt, ...) \
do { \
if (DEBUG_BLOCK_PRINT) { \
printf(fmt, ## __VA_ARGS__); \
} \
} while (0)
/* OS X does not have O_DSYNC */ /* OS X does not have O_DSYNC */
#ifndef O_DSYNC #ifndef O_DSYNC
@@ -303,9 +310,9 @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
char *buf; char *buf;
size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize()); size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
/* For /dev/sg devices the alignment is not really used. /* For SCSI generic devices the alignment is not really used.
With buffered I/O, we don't have any restrictions. */ With buffered I/O, we don't have any restrictions. */
if (bs->sg || !s->needs_alignment) { if (bdrv_is_sg(bs) || !s->needs_alignment) {
bs->request_alignment = 1; bs->request_alignment = 1;
s->buf_align = 1; s->buf_align = 1;
return; return;
@@ -1018,6 +1025,7 @@ static ssize_t handle_aiocb_rw(RawPosixAIOData *aiocb)
static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes) static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes)
{ {
struct xfs_flock64 fl; struct xfs_flock64 fl;
int err;
memset(&fl, 0, sizeof(fl)); memset(&fl, 0, sizeof(fl));
fl.l_whence = SEEK_SET; fl.l_whence = SEEK_SET;
@@ -1025,8 +1033,9 @@ static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes)
fl.l_len = bytes; fl.l_len = bytes;
if (xfsctl(NULL, s->fd, XFS_IOC_ZERO_RANGE, &fl) < 0) { if (xfsctl(NULL, s->fd, XFS_IOC_ZERO_RANGE, &fl) < 0) {
DEBUG_BLOCK_PRINT("cannot write zero range (%s)\n", strerror(errno)); err = errno;
return -errno; DPRINTF("cannot write zero range (%s)\n", strerror(errno));
return -err;
} }
return 0; return 0;
@@ -1035,6 +1044,7 @@ static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes)
static int xfs_discard(BDRVRawState *s, int64_t offset, uint64_t bytes) static int xfs_discard(BDRVRawState *s, int64_t offset, uint64_t bytes)
{ {
struct xfs_flock64 fl; struct xfs_flock64 fl;
int err;
memset(&fl, 0, sizeof(fl)); memset(&fl, 0, sizeof(fl));
fl.l_whence = SEEK_SET; fl.l_whence = SEEK_SET;
@@ -1042,8 +1052,9 @@ static int xfs_discard(BDRVRawState *s, int64_t offset, uint64_t bytes)
fl.l_len = bytes; fl.l_len = bytes;
if (xfsctl(NULL, s->fd, XFS_IOC_UNRESVSP64, &fl) < 0) { if (xfsctl(NULL, s->fd, XFS_IOC_UNRESVSP64, &fl) < 0) {
DEBUG_BLOCK_PRINT("cannot punch hole (%s)\n", strerror(errno)); err = errno;
return -errno; DPRINTF("cannot punch hole (%s)\n", strerror(errno));
return -err;
} }
return 0; return 0;
@@ -2076,15 +2087,38 @@ static void hdev_parse_filename(const char *filename, QDict *options,
qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename))); qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
} }
static bool hdev_is_sg(BlockDriverState *bs)
{
#if defined(__linux__)
struct stat st;
struct sg_scsi_id scsiid;
int sg_version;
if (stat(bs->filename, &st) >= 0 && S_ISCHR(st.st_mode) &&
!bdrv_ioctl(bs, SG_GET_VERSION_NUM, &sg_version) &&
!bdrv_ioctl(bs, SG_GET_SCSI_ID, &scsiid)) {
DPRINTF("SG device found: type=%d, version=%d\n",
scsiid.scsi_type, sg_version);
return true;
}
#endif
return false;
}
static int hdev_open(BlockDriverState *bs, QDict *options, int flags, static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp) Error **errp)
{ {
BDRVRawState *s = bs->opaque; BDRVRawState *s = bs->opaque;
Error *local_err = NULL; Error *local_err = NULL;
int ret; int ret;
const char *filename = qdict_get_str(options, "filename");
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
const char *filename = qdict_get_str(options, "filename");
if (strstart(filename, "/dev/cdrom", NULL)) { if (strstart(filename, "/dev/cdrom", NULL)) {
kern_return_t kernResult; kern_return_t kernResult;
io_iterator_t mediaIterator; io_iterator_t mediaIterator;
@@ -2113,16 +2147,6 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
#endif #endif
s->type = FTYPE_FILE; s->type = FTYPE_FILE;
#if defined(__linux__)
{
char resolved_path[ MAXPATHLEN ], *temp;
temp = realpath(filename, resolved_path);
if (temp && strstart(temp, "/dev/sg", NULL)) {
bs->sg = 1;
}
}
#endif
ret = raw_open_common(bs, options, flags, 0, &local_err); ret = raw_open_common(bs, options, flags, 0, &local_err);
if (ret < 0) { if (ret < 0) {
@@ -2132,6 +2156,9 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
return ret; return ret;
} }
/* Since this does ioctl the device must be already opened */
bs->sg = hdev_is_sg(bs);
if (flags & BDRV_O_RDWR) { if (flags & BDRV_O_RDWR) {
ret = check_hdev_writable(s); ret = check_hdev_writable(s);
if (ret < 0) { if (ret < 0) {
@@ -2160,16 +2187,12 @@ static int fd_open(BlockDriverState *bs)
(qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_open_time) >= FD_OPEN_TIMEOUT) { (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_open_time) >= FD_OPEN_TIMEOUT) {
qemu_close(s->fd); qemu_close(s->fd);
s->fd = -1; s->fd = -1;
#ifdef DEBUG_FLOPPY DPRINTF("Floppy closed\n");
printf("Floppy closed\n");
#endif
} }
if (s->fd < 0) { if (s->fd < 0) {
if (s->fd_got_error && if (s->fd_got_error &&
(qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_error_time) < FD_OPEN_TIMEOUT) { (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_error_time) < FD_OPEN_TIMEOUT) {
#ifdef DEBUG_FLOPPY DPRINTF("No floppy (open delayed)\n");
printf("No floppy (open delayed)\n");
#endif
return -EIO; return -EIO;
} }
s->fd = qemu_open(bs->filename, s->open_flags & ~O_NONBLOCK); s->fd = qemu_open(bs->filename, s->open_flags & ~O_NONBLOCK);
@@ -2178,14 +2201,10 @@ static int fd_open(BlockDriverState *bs)
s->fd_got_error = 1; s->fd_got_error = 1;
if (last_media_present) if (last_media_present)
s->fd_media_changed = 1; s->fd_media_changed = 1;
#ifdef DEBUG_FLOPPY DPRINTF("No floppy\n");
printf("No floppy\n");
#endif
return -EIO; return -EIO;
} }
#ifdef DEBUG_FLOPPY DPRINTF("Floppy opened\n");
printf("Floppy opened\n");
#endif
} }
if (!last_media_present) if (!last_media_present)
s->fd_media_changed = 1; s->fd_media_changed = 1;
@@ -2453,9 +2472,7 @@ static int floppy_media_changed(BlockDriverState *bs)
fd_open(bs); fd_open(bs);
ret = s->fd_media_changed; ret = s->fd_media_changed;
s->fd_media_changed = 0; s->fd_media_changed = 0;
#ifdef DEBUG_FLOPPY DPRINTF("Floppy changed=%d\n", ret);
printf("Floppy changed=%d\n", ret);
#endif
return ret; return ret;
} }

View File

@@ -29,6 +29,7 @@
#include "trace.h" #include "trace.h"
#include "block/thread-pool.h" #include "block/thread-pool.h"
#include "qemu/iov.h" #include "qemu/iov.h"
#include "qapi/qmp/qstring.h"
#include <windows.h> #include <windows.h>
#include <winioctl.h> #include <winioctl.h>

View File

@@ -24,6 +24,7 @@
#include "block/snapshot.h" #include "block/snapshot.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "qapi/qmp/qerror.h"
QemuOptsList internal_snapshot_opts = { QemuOptsList internal_snapshot_opts = {
.name = "snapshot", .name = "snapshot",
@@ -229,7 +230,7 @@ int bdrv_snapshot_delete(BlockDriverState *bs,
{ {
BlockDriver *drv = bs->drv; BlockDriver *drv = bs->drv;
if (!drv) { if (!drv) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs)); error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
return -ENOMEDIUM; return -ENOMEDIUM;
} }
if (!snapshot_id && !name) { if (!snapshot_id && !name) {
@@ -315,7 +316,7 @@ int bdrv_snapshot_load_tmp(BlockDriverState *bs,
BlockDriver *drv = bs->drv; BlockDriver *drv = bs->drv;
if (!drv) { if (!drv) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs)); error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
return -ENOMEDIUM; return -ENOMEDIUM;
} }
if (!snapshot_id && !name) { if (!snapshot_id && !name) {

View File

@@ -30,9 +30,11 @@
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#include "block/block_int.h" #include "block/block_int.h"
#include "qemu/error-report.h"
#include "qemu/sockets.h" #include "qemu/sockets.h"
#include "qemu/uri.h" #include "qemu/uri.h"
#include "qapi/qmp/qint.h" #include "qapi/qmp/qint.h"
#include "qapi/qmp/qstring.h"
/* DEBUG_SSH=1 enables the DPRINTF (debugging printf) statements in /* DEBUG_SSH=1 enables the DPRINTF (debugging printf) statements in
* this block driver code. * this block driver code.

View File

@@ -14,6 +14,7 @@
#include "trace.h" #include "trace.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "block/blockjob.h" #include "block/blockjob.h"
#include "qapi/qmp/qerror.h"
#include "qemu/ratelimit.h" #include "qemu/ratelimit.h"
enum { enum {
@@ -227,7 +228,7 @@ static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)
StreamBlockJob *s = container_of(job, StreamBlockJob, common); StreamBlockJob *s = container_of(job, StreamBlockJob, common);
if (speed < 0) { if (speed < 0) {
error_set(errp, QERR_INVALID_PARAMETER, "speed"); error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return; return;
} }
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME); ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
@@ -250,7 +251,7 @@ void stream_start(BlockDriverState *bs, BlockDriverState *base,
if ((on_error == BLOCKDEV_ON_ERROR_STOP || if ((on_error == BLOCKDEV_ON_ERROR_STOP ||
on_error == BLOCKDEV_ON_ERROR_ENOSPC) && on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) { !bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER, "on-error"); error_setg(errp, QERR_INVALID_PARAMETER, "on-error");
return; return;
} }

View File

@@ -324,9 +324,14 @@ void throttle_group_config(BlockDriverState *bs, ThrottleConfig *cfg)
ThrottleState *ts = bs->throttle_state; ThrottleState *ts = bs->throttle_state;
ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
qemu_mutex_lock(&tg->lock); qemu_mutex_lock(&tg->lock);
throttle_config(ts, tt, cfg);
/* throttle_config() cancels the timers */ /* throttle_config() cancels the timers */
tg->any_timer_armed[0] = tg->any_timer_armed[1] = false; if (timer_pending(tt->timers[0])) {
tg->any_timer_armed[0] = false;
}
if (timer_pending(tt->timers[1])) {
tg->any_timer_armed[1] = false;
}
throttle_config(ts, tt, cfg);
qemu_mutex_unlock(&tg->lock); qemu_mutex_unlock(&tg->lock);
} }

View File

@@ -19,6 +19,7 @@
*/ */
#include "qemu-common.h" #include "qemu-common.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "qemu/error-report.h"
#include "qemu/module.h" #include "qemu/module.h"
#include "block/vhdx.h" #include "block/vhdx.h"

View File

@@ -25,6 +25,8 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "qapi/qmp/qerror.h"
#include "qemu/error-report.h"
#include "qemu/module.h" #include "qemu/module.h"
#include "migration/migration.h" #include "migration/migration.h"
#include <zlib.h> #include <zlib.h>
@@ -645,8 +647,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
char buf[64]; char buf[64];
snprintf(buf, sizeof(buf), "VMDK version %" PRId32, snprintf(buf, sizeof(buf), "VMDK version %" PRId32,
le32_to_cpu(header.version)); le32_to_cpu(header.version));
error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bdrv_get_device_or_node_name(bs), "vmdk", buf); bdrv_get_device_or_node_name(bs), "vmdk", buf);
return -ENOTSUP; return -ENOTSUP;
} else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) { } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) {
/* VMware KB 2064959 explains that version 3 added support for /* VMware KB 2064959 explains that version 3 added support for
@@ -1688,12 +1690,12 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
/* write all the data */ /* write all the data */
ret = bdrv_pwrite(bs, 0, &magic, sizeof(magic)); ret = bdrv_pwrite(bs, 0, &magic, sizeof(magic));
if (ret < 0) { if (ret < 0) {
error_set(errp, QERR_IO_ERROR); error_setg(errp, QERR_IO_ERROR);
goto exit; goto exit;
} }
ret = bdrv_pwrite(bs, sizeof(magic), &header, sizeof(header)); ret = bdrv_pwrite(bs, sizeof(magic), &header, sizeof(header));
if (ret < 0) { if (ret < 0) {
error_set(errp, QERR_IO_ERROR); error_setg(errp, QERR_IO_ERROR);
goto exit; goto exit;
} }
@@ -1713,7 +1715,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
ret = bdrv_pwrite(bs, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE, ret = bdrv_pwrite(bs, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE,
gd_buf, gd_buf_size); gd_buf, gd_buf_size);
if (ret < 0) { if (ret < 0) {
error_set(errp, QERR_IO_ERROR); error_setg(errp, QERR_IO_ERROR);
goto exit; goto exit;
} }
@@ -1725,7 +1727,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
ret = bdrv_pwrite(bs, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE, ret = bdrv_pwrite(bs, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE,
gd_buf, gd_buf_size); gd_buf, gd_buf_size);
if (ret < 0) { if (ret < 0) {
error_set(errp, QERR_IO_ERROR); error_setg(errp, QERR_IO_ERROR);
goto exit; goto exit;
} }

View File

@@ -30,6 +30,7 @@
#include "migration/migration.h" #include "migration/migration.h"
#include "qapi/qmp/qint.h" #include "qapi/qmp/qint.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qstring.h"
#ifndef S_IWGRP #ifndef S_IWGRP
#define S_IWGRP 0 #define S_IWGRP 0
@@ -322,6 +323,7 @@ typedef struct BDRVVVFATState {
int fat_type; /* 16 or 32 */ int fat_type; /* 16 or 32 */
array_t fat,directory,mapping; array_t fat,directory,mapping;
char volume_label[11];
unsigned int cluster_size; unsigned int cluster_size;
unsigned int sectors_per_cluster; unsigned int sectors_per_cluster;
@@ -859,7 +861,7 @@ static int init_directories(BDRVVVFATState* s,
{ {
direntry_t* entry=array_get_next(&(s->directory)); direntry_t* entry=array_get_next(&(s->directory));
entry->attributes=0x28; /* archive | volume label */ entry->attributes=0x28; /* archive | volume label */
memcpy(entry->name, "QEMU VVFAT ", sizeof(entry->name)); memcpy(entry->name, s->volume_label, sizeof(entry->name));
} }
/* Now build FAT, and write back information into directory */ /* Now build FAT, and write back information into directory */
@@ -968,7 +970,8 @@ static int init_directories(BDRVVVFATState* s,
bootsector->u.fat16.signature=0x29; bootsector->u.fat16.signature=0x29;
bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd); bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);
memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11); memcpy(bootsector->u.fat16.volume_label, s->volume_label,
sizeof(bootsector->u.fat16.volume_label));
memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8); memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8);
bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa; bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;
@@ -1007,6 +1010,11 @@ static QemuOptsList runtime_opts = {
.type = QEMU_OPT_BOOL, .type = QEMU_OPT_BOOL,
.help = "Create a floppy rather than a hard disk image", .help = "Create a floppy rather than a hard disk image",
}, },
{
.name = "label",
.type = QEMU_OPT_STRING,
.help = "Use a volume label other than QEMU VVFAT",
},
{ {
.name = "rw", .name = "rw",
.type = QEMU_OPT_BOOL, .type = QEMU_OPT_BOOL,
@@ -1059,8 +1067,8 @@ static void vvfat_parse_filename(const char *filename, QDict *options,
/* Fill in the options QDict */ /* Fill in the options QDict */
qdict_put(options, "dir", qstring_from_str(filename)); qdict_put(options, "dir", qstring_from_str(filename));
qdict_put(options, "fat-type", qint_from_int(fat_type)); qdict_put(options, "fat-type", qint_from_int(fat_type));
qdict_put(options, "floppy", qbool_from_int(floppy)); qdict_put(options, "floppy", qbool_from_bool(floppy));
qdict_put(options, "rw", qbool_from_int(rw)); qdict_put(options, "rw", qbool_from_bool(rw));
} }
static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
@@ -1069,7 +1077,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
BDRVVVFATState *s = bs->opaque; BDRVVVFATState *s = bs->opaque;
int cyls, heads, secs; int cyls, heads, secs;
bool floppy; bool floppy;
const char *dirname; const char *dirname, *label;
QemuOpts *opts; QemuOpts *opts;
Error *local_err = NULL; Error *local_err = NULL;
int ret; int ret;
@@ -1096,6 +1104,18 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
s->fat_type = qemu_opt_get_number(opts, "fat-type", 0); s->fat_type = qemu_opt_get_number(opts, "fat-type", 0);
floppy = qemu_opt_get_bool(opts, "floppy", false); floppy = qemu_opt_get_bool(opts, "floppy", false);
memset(s->volume_label, ' ', sizeof(s->volume_label));
label = qemu_opt_get(opts, "label");
if (label) {
size_t label_length = strlen(label);
if (label_length > 11) {
error_setg(errp, "vvfat label cannot be longer than 11 bytes");
ret = -EINVAL;
goto fail;
}
memcpy(s->volume_label, label, label_length);
}
if (floppy) { if (floppy) {
/* 1.44MB or 2.88MB floppy. 2.88MB can be FAT12 (default) or FAT16. */ /* 1.44MB or 2.88MB floppy. 2.88MB can be FAT12 (default) or FAT16. */
if (!s->fat_type) { if (!s->fat_type) {

View File

@@ -12,7 +12,6 @@
#include "sysemu/blockdev.h" #include "sysemu/blockdev.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "hw/block/block.h" #include "hw/block/block.h"
#include "monitor/monitor.h"
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "qmp-commands.h" #include "qmp-commands.h"
@@ -91,11 +90,12 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
if (!blk_is_inserted(blk)) { if (!blk_is_inserted(blk)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return; return;
} }

View File

@@ -36,10 +36,12 @@
#include "block/blockjob.h" #include "block/blockjob.h"
#include "block/throttle-groups.h" #include "block/throttle-groups.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "qemu/error-report.h"
#include "qemu/option.h" #include "qemu/option.h"
#include "qemu/config-file.h" #include "qemu/config-file.h"
#include "qapi/qmp/types.h" #include "qapi/qmp/types.h"
#include "qapi-visit.h" #include "qapi-visit.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp-output-visitor.h" #include "qapi/qmp-output-visitor.h"
#include "qapi/util.h" #include "qapi/util.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
@@ -174,7 +176,7 @@ static int drive_index_to_unit_id(BlockInterfaceType type, int index)
QemuOpts *drive_def(const char *optstr) QemuOpts *drive_def(const char *optstr)
{ {
return qemu_opts_parse(qemu_find_opts("drive"), optstr, 0); return qemu_opts_parse_noisily(qemu_find_opts("drive"), optstr, false);
} }
QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
@@ -1111,7 +1113,8 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return NULL; return NULL;
} }
bs = blk_bs(blk); bs = blk_bs(blk);
@@ -1300,7 +1303,8 @@ static void internal_snapshot_prepare(BlkTransactionState *common,
/* 2. check for validation */ /* 2. check for validation */
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
bs = blk_bs(blk); bs = blk_bs(blk);
@@ -1310,7 +1314,7 @@ static void internal_snapshot_prepare(BlkTransactionState *common,
aio_context_acquire(state->aio_context); aio_context_acquire(state->aio_context);
if (!bdrv_is_inserted(bs)) { if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return; return;
} }
@@ -1451,7 +1455,7 @@ static void external_snapshot_prepare(BlkTransactionState *common,
/* start processing */ /* start processing */
drv = bdrv_find_format(format); drv = bdrv_find_format(format);
if (!drv) { if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
return; return;
} }
@@ -1478,7 +1482,7 @@ static void external_snapshot_prepare(BlkTransactionState *common,
aio_context_acquire(state->aio_context); aio_context_acquire(state->aio_context);
if (!bdrv_is_inserted(state->old_bs)) { if (!bdrv_is_inserted(state->old_bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return; return;
} }
@@ -1489,13 +1493,13 @@ static void external_snapshot_prepare(BlkTransactionState *common,
if (!bdrv_is_read_only(state->old_bs)) { if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) { if (bdrv_flush(state->old_bs)) {
error_set(errp, QERR_IO_ERROR); error_setg(errp, QERR_IO_ERROR);
return; return;
} }
} }
if (!bdrv_is_first_non_filter(state->old_bs)) { if (!bdrv_is_first_non_filter(state->old_bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "snapshot"); error_setg(errp, QERR_FEATURE_DISABLED, "snapshot");
return; return;
} }
@@ -1580,7 +1584,8 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp)
blk = blk_by_name(backup->device); blk = blk_by_name(backup->device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, backup->device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", backup->device);
return; return;
} }
bs = blk_bs(blk); bs = blk_bs(blk);
@@ -1850,7 +1855,8 @@ void qmp_eject(const char *device, bool has_force, bool force, Error **errp)
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
@@ -1910,7 +1916,8 @@ void qmp_change_blockdev(const char *device, const char *filename,
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
bs = blk_bs(blk); bs = blk_bs(blk);
@@ -1921,7 +1928,7 @@ void qmp_change_blockdev(const char *device, const char *filename,
if (format) { if (format) {
drv = bdrv_find_whitelisted_format(format, bs->read_only); drv = bdrv_find_whitelisted_format(format, bs->read_only);
if (!drv) { if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
goto out; goto out;
} }
} }
@@ -1971,7 +1978,8 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
bs = blk_bs(blk); bs = blk_bs(blk);
@@ -2159,9 +2167,6 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
return; return;
} }
/* quiesce block driver; prevent further io */
bdrv_drain_all();
bdrv_flush(bs);
bdrv_close(bs); bdrv_close(bs);
/* if we have a device attached to this BlockDriverState /* if we have a device attached to this BlockDriverState
@@ -2202,17 +2207,17 @@ void qmp_block_resize(bool has_device, const char *device,
aio_context_acquire(aio_context); aio_context_acquire(aio_context);
if (!bdrv_is_first_non_filter(bs)) { if (!bdrv_is_first_non_filter(bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "resize"); error_setg(errp, QERR_FEATURE_DISABLED, "resize");
goto out; goto out;
} }
if (size < 0) { if (size < 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size"); error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
goto out; goto out;
} }
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) { if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) {
error_set(errp, QERR_DEVICE_IN_USE, device); error_setg(errp, QERR_DEVICE_IN_USE, device);
goto out; goto out;
} }
@@ -2224,16 +2229,16 @@ void qmp_block_resize(bool has_device, const char *device,
case 0: case 0:
break; break;
case -ENOMEDIUM: case -ENOMEDIUM:
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
break; break;
case -ENOTSUP: case -ENOTSUP:
error_set(errp, QERR_UNSUPPORTED); error_setg(errp, QERR_UNSUPPORTED);
break; break;
case -EACCES: case -EACCES:
error_setg(errp, "Device '%s' is read only", device); error_setg(errp, "Device '%s' is read only", device);
break; break;
case -EBUSY: case -EBUSY:
error_set(errp, QERR_DEVICE_IN_USE, device); error_setg(errp, QERR_DEVICE_IN_USE, device);
break; break;
default: default:
error_setg_errno(errp, -ret, "Could not resize"); error_setg_errno(errp, -ret, "Could not resize");
@@ -2291,7 +2296,8 @@ void qmp_block_stream(const char *device,
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
bs = blk_bs(blk); bs = blk_bs(blk);
@@ -2306,7 +2312,7 @@ void qmp_block_stream(const char *device,
if (has_base) { if (has_base) {
base_bs = bdrv_find_backing_image(bs, base); base_bs = bdrv_find_backing_image(bs, base);
if (base_bs == NULL) { if (base_bs == NULL) {
error_set(errp, QERR_BASE_NOT_FOUND, base); error_setg(errp, QERR_BASE_NOT_FOUND, base);
goto out; goto out;
} }
assert(bdrv_get_aio_context(base_bs) == aio_context); assert(bdrv_get_aio_context(base_bs) == aio_context);
@@ -2365,7 +2371,8 @@ void qmp_block_commit(const char *device,
* scenario in which all optional arguments are omitted. */ * scenario in which all optional arguments are omitted. */
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
bs = blk_bs(blk); bs = blk_bs(blk);
@@ -2403,7 +2410,7 @@ void qmp_block_commit(const char *device,
} }
if (base_bs == NULL) { if (base_bs == NULL) {
error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL"); error_setg(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
goto out; goto out;
} }
@@ -2477,7 +2484,8 @@ void qmp_drive_backup(const char *device, const char *target,
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
bs = blk_bs(blk); bs = blk_bs(blk);
@@ -2488,7 +2496,7 @@ void qmp_drive_backup(const char *device, const char *target,
/* Although backup_run has this check too, we need to use bs->drv below, so /* Although backup_run has this check too, we need to use bs->drv below, so
* do an early check redundantly. */ * do an early check redundantly. */
if (!bdrv_is_inserted(bs)) { if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
goto out; goto out;
} }
@@ -2498,7 +2506,7 @@ void qmp_drive_backup(const char *device, const char *target,
if (format) { if (format) {
drv = bdrv_find_format(format); drv = bdrv_find_format(format);
if (!drv) { if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
goto out; goto out;
} }
} }
@@ -2647,6 +2655,7 @@ void qmp_drive_mirror(const char *device, const char *target,
bool has_buf_size, int64_t buf_size, bool has_buf_size, int64_t buf_size,
bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_source_error, BlockdevOnError on_source_error,
bool has_on_target_error, BlockdevOnError on_target_error, bool has_on_target_error, BlockdevOnError on_target_error,
bool has_unmap, bool unmap,
Error **errp) Error **errp)
{ {
BlockBackend *blk; BlockBackend *blk;
@@ -2678,20 +2687,25 @@ void qmp_drive_mirror(const char *device, const char *target,
if (!has_buf_size) { if (!has_buf_size) {
buf_size = DEFAULT_MIRROR_BUF_SIZE; buf_size = DEFAULT_MIRROR_BUF_SIZE;
} }
if (!has_unmap) {
unmap = true;
}
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) { if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
"a value in range [512B, 64MB]"); "a value in range [512B, 64MB]");
return; return;
} }
if (granularity & (granularity - 1)) { if (granularity & (granularity - 1)) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2"); error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
"power of 2");
return; return;
} }
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
bs = blk_bs(blk); bs = blk_bs(blk);
@@ -2700,7 +2714,7 @@ void qmp_drive_mirror(const char *device, const char *target,
aio_context_acquire(aio_context); aio_context_acquire(aio_context);
if (!bdrv_is_inserted(bs)) { if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
goto out; goto out;
} }
@@ -2710,7 +2724,7 @@ void qmp_drive_mirror(const char *device, const char *target,
if (format) { if (format) {
drv = bdrv_find_format(format); drv = bdrv_find_format(format);
if (!drv) { if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
goto out; goto out;
} }
} }
@@ -2817,6 +2831,7 @@ void qmp_drive_mirror(const char *device, const char *target,
has_replaces ? replaces : NULL, has_replaces ? replaces : NULL,
speed, granularity, buf_size, sync, speed, granularity, buf_size, sync,
on_source_error, on_target_error, on_source_error, on_target_error,
unmap,
block_job_cb, bs, &local_err); block_job_cb, bs, &local_err);
if (local_err != NULL) { if (local_err != NULL) {
bdrv_unref(target_bs); bdrv_unref(target_bs);
@@ -2957,7 +2972,8 @@ void qmp_change_backing_file(const char *device,
blk = blk_by_name(device); blk = blk_by_name(device);
if (!blk) { if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device); error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return; return;
} }
bs = blk_bs(blk); bs = blk_bs(blk);

View File

@@ -29,6 +29,7 @@
#include "block/block.h" #include "block/block.h"
#include "block/blockjob.h" #include "block/blockjob.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "block/coroutine.h" #include "block/coroutine.h"
#include "qmp-commands.h" #include "qmp-commands.h"
@@ -42,7 +43,7 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
BlockJob *job; BlockJob *job;
if (bs->job) { if (bs->job) {
error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs)); error_setg(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
return NULL; return NULL;
} }
bdrv_ref(bs); bdrv_ref(bs);
@@ -93,7 +94,7 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
Error *local_err = NULL; Error *local_err = NULL;
if (!job->driver->set_speed) { if (!job->driver->set_speed) {
error_set(errp, QERR_UNSUPPORTED); error_setg(errp, QERR_UNSUPPORTED);
return; return;
} }
job->driver->set_speed(job, speed, &local_err); job->driver->set_speed(job, speed, &local_err);
@@ -108,8 +109,8 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
void block_job_complete(BlockJob *job, Error **errp) void block_job_complete(BlockJob *job, Error **errp)
{ {
if (job->pause_count || job->cancelled || !job->driver->complete) { if (job->pause_count || job->cancelled || !job->driver->complete) {
error_set(errp, QERR_BLOCK_JOB_NOT_READY, error_setg(errp, QERR_BLOCK_JOB_NOT_READY,
bdrv_get_device_name(job->bs)); bdrv_get_device_name(job->bs));
return; return;
} }

201
configure vendored
View File

@@ -355,7 +355,7 @@ for opt do
--extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg" --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
EXTRA_CFLAGS="$optarg" EXTRA_CFLAGS="$optarg"
;; ;;
--extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS" --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
EXTRA_LDFLAGS="$optarg" EXTRA_LDFLAGS="$optarg"
;; ;;
--enable-debug-info) debug_info="yes" --enable-debug-info) debug_info="yes"
@@ -1282,29 +1282,10 @@ Advanced options (experts only):
--sysconfdir=PATH install config in PATH$confsuffix --sysconfdir=PATH install config in PATH$confsuffix
--localstatedir=PATH install local state in PATH (set at runtime on win32) --localstatedir=PATH install local state in PATH (set at runtime on win32)
--with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix] --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
--enable-modules enable modules support
--enable-debug-tcg enable TCG debugging
--disable-debug-tcg disable TCG debugging (default)
--enable-debug-info enable debugging information (default)
--disable-debug-info disable debugging information
--enable-debug enable common debug build options --enable-debug enable common debug build options
--enable-sparse enable sparse checker
--disable-sparse disable sparse checker (default)
--disable-strip disable stripping binaries --disable-strip disable stripping binaries
--disable-werror disable compilation abort on warning --disable-werror disable compilation abort on warning
--disable-stack-protector disable compiler-provided stack protection --disable-stack-protector disable compiler-provided stack protection
--disable-sdl disable SDL
--enable-sdl enable SDL
--with-sdlabi select preferred SDL ABI 1.2 or 2.0
--disable-gtk disable gtk UI
--enable-gtk enable gtk UI
--with-gtkabi select preferred GTK ABI 2.0 or 3.0
--disable-virtfs disable VirtFS
--enable-virtfs enable VirtFS
--disable-vnc disable VNC
--enable-vnc enable VNC
--disable-cocoa disable Cocoa (Mac OS X only)
--enable-cocoa enable Cocoa (default on Mac OS X)
--audio-drv-list=LIST set audio drivers list: --audio-drv-list=LIST set audio drivers list:
Available drivers: $audio_possible_drivers Available drivers: $audio_possible_drivers
--block-drv-whitelist=L Same as --block-drv-rw-whitelist=L --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
@@ -1314,119 +1295,89 @@ Advanced options (experts only):
--block-drv-ro-whitelist=L --block-drv-ro-whitelist=L
set block driver read-only whitelist set block driver read-only whitelist
(affects only QEMU, not qemu-img) (affects only QEMU, not qemu-img)
--disable-xen disable xen backend driver support
--enable-xen enable xen backend driver support
--disable-xen-pci-passthrough
--enable-xen-pci-passthrough
--disable-brlapi disable BrlAPI
--enable-brlapi enable BrlAPI
--disable-vnc-tls disable TLS encryption for VNC server
--enable-vnc-tls enable TLS encryption for VNC server
--disable-vnc-sasl disable SASL encryption for VNC server
--enable-vnc-sasl enable SASL encryption for VNC server
--disable-vnc-jpeg disable JPEG lossy compression for VNC server
--enable-vnc-jpeg enable JPEG lossy compression for VNC server
--disable-vnc-png disable PNG compression for VNC server (default)
--enable-vnc-png enable PNG compression for VNC server
--disable-vnc-ws disable Websockets support for VNC server
--enable-vnc-ws enable Websockets support for VNC server
--disable-curses disable curses output
--enable-curses enable curses output
--disable-curl disable curl connectivity
--enable-curl enable curl connectivity
--disable-fdt disable fdt device tree
--enable-fdt enable fdt device tree
--disable-bluez disable bluez stack connectivity
--enable-bluez enable bluez stack connectivity
--disable-slirp disable SLIRP userspace network connectivity
--disable-kvm disable KVM acceleration support
--enable-kvm enable KVM acceleration support
--disable-rdma disable RDMA-based migration support
--enable-rdma enable RDMA-based migration support
--enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
--enable-system enable all system emulation targets
--disable-system disable all system emulation targets
--enable-user enable supported user emulation targets
--disable-user disable all user emulation targets
--enable-linux-user enable all linux usermode emulation targets
--disable-linux-user disable all linux usermode emulation targets
--enable-bsd-user enable all BSD usermode emulation targets
--disable-bsd-user disable all BSD usermode emulation targets
--enable-guest-base enable GUEST_BASE support for usermode
emulation targets
--disable-guest-base disable GUEST_BASE support
--enable-pie build Position Independent Executables
--disable-pie do not build Position Independent Executables
--oss-lib path to OSS library
--cpu=CPU Build for host CPU [$cpu]
--disable-uuid disable uuid support
--enable-uuid enable uuid support
--disable-vde disable support for vde network
--enable-vde enable support for vde network
--disable-netmap disable support for netmap network
--enable-netmap enable support for netmap network
--disable-linux-aio disable Linux AIO support
--enable-linux-aio enable Linux AIO support
--disable-cap-ng disable libcap-ng support
--enable-cap-ng enable libcap-ng support
--disable-attr disable attr and xattr support
--enable-attr enable attr and xattr support
--disable-blobs disable installing provided firmware blobs
--enable-docs enable documentation build
--disable-docs disable documentation build
--disable-vhost-net disable vhost-net acceleration support
--enable-vhost-net enable vhost-net acceleration support
--enable-trace-backends=B Set trace backend --enable-trace-backends=B Set trace backend
Available backends: $($python $source_path/scripts/tracetool.py --list-backends) Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
--with-trace-file=NAME Full PATH,NAME of file to store traces --with-trace-file=NAME Full PATH,NAME of file to store traces
Default:trace-<pid> Default:trace-<pid>
--disable-spice disable spice --disable-slirp disable SLIRP userspace network connectivity
--enable-spice enable spice --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
--enable-rbd enable building the rados block device (rbd) --oss-lib path to OSS library
--disable-libiscsi disable iscsi support --cpu=CPU Build for host CPU [$cpu]
--enable-libiscsi enable iscsi support
--disable-libnfs disable nfs support
--enable-libnfs enable nfs support
--disable-smartcard-nss disable smartcard nss support
--enable-smartcard-nss enable smartcard nss support
--disable-libusb disable libusb (for usb passthrough)
--enable-libusb enable libusb (for usb passthrough)
--disable-usb-redir disable usb network redirection support
--enable-usb-redir enable usb network redirection support
--enable-lzo enable the support of lzo compression library
--enable-snappy enable the support of snappy compression library
--enable-bzip2 enable the support of bzip2 compression library (for
reading bzip2-compressed dmg images)
--disable-guest-agent disable building of the QEMU Guest Agent
--enable-guest-agent enable building of the QEMU Guest Agent
--enable-guest-agent-msi enable building guest agent Windows MSI installation package
--disable-guest-agent-msi disable building guest agent Windows MSI installation
--with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
--with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
--disable-seccomp disable seccomp support
--enable-seccomp enable seccomp support
--with-coroutine=BACKEND coroutine backend. Supported options: --with-coroutine=BACKEND coroutine backend. Supported options:
gthread, ucontext, sigaltstack, windows gthread, ucontext, sigaltstack, windows
--disable-coroutine-pool disable coroutine freelist (worse performance)
--enable-coroutine-pool enable coroutine freelist (better performance)
--enable-glusterfs enable GlusterFS backend
--disable-glusterfs disable GlusterFS backend
--enable-archipelago enable Archipelago backend
--disable-archipelago disable Archipelago backend
--enable-gcov enable test coverage analysis with gcov --enable-gcov enable test coverage analysis with gcov
--gcov=GCOV use specified gcov [$gcov_tool] --gcov=GCOV use specified gcov [$gcov_tool]
--disable-tpm disable TPM support --disable-blobs disable installing provided firmware blobs
--enable-tpm enable TPM support --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
--disable-libssh2 disable ssh block device support --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
--enable-libssh2 enable ssh block device support
--disable-vhdx disable support for the Microsoft VHDX image format Optional features, enabled with --enable-FEATURE and
--enable-vhdx enable support for the Microsoft VHDX image format disabled with --disable-FEATURE, default is enabled if available:
--disable-quorum disable quorum block filter support
--enable-quorum enable quorum block filter support system all system emulation targets
--disable-numa disable libnuma support user supported user emulation targets
--enable-numa enable libnuma support linux-user all linux usermode emulation targets
--disable-tcmalloc disable tcmalloc support bsd-user all BSD usermode emulation targets
--enable-tcmalloc enable tcmalloc support guest-base GUEST_BASE support for usermode emulation targets
docs build documentation
guest-agent build the QEMU Guest Agent
guest-agent-msi build guest agent Windows MSI installation package
pie Position Independent Executables
modules modules support
debug-tcg TCG debugging (default is disabled)
debug-info debugging information
sparse sparse checker
sdl SDL UI
--with-sdlabi select preferred SDL ABI 1.2 or 2.0
gtk gtk UI
--with-gtkabi select preferred GTK ABI 2.0 or 3.0
vte vte support for the gtk UI
curses curses UI
vnc VNC UI support
vnc-tls TLS encryption for VNC server
vnc-sasl SASL encryption for VNC server
vnc-jpeg JPEG lossy compression for VNC server
vnc-png PNG compression for VNC server
vnc-ws Websockets support for VNC server
cocoa Cocoa UI (Mac OS X only)
virtfs VirtFS
xen xen backend driver support
xen-pci-passthrough
brlapi BrlAPI (Braile)
curl curl connectivity
fdt fdt device tree
bluez bluez stack connectivity
kvm KVM acceleration support
rdma RDMA-based migration support
uuid uuid support
vde support for vde network
netmap support for netmap network
linux-aio Linux AIO support
cap-ng libcap-ng support
attr attr and xattr support
vhost-net vhost-net acceleration support
spice spice
rbd rados block device (rbd)
libiscsi iscsi support
libnfs nfs support
smartcard-nss smartcard nss support
libusb libusb (for usb passthrough)
usb-redir usb network redirection support
lzo support of lzo compression library
snappy support of snappy compression library
bzip2 support of bzip2 compression library
(for reading bzip2-compressed dmg images)
seccomp seccomp support
coroutine-pool coroutine freelist (better performance)
glusterfs GlusterFS backend
archipelago Archipelago backend
tpm TPM support
libssh2 ssh block device support
vhdx support for the Microsoft VHDX image format
quorum quorum block filter support
numa libnuma support
tcmalloc tcmalloc support
NOTE: The object files are built at the place where configure is launched NOTE: The object files are built at the place where configure is launched
EOF EOF

9
cpus.c
View File

@@ -27,6 +27,7 @@
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "qemu/error-report.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "exec/gdbstub.h" #include "exec/gdbstub.h"
#include "sysemu/dma.h" #include "sysemu/dma.h"
@@ -1512,8 +1513,8 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
cpu = qemu_get_cpu(cpu_index); cpu = qemu_get_cpu(cpu_index);
if (cpu == NULL) { if (cpu == NULL) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index", error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
"a CPU number"); "a CPU number");
return; return;
} }
@@ -1533,7 +1534,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
goto exit; goto exit;
} }
if (fwrite(buf, 1, l, f) != l) { if (fwrite(buf, 1, l, f) != l) {
error_set(errp, QERR_IO_ERROR); error_setg(errp, QERR_IO_ERROR);
goto exit; goto exit;
} }
addr += l; addr += l;
@@ -1563,7 +1564,7 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename,
l = size; l = size;
cpu_physical_memory_read(addr, buf, l); cpu_physical_memory_read(addr, buf, l);
if (fwrite(buf, 1, l, f) != l) { if (fwrite(buf, 1, l, f) != l) {
error_set(errp, QERR_IO_ERROR); error_setg(errp, QERR_IO_ERROR);
goto exit; goto exit;
} }
addr += l; addr += l;

14
disas.c
View File

@@ -9,7 +9,7 @@
typedef struct CPUDebug { typedef struct CPUDebug {
struct disassemble_info info; struct disassemble_info info;
CPUArchState *env; CPUState *cpu;
} CPUDebug; } CPUDebug;
/* Filled in by elfload.c. Simplistic, but will do for now. */ /* Filled in by elfload.c. Simplistic, but will do for now. */
@@ -39,7 +39,7 @@ target_read_memory (bfd_vma memaddr,
{ {
CPUDebug *s = container_of(info, CPUDebug, info); CPUDebug *s = container_of(info, CPUDebug, info);
cpu_memory_rw_debug(ENV_GET_CPU(s->env), memaddr, myaddr, length, 0); cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0);
return 0; return 0;
} }
@@ -195,7 +195,7 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info)
bit 16 indicates little endian. bit 16 indicates little endian.
other targets - unused other targets - unused
*/ */
void target_disas(FILE *out, CPUArchState *env, target_ulong code, void target_disas(FILE *out, CPUState *cpu, target_ulong code,
target_ulong size, int flags) target_ulong size, int flags)
{ {
target_ulong pc; target_ulong pc;
@@ -205,7 +205,7 @@ void target_disas(FILE *out, CPUArchState *env, target_ulong code,
INIT_DISASSEMBLE_INFO(s.info, out, fprintf); INIT_DISASSEMBLE_INFO(s.info, out, fprintf);
s.env = env; s.cpu = cpu;
s.info.read_memory_func = target_read_memory; s.info.read_memory_func = target_read_memory;
s.info.buffer_vma = code; s.info.buffer_vma = code;
s.info.buffer_length = size; s.info.buffer_length = size;
@@ -430,7 +430,7 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,
if (monitor_disas_is_physical) { if (monitor_disas_is_physical) {
cpu_physical_memory_read(memaddr, myaddr, length); cpu_physical_memory_read(memaddr, myaddr, length);
} else { } else {
cpu_memory_rw_debug(ENV_GET_CPU(s->env), memaddr, myaddr, length, 0); cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0);
} }
return 0; return 0;
} }
@@ -447,7 +447,7 @@ monitor_fprintf(FILE *stream, const char *fmt, ...)
/* Disassembler for the monitor. /* Disassembler for the monitor.
See target_disas for a description of flags. */ See target_disas for a description of flags. */
void monitor_disas(Monitor *mon, CPUArchState *env, void monitor_disas(Monitor *mon, CPUState *cpu,
target_ulong pc, int nb_insn, int is_physical, int flags) target_ulong pc, int nb_insn, int is_physical, int flags)
{ {
int count, i; int count, i;
@@ -456,7 +456,7 @@ void monitor_disas(Monitor *mon, CPUArchState *env,
INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf); INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf);
s.env = env; s.cpu = cpu;
monitor_disas_is_physical = is_physical; monitor_disas_is_physical = is_physical;
s.info.read_memory_func = monitor_read_memory; s.info.read_memory_func = monitor_read_memory;
s.info.print_address_func = generic_print_target_address; s.info.print_address_func = generic_print_target_address;

View File

@@ -210,7 +210,7 @@ full backup as a backing image.
"bitmap": "bitmap0", "bitmap": "bitmap0",
"target": "incremental.0.img", "target": "incremental.0.img",
"format": "qcow2", "format": "qcow2",
"sync": "dirty-bitmap", "sync": "incremental",
"mode": "existing" "mode": "existing"
} }
} }
@@ -235,7 +235,7 @@ full backup as a backing image.
"bitmap": "bitmap0", "bitmap": "bitmap0",
"target": "incremental.1.img", "target": "incremental.1.img",
"format": "qcow2", "format": "qcow2",
"sync": "dirty-bitmap", "sync": "incremental",
"mode": "existing" "mode": "existing"
} }
} }
@@ -275,7 +275,7 @@ full backup as a backing image.
"bitmap": "bitmap0", "bitmap": "bitmap0",
"target": "incremental.0.img", "target": "incremental.0.img",
"format": "qcow2", "format": "qcow2",
"sync": "dirty-bitmap", "sync": "incremental",
"mode": "existing" "mode": "existing"
} }
} }
@@ -308,7 +308,7 @@ full backup as a backing image.
"bitmap": "bitmap0", "bitmap": "bitmap0",
"target": "incremental.0.img", "target": "incremental.0.img",
"format": "qcow2", "format": "qcow2",
"sync": "dirty-bitmap", "sync": "incremental",
"mode": "existing" "mode": "existing"
} }
} }

View File

@@ -2,8 +2,8 @@
multiseat howto (with some multihead coverage) multiseat howto (with some multihead coverage)
============================================== ==============================================
host side host devices
--------- ------------
First you must compile qemu with a user interface supporting First you must compile qemu with a user interface supporting
multihead/multiseat and input event routing. Right now this multihead/multiseat and input event routing. Right now this
@@ -41,6 +41,19 @@ The "display=video2" sets up the input routing. Any input coming from
the window which belongs to the video.2 display adapter will be routed the window which belongs to the video.2 display adapter will be routed
to these input devices. to these input devices.
Starting with qemu 2.4 and linux kernel 4.1 you can also use virtio
for the input devices, using this ...
-device pci-bridge,addr=12.0,chassis_nr=2,id=head.2 \
-device secondary-vga,bus=head.2,addr=02.0,id=video.2 \
-device virtio-keyboard-pci,bus=head.2,addr=03.0,display=video.2 \
-device virtio-tablet-pci,bus=head.2,addr=03.0,display=video.2
... instead of xhci and usb hid devices.
host ui
-------
The sdl2 ui will start up with two windows, one for each display The sdl2 ui will start up with two windows, one for each display
device. The gtk ui will start with a single window and each display device. The gtk ui will start with a single window and each display
in a separate tab. You can either simply switch tabs to switch heads, in a separate tab. You can either simply switch tabs to switch heads,
@@ -110,7 +123,7 @@ Background info is here:
guest side with pci-bridge-seat guest side with pci-bridge-seat
------------------------------- -------------------------------
Qemu version FIXME and newer has a new pci-bridge-seat device which Qemu version 2.4 and newer has a new pci-bridge-seat device which
can be used instead of pci-bridge. Just swap the device name in the can be used instead of pci-bridge. Just swap the device name in the
qemu command line above. The only difference between the two devices qemu command line above. The only difference between the two devices
is the pci id. We can match the pci id instead of the device path is the pci id. We can match the pci id instead of the device path
@@ -121,9 +134,10 @@ configuration:
SUBSYSTEM=="pci", ATTR{vendor}=="0x1b36", ATTR{device}=="0x000a", \ SUBSYSTEM=="pci", ATTR{vendor}=="0x1b36", ATTR{device}=="0x000a", \
TAG+="seat", ENV{ID_AUTOSEAT}="1" TAG+="seat", ENV{ID_AUTOSEAT}="1"
Patch with this rule will be submitted to upstream udev/systemd, so Patch with this rule has been submitted to upstream udev/systemd, was
long-term, when systemd with this lands in distros, things will work accepted and and should be included in the next systemd release (222).
just fine without any manual guest configuration. So, if your guest has this or a newer version, multiseat will work just
fine without any manual guest configuration.
Enjoy! Enjoy!

13
dump.c
View File

@@ -23,6 +23,7 @@
#include "sysemu/memory_mapping.h" #include "sysemu/memory_mapping.h"
#include "sysemu/cpus.h" #include "sysemu/cpus.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qmp/qerror.h"
#include "qmp-commands.h" #include "qmp-commands.h"
#include <zlib.h> #include <zlib.h>
@@ -1474,7 +1475,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
s->start = get_start_block(s); s->start = get_start_block(s);
if (s->start == -1) { if (s->start == -1) {
error_set(errp, QERR_INVALID_PARAMETER, "begin"); error_setg(errp, QERR_INVALID_PARAMETER, "begin");
goto cleanup; goto cleanup;
} }
@@ -1484,14 +1485,14 @@ static void dump_init(DumpState *s, int fd, bool has_format,
*/ */
ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks); ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks);
if (ret < 0) { if (ret < 0) {
error_set(errp, QERR_UNSUPPORTED); error_setg(errp, QERR_UNSUPPORTED);
goto cleanup; goto cleanup;
} }
s->note_size = cpu_get_note_size(s->dump_info.d_class, s->note_size = cpu_get_note_size(s->dump_info.d_class,
s->dump_info.d_machine, nr_cpus); s->dump_info.d_machine, nr_cpus);
if (s->note_size < 0) { if (s->note_size < 0) {
error_set(errp, QERR_UNSUPPORTED); error_setg(errp, QERR_UNSUPPORTED);
goto cleanup; goto cleanup;
} }
@@ -1615,11 +1616,11 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
return; return;
} }
if (has_begin && !has_length) { if (has_begin && !has_length) {
error_set(errp, QERR_MISSING_PARAMETER, "length"); error_setg(errp, QERR_MISSING_PARAMETER, "length");
return; return;
} }
if (!has_begin && has_length) { if (!has_begin && has_length) {
error_set(errp, QERR_MISSING_PARAMETER, "begin"); error_setg(errp, QERR_MISSING_PARAMETER, "begin");
return; return;
} }
@@ -1656,7 +1657,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
} }
if (fd == -1) { if (fd == -1) {
error_set(errp, QERR_INVALID_PARAMETER, "protocol"); error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
return; return;
} }

66
hmp.c
View File

@@ -25,6 +25,7 @@
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "monitor/qdev.h" #include "monitor/qdev.h"
#include "qapi/opts-visitor.h" #include "qapi/opts-visitor.h"
#include "qapi/qmp/qerror.h"
#include "qapi/string-output-visitor.h" #include "qapi/string-output-visitor.h"
#include "qapi-visit.h" #include "qapi-visit.h"
#include "ui/console.h" #include "ui/console.h"
@@ -438,8 +439,8 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
BlockInfoList *block_list, *info; BlockInfoList *block_list, *info;
BlockDeviceInfoList *blockdev_list, *blockdev; BlockDeviceInfoList *blockdev_list, *blockdev;
const char *device = qdict_get_try_str(qdict, "device"); const char *device = qdict_get_try_str(qdict, "device");
bool verbose = qdict_get_try_bool(qdict, "verbose", 0); bool verbose = qdict_get_try_bool(qdict, "verbose", false);
bool nodes = qdict_get_try_bool(qdict, "nodes", 0); bool nodes = qdict_get_try_bool(qdict, "nodes", false);
bool printed = false; bool printed = false;
/* Print BlockBackend information */ /* Print BlockBackend information */
@@ -995,7 +996,7 @@ void hmp_nmi(Monitor *mon, const QDict *qdict)
void hmp_set_link(Monitor *mon, const QDict *qdict) void hmp_set_link(Monitor *mon, const QDict *qdict)
{ {
const char *name = qdict_get_str(qdict, "name"); const char *name = qdict_get_str(qdict, "name");
int up = qdict_get_bool(qdict, "up"); bool up = qdict_get_bool(qdict, "up");
Error *err = NULL; Error *err = NULL;
qmp_set_link(name, up, &err); qmp_set_link(name, up, &err);
@@ -1039,13 +1040,13 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
const char *filename = qdict_get_str(qdict, "target"); const char *filename = qdict_get_str(qdict, "target");
const char *format = qdict_get_try_str(qdict, "format"); const char *format = qdict_get_try_str(qdict, "format");
int reuse = qdict_get_try_bool(qdict, "reuse", 0); bool reuse = qdict_get_try_bool(qdict, "reuse", false);
int full = qdict_get_try_bool(qdict, "full", 0); bool full = qdict_get_try_bool(qdict, "full", false);
enum NewImageMode mode; enum NewImageMode mode;
Error *err = NULL; Error *err = NULL;
if (!filename) { if (!filename) {
error_set(&err, QERR_MISSING_PARAMETER, "target"); error_setg(&err, QERR_MISSING_PARAMETER, "target");
hmp_handle_error(mon, &err); hmp_handle_error(mon, &err);
return; return;
} }
@@ -1060,7 +1061,7 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
false, NULL, false, NULL, false, NULL, false, NULL,
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
true, mode, false, 0, false, 0, false, 0, true, mode, false, 0, false, 0, false, 0,
false, 0, false, 0, &err); false, 0, false, 0, false, true, &err);
hmp_handle_error(mon, &err); hmp_handle_error(mon, &err);
} }
@@ -1069,13 +1070,13 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
const char *filename = qdict_get_str(qdict, "target"); const char *filename = qdict_get_str(qdict, "target");
const char *format = qdict_get_try_str(qdict, "format"); const char *format = qdict_get_try_str(qdict, "format");
int reuse = qdict_get_try_bool(qdict, "reuse", 0); bool reuse = qdict_get_try_bool(qdict, "reuse", false);
int full = qdict_get_try_bool(qdict, "full", 0); bool full = qdict_get_try_bool(qdict, "full", false);
enum NewImageMode mode; enum NewImageMode mode;
Error *err = NULL; Error *err = NULL;
if (!filename) { if (!filename) {
error_set(&err, QERR_MISSING_PARAMETER, "target"); error_setg(&err, QERR_MISSING_PARAMETER, "target");
hmp_handle_error(mon, &err); hmp_handle_error(mon, &err);
return; return;
} }
@@ -1098,14 +1099,14 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
const char *filename = qdict_get_try_str(qdict, "snapshot-file"); const char *filename = qdict_get_try_str(qdict, "snapshot-file");
const char *format = qdict_get_try_str(qdict, "format"); const char *format = qdict_get_try_str(qdict, "format");
int reuse = qdict_get_try_bool(qdict, "reuse", 0); bool reuse = qdict_get_try_bool(qdict, "reuse", false);
enum NewImageMode mode; enum NewImageMode mode;
Error *err = NULL; Error *err = NULL;
if (!filename) { if (!filename) {
/* In the future, if 'snapshot-file' is not specified, the snapshot /* In the future, if 'snapshot-file' is not specified, the snapshot
will be taken internally. Today it's actually required. */ will be taken internally. Today it's actually required. */
error_set(&err, QERR_MISSING_PARAMETER, "snapshot-file"); error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
hmp_handle_error(mon, &err); hmp_handle_error(mon, &err);
return; return;
} }
@@ -1200,7 +1201,7 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
} }
if (i == MIGRATION_CAPABILITY_MAX) { if (i == MIGRATION_CAPABILITY_MAX) {
error_set(&err, QERR_INVALID_PARAMETER, cap); error_setg(&err, QERR_INVALID_PARAMETER, cap);
} }
qapi_free_MigrationCapabilityStatusList(caps); qapi_free_MigrationCapabilityStatusList(caps);
@@ -1244,7 +1245,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
} }
if (i == MIGRATION_PARAMETER_MAX) { if (i == MIGRATION_PARAMETER_MAX) {
error_set(&err, QERR_INVALID_PARAMETER, param); error_setg(&err, QERR_INVALID_PARAMETER, param);
} }
if (err) { if (err) {
@@ -1294,7 +1295,7 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
void hmp_eject(Monitor *mon, const QDict *qdict) void hmp_eject(Monitor *mon, const QDict *qdict)
{ {
int force = qdict_get_try_bool(qdict, "force", 0); bool force = qdict_get_try_bool(qdict, "force", false);
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
Error *err = NULL; Error *err = NULL;
@@ -1394,7 +1395,7 @@ void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
{ {
Error *error = NULL; Error *error = NULL;
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
bool force = qdict_get_try_bool(qdict, "force", 0); bool force = qdict_get_try_bool(qdict, "force", false);
qmp_block_job_cancel(device, true, force, &error); qmp_block_job_cancel(device, true, force, &error);
@@ -1474,9 +1475,9 @@ static void hmp_migrate_status_cb(void *opaque)
void hmp_migrate(Monitor *mon, const QDict *qdict) void hmp_migrate(Monitor *mon, const QDict *qdict)
{ {
int detach = qdict_get_try_bool(qdict, "detach", 0); bool detach = qdict_get_try_bool(qdict, "detach", false);
int blk = qdict_get_try_bool(qdict, "blk", 0); bool blk = qdict_get_try_bool(qdict, "blk", false);
int inc = qdict_get_try_bool(qdict, "inc", 0); bool inc = qdict_get_try_bool(qdict, "inc", false);
const char *uri = qdict_get_str(qdict, "uri"); const char *uri = qdict_get_str(qdict, "uri");
Error *err = NULL; Error *err = NULL;
@@ -1507,7 +1508,10 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
void hmp_device_add(Monitor *mon, const QDict *qdict) void hmp_device_add(Monitor *mon, const QDict *qdict)
{ {
do_device_add(mon, qdict, NULL); Error *err = NULL;
qmp_device_add((QDict *)qdict, NULL, &err);
hmp_handle_error(mon, &err);
} }
void hmp_device_del(Monitor *mon, const QDict *qdict) void hmp_device_del(Monitor *mon, const QDict *qdict)
@@ -1522,10 +1526,10 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)
void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
{ {
Error *err = NULL; Error *err = NULL;
int paging = qdict_get_try_bool(qdict, "paging", 0); bool paging = qdict_get_try_bool(qdict, "paging", false);
int zlib = qdict_get_try_bool(qdict, "zlib", 0); bool zlib = qdict_get_try_bool(qdict, "zlib", false);
int lzo = qdict_get_try_bool(qdict, "lzo", 0); bool lzo = qdict_get_try_bool(qdict, "lzo", false);
int snappy = qdict_get_try_bool(qdict, "snappy", 0); bool snappy = qdict_get_try_bool(qdict, "snappy", false);
const char *file = qdict_get_str(qdict, "filename"); const char *file = qdict_get_str(qdict, "filename");
bool has_begin = qdict_haskey(qdict, "begin"); bool has_begin = qdict_haskey(qdict, "begin");
bool has_length = qdict_haskey(qdict, "length"); bool has_length = qdict_haskey(qdict, "length");
@@ -1751,8 +1755,8 @@ void hmp_screendump(Monitor *mon, const QDict *qdict)
void hmp_nbd_server_start(Monitor *mon, const QDict *qdict) void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
{ {
const char *uri = qdict_get_str(qdict, "uri"); const char *uri = qdict_get_str(qdict, "uri");
int writable = qdict_get_try_bool(qdict, "writable", 0); bool writable = qdict_get_try_bool(qdict, "writable", false);
int all = qdict_get_try_bool(qdict, "all", 0); bool all = qdict_get_try_bool(qdict, "all", false);
Error *local_err = NULL; Error *local_err = NULL;
BlockInfoList *block_list, *info; BlockInfoList *block_list, *info;
SocketAddress *addr; SocketAddress *addr;
@@ -1805,7 +1809,7 @@ exit:
void hmp_nbd_server_add(Monitor *mon, const QDict *qdict) void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
{ {
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
int writable = qdict_get_try_bool(qdict, "writable", 0); bool writable = qdict_get_try_bool(qdict, "writable", false);
Error *local_err = NULL; Error *local_err = NULL;
qmp_nbd_server_add(device, true, writable, &local_err); qmp_nbd_server_add(device, true, writable, &local_err);
@@ -1839,7 +1843,7 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict)
Error *err = NULL; Error *err = NULL;
QemuOpts *opts; QemuOpts *opts;
opts = qemu_opts_parse(qemu_find_opts("chardev"), args, 1); opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), args, true);
if (opts == NULL) { if (opts == NULL) {
error_setg(&err, "Parsing chardev args failed"); error_setg(&err, "Parsing chardev args failed");
} else { } else {
@@ -1867,7 +1871,8 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
if (blk) { if (blk) {
qemuio_command(blk, command); qemuio_command(blk, command);
} else { } else {
error_set(&err, QERR_DEVICE_NOT_FOUND, device); error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
} }
hmp_handle_error(mon, &err); hmp_handle_error(mon, &err);
@@ -1995,7 +2000,8 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
obj = object_resolve_path(path, &ambiguous); obj = object_resolve_path(path, &ambiguous);
if (obj == NULL) { if (obj == NULL) {
error_set(&err, QERR_DEVICE_NOT_FOUND, path); error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", path);
} else { } else {
if (ambiguous) { if (ambiguous) {
monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path); monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path);

View File

@@ -13,6 +13,7 @@
#include "hw/virtio/virtio.h" #include "hw/virtio/virtio.h"
#include "hw/i386/pc.h" #include "hw/i386/pc.h"
#include "qemu/error-report.h"
#include "qemu/sockets.h" #include "qemu/sockets.h"
#include "virtio-9p.h" #include "virtio-9p.h"
#include "fsdev/qemu-fsdev.h" #include "fsdev/qemu-fsdev.h"

View File

@@ -387,7 +387,7 @@ build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
mcfg->allocation[0].end_bus_number = (memmap[VIRT_PCIE_ECAM].size mcfg->allocation[0].end_bus_number = (memmap[VIRT_PCIE_ECAM].size
/ PCIE_MMCFG_SIZE_MIN) - 1; / PCIE_MMCFG_SIZE_MIN) - 1;
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 5); build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1);
} }
/* GTDT */ /* GTDT */
@@ -413,7 +413,7 @@ build_gtdt(GArray *table_data, GArray *linker)
build_header(linker, table_data, build_header(linker, table_data,
(void *)(table_data->data + gtdt_start), "GTDT", (void *)(table_data->data + gtdt_start), "GTDT",
table_data->len - gtdt_start, 5); table_data->len - gtdt_start, 2);
} }
/* MADT */ /* MADT */
@@ -423,8 +423,10 @@ build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info,
{ {
int madt_start = table_data->len; int madt_start = table_data->len;
const MemMapEntry *memmap = guest_info->memmap; const MemMapEntry *memmap = guest_info->memmap;
const int *irqmap = guest_info->irqmap;
AcpiMultipleApicTable *madt; AcpiMultipleApicTable *madt;
AcpiMadtGenericDistributor *gicd; AcpiMadtGenericDistributor *gicd;
AcpiMadtGenericMsiFrame *gic_msi;
int i; int i;
madt = acpi_data_push(table_data, sizeof *madt); madt = acpi_data_push(table_data, sizeof *madt);
@@ -448,9 +450,18 @@ build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info,
gicd->length = sizeof(*gicd); gicd->length = sizeof(*gicd);
gicd->base_address = memmap[VIRT_GIC_DIST].base; gicd->base_address = memmap[VIRT_GIC_DIST].base;
gic_msi = acpi_data_push(table_data, sizeof *gic_msi);
gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;
gic_msi->length = sizeof(*gic_msi);
gic_msi->gic_msi_frame_id = 0;
gic_msi->base_address = cpu_to_le64(memmap[VIRT_GIC_V2M].base);
gic_msi->flags = cpu_to_le32(1);
gic_msi->spi_count = cpu_to_le16(NUM_GICV2M_SPIS);
gic_msi->spi_base = cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_BASE);
build_header(linker, table_data, build_header(linker, table_data,
(void *)(table_data->data + madt_start), "APIC", (void *)(table_data->data + madt_start), "APIC",
table_data->len - madt_start, 5); table_data->len - madt_start, 3);
} }
/* FADT */ /* FADT */
@@ -507,7 +518,7 @@ build_dsdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
build_header(linker, table_data, build_header(linker, table_data,
(void *)(table_data->data + table_data->len - dsdt->buf->len), (void *)(table_data->data + table_data->len - dsdt->buf->len),
"DSDT", dsdt->buf->len, 5); "DSDT", dsdt->buf->len, 2);
free_aml_allocator(); free_aml_allocator();
} }
@@ -545,6 +556,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
* FADT * FADT
* GTDT * GTDT
* MADT * MADT
* MCFG
* DSDT * DSDT
*/ */
@@ -552,7 +564,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
dsdt = tables_blob->len; dsdt = tables_blob->len;
build_dsdt(tables_blob, tables->linker, guest_info); build_dsdt(tables_blob, tables->linker, guest_info);
/* FADT MADT GTDT SPCR pointed to by RSDT */ /* FADT MADT GTDT MCFG SPCR pointed to by RSDT */
acpi_add_table(table_offsets, tables_blob); acpi_add_table(table_offsets, tables_blob);
build_fadt(tables_blob, tables->linker, dsdt); build_fadt(tables_blob, tables->linker, dsdt);

View File

@@ -956,6 +956,8 @@ static void virt_class_init(ObjectClass *oc, void *data)
mc->init = machvirt_init; mc->init = machvirt_init;
mc->max_cpus = 8; mc->max_cpus = 8;
mc->has_dynamic_sysbus = true; mc->has_dynamic_sysbus = true;
mc->block_default_type = IF_VIRTIO;
mc->no_cdrom = 1;
} }
static const TypeInfo machvirt_info = { static const TypeInfo machvirt_info = {

View File

@@ -154,6 +154,7 @@ static uint16_t nvme_dma_read_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len,
qemu_sglist_destroy(&qsg); qemu_sglist_destroy(&qsg);
return NVME_INVALID_FIELD | NVME_DNR; return NVME_INVALID_FIELD | NVME_DNR;
} }
qemu_sglist_destroy(&qsg);
return NVME_SUCCESS; return NVME_SUCCESS;
} }

View File

@@ -499,8 +499,7 @@ void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
iov_discard_front(&iov, &out_num, sizeof(req->out)); iov_discard_front(&iov, &out_num, sizeof(req->out));
if (in_num < 1 || if (in_iov[in_num - 1].iov_len < sizeof(struct virtio_blk_inhdr)) {
in_iov[in_num - 1].iov_len < sizeof(struct virtio_blk_inhdr)) {
error_report("virtio-blk request inhdr too short"); error_report("virtio-blk request inhdr too short");
exit(1); exit(1);
} }
@@ -651,16 +650,21 @@ static void virtio_blk_dma_restart_cb(void *opaque, int running,
static void virtio_blk_reset(VirtIODevice *vdev) static void virtio_blk_reset(VirtIODevice *vdev)
{ {
VirtIOBlock *s = VIRTIO_BLK(vdev); VirtIOBlock *s = VIRTIO_BLK(vdev);
AioContext *ctx;
if (s->dataplane) {
virtio_blk_data_plane_stop(s->dataplane);
}
/* /*
* This should cancel pending requests, but can't do nicely until there * This should cancel pending requests, but can't do nicely until there
* are per-device request lists. * are per-device request lists.
*/ */
blk_drain_all(); ctx = blk_get_aio_context(s->blk);
aio_context_acquire(ctx);
blk_drain(s->blk);
if (s->dataplane) {
virtio_blk_data_plane_stop(s->dataplane);
}
aio_context_release(ctx);
blk_set_enable_write_cache(s->blk, s->original_wce); blk_set_enable_write_cache(s->blk, s->original_wce);
} }

View File

@@ -27,7 +27,6 @@
#include "hw/char/serial.h" #include "hw/char/serial.h"
#include "hw/pci/pci.h" #include "hw/pci/pci.h"
#include "qapi/qmp/qerror.h"
#define PCI_SERIAL_MAX_PORTS 4 #define PCI_SERIAL_MAX_PORTS 4

View File

@@ -20,6 +20,7 @@
#include "qemu/iov.h" #include "qemu/iov.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "qemu/error-report.h"
#include "qemu/queue.h" #include "qemu/queue.h"
#include "hw/sysbus.h" #include "hw/sysbus.h"
#include "trace.h" #include "trace.h"

View File

@@ -67,7 +67,7 @@ void nmi_monitor_handle(int cpu_index, Error **errp)
if (ns.handled) { if (ns.handled) {
error_propagate(errp, ns.errp); error_propagate(errp, ns.errp);
} else { } else {
error_set(errp, QERR_UNSUPPORTED); error_setg(errp, QERR_UNSUPPORTED);
} }
} }

View File

@@ -20,7 +20,6 @@
*/ */
#include "hw/platform-bus.h" #include "hw/platform-bus.h"
#include "monitor/monitor.h"
#include "exec/address-spaces.h" #include "exec/address-spaces.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"

View File

@@ -35,15 +35,15 @@ static void get_pointer(Object *obj, Visitor *v, Property *prop,
} }
static void set_pointer(Object *obj, Visitor *v, Property *prop, static void set_pointer(Object *obj, Visitor *v, Property *prop,
int (*parse)(DeviceState *dev, const char *str, void (*parse)(DeviceState *dev, const char *str,
void **ptr), void **ptr, const char *propname,
Error **errp),
const char *name, Error **errp) const char *name, Error **errp)
{ {
DeviceState *dev = DEVICE(obj); DeviceState *dev = DEVICE(obj);
Error *local_err = NULL; Error *local_err = NULL;
void **ptr = qdev_get_prop_ptr(dev, prop); void **ptr = qdev_get_prop_ptr(dev, prop);
char *str; char *str;
int ret;
if (dev->realized) { if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp); qdev_prop_set_after_realize(dev, name, errp);
@@ -60,26 +60,38 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,
*ptr = NULL; *ptr = NULL;
return; return;
} }
ret = parse(dev, str, ptr); parse(dev, str, ptr, prop->name, errp);
error_set_from_qdev_prop_error(errp, ret, dev, prop, str);
g_free(str); g_free(str);
} }
/* --- drive --- */ /* --- drive --- */
static int parse_drive(DeviceState *dev, const char *str, void **ptr) static void parse_drive(DeviceState *dev, const char *str, void **ptr,
const char *propname, Error **errp)
{ {
BlockBackend *blk; BlockBackend *blk;
blk = blk_by_name(str); blk = blk_by_name(str);
if (!blk) { if (!blk) {
return -ENOENT; error_setg(errp, "Property '%s.%s' can't find value '%s'",
object_get_typename(OBJECT(dev)), propname, str);
return;
} }
if (blk_attach_dev(blk, dev) < 0) { if (blk_attach_dev(blk, dev) < 0) {
return -EEXIST; DriveInfo *dinfo = blk_legacy_dinfo(blk);
if (dinfo->type != IF_NONE) {
error_setg(errp, "Drive '%s' is already in use because "
"it has been automatically connected to another "
"device (did you need 'if=none' in the drive options?)",
str);
} else {
error_setg(errp, "Drive '%s' is already in use by another device",
str);
}
return;
} }
*ptr = blk; *ptr = blk;
return 0;
} }
static void release_drive(Object *obj, const char *name, void *opaque) static void release_drive(Object *obj, const char *name, void *opaque)
@@ -121,17 +133,21 @@ PropertyInfo qdev_prop_drive = {
/* --- character device --- */ /* --- character device --- */
static int parse_chr(DeviceState *dev, const char *str, void **ptr) static void parse_chr(DeviceState *dev, const char *str, void **ptr,
const char *propname, Error **errp)
{ {
CharDriverState *chr = qemu_chr_find(str); CharDriverState *chr = qemu_chr_find(str);
if (chr == NULL) { if (chr == NULL) {
return -ENOENT; error_setg(errp, "Property '%s.%s' can't find value '%s'",
object_get_typename(OBJECT(dev)), propname, str);
return;
} }
if (qemu_chr_fe_claim(chr) != 0) { if (qemu_chr_fe_claim(chr) != 0) {
return -EEXIST; error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use",
object_get_typename(OBJECT(dev)), propname, str);
return;
} }
*ptr = chr; *ptr = chr;
return 0;
} }
static void release_chr(Object *obj, const char *name, void *opaque) static void release_chr(Object *obj, const char *name, void *opaque)
@@ -326,8 +342,8 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,
hubport = net_hub_port_find(id); hubport = net_hub_port_find(id);
if (!hubport) { if (!hubport) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name, prop->info->name); name, prop->info->name);
return; return;
} }
*ptr = hubport; *ptr = hubport;

View File

@@ -1,6 +1,7 @@
#include "net/net.h" #include "net/net.h"
#include "hw/qdev.h" #include "hw/qdev.h"
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "qemu/error-report.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "hw/block/block.h" #include "hw/block/block.h"
#include "net/hub.h" #include "net/hub.h"
@@ -570,8 +571,8 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
if (local_err) { if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
} else if (value < -1 || value > 255) { } else if (value < -1 || value > 255) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"pci_devfn"); name ? name : "null", "pci_devfn");
} else { } else {
*ptr = value; *ptr = value;
} }
@@ -640,8 +641,8 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,
} }
/* value of 0 means "unset" */ /* value of 0 means "unset" */
if (value && (value < min || value > max)) { if (value && (value < min || value > max)) {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
dev->id?:"", name, (int64_t)value, min, max); dev->id ? : "", name, (int64_t)value, min, max);
return; return;
} }
@@ -923,8 +924,8 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
break; break;
default: default:
case -EINVAL: case -EINVAL:
error_set(errp, QERR_PROPERTY_VALUE_BAD, error_setg(errp, QERR_PROPERTY_VALUE_BAD,
object_get_typename(OBJECT(dev)), prop->name, value); object_get_typename(OBJECT(dev)), prop->name, value);
break; break;
case -ENOENT: case -ENOENT:
error_setg(errp, "Property '%s.%s' can't find value '%s'", error_setg(errp, "Property '%s.%s' can't find value '%s'",

View File

@@ -32,6 +32,7 @@
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "qapi/visitor.h" #include "qapi/visitor.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "qemu/error-report.h"
#include "hw/hotplug.h" #include "hw/hotplug.h"
#include "hw/boards.h" #include "hw/boards.h"
#include "qapi-event.h" #include "qapi-event.h"
@@ -276,13 +277,13 @@ void qdev_unplug(DeviceState *dev, Error **errp)
HotplugHandlerClass *hdc; HotplugHandlerClass *hdc;
if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) { if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) {
error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name); error_setg(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
return; return;
} }
if (!dc->hotpluggable) { if (!dc->hotpluggable) {
error_set(errp, QERR_DEVICE_NO_HOTPLUG, error_setg(errp, QERR_DEVICE_NO_HOTPLUG,
object_get_typename(OBJECT(dev))); object_get_typename(OBJECT(dev)));
return; return;
} }
@@ -1026,7 +1027,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
Error *local_err = NULL; Error *local_err = NULL;
if (dev->hotplugged && !dc->hotpluggable) { if (dev->hotplugged && !dc->hotpluggable) {
error_set(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj)); error_setg(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
return; return;
} }

View File

@@ -303,6 +303,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
if (fcode_filename) { if (fcode_filename) {
ret = load_image_targphys(fcode_filename, s->prom_addr, ret = load_image_targphys(fcode_filename, s->prom_addr,
FCODE_MAX_ROM_SIZE); FCODE_MAX_ROM_SIZE);
g_free(fcode_filename);
if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) { if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) {
error_report("cg3: could not load prom '%s'", CG3_ROM_FILE); error_report("cg3: could not load prom '%s'", CG3_ROM_FILE);
} }

View File

@@ -18,6 +18,7 @@
*/ */
#include "hw/hw.h" #include "hw/hw.h"
#include "qemu/error-report.h"
#include "ui/console.h" #include "ui/console.h"
#include "ui/pixel_ops.h" #include "ui/pixel_ops.h"
#include "trace.h" #include "trace.h"

View File

@@ -22,7 +22,7 @@
#include "qemu/timer.h" #include "qemu/timer.h"
#include "qxl.h" #include "qxl.h"
static const char *qxl_type[] = { static const char *const qxl_type[] = {
[ QXL_CMD_NOP ] = "nop", [ QXL_CMD_NOP ] = "nop",
[ QXL_CMD_DRAW ] = "draw", [ QXL_CMD_DRAW ] = "draw",
[ QXL_CMD_UPDATE ] = "update", [ QXL_CMD_UPDATE ] = "update",
@@ -31,7 +31,7 @@ static const char *qxl_type[] = {
[ QXL_CMD_SURFACE ] = "surface", [ QXL_CMD_SURFACE ] = "surface",
}; };
static const char *qxl_draw_type[] = { static const char *const qxl_draw_type[] = {
[ QXL_DRAW_NOP ] = "nop", [ QXL_DRAW_NOP ] = "nop",
[ QXL_DRAW_FILL ] = "fill", [ QXL_DRAW_FILL ] = "fill",
[ QXL_DRAW_OPAQUE ] = "opaque", [ QXL_DRAW_OPAQUE ] = "opaque",
@@ -48,7 +48,7 @@ static const char *qxl_draw_type[] = {
[ QXL_DRAW_ALPHA_BLEND ] = "alpha-blend", [ QXL_DRAW_ALPHA_BLEND ] = "alpha-blend",
}; };
static const char *qxl_draw_effect[] = { static const char *const qxl_draw_effect[] = {
[ QXL_EFFECT_BLEND ] = "blend", [ QXL_EFFECT_BLEND ] = "blend",
[ QXL_EFFECT_OPAQUE ] = "opaque", [ QXL_EFFECT_OPAQUE ] = "opaque",
[ QXL_EFFECT_REVERT_ON_DUP ] = "revert-on-dup", [ QXL_EFFECT_REVERT_ON_DUP ] = "revert-on-dup",
@@ -59,12 +59,12 @@ static const char *qxl_draw_effect[] = {
[ QXL_EFFECT_OPAQUE_BRUSH ] = "opaque-brush", [ QXL_EFFECT_OPAQUE_BRUSH ] = "opaque-brush",
}; };
static const char *qxl_surface_cmd[] = { static const char *const qxl_surface_cmd[] = {
[ QXL_SURFACE_CMD_CREATE ] = "create", [ QXL_SURFACE_CMD_CREATE ] = "create",
[ QXL_SURFACE_CMD_DESTROY ] = "destroy", [ QXL_SURFACE_CMD_DESTROY ] = "destroy",
}; };
static const char *spice_surface_fmt[] = { static const char *const spice_surface_fmt[] = {
[ SPICE_SURFACE_FMT_INVALID ] = "invalid", [ SPICE_SURFACE_FMT_INVALID ] = "invalid",
[ SPICE_SURFACE_FMT_1_A ] = "alpha/1", [ SPICE_SURFACE_FMT_1_A ] = "alpha/1",
[ SPICE_SURFACE_FMT_8_A ] = "alpha/8", [ SPICE_SURFACE_FMT_8_A ] = "alpha/8",
@@ -74,14 +74,14 @@ static const char *spice_surface_fmt[] = {
[ SPICE_SURFACE_FMT_32_ARGB ] = "ARGB/32", [ SPICE_SURFACE_FMT_32_ARGB ] = "ARGB/32",
}; };
static const char *qxl_cursor_cmd[] = { static const char *const qxl_cursor_cmd[] = {
[ QXL_CURSOR_SET ] = "set", [ QXL_CURSOR_SET ] = "set",
[ QXL_CURSOR_MOVE ] = "move", [ QXL_CURSOR_MOVE ] = "move",
[ QXL_CURSOR_HIDE ] = "hide", [ QXL_CURSOR_HIDE ] = "hide",
[ QXL_CURSOR_TRAIL ] = "trail", [ QXL_CURSOR_TRAIL ] = "trail",
}; };
static const char *spice_cursor_type[] = { static const char *const spice_cursor_type[] = {
[ SPICE_CURSOR_TYPE_ALPHA ] = "alpha", [ SPICE_CURSOR_TYPE_ALPHA ] = "alpha",
[ SPICE_CURSOR_TYPE_MONO ] = "mono", [ SPICE_CURSOR_TYPE_MONO ] = "mono",
[ SPICE_CURSOR_TYPE_COLOR4 ] = "color4", [ SPICE_CURSOR_TYPE_COLOR4 ] = "color4",
@@ -91,7 +91,7 @@ static const char *spice_cursor_type[] = {
[ SPICE_CURSOR_TYPE_COLOR32 ] = "color32", [ SPICE_CURSOR_TYPE_COLOR32 ] = "color32",
}; };
static const char *qxl_v2n(const char *n[], size_t l, int v) static const char *qxl_v2n(const char *const n[], size_t l, int v)
{ {
if (v >= l || !n[v]) { if (v >= l || !n[v]) {
return "???"; return "???";

View File

@@ -25,7 +25,6 @@
#include "qemu/timer.h" #include "qemu/timer.h"
#include "qemu/queue.h" #include "qemu/queue.h"
#include "qemu/atomic.h" #include "qemu/atomic.h"
#include "monitor/monitor.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "trace.h" #include "trace.h"

View File

@@ -27,6 +27,7 @@
#include "ui/pixel_ops.h" #include "ui/pixel_ops.h"
#include "hw/loader.h" #include "hw/loader.h"
#include "hw/sysbus.h" #include "hw/sysbus.h"
#include "qemu/error-report.h"
#define TCX_ROM_FILE "QEMU,tcx.bin" #define TCX_ROM_FILE "QEMU,tcx.bin"
#define FCODE_MAX_ROM_SIZE 0x10000 #define FCODE_MAX_ROM_SIZE 0x10000
@@ -1017,6 +1018,7 @@ static void tcx_realizefn(DeviceState *dev, Error **errp)
if (fcode_filename) { if (fcode_filename) {
ret = load_image_targphys(fcode_filename, s->prom_addr, ret = load_image_targphys(fcode_filename, s->prom_addr,
FCODE_MAX_ROM_SIZE); FCODE_MAX_ROM_SIZE);
g_free(fcode_filename);
if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) { if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) {
error_report("tcx: could not load prom '%s'", TCX_ROM_FILE); error_report("tcx: could not load prom '%s'", TCX_ROM_FILE);
} }

View File

@@ -26,7 +26,6 @@
#include "qemu/timer.h" #include "qemu/timer.h"
#include "hw/ptimer.h" #include "hw/ptimer.h"
#include "qemu/log.h" #include "qemu/log.h"
#include "qapi/qmp/qerror.h"
#include "qemu/main-loop.h" #include "qemu/main-loop.h"
#include "hw/stream.h" #include "hw/stream.h"

View File

@@ -141,6 +141,9 @@ typedef struct AssignedDevice {
int32_t bootindex; int32_t bootindex;
} AssignedDevice; } AssignedDevice;
#define TYPE_PCI_ASSIGN "kvm-pci-assign"
#define PCI_ASSIGN(obj) OBJECT_CHECK(AssignedDevice, (obj), TYPE_PCI_ASSIGN)
static void assigned_dev_update_irq_routing(PCIDevice *dev); static void assigned_dev_update_irq_routing(PCIDevice *dev);
static void assigned_dev_load_option_rom(AssignedDevice *dev); static void assigned_dev_load_option_rom(AssignedDevice *dev);
@@ -257,7 +260,7 @@ static const MemoryRegionOps slow_bar_ops = {
static void assigned_dev_iomem_setup(PCIDevice *pci_dev, int region_num, static void assigned_dev_iomem_setup(PCIDevice *pci_dev, int region_num,
pcibus_t e_size) pcibus_t e_size)
{ {
AssignedDevice *r_dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *r_dev = PCI_ASSIGN(pci_dev);
AssignedDevRegion *region = &r_dev->v_addrs[region_num]; AssignedDevRegion *region = &r_dev->v_addrs[region_num];
PCIRegion *real_region = &r_dev->real_device.regions[region_num]; PCIRegion *real_region = &r_dev->real_device.regions[region_num];
@@ -289,7 +292,7 @@ static const MemoryRegionOps assigned_dev_ioport_ops = {
static void assigned_dev_ioport_setup(PCIDevice *pci_dev, int region_num, static void assigned_dev_ioport_setup(PCIDevice *pci_dev, int region_num,
pcibus_t size) pcibus_t size)
{ {
AssignedDevice *r_dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *r_dev = PCI_ASSIGN(pci_dev);
AssignedDevRegion *region = &r_dev->v_addrs[region_num]; AssignedDevRegion *region = &r_dev->v_addrs[region_num];
region->e_size = size; region->e_size = size;
@@ -303,7 +306,7 @@ static void assigned_dev_ioport_setup(PCIDevice *pci_dev, int region_num,
static uint32_t assigned_dev_pci_read(PCIDevice *d, int pos, int len) static uint32_t assigned_dev_pci_read(PCIDevice *d, int pos, int len)
{ {
AssignedDevice *pci_dev = DO_UPCAST(AssignedDevice, dev, d); AssignedDevice *pci_dev = PCI_ASSIGN(d);
uint32_t val; uint32_t val;
ssize_t ret; ssize_t ret;
int fd = pci_dev->real_device.config_fd; int fd = pci_dev->real_device.config_fd;
@@ -328,7 +331,7 @@ static uint8_t assigned_dev_pci_read_byte(PCIDevice *d, int pos)
static void assigned_dev_pci_write(PCIDevice *d, int pos, uint32_t val, int len) static void assigned_dev_pci_write(PCIDevice *d, int pos, uint32_t val, int len)
{ {
AssignedDevice *pci_dev = DO_UPCAST(AssignedDevice, dev, d); AssignedDevice *pci_dev = PCI_ASSIGN(d);
ssize_t ret; ssize_t ret;
int fd = pci_dev->real_device.config_fd; int fd = pci_dev->real_device.config_fd;
@@ -946,7 +949,7 @@ static void deassign_device(AssignedDevice *dev)
*/ */
static void assigned_dev_update_irq_routing(PCIDevice *dev) static void assigned_dev_update_irq_routing(PCIDevice *dev)
{ {
AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, dev); AssignedDevice *assigned_dev = PCI_ASSIGN(dev);
Error *err = NULL; Error *err = NULL;
int r; int r;
@@ -961,7 +964,7 @@ static void assigned_dev_update_irq_routing(PCIDevice *dev)
static void assigned_dev_update_msi(PCIDevice *pci_dev) static void assigned_dev_update_msi(PCIDevice *pci_dev)
{ {
AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint8_t ctrl_byte = pci_get_byte(pci_dev->config + pci_dev->msi_cap + uint8_t ctrl_byte = pci_get_byte(pci_dev->config + pci_dev->msi_cap +
PCI_MSI_FLAGS); PCI_MSI_FLAGS);
int r; int r;
@@ -1015,7 +1018,7 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev)
static void assigned_dev_update_msi_msg(PCIDevice *pci_dev) static void assigned_dev_update_msi_msg(PCIDevice *pci_dev)
{ {
AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint8_t ctrl_byte = pci_get_byte(pci_dev->config + pci_dev->msi_cap + uint8_t ctrl_byte = pci_get_byte(pci_dev->config + pci_dev->msi_cap +
PCI_MSI_FLAGS); PCI_MSI_FLAGS);
@@ -1048,7 +1051,7 @@ static bool assigned_dev_msix_skipped(MSIXTableEntry *entry)
static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev) static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
{ {
AssignedDevice *adev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *adev = PCI_ASSIGN(pci_dev);
uint16_t entries_nr = 0; uint16_t entries_nr = 0;
int i, r = 0; int i, r = 0;
MSIXTableEntry *entry = adev->msix_table; MSIXTableEntry *entry = adev->msix_table;
@@ -1113,7 +1116,7 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
static void assigned_dev_update_msix(PCIDevice *pci_dev) static void assigned_dev_update_msix(PCIDevice *pci_dev)
{ {
AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint16_t ctrl_word = pci_get_word(pci_dev->config + pci_dev->msix_cap + uint16_t ctrl_word = pci_get_word(pci_dev->config + pci_dev->msix_cap +
PCI_MSIX_FLAGS); PCI_MSIX_FLAGS);
int r; int r;
@@ -1163,7 +1166,7 @@ static void assigned_dev_update_msix(PCIDevice *pci_dev)
static uint32_t assigned_dev_pci_read_config(PCIDevice *pci_dev, static uint32_t assigned_dev_pci_read_config(PCIDevice *pci_dev,
uint32_t address, int len) uint32_t address, int len)
{ {
AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint32_t virt_val = pci_default_read_config(pci_dev, address, len); uint32_t virt_val = pci_default_read_config(pci_dev, address, len);
uint32_t real_val, emulate_mask, full_emulation_mask; uint32_t real_val, emulate_mask, full_emulation_mask;
@@ -1184,7 +1187,7 @@ static uint32_t assigned_dev_pci_read_config(PCIDevice *pci_dev,
static void assigned_dev_pci_write_config(PCIDevice *pci_dev, uint32_t address, static void assigned_dev_pci_write_config(PCIDevice *pci_dev, uint32_t address,
uint32_t val, int len) uint32_t val, int len)
{ {
AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint16_t old_cmd = pci_get_word(pci_dev->config + PCI_COMMAND); uint16_t old_cmd = pci_get_word(pci_dev->config + PCI_COMMAND);
uint32_t emulate_mask, full_emulation_mask; uint32_t emulate_mask, full_emulation_mask;
int ret; int ret;
@@ -1244,7 +1247,7 @@ static void assigned_dev_setup_cap_read(AssignedDevice *dev, uint32_t offset,
static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp) static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
{ {
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *dev = PCI_ASSIGN(pci_dev);
PCIRegion *pci_region = dev->real_device.regions; PCIRegion *pci_region = dev->real_device.regions;
int ret, pos; int ret, pos;
Error *local_err = NULL; Error *local_err = NULL;
@@ -1684,8 +1687,8 @@ static const VMStateDescription vmstate_assigned_device = {
static void reset_assigned_device(DeviceState *dev) static void reset_assigned_device(DeviceState *dev)
{ {
PCIDevice *pci_dev = DO_UPCAST(PCIDevice, qdev, dev); PCIDevice *pci_dev = PCI_DEVICE(dev);
AssignedDevice *adev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *adev = PCI_ASSIGN(pci_dev);
char reset_file[64]; char reset_file[64];
const char reset[] = "1"; const char reset[] = "1";
int fd, ret; int fd, ret;
@@ -1740,7 +1743,7 @@ static void reset_assigned_device(DeviceState *dev)
static void assigned_realize(struct PCIDevice *pci_dev, Error **errp) static void assigned_realize(struct PCIDevice *pci_dev, Error **errp)
{ {
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *dev = PCI_ASSIGN(pci_dev);
uint8_t e_intx; uint8_t e_intx;
int r; int r;
Error *local_err = NULL; Error *local_err = NULL;
@@ -1836,7 +1839,7 @@ exit_with_error:
static void assigned_exitfn(struct PCIDevice *pci_dev) static void assigned_exitfn(struct PCIDevice *pci_dev)
{ {
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *dev = PCI_ASSIGN(pci_dev);
deassign_device(dev); deassign_device(dev);
free_assigned_device(dev); free_assigned_device(dev);
@@ -1845,7 +1848,7 @@ static void assigned_exitfn(struct PCIDevice *pci_dev)
static void assigned_dev_instance_init(Object *obj) static void assigned_dev_instance_init(Object *obj)
{ {
PCIDevice *pci_dev = PCI_DEVICE(obj); PCIDevice *pci_dev = PCI_DEVICE(obj);
AssignedDevice *d = DO_UPCAST(AssignedDevice, dev, PCI_DEVICE(obj)); AssignedDevice *d = PCI_ASSIGN(pci_dev);
device_add_bootindex_property(obj, &d->bootindex, device_add_bootindex_property(obj, &d->bootindex,
"bootindex", NULL, "bootindex", NULL,
@@ -1879,7 +1882,7 @@ static void assign_class_init(ObjectClass *klass, void *data)
} }
static const TypeInfo assign_info = { static const TypeInfo assign_info = {
.name = "kvm-pci-assign", .name = TYPE_PCI_ASSIGN,
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(AssignedDevice), .instance_size = sizeof(AssignedDevice),
.class_init = assign_class_init, .class_init = assign_class_init,

View File

@@ -31,7 +31,6 @@
#include "hw/ide.h" #include "hw/ide.h"
#include "hw/pci/pci.h" #include "hw/pci/pci.h"
#include "hw/pci/pci_bus.h" #include "hw/pci/pci_bus.h"
#include "monitor/monitor.h"
#include "hw/nvram/fw_cfg.h" #include "hw/nvram/fw_cfg.h"
#include "hw/timer/hpet.h" #include "hw/timer/hpet.h"
#include "hw/i386/smbios.h" #include "hw/i386/smbios.h"
@@ -57,6 +56,7 @@
#include "sysemu/arch_init.h" #include "sysemu/arch_init.h"
#include "qemu/bitmap.h" #include "qemu/bitmap.h"
#include "qemu/config-file.h" #include "qemu/config-file.h"
#include "qemu/error-report.h"
#include "hw/acpi/acpi.h" #include "hw/acpi/acpi.h"
#include "hw/acpi/cpu_hotplug.h" #include "hw/acpi/cpu_hotplug.h"
#include "hw/cpu/icc_bus.h" #include "hw/cpu/icc_bus.h"

View File

@@ -27,7 +27,7 @@
#include <hw/pci/pci.h> #include <hw/pci/pci.h>
#include <hw/sysbus.h> #include <hw/sysbus.h>
#include "monitor/monitor.h" #include "qemu/error-report.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "sysemu/dma.h" #include "sysemu/dma.h"
#include "internal.h" #include "internal.h"

View File

@@ -11,6 +11,7 @@ common-obj-$(CONFIG_VMMOUSE) += vmmouse.o
ifeq ($(CONFIG_LINUX),y) ifeq ($(CONFIG_LINUX),y)
common-obj-$(CONFIG_VIRTIO) += virtio-input.o common-obj-$(CONFIG_VIRTIO) += virtio-input.o
common-obj-$(CONFIG_VIRTIO) += virtio-input-hid.o common-obj-$(CONFIG_VIRTIO) += virtio-input-hid.o
common-obj-$(CONFIG_VIRTIO) += virtio-input-host.o
endif endif
obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o

View File

@@ -252,7 +252,11 @@ static void virtio_input_handle_sync(DeviceState *dev)
static void virtio_input_hid_realize(DeviceState *dev, Error **errp) static void virtio_input_hid_realize(DeviceState *dev, Error **errp)
{ {
VirtIOInputHID *vhid = VIRTIO_INPUT_HID(dev); VirtIOInputHID *vhid = VIRTIO_INPUT_HID(dev);
vhid->hs = qemu_input_handler_register(dev, vhid->handler); vhid->hs = qemu_input_handler_register(dev, vhid->handler);
if (vhid->display && vhid->hs) {
qemu_input_handler_bind(vhid->hs, vhid->display, vhid->head, NULL);
}
} }
static void virtio_input_hid_unrealize(DeviceState *dev, Error **errp) static void virtio_input_hid_unrealize(DeviceState *dev, Error **errp)
@@ -301,10 +305,17 @@ static void virtio_input_hid_handle_status(VirtIOInput *vinput,
} }
} }
static Property virtio_input_hid_properties[] = {
DEFINE_PROP_STRING("display", VirtIOInputHID, display),
DEFINE_PROP_UINT32("head", VirtIOInputHID, head, 0),
};
static void virtio_input_hid_class_init(ObjectClass *klass, void *data) static void virtio_input_hid_class_init(ObjectClass *klass, void *data)
{ {
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOInputClass *vic = VIRTIO_INPUT_CLASS(klass); VirtIOInputClass *vic = VIRTIO_INPUT_CLASS(klass);
dc->props = virtio_input_hid_properties;
vic->realize = virtio_input_hid_realize; vic->realize = virtio_input_hid_realize;
vic->unrealize = virtio_input_hid_unrealize; vic->unrealize = virtio_input_hid_unrealize;
vic->change_active = virtio_input_hid_change_active; vic->change_active = virtio_input_hid_change_active;

View File

@@ -0,0 +1,188 @@
/*
* This work is licensed under the terms of the GNU GPL, version 2 or
* (at your option) any later version. See the COPYING file in the
* top-level directory.
*/
#include "qemu-common.h"
#include "qemu/sockets.h"
#include "hw/qdev.h"
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-input.h"
#include "standard-headers/linux/input.h"
/* ----------------------------------------------------------------- */
static struct virtio_input_config virtio_input_host_config[] = {
{ /* empty list */ },
};
static void virtio_input_host_event(void *opaque)
{
VirtIOInputHost *vih = opaque;
VirtIOInput *vinput = VIRTIO_INPUT(vih);
struct virtio_input_event virtio;
struct input_event evdev;
int rc;
for (;;) {
rc = read(vih->fd, &evdev, sizeof(evdev));
if (rc != sizeof(evdev)) {
break;
}
virtio.type = cpu_to_le16(evdev.type);
virtio.code = cpu_to_le16(evdev.code);
virtio.value = cpu_to_le32(evdev.value);
virtio_input_send(vinput, &virtio);
}
}
static void virtio_input_bits_config(VirtIOInputHost *vih,
int type, int count)
{
virtio_input_config bits;
int rc, i, size = 0;
memset(&bits, 0, sizeof(bits));
rc = ioctl(vih->fd, EVIOCGBIT(type, count/8), bits.u.bitmap);
if (rc < 0) {
return;
}
for (i = 0; i < count/8; i++) {
if (bits.u.bitmap[i]) {
size = i+1;
}
}
if (size == 0) {
return;
}
bits.select = VIRTIO_INPUT_CFG_EV_BITS;
bits.subsel = type;
bits.size = size;
virtio_input_add_config(VIRTIO_INPUT(vih), &bits);
}
static void virtio_input_host_realize(DeviceState *dev, Error **errp)
{
VirtIOInputHost *vih = VIRTIO_INPUT_HOST(dev);
VirtIOInput *vinput = VIRTIO_INPUT(dev);
virtio_input_config id;
struct input_id ids;
int rc, ver;
if (!vih->evdev) {
error_setg(errp, "evdev property is required");
return;
}
vih->fd = open(vih->evdev, O_RDWR);
if (vih->fd < 0) {
error_setg_file_open(errp, errno, vih->evdev);
return;
}
qemu_set_nonblock(vih->fd);
rc = ioctl(vih->fd, EVIOCGVERSION, &ver);
if (rc < 0) {
error_setg(errp, "%s: is not an evdev device", vih->evdev);
goto err_close;
}
rc = ioctl(vih->fd, EVIOCGRAB, 1);
if (rc < 0) {
error_setg_errno(errp, errno, "%s: failed to get exclusive access",
vih->evdev);
goto err_close;
}
memset(&id, 0, sizeof(id));
ioctl(vih->fd, EVIOCGNAME(sizeof(id.u.string)-1), id.u.string);
id.select = VIRTIO_INPUT_CFG_ID_NAME;
id.size = strlen(id.u.string);
virtio_input_add_config(vinput, &id);
if (ioctl(vih->fd, EVIOCGID, &ids) == 0) {
memset(&id, 0, sizeof(id));
id.select = VIRTIO_INPUT_CFG_ID_DEVIDS;
id.size = sizeof(struct virtio_input_devids);
id.u.ids.bustype = cpu_to_le16(ids.bustype);
id.u.ids.vendor = cpu_to_le16(ids.vendor);
id.u.ids.product = cpu_to_le16(ids.product);
id.u.ids.version = cpu_to_le16(ids.version);
virtio_input_add_config(vinput, &id);
}
virtio_input_bits_config(vih, EV_KEY, KEY_CNT);
virtio_input_bits_config(vih, EV_REL, REL_CNT);
virtio_input_bits_config(vih, EV_ABS, ABS_CNT);
virtio_input_bits_config(vih, EV_MSC, MSC_CNT);
virtio_input_bits_config(vih, EV_SW, SW_CNT);
qemu_set_fd_handler(vih->fd, virtio_input_host_event, NULL, vih);
return;
err_close:
close(vih->fd);
vih->fd = -1;
return;
}
static void virtio_input_host_unrealize(DeviceState *dev, Error **errp)
{
VirtIOInputHost *vih = VIRTIO_INPUT_HOST(dev);
if (vih->fd > 0) {
qemu_set_fd_handler(vih->fd, NULL, NULL, NULL);
close(vih->fd);
}
}
static const VMStateDescription vmstate_virtio_input_host = {
.name = "virtio-input-host",
.unmigratable = 1,
};
static Property virtio_input_host_properties[] = {
DEFINE_PROP_STRING("evdev", VirtIOInputHost, evdev),
DEFINE_PROP_END_OF_LIST(),
};
static void virtio_input_host_class_init(ObjectClass *klass, void *data)
{
VirtIOInputClass *vic = VIRTIO_INPUT_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &vmstate_virtio_input_host;
dc->props = virtio_input_host_properties;
vic->realize = virtio_input_host_realize;
vic->unrealize = virtio_input_host_unrealize;
}
static void virtio_input_host_init(Object *obj)
{
VirtIOInput *vinput = VIRTIO_INPUT(obj);
virtio_input_init_config(vinput, virtio_input_host_config);
}
static const TypeInfo virtio_input_host_info = {
.name = TYPE_VIRTIO_INPUT_HOST,
.parent = TYPE_VIRTIO_INPUT,
.instance_size = sizeof(VirtIOInputHost),
.instance_init = virtio_input_host_init,
.class_init = virtio_input_host_class_init,
};
/* ----------------------------------------------------------------- */
static void virtio_register_types(void)
{
type_register_static(&virtio_input_host_info);
}
type_init(virtio_register_types)

View File

@@ -216,7 +216,7 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp)
} }
virtio_input_idstr_config(vinput, VIRTIO_INPUT_CFG_ID_SERIAL, virtio_input_idstr_config(vinput, VIRTIO_INPUT_CFG_ID_SERIAL,
vinput->input.serial); vinput->serial);
QTAILQ_FOREACH(cfg, &vinput->cfg_list, node) { QTAILQ_FOREACH(cfg, &vinput->cfg_list, node) {
if (vinput->cfg_size < cfg->config.size) { if (vinput->cfg_size < cfg->config.size) {
@@ -248,11 +248,17 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
virtio_cleanup(vdev); virtio_cleanup(vdev);
} }
static Property virtio_input_properties[] = {
DEFINE_PROP_STRING("serial", VirtIOInput, serial),
DEFINE_PROP_END_OF_LIST(),
};
static void virtio_input_class_init(ObjectClass *klass, void *data) static void virtio_input_class_init(ObjectClass *klass, void *data)
{ {
DeviceClass *dc = DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->props = virtio_input_properties;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories); set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
vdc->realize = virtio_input_device_realize; vdc->realize = virtio_input_device_realize;
vdc->unrealize = virtio_input_device_unrealize; vdc->unrealize = virtio_input_device_unrealize;

View File

@@ -1556,9 +1556,9 @@ static void openpic_realize(DeviceState *dev, Error **errp)
}; };
if (opp->nb_cpus > MAX_CPU) { if (opp->nb_cpus > MAX_CPU) {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
TYPE_OPENPIC, "nb_cpus", (uint64_t)opp->nb_cpus, TYPE_OPENPIC, "nb_cpus", (uint64_t)opp->nb_cpus,
(uint64_t)0, (uint64_t)MAX_CPU); (uint64_t)0, (uint64_t)MAX_CPU);
return; return;
} }

View File

@@ -34,6 +34,10 @@ typedef struct PIIX4State {
PCIDevice dev; PCIDevice dev;
} PIIX4State; } PIIX4State;
#define TYPE_PIIX4_PCI_DEVICE "PIIX4"
#define PIIX4_PCI_DEVICE(obj) \
OBJECT_CHECK(PIIX4State, (obj), TYPE_PIIX4_PCI_DEVICE)
static void piix4_reset(void *opaque) static void piix4_reset(void *opaque)
{ {
PIIX4State *d = opaque; PIIX4State *d = opaque;
@@ -84,7 +88,7 @@ static const VMStateDescription vmstate_piix4 = {
static void piix4_realize(PCIDevice *dev, Error **errp) static void piix4_realize(PCIDevice *dev, Error **errp)
{ {
PIIX4State *d = DO_UPCAST(PIIX4State, dev, dev); PIIX4State *d = PIIX4_PCI_DEVICE(dev);
isa_bus_new(DEVICE(d), pci_address_space(dev), isa_bus_new(DEVICE(d), pci_address_space(dev),
pci_address_space_io(dev)); pci_address_space_io(dev));
@@ -121,7 +125,7 @@ static void piix4_class_init(ObjectClass *klass, void *data)
} }
static const TypeInfo piix4_info = { static const TypeInfo piix4_info = {
.name = "PIIX4", .name = TYPE_PIIX4_PCI_DEVICE,
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PIIX4State), .instance_size = sizeof(PIIX4State),
.class_init = piix4_class_init, .class_init = piix4_class_init,

View File

@@ -47,6 +47,10 @@ typedef struct VT82C686BState {
SuperIOConfig superio_conf; SuperIOConfig superio_conf;
} VT82C686BState; } VT82C686BState;
#define TYPE_VT82C686B_DEVICE "VT82C686B"
#define VT82C686B_DEVICE(obj) \
OBJECT_CHECK(VT82C686BState, (obj), TYPE_VT82C686B_DEVICE)
static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data, static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data,
unsigned size) unsigned size)
{ {
@@ -114,7 +118,7 @@ static void vt82c686b_reset(void * opaque)
{ {
PCIDevice *d = opaque; PCIDevice *d = opaque;
uint8_t *pci_conf = d->config; uint8_t *pci_conf = d->config;
VT82C686BState *vt82c = DO_UPCAST(VT82C686BState, dev, d); VT82C686BState *vt82c = VT82C686B_DEVICE(d);
pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY | pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
@@ -142,7 +146,7 @@ static void vt82c686b_reset(void * opaque)
static void vt82c686b_write_config(PCIDevice * d, uint32_t address, static void vt82c686b_write_config(PCIDevice * d, uint32_t address,
uint32_t val, int len) uint32_t val, int len)
{ {
VT82C686BState *vt686 = DO_UPCAST(VT82C686BState, dev, d); VT82C686BState *vt686 = VT82C686B_DEVICE(d);
DPRINTF("vt82c686b_write_config address 0x%x val 0x%x len 0x%x\n", DPRINTF("vt82c686b_write_config address 0x%x val 0x%x len 0x%x\n",
address, val, len); address, val, len);
@@ -172,6 +176,18 @@ typedef struct VT686MC97State {
PCIDevice dev; PCIDevice dev;
} VT686MC97State; } VT686MC97State;
#define TYPE_VT82C686B_PM_DEVICE "VT82C686B_PM"
#define VT82C686B_PM_DEVICE(obj) \
OBJECT_CHECK(VT686PMState, (obj), TYPE_VT82C686B_PM_DEVICE)
#define TYPE_VT82C686B_MC97_DEVICE "VT82C686B_MC97"
#define VT82C686B_MC97_DEVICE(obj) \
OBJECT_CHECK(VT686MC97State, (obj), TYPE_VT82C686B_MC97_DEVICE)
#define TYPE_VT82C686B_AC97_DEVICE "VT82C686B_AC97"
#define VT82C686B_AC97_DEVICE(obj) \
OBJECT_CHECK(VT686AC97State, (obj), TYPE_VT82C686B_AC97_DEVICE)
static void pm_update_sci(VT686PMState *s) static void pm_update_sci(VT686PMState *s)
{ {
int sci_level, pmsts; int sci_level, pmsts;
@@ -247,7 +263,7 @@ static const VMStateDescription vmstate_acpi = {
static void vt82c686b_ac97_realize(PCIDevice *dev, Error **errp) static void vt82c686b_ac97_realize(PCIDevice *dev, Error **errp)
{ {
VT686AC97State *s = DO_UPCAST(VT686AC97State, dev, dev); VT686AC97State *s = VT82C686B_AC97_DEVICE(dev);
uint8_t *pci_conf = s->dev.config; uint8_t *pci_conf = s->dev.config;
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE | pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
@@ -261,7 +277,7 @@ void vt82c686b_ac97_init(PCIBus *bus, int devfn)
{ {
PCIDevice *dev; PCIDevice *dev;
dev = pci_create(bus, devfn, "VT82C686B_AC97"); dev = pci_create(bus, devfn, TYPE_VT82C686B_AC97_DEVICE);
qdev_init_nofail(&dev->qdev); qdev_init_nofail(&dev->qdev);
} }
@@ -280,7 +296,7 @@ static void via_ac97_class_init(ObjectClass *klass, void *data)
} }
static const TypeInfo via_ac97_info = { static const TypeInfo via_ac97_info = {
.name = "VT82C686B_AC97", .name = TYPE_VT82C686B_AC97_DEVICE,
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT686AC97State), .instance_size = sizeof(VT686AC97State),
.class_init = via_ac97_class_init, .class_init = via_ac97_class_init,
@@ -288,7 +304,7 @@ static const TypeInfo via_ac97_info = {
static void vt82c686b_mc97_realize(PCIDevice *dev, Error **errp) static void vt82c686b_mc97_realize(PCIDevice *dev, Error **errp)
{ {
VT686MC97State *s = DO_UPCAST(VT686MC97State, dev, dev); VT686MC97State *s = VT82C686B_MC97_DEVICE(dev);
uint8_t *pci_conf = s->dev.config; uint8_t *pci_conf = s->dev.config;
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE | pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
@@ -301,7 +317,7 @@ void vt82c686b_mc97_init(PCIBus *bus, int devfn)
{ {
PCIDevice *dev; PCIDevice *dev;
dev = pci_create(bus, devfn, "VT82C686B_MC97"); dev = pci_create(bus, devfn, TYPE_VT82C686B_MC97_DEVICE);
qdev_init_nofail(&dev->qdev); qdev_init_nofail(&dev->qdev);
} }
@@ -320,7 +336,7 @@ static void via_mc97_class_init(ObjectClass *klass, void *data)
} }
static const TypeInfo via_mc97_info = { static const TypeInfo via_mc97_info = {
.name = "VT82C686B_MC97", .name = TYPE_VT82C686B_MC97_DEVICE,
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT686MC97State), .instance_size = sizeof(VT686MC97State),
.class_init = via_mc97_class_init, .class_init = via_mc97_class_init,
@@ -329,7 +345,7 @@ static const TypeInfo via_mc97_info = {
/* vt82c686 pm init */ /* vt82c686 pm init */
static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)
{ {
VT686PMState *s = DO_UPCAST(VT686PMState, dev, dev); VT686PMState *s = VT82C686B_PM_DEVICE(dev);
uint8_t *pci_conf; uint8_t *pci_conf;
pci_conf = s->dev.config; pci_conf = s->dev.config;
@@ -365,10 +381,10 @@ I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
PCIDevice *dev; PCIDevice *dev;
VT686PMState *s; VT686PMState *s;
dev = pci_create(bus, devfn, "VT82C686B_PM"); dev = pci_create(bus, devfn, TYPE_VT82C686B_PM_DEVICE);
qdev_prop_set_uint32(&dev->qdev, "smb_io_base", smb_io_base); qdev_prop_set_uint32(&dev->qdev, "smb_io_base", smb_io_base);
s = DO_UPCAST(VT686PMState, dev, dev); s = VT82C686B_PM_DEVICE(dev);
qdev_init_nofail(&dev->qdev); qdev_init_nofail(&dev->qdev);
@@ -398,7 +414,7 @@ static void via_pm_class_init(ObjectClass *klass, void *data)
} }
static const TypeInfo via_pm_info = { static const TypeInfo via_pm_info = {
.name = "VT82C686B_PM", .name = TYPE_VT82C686B_PM_DEVICE,
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT686PMState), .instance_size = sizeof(VT686PMState),
.class_init = via_pm_class_init, .class_init = via_pm_class_init,
@@ -417,7 +433,7 @@ static const VMStateDescription vmstate_via = {
/* init the PCI-to-ISA bridge */ /* init the PCI-to-ISA bridge */
static void vt82c686b_realize(PCIDevice *d, Error **errp) static void vt82c686b_realize(PCIDevice *d, Error **errp)
{ {
VT82C686BState *vt82c = DO_UPCAST(VT82C686BState, dev, d); VT82C686BState *vt82c = VT82C686B_DEVICE(d);
uint8_t *pci_conf; uint8_t *pci_conf;
ISABus *isa_bus; ISABus *isa_bus;
uint8_t *wmask; uint8_t *wmask;
@@ -451,7 +467,8 @@ ISABus *vt82c686b_init(PCIBus *bus, int devfn)
{ {
PCIDevice *d; PCIDevice *d;
d = pci_create_simple_multifunction(bus, devfn, true, "VT82C686B"); d = pci_create_simple_multifunction(bus, devfn, true,
TYPE_VT82C686B_DEVICE);
return ISA_BUS(qdev_get_child_bus(DEVICE(d), "isa.0")); return ISA_BUS(qdev_get_child_bus(DEVICE(d), "isa.0"));
} }
@@ -477,7 +494,7 @@ static void via_class_init(ObjectClass *klass, void *data)
} }
static const TypeInfo via_info = { static const TypeInfo via_info = {
.name = "VT82C686B", .name = TYPE_VT82C686B_DEVICE,
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT82C686BState), .instance_size = sizeof(VT82C686BState),
.class_init = via_class_init, .class_init = via_class_init,

View File

@@ -53,6 +53,7 @@
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "hw/empty_slot.h" #include "hw/empty_slot.h"
#include "sysemu/kvm.h" #include "sysemu/kvm.h"
#include "exec/semihost.h"
//#define DEBUG_BOARD_INIT //#define DEBUG_BOARD_INIT
@@ -634,7 +635,13 @@ static void write_bootloader (CPUMIPSState *env, uint8_t *base,
/* Second part of the bootloader */ /* Second part of the bootloader */
p = (uint32_t *) (base + 0x580); p = (uint32_t *) (base + 0x580);
stl_p(p++, 0x24040002); /* addiu a0, zero, 2 */
if (semihosting_get_argc()) {
/* Preserve a0 content as arguments have been passed */
stl_p(p++, 0x00000000); /* nop */
} else {
stl_p(p++, 0x24040002); /* addiu a0, zero, 2 */
}
stl_p(p++, 0x3c1d0000 | (((ENVP_ADDR - 64) >> 16) & 0xffff)); /* lui sp, high(ENVP_ADDR) */ stl_p(p++, 0x3c1d0000 | (((ENVP_ADDR - 64) >> 16) & 0xffff)); /* lui sp, high(ENVP_ADDR) */
stl_p(p++, 0x37bd0000 | ((ENVP_ADDR - 64) & 0xffff)); /* ori sp, sp, low(ENVP_ADDR) */ stl_p(p++, 0x37bd0000 | ((ENVP_ADDR - 64) & 0xffff)); /* ori sp, sp, low(ENVP_ADDR) */
stl_p(p++, 0x3c050000 | ((ENVP_ADDR >> 16) & 0xffff)); /* lui a1, high(ENVP_ADDR) */ stl_p(p++, 0x3c050000 | ((ENVP_ADDR >> 16) & 0xffff)); /* lui a1, high(ENVP_ADDR) */
@@ -887,7 +894,7 @@ static void main_cpu_reset(void *opaque)
read only location. The kernel location and the arguments table read only location. The kernel location and the arguments table
location does not change. */ location does not change. */
if (loaderparams.kernel_filename) { if (loaderparams.kernel_filename) {
env->CP0_Status &= ~((1 << CP0St_BEV) | (1 << CP0St_ERL)); env->CP0_Status &= ~(1 << CP0St_ERL);
} }
malta_mips_config(cpu); malta_mips_config(cpu);

View File

@@ -22,7 +22,7 @@
#include "hw/pci/msix.h" #include "hw/pci/msix.h"
#include "sysemu/kvm.h" #include "sysemu/kvm.h"
#include "migration/migration.h" #include "migration/migration.h"
#include "qapi/qmp/qerror.h" #include "qemu/error-report.h"
#include "qemu/event_notifier.h" #include "qemu/event_notifier.h"
#include "qemu/fifo8.h" #include "qemu/fifo8.h"
#include "sysemu/char.h" #include "sysemu/char.h"

View File

@@ -21,13 +21,13 @@
RockerSwitch *qmp_query_rocker(const char *name, Error **errp) RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
{ {
error_set(errp, QERR_FEATURE_DISABLED, "rocker"); error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
return NULL; return NULL;
}; };
RockerPortList *qmp_query_rocker_ports(const char *name, Error **errp) RockerPortList *qmp_query_rocker_ports(const char *name, Error **errp)
{ {
error_set(errp, QERR_FEATURE_DISABLED, "rocker"); error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
return NULL; return NULL;
}; };
@@ -36,7 +36,7 @@ RockerOfDpaFlowList *qmp_query_rocker_of_dpa_flows(const char *name,
uint32_t tbl_id, uint32_t tbl_id,
Error **errp) Error **errp)
{ {
error_set(errp, QERR_FEATURE_DISABLED, "rocker"); error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
return NULL; return NULL;
}; };
@@ -45,6 +45,6 @@ RockerOfDpaGroupList *qmp_query_rocker_of_dpa_groups(const char *name,
uint8_t type, uint8_t type,
Error **errp) Error **errp)
{ {
error_set(errp, QERR_FEATURE_DISABLED, "rocker"); error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
return NULL; return NULL;
}; };

View File

@@ -26,7 +26,6 @@
#include "qemu/log.h" #include "qemu/log.h"
#include "net/net.h" #include "net/net.h"
#include "net/checksum.h" #include "net/checksum.h"
#include "qapi/qmp/qerror.h"
#include "hw/stream.h" #include "hw/stream.h"

View File

@@ -91,6 +91,10 @@ typedef struct PIIX3State {
MemoryRegion rcr_mem; MemoryRegion rcr_mem;
} PIIX3State; } PIIX3State;
#define TYPE_PIIX3_PCI_DEVICE "pci-piix3"
#define PIIX3_PCI_DEVICE(obj) \
OBJECT_CHECK(PIIX3State, (obj), TYPE_PIIX3_PCI_DEVICE)
#define TYPE_I440FX_PCI_DEVICE "i440FX" #define TYPE_I440FX_PCI_DEVICE "i440FX"
#define I440FX_PCI_DEVICE(obj) \ #define I440FX_PCI_DEVICE(obj) \
OBJECT_CHECK(PCII440FXState, (obj), TYPE_I440FX_PCI_DEVICE) OBJECT_CHECK(PCII440FXState, (obj), TYPE_I440FX_PCI_DEVICE)
@@ -368,13 +372,15 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
* connected to the IOAPIC directly. * connected to the IOAPIC directly.
* These additional routes can be discovered through ACPI. */ * These additional routes can be discovered through ACPI. */
if (xen_enabled()) { if (xen_enabled()) {
piix3 = DO_UPCAST(PIIX3State, dev, PCIDevice *pci_dev = pci_create_simple_multifunction(b,
pci_create_simple_multifunction(b, -1, true, "PIIX3-xen")); -1, true, "PIIX3-xen");
piix3 = PIIX3_PCI_DEVICE(pci_dev);
pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq, pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq,
piix3, XEN_PIIX_NUM_PIRQS); piix3, XEN_PIIX_NUM_PIRQS);
} else { } else {
piix3 = DO_UPCAST(PIIX3State, dev, PCIDevice *pci_dev = pci_create_simple_multifunction(b,
pci_create_simple_multifunction(b, -1, true, "PIIX3")); -1, true, "PIIX3");
piix3 = PIIX3_PCI_DEVICE(pci_dev);
pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3,
PIIX_NUM_PIRQS); PIIX_NUM_PIRQS);
pci_bus_set_route_irq_fn(b, piix3_route_intx_pin_to_irq); pci_bus_set_route_irq_fn(b, piix3_route_intx_pin_to_irq);
@@ -480,7 +486,7 @@ static void piix3_write_config(PCIDevice *dev,
{ {
pci_default_write_config(dev, address, val, len); pci_default_write_config(dev, address, val, len);
if (ranges_overlap(address, len, PIIX_PIRQC, 4)) { if (ranges_overlap(address, len, PIIX_PIRQC, 4)) {
PIIX3State *piix3 = DO_UPCAST(PIIX3State, dev, dev); PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev);
int pic_irq; int pic_irq;
pci_bus_fire_intx_routing_notifier(piix3->dev.bus); pci_bus_fire_intx_routing_notifier(piix3->dev.bus);
@@ -634,7 +640,7 @@ static const MemoryRegionOps rcr_ops = {
static void piix3_realize(PCIDevice *dev, Error **errp) static void piix3_realize(PCIDevice *dev, Error **errp)
{ {
PIIX3State *d = DO_UPCAST(PIIX3State, dev, dev); PIIX3State *d = PIIX3_PCI_DEVICE(dev);
isa_bus_new(DEVICE(d), get_system_memory(), isa_bus_new(DEVICE(d), get_system_memory(),
pci_address_space_io(dev)); pci_address_space_io(dev));
@@ -647,7 +653,7 @@ static void piix3_realize(PCIDevice *dev, Error **errp)
qemu_register_reset(piix3_reset, d); qemu_register_reset(piix3_reset, d);
} }
static void piix3_class_init(ObjectClass *klass, void *data) static void pci_piix3_class_init(ObjectClass *klass, void *data)
{ {
DeviceClass *dc = DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
@@ -656,7 +662,6 @@ static void piix3_class_init(ObjectClass *klass, void *data)
dc->vmsd = &vmstate_piix3; dc->vmsd = &vmstate_piix3;
dc->hotpluggable = false; dc->hotpluggable = false;
k->realize = piix3_realize; k->realize = piix3_realize;
k->config_write = piix3_write_config;
k->vendor_id = PCI_VENDOR_ID_INTEL; k->vendor_id = PCI_VENDOR_ID_INTEL;
/* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */ /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0; k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0;
@@ -668,38 +673,37 @@ static void piix3_class_init(ObjectClass *klass, void *data)
dc->cannot_instantiate_with_device_add_yet = true; dc->cannot_instantiate_with_device_add_yet = true;
} }
static const TypeInfo piix3_pci_type_info = {
.name = TYPE_PIIX3_PCI_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PIIX3State),
.abstract = true,
.class_init = pci_piix3_class_init,
};
static void piix3_class_init(ObjectClass *klass, void *data)
{
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->config_write = piix3_write_config;
}
static const TypeInfo piix3_info = { static const TypeInfo piix3_info = {
.name = "PIIX3", .name = "PIIX3",
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PIIX3_PCI_DEVICE,
.instance_size = sizeof(PIIX3State),
.class_init = piix3_class_init, .class_init = piix3_class_init,
}; };
static void piix3_xen_class_init(ObjectClass *klass, void *data) static void piix3_xen_class_init(ObjectClass *klass, void *data)
{ {
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
dc->desc = "ISA bridge";
dc->vmsd = &vmstate_piix3;
dc->hotpluggable = false;
k->realize = piix3_realize;
k->config_write = piix3_write_config_xen; k->config_write = piix3_write_config_xen;
k->vendor_id = PCI_VENDOR_ID_INTEL;
/* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0;
k->class_id = PCI_CLASS_BRIDGE_ISA;
/*
* Reason: part of PIIX3 southbridge, needs to be wired up by
* pc_piix.c's pc_init1()
*/
dc->cannot_instantiate_with_device_add_yet = true;
}; };
static const TypeInfo piix3_xen_info = { static const TypeInfo piix3_xen_info = {
.name = "PIIX3-xen", .name = "PIIX3-xen",
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PIIX3_PCI_DEVICE,
.instance_size = sizeof(PIIX3State),
.class_init = piix3_xen_class_init, .class_init = piix3_xen_class_init,
}; };
@@ -772,6 +776,7 @@ static const TypeInfo i440fx_pcihost_info = {
static void i440fx_register_types(void) static void i440fx_register_types(void)
{ {
type_register_static(&i440fx_info); type_register_static(&i440fx_info);
type_register_static(&piix3_pci_type_info);
type_register_static(&piix3_info); type_register_static(&piix3_info);
type_register_static(&piix3_xen_info); type_register_static(&piix3_xen_info);
type_register_static(&i440fx_pcihost_info); type_register_static(&i440fx_pcihost_info);

View File

@@ -20,12 +20,13 @@
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "qapi/qmp/qerror.h"
#include "hw/pci/pci.h" #include "hw/pci/pci.h"
#include "qmp-commands.h" #include "qmp-commands.h"
PciInfoList *qmp_query_pci(Error **errp) PciInfoList *qmp_query_pci(Error **errp)
{ {
error_set(errp, QERR_UNSUPPORTED); error_setg(errp, QERR_UNSUPPORTED);
return NULL; return NULL;
} }

View File

@@ -30,6 +30,7 @@
#include "net/net.h" #include "net/net.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "hw/loader.h" #include "hw/loader.h"
#include "qemu/error-report.h"
#include "qemu/range.h" #include "qemu/range.h"
#include "qmp-commands.h" #include "qmp-commands.h"
#include "trace.h" #include "trace.h"
@@ -427,6 +428,10 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
for (i = 0; i < size; ++i) { for (i = 0; i < size; ++i) {
if ((config[i] ^ s->config[i]) & if ((config[i] ^ s->config[i]) &
s->cmask[i] & ~s->wmask[i] & ~s->w1cmask[i]) { s->cmask[i] & ~s->wmask[i] & ~s->w1cmask[i]) {
error_report("%s: Bad config data: i=0x%x read: %x device: %x "
"cmask: %x wmask: %x w1cmask:%x", __func__,
i, config[i], s->config[i],
s->cmask[i], s->wmask[i], s->w1cmask[i]);
g_free(config); g_free(config);
return -EINVAL; return -EINVAL;
} }

View File

@@ -26,7 +26,6 @@
#include "hw/pci/pci_bus.h" #include "hw/pci/pci_bus.h"
#include "hw/pci/pcie_regs.h" #include "hw/pci/pcie_regs.h"
#include "qemu/range.h" #include "qemu/range.h"
#include "qapi/qmp/qerror.h"
//#define DEBUG_PCIE //#define DEBUG_PCIE
#ifdef DEBUG_PCIE #ifdef DEBUG_PCIE

View File

@@ -975,7 +975,7 @@ static int do_pcie_aer_inject_error(Monitor *mon,
if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) { if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) {
char *e = NULL; char *e = NULL;
error_status = strtoul(error_name, &e, 0); error_status = strtoul(error_name, &e, 0);
correctable = qdict_get_try_bool(qdict, "correctable", 0); correctable = qdict_get_try_bool(qdict, "correctable", false);
if (!e || *e != '\0') { if (!e || *e != '\0') {
monitor_printf(mon, "invalid error status value. \"%s\"", monitor_printf(mon, "invalid error status value. \"%s\"",
error_name); error_name);
@@ -989,7 +989,7 @@ static int do_pcie_aer_inject_error(Monitor *mon,
if (correctable) { if (correctable) {
err.flags |= PCIE_AER_ERR_IS_CORRECTABLE; err.flags |= PCIE_AER_ERR_IS_CORRECTABLE;
} }
if (qdict_get_try_bool(qdict, "advisory_non_fatal", 0)) { if (qdict_get_try_bool(qdict, "advisory_non_fatal", false)) {
err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY; err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY;
} }
if (qdict_haskey(qdict, "header0")) { if (qdict_haskey(qdict, "header0")) {

View File

@@ -7,7 +7,6 @@
#include "hw/pci/pci.h" #include "hw/pci/pci.h"
#include "hw/pci/pci_bus.h" #include "hw/pci/pci_bus.h"
#include "hw/pci/msi.h" #include "hw/pci/msi.h"
#include "qapi/qmp/qerror.h"
/* TODO: model power only and disabled slot states. */ /* TODO: model power only and disabled slot states. */
/* TODO: handle SERR and wakeups */ /* TODO: handle SERR and wakeups */

View File

@@ -51,8 +51,6 @@
# define LOG_TB(...) do { } while (0) # define LOG_TB(...) do { } while (0)
#endif #endif
#define NSEC_PER_SEC 1000000000LL
static void cpu_ppc_tb_stop (CPUPPCState *env); static void cpu_ppc_tb_stop (CPUPPCState *env);
static void cpu_ppc_tb_start (CPUPPCState *env); static void cpu_ppc_tb_start (CPUPPCState *env);

View File

@@ -1062,8 +1062,8 @@ static void spapr_phb_hot_plug_child(HotplugHandler *plug_handler,
* we need to let them know it's not enabled * we need to let them know it's not enabled
*/ */
if (plugged_dev->hotplugged) { if (plugged_dev->hotplugged) {
error_set(errp, QERR_BUS_NO_HOTPLUG, error_setg(errp, QERR_BUS_NO_HOTPLUG,
object_get_typename(OBJECT(phb))); object_get_typename(OBJECT(phb)));
} }
return; return;
} }
@@ -1090,8 +1090,8 @@ static void spapr_phb_hot_unplug_child(HotplugHandler *plug_handler,
Error *local_err = NULL; Error *local_err = NULL;
if (!phb->dr_enabled) { if (!phb->dr_enabled) {
error_set(errp, QERR_BUS_NO_HOTPLUG, error_setg(errp, QERR_BUS_NO_HOTPLUG,
object_get_typename(OBJECT(phb))); object_get_typename(OBJECT(phb)));
return; return;
} }

View File

@@ -26,6 +26,7 @@
* *
*/ */
#include "cpu.h" #include "cpu.h"
#include "qemu/timer.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "hw/ppc/spapr.h" #include "hw/ppc/spapr.h"
#include "qapi-event.h" #include "qapi-event.h"
@@ -40,8 +41,6 @@ struct sPAPRRTCState {
int64_t ns_offset; int64_t ns_offset;
}; };
#define NSEC_PER_SEC 1000000000LL
void spapr_rtc_read(DeviceState *dev, struct tm *tm, uint32_t *ns) void spapr_rtc_read(DeviceState *dev, struct tm *tm, uint32_t *ns)
{ {
sPAPRRTCState *rtc = SPAPR_RTC(dev); sPAPRRTCState *rtc = SPAPR_RTC(dev);

View File

@@ -22,7 +22,6 @@
#include "hw/hw.h" #include "hw/hw.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "hw/boards.h" #include "hw/boards.h"
#include "monitor/monitor.h"
#include "hw/loader.h" #include "hw/loader.h"
#include "elf.h" #include "elf.h"
#include "hw/sysbus.h" #include "hw/sysbus.h"

View File

@@ -32,6 +32,7 @@
#include "sysemu/device_tree.h" #include "sysemu/device_tree.h"
#include "hw/loader.h" #include "hw/loader.h"
#include "elf.h" #include "elf.h"
#include "qemu/error-report.h"
#include "qemu/log.h" #include "qemu/log.h"
#include "exec/address-spaces.h" #include "exec/address-spaces.h"
@@ -40,7 +41,6 @@
#include "ppc405.h" #include "ppc405.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "qapi/qmp/qerror.h"
#define EPAPR_MAGIC (0x45504150) #define EPAPR_MAGIC (0x45504150)
#define FLASH_SIZE (16 * 1024 * 1024) #define FLASH_SIZE (16 * 1024 * 1024)

View File

@@ -15,7 +15,6 @@
* *
*/ */
#include "monitor/monitor.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "hw/s390x/sclp.h" #include "hw/s390x/sclp.h"

View File

@@ -21,7 +21,6 @@
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "hw/boards.h" #include "hw/boards.h"
#include "monitor/monitor.h"
#include "hw/loader.h" #include "hw/loader.h"
#include "elf.h" #include "elf.h"
#include "hw/virtio/virtio.h" #include "hw/virtio/virtio.h"

View File

@@ -22,12 +22,12 @@
*/ */
#include "hw/hw.h" #include "hw/hw.h"
#include "qapi/qmp/qerror.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "sysemu/blockdev.h" #include "sysemu/blockdev.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "net/net.h" #include "net/net.h"
#include "hw/boards.h" #include "hw/boards.h"
#include "monitor/monitor.h"
#include "hw/loader.h" #include "hw/loader.h"
#include "hw/virtio/virtio.h" #include "hw/virtio/virtio.h"
#include "hw/sysbus.h" #include "hw/sysbus.h"
@@ -324,7 +324,7 @@ void s390_nmi(NMIState *n, int cpu_index, Error **errp)
CPUState *cs = qemu_get_cpu(cpu_index); CPUState *cs = qemu_get_cpu(cpu_index);
if (s390_cpu_restart(S390_CPU(cs))) { if (s390_cpu_restart(S390_CPU(cs))) {
error_set(errp, QERR_UNSUPPORTED); error_setg(errp, QERR_UNSUPPORTED);
} }
} }

View File

@@ -15,12 +15,12 @@
#include "sysemu/blockdev.h" #include "sysemu/blockdev.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "net/net.h" #include "net/net.h"
#include "monitor/monitor.h"
#include "hw/virtio/virtio.h" #include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-serial.h"
#include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-net.h"
#include "hw/sysbus.h" #include "hw/sysbus.h"
#include "qemu/bitops.h" #include "qemu/bitops.h"
#include "qemu/error-report.h"
#include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-bus.h"
#include "hw/s390x/adapter.h" #include "hw/s390x/adapter.h"
#include "hw/s390x/s390_flic.h" #include "hw/s390x/s390_flic.h"

View File

@@ -16,6 +16,7 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "config.h" #include "config.h"
#include "qemu/error-report.h"
#include "qemu/queue.h" #include "qemu/queue.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "migration/migration.h" #include "migration/migration.h"

View File

@@ -27,6 +27,7 @@
#include "hw/hw.h" #include "hw/hw.h"
#include "hw/i386/pc.h" #include "hw/i386/pc.h"
#include "ui/console.h" #include "ui/console.h"
#include "qemu/error-report.h"
#include "qemu/timer.h" #include "qemu/timer.h"
#include "hw/timer/hpet.h" #include "hw/timer/hpet.h"
#include "hw/sysbus.h" #include "hw/sysbus.h"

View File

@@ -48,7 +48,6 @@
# define DPRINTF_C(format, ...) do { } while (0) # define DPRINTF_C(format, ...) do { } while (0)
#endif #endif
#define NSEC_PER_SEC 1000000000LL
#define SEC_PER_MIN 60 #define SEC_PER_MIN 60
#define MIN_PER_HOUR 60 #define MIN_PER_HOUR 60
#define SEC_PER_HOUR 3600 #define SEC_PER_HOUR 3600

View File

@@ -26,6 +26,7 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/sockets.h" #include "qemu/sockets.h"
#include "sysemu/tpm_backend.h" #include "sysemu/tpm_backend.h"
#include "tpm_int.h" #include "tpm_int.h"

View File

@@ -1,6 +1,7 @@
#include "hw/hw.h" #include "hw/hw.h"
#include "hw/usb.h" #include "hw/usb.h"
#include "hw/qdev.h" #include "hw/qdev.h"
#include "qemu/error-report.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "trace.h" #include "trace.h"

View File

@@ -33,7 +33,6 @@
#include "qemu/thread.h" #include "qemu/thread.h"
#include "sysemu/char.h" #include "sysemu/char.h"
#include "monitor/monitor.h"
#include "ccid.h" #include "ccid.h"
#define DPRINTF(card, lvl, fmt, ...) \ #define DPRINTF(card, lvl, fmt, ...) \

View File

@@ -9,8 +9,8 @@
*/ */
#include "sysemu/char.h" #include "sysemu/char.h"
#include "qemu/error-report.h"
#include "qemu/sockets.h" #include "qemu/sockets.h"
#include "monitor/monitor.h"
#include "ccid.h" #include "ccid.h"
#include "libcacard/vscard_common.h" #include "libcacard/vscard_common.h"

Some files were not shown because too many files have changed in this diff Show More