]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
8 years agoblockjob: Add "completed" and "ret" in BlockJob
Fam Zheng [Thu, 5 Nov 2015 23:13:13 +0000 (18:13 -0500)]
blockjob: Add "completed" and "ret" in BlockJob

They are set when block_job_completed is called.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1446765200-3054-8-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblockjob: Add .commit and .abort block job actions
Fam Zheng [Thu, 5 Nov 2015 23:13:12 +0000 (18:13 -0500)]
blockjob: Add .commit and .abort block job actions

Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1446765200-3054-7-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblockjob: Introduce reference count and fix reference to job->bs
Fam Zheng [Thu, 5 Nov 2015 23:13:11 +0000 (18:13 -0500)]
blockjob: Introduce reference count and fix reference to job->bs

Add reference count to block job, meanwhile move the ownership of the
reference to job->bs from the caller (which is released in two
completion callbacks) to the block job itself. It is necessary for
block_job_complete_sync to work, because block job shouldn't live longer
than its bs, as asserted in bdrv_delete.

Now block_job_complete_sync can be simplified.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1446765200-3054-6-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agobackup: Extract dirty bitmap handling as a separate function
Fam Zheng [Thu, 5 Nov 2015 23:13:10 +0000 (18:13 -0500)]
backup: Extract dirty bitmap handling as a separate function

This will be reused by the coming new transactional completion code.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1446765200-3054-5-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: rename BlkTransactionState and BdrvActionOps
John Snow [Thu, 5 Nov 2015 23:13:09 +0000 (18:13 -0500)]
block: rename BlkTransactionState and BdrvActionOps

These structures are misnomers, somewhat.

(1) BlockTransactionState is not state for a transaction,
    but is rather state for a single transaction action.
    Rename it "BlkActionState" to be more accurate.

(2) The BdrvActionOps describes operations for the BlkActionState,
    above. This name might imply a 'BdrvAction' or a 'BdrvActionState',
    which there isn't.
    Rename this to 'BlkActionOps' to match 'BlkActionState'.

Lastly, update the surrounding in-line documentation and comments
to reflect the current nature of how Transactions operate.

This patch changes only comments and names, and should not affect
behavior in any way.

Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1446765200-3054-4-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoiotests: add transactional incremental backup test
John Snow [Thu, 5 Nov 2015 23:13:08 +0000 (18:13 -0500)]
iotests: add transactional incremental backup test

Test simple usage cases for using transactions to create
and synchronize incremental backups.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-id: 1446765200-3054-3-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqed: Implement .bdrv_drain
Fam Zheng [Mon, 9 Nov 2015 10:16:54 +0000 (18:16 +0800)]
qed: Implement .bdrv_drain

The "need_check_timer" is used to clear the "NEED_CHECK" flag in the
image header after a grace period once metadata update has finished. In
compliance to the bdrv_drain semantics we should make sure it remains
deleted once .bdrv_drain is called.

We cannot reuse qed_need_check_timer_cb because here it doesn't satisfy
the assertion.  Do the "plug" and "flush" calls manually.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1447064214-29930-10-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Introduce BlockDriver.bdrv_drain callback
Fam Zheng [Mon, 9 Nov 2015 10:16:53 +0000 (18:16 +0800)]
block: Introduce BlockDriver.bdrv_drain callback

Drivers can have internal request sources that generate IO, like the
need_check_timer in QED. Since we want quiesced periods that contain
nested event loops in block layer, we need to have a way to disable such
event sources.

Block drivers must implement the "bdrv_drain" callback if it has any
internal sources that can generate I/O activity, like a timer or a
worker thread (even in a library) that can schedule QEMUBH in an
asynchronous callback.

Update the comments of bdrv_drain and bdrv_drained_begin accordingly.

Like bdrv_requests_pending(), we should consider all the children of bs.
Before, the while loop just works, as bdrv_requests_pending() already
tracks its children; now we mustn't miss the callback, so recurse down
explicitly.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1447064214-29930-9-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Drop BlockDriver.bdrv_ioctl
Fam Zheng [Mon, 9 Nov 2015 10:16:52 +0000 (18:16 +0800)]
block: Drop BlockDriver.bdrv_ioctl

Now the callback is not used any more, drop the field along with all
implementations in block drivers, which are iscsi and raw.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1447064214-29930-8-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Emulate bdrv_ioctl with bdrv_aio_ioctl and track both
Fam Zheng [Mon, 9 Nov 2015 10:16:51 +0000 (18:16 +0800)]
block: Emulate bdrv_ioctl with bdrv_aio_ioctl and track both

Currently all drivers that support .bdrv_aio_ioctl also implement
.bdrv_ioctl redundantly.  To track ioctl requests in block layer it is
easier if we unify the two paths, because we'll need to run it in a
coroutine, as required by tracked_request_begin. While we're at it, use
.bdrv_aio_ioctl plus aio_poll() to emulate bdrv_ioctl().

Signed-off-by: Fam Zheng <famz@redhat.com>
Message-id: 1447064214-29930-7-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Add ioctl parameter fields to BlockRequest
Fam Zheng [Mon, 9 Nov 2015 10:16:50 +0000 (18:16 +0800)]
block: Add ioctl parameter fields to BlockRequest

The two fields that will be used by ioctl handling code later are added
as union, because it's used exclusively by ioctl code which dosn't need
the four fields in the other struct of the union.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1447064214-29930-6-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoiscsi: Emulate commands in iscsi_aio_ioctl as iscsi_ioctl
Fam Zheng [Mon, 9 Nov 2015 10:16:49 +0000 (18:16 +0800)]
iscsi: Emulate commands in iscsi_aio_ioctl as iscsi_ioctl

iscsi_ioctl emulates SG_GET_VERSION_NUM and SG_GET_SCSI_ID. Now that
bdrv_ioctl() will be emulated with .bdrv_aio_ioctl, replicate the logic
into iscsi_aio_ioctl to make them consistent.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1447064214-29930-5-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Track discard requests
Fam Zheng [Mon, 9 Nov 2015 10:16:48 +0000 (18:16 +0800)]
block: Track discard requests

Both bdrv_discard and bdrv_aio_discard will call into bdrv_co_discard,
so add tracked_request_begin/end calls around the loop.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1447064214-29930-4-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Track flush requests
Fam Zheng [Mon, 9 Nov 2015 10:16:47 +0000 (18:16 +0800)]
block: Track flush requests

Both bdrv_flush and bdrv_aio_flush eventually call bdrv_co_flush, add
tracked_request_begin and tracked_request_end pair in that function so
that all flush requests are now tracked.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1447064214-29930-3-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Add more types for tracked request
Fam Zheng [Mon, 9 Nov 2015 10:16:46 +0000 (18:16 +0800)]
block: Add more types for tracked request

We'll track more request types besides read and write, change the
boolean field to an enum.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1447064214-29930-2-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
Peter Maydell [Thu, 12 Nov 2015 14:15:32 +0000 (14:15 +0000)]
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging

# gpg: Signature made Thu 12 Nov 2015 08:01:55 GMT using RSA key ID 398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  net: netmap: use error_setg() helpers in place of error_report()
  net: netmap: Fix compilation issue
  e1000: Introducing backward compatibility command line parameter
  e1000: Implementing various counters
  e1000: Fixing the packet address filtering procedure
  e1000: Fixing the received/transmitted octets' counters
  e1000: Fixing the received/transmitted packets' counters
  e1000: Trivial implementation of various MAC registers
  e1000: Introduced an array to control the access to the MAC registers
  e1000: Add support for migrating the entire MAC registers' array
  e1000: Cosmetic and alignment fixes
  slirp: Fix type casts and format strings in debug code

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/dgibson/tags/ppc-next-20151112' into staging
Peter Maydell [Thu, 12 Nov 2015 13:41:44 +0000 (13:41 +0000)]
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-next-20151112' into staging

ppc patch queue -2015-11-12

Highlights:
   - A number of fixes for MacOS 9 compatibility based on the old MOL
     (Mac-On-Linux) code and a GSoC project.
   - Cleaner and more general way of handling register access from the
     monitor

# gpg: Signature made Thu 12 Nov 2015 04:33:26 GMT using RSA key ID 20D9B392
# gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>"
# gpg:                 aka "David Gibson (Red Hat) <dgibson@redhat.com>"
# gpg:                 aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 75F4 6586 AE61 A66C C44E  87DC 6C38 CACA 20D9 B392

* remotes/dgibson/tags/ppc-next-20151112:
  monitor/target-ppc: Define target_get_monitor_def
  cuda.c: add delay to setting of SR_INT bit
  cuda.c: fix T2 timer and enable its interrupt
  cuda.c: rename get_counter() state variable from s to ti for consistency
  cuda.c: refactor get_tb() so that the time can be passed in
  cuda.c: add defines for CUDA registers
  cuda.c: fix CUDA SR interrupt clearing
  cuda.c: implement dummy IIC access commands
  cuda.c: implement simple CUDA_GET_6805_ADDR command
  cuda.c: fix CUDA_PACKET response packet format
  cuda.c: fix CUDA ADB error packet format
  PPC: mac99: Always add USB controller
  PPC: Fix lswx bounds checks
  PPC: Allow Rc bit to be set on mtspr

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2015-11-11-tag' into staging
Peter Maydell [Thu, 12 Nov 2015 13:11:06 +0000 (13:11 +0000)]
Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2015-11-11-tag' into staging

qemu-ga patch queue

* fix for unintended overwriting of data on w32 using
  guest-file-open with append mode

# gpg: Signature made Wed 11 Nov 2015 22:14:52 GMT using RSA key ID F108B584
# gpg: Good signature from "Michael Roth <flukshun@gmail.com>"
# gpg:                 aka "Michael Roth <mdroth@utexas.edu>"
# gpg:                 aka "Michael Roth <mdroth@linux.vnet.ibm.com>"

* remotes/mdroth/tags/qga-pull-2015-11-11-tag:
  qga: fix append file open modes for win32

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agotests: classify some ivshmem tests as slow
Marc-André Lureau [Thu, 12 Nov 2015 11:10:18 +0000 (12:10 +0100)]
tests: classify some ivshmem tests as slow

Some tests may take long to run, move them under g_test_slow()
condition.

The 5s timeout for the "server" test will have to be adjusted to the worst
known time (for the records, it takes ~0.2s on my host). The "pair"
test takes ~1.7, a quickest version could be implemented.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 1447326618-11686-1-git-send-email-marcandre.lureau@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-error-2015-11-11' into staging
Peter Maydell [Thu, 12 Nov 2015 10:09:14 +0000 (10:09 +0000)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2015-11-11' into staging

error: More error_setg() usage

# gpg: Signature made Wed 11 Nov 2015 17:57:15 GMT 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-error-2015-11-11:
  error: More error_setg() usage

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agonet: netmap: use error_setg() helpers in place of error_report()
Vincenzo Maffione [Tue, 10 Nov 2015 09:47:22 +0000 (10:47 +0100)]
net: netmap: use error_setg() helpers in place of error_report()

This update was required to align error reporting of netmap backend
initialization to the modifications introduced by commit a30ecde.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Vincenzo Maffione <v.maffione@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agonet: netmap: Fix compilation issue
Vincenzo Maffione [Tue, 10 Nov 2015 09:47:21 +0000 (10:47 +0100)]
net: netmap: Fix compilation issue

Reorganization of struct NetClientOptions (commit e4ba22b) caused a
compilation failure of the netmap backend. This patch fixes the issue
by properly accessing the union field.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Vincenzo Maffione <v.maffione@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Introducing backward compatibility command line parameter
Leonid Bloch [Wed, 11 Nov 2015 13:52:47 +0000 (15:52 +0200)]
e1000: Introducing backward compatibility command line parameter

This follows the previous patches, where support for migrating the
entire MAC registers' array, and some new MAC registers were introduced.

This patch introduces the e1000-specific boolean parameter
"extra_mac_registers", which is on by default. Setting it to off will
enable migration to older versions of QEMU, but will disable the read
and write access to the new registers, that were introduced since adding
the ability to migrate the entire MAC array.

Example for usage to enable backward compatibility and to disable the
new MAC registers:

    qemu-system-x86_64 -device e1000,extra_mac_registers=off,... ...

As mentioned above, the default value is "on".

Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Implementing various counters
Leonid Bloch [Wed, 11 Nov 2015 13:52:46 +0000 (15:52 +0200)]
e1000: Implementing various counters

This implements the following Statistic registers (various counters)
according to Intel's specs:

TSCTC  GOTCL  GOTCH  GORCL  GORCH  MPRC   BPRC   RUC    ROC
BPTC   MPTC   PTC... PRC...

PLEASE NOTE: these registers will not be active, nor will migrate, until
a compatibility flag will be set (in the next patch in this series).

Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Fixing the packet address filtering procedure
Leonid Bloch [Wed, 11 Nov 2015 13:52:45 +0000 (15:52 +0200)]
e1000: Fixing the packet address filtering procedure

Previously, if promiscuous unicast was enabled, a packet was received
straight away, even if it was a multicast or a broadcast packet. This
patch fixes that behavior, while making the filtering procedure a bit
more human-readable.

Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Fixing the received/transmitted octets' counters
Leonid Bloch [Wed, 11 Nov 2015 13:52:44 +0000 (15:52 +0200)]
e1000: Fixing the received/transmitted octets' counters

Previously, these 64-bit registers did not stick at their maximal
values when (and if) they reached them, as they should do, according to
the specs.

This patch introduces a function that takes care of such registers,
avoiding code duplication, making the relevant parts more compatible
with the QEMU coding style, while ensuring that in the unlikely case
of reaching the maximal value, the counter will stick there, as it
supposed to.

Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Fixing the received/transmitted packets' counters
Leonid Bloch [Wed, 11 Nov 2015 13:52:43 +0000 (15:52 +0200)]
e1000: Fixing the received/transmitted packets' counters

According to Intel's specs, these counters (as the other Statistic
registers) stick at 0xffffffff when this maximal value is reached.
Previously, they would reset after the max. value.

Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Trivial implementation of various MAC registers
Leonid Bloch [Wed, 11 Nov 2015 13:52:42 +0000 (15:52 +0200)]
e1000: Trivial implementation of various MAC registers

These registers appear in Intel's specs, but were not implemented.
These registers are now implemented trivially, i.e. they are initiated
with zero values, and if they are RW, they can be written or read by the
driver, or read only if they are R (essentially retaining their zero
values). For these registers no other procedures are performed.

For the trivially implemented Diagnostic registers, a debug warning is
produced on read/write attempts.

PLEASE NOTE: these registers will not be active, nor will migrate, until
a compatibility flag will be set (in a later patch in this series).

The registers implemented here are:

Transmit:
RW: AIT

Management:
RW: WUC     WUS     IPAV    IP6AT*  IP4AT*  FFLT*   WUPM*   FFMT*   FFVT*

Diagnostic:
RW: RDFH    RDFT    RDFHS   RDFTS   RDFPC   PBM*    TDFH    TDFT    TDFHS
    TDFTS   TDFPC

Statistic:
RW: FCRUC
R:  RNBC    TSCTFC  MGTPRC  MGTPDC  MGTPTC  RFC     RJC     SCC     ECOL
    LATECOL MCC     COLC    DC      TNCRS   SEC     CEXTERR RLEC    XONRXC
    XONTXC  XOFFRXC XOFFTXC

Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Introduced an array to control the access to the MAC registers
Leonid Bloch [Wed, 11 Nov 2015 13:52:41 +0000 (15:52 +0200)]
e1000: Introduced an array to control the access to the MAC registers

The array of uint8_t's which is introduced here, contains access metadata
about the MAC registers: if a register is accessible, but partly implemented,
or if a register requires a certain compatibility flag in order to be
accessed. Currently, 6 hypothetical flags are supported (3 exist for e1000
so far) but in the future, if more than 6 flags will be needed, the datatype
of this array can simply be swapped for a larger one.

This patch is intended to solve the following current problems:

1) In a scenario of migration between different versions of QEMU, which
differ by the MAC registers implemented in them, some registers need not to
be active if a compatibility flag is set, in order to preserve the machine's
state perfectly for the older version. Checking this for each register
individually, would create a lot of clutter in the code.

2) Some registers are (or may be) only partly implemented (e.g.
placeholders that allow reading and writing, but lack other functions).
In such cases it is better to print a debug warning on read/write attempts.
As above, dealing with this functionality on a per-register level, would
require longer and more messy code.

Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Add support for migrating the entire MAC registers' array
Leonid Bloch [Wed, 11 Nov 2015 13:52:40 +0000 (15:52 +0200)]
e1000: Add support for migrating the entire MAC registers' array

This patch makes the migration of the entire array of MAC registers
possible during live migration. The entire array is just 128 KB long, so
practically no penalty should be felt when transmitting it, additionally
to the previously transmitted individual registers. The advantage here is
eliminating the need to introduce new vmstate subsections in the future,
when additional MAC registers will be implemented.

Backward compatibility is preserved by introducing a e1000-specific
boolean parameter (in a later patch), which will be on by default.
Setting it to off would enable migration to older versions of QEMU.

Additionally, this parameter will be used to control the access to the
extra MAC registers in the future.

Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Cosmetic and alignment fixes
Leonid Bloch [Wed, 11 Nov 2015 13:52:39 +0000 (15:52 +0200)]
e1000: Cosmetic and alignment fixes

This fixes some alignment and cosmetic issues. The changes are made
in order that the following patches in this series will look like
integral parts of the code surrounding them, while conforming to the
coding style. Although some changes in unrelated areas are also made.

Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoslirp: Fix type casts and format strings in debug code
Stefan Weil [Sat, 29 Aug 2015 07:12:35 +0000 (09:12 +0200)]
slirp: Fix type casts and format strings in debug code

Casting pointers to long won't work on 64 bit Windows.
It is not needed with the right format strings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agomonitor/target-ppc: Define target_get_monitor_def
Alexey Kardashevskiy [Thu, 12 Nov 2015 03:44:23 +0000 (14:44 +1100)]
monitor/target-ppc: Define target_get_monitor_def

At the moment get_monitor_def() returns only registers from statically
defined monitor_defs array. However there is a lot of BOOK3S SPRs
which are not in the list and cannot be printed from the monitor.

This adds a new target platform hook - target_get_monitor_def().
The hook is called if a register was not found in the static
array returned by the target_monitor_defs() hook.

The hook is only defined for POWERPC, it returns registered
SPRs and fails on unregistered ones providing the user with information
on what is actually supported on the running CPU. The register value is
saved as uint64_t as it is the biggest supported register size;
target_ulong cannot be used because of the stub - it is in a "common"
code and cannot include "cpu.h", etc; this is also why the hook prototype
is redefined in the stub instead of being included from some header.

This replaces static descriptors for GPRs, FPRs, SRs with a helper which
looks for a value in a corresponding array in the CPUPPCState.
The immediate effect is that all 32 SRs can be printed now (instead of 16);
later this can be reused for VSX or TM registers.

This replaces callbacks for MSR and XER with static descriptors in
monitor_defs as they are stored in CPUPPCState.

While we are here, this adds "cr" as a synonym of "ccr".

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: add delay to setting of SR_INT bit
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:51 +0000 (22:49 +0000)]
cuda.c: add delay to setting of SR_INT bit

MacOS 9 is racy when it comes to accessing the shift register. Fix this by
introducing a small delay between data accesses and raising the SR_INT
interrupt bit.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: fix T2 timer and enable its interrupt
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:50 +0000 (22:49 +0000)]
cuda.c: fix T2 timer and enable its interrupt

Fix the counter loading logic and enable the T2 interrupt when the timer
expires. Otherwise MacOS 9 hangs on boot.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: rename get_counter() state variable from s to ti for consistency
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:49 +0000 (22:49 +0000)]
cuda.c: rename get_counter() state variable from s to ti for consistency

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: refactor get_tb() so that the time can be passed in
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:48 +0000 (22:49 +0000)]
cuda.c: refactor get_tb() so that the time can be passed in

This is in preparation for sharing the code between timers.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: add defines for CUDA registers
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:47 +0000 (22:49 +0000)]
cuda.c: add defines for CUDA registers

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: fix CUDA SR interrupt clearing
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:46 +0000 (22:49 +0000)]
cuda.c: fix CUDA SR interrupt clearing

Make sure that we also clear the data and clock interrupts at the same time.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: implement dummy IIC access commands
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:45 +0000 (22:49 +0000)]
cuda.c: implement dummy IIC access commands

These are used by MacOS 9 on boot. Here we return an error except for 4-byte
commands which write to the IIC bus in a similar manner to MOL.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: implement simple CUDA_GET_6805_ADDR command
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:44 +0000 (22:49 +0000)]
cuda.c: implement simple CUDA_GET_6805_ADDR command

This simply returns an empty response with no error status as implemented by
MOL to allow MacOS 9 boot to proceed further.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: fix CUDA_PACKET response packet format
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:43 +0000 (22:49 +0000)]
cuda.c: fix CUDA_PACKET response packet format

According to comments in MOL, the response to a CUDA_PACKET should be one of
the following:

Reply: (CUDA_PACKET, status, cmd)
Error: (ERROR_PACKET, status, CUDA_PACKET, cmd)

Update cuda_receive_packet() accordingly to reflect this in order to make
MacOS 9 happy.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agocuda.c: fix CUDA ADB error packet format
Mark Cave-Ayland [Wed, 11 Nov 2015 22:49:42 +0000 (22:49 +0000)]
cuda.c: fix CUDA ADB error packet format

According to MOL, ADB error packets should be of the form (type, status, cmd)
rather than just (type, status). This fixes ADB device detection under MacOS 9.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoPPC: mac99: Always add USB controller
Alexander Graf [Wed, 11 Nov 2015 22:49:41 +0000 (22:49 +0000)]
PPC: mac99: Always add USB controller

The mac99 machines always have a USB controller. Usually not having one around
doesn't hurt quite as much, but Mac OS 9 really really wants one or it crashes
on bootup.

So always add OHCI to make it happy.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoPPC: Fix lswx bounds checks
Alexander Graf [Wed, 11 Nov 2015 22:49:40 +0000 (22:49 +0000)]
PPC: Fix lswx bounds checks

The lswx instruction checks whether the desired string actually fits
into all defined registers. Unfortunately it does the calculation wrong,
resulting in illegal instruction traps for loads that really should fit.

Fix it up, making Mac OS happier.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoPPC: Allow Rc bit to be set on mtspr
Alexander Graf [Wed, 11 Nov 2015 22:49:39 +0000 (22:49 +0000)]
PPC: Allow Rc bit to be set on mtspr

According to the ISA setting the Rc bit on mtspr is undefined behavior.
Real 750 hardware simply ignores the bit and doesn't touch cr0 though.

Unfortunately, Mac OS 9 relies on this fact and executes a few mtspr
instructions (to set XER for example) with Rc set.

So let's handle the bit the same way hardware does and ignore it.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoMerge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging
Peter Maydell [Wed, 11 Nov 2015 23:20:07 +0000 (23:20 +0000)]
Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging

# gpg: Signature made Wed 11 Nov 2015 17:59:33 GMT using RSA key ID C0DE3057
# gpg: Good signature from "Jeffrey Cody <jcody@redhat.com>"
# gpg:                 aka "Jeffrey Cody <jeff@codyprime.org>"
# gpg:                 aka "Jeffrey Cody <codyprime@gmail.com>"

* remotes/cody/tags/block-pull-request:
  gluster: allocate GlusterAIOCBs on the stack

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20151111' into staging
Peter Maydell [Wed, 11 Nov 2015 18:23:08 +0000 (18:23 +0000)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20151111' into staging

Hopefully last big batch of s390x patches, including:
- bugfixes for LE host and for pci translation
- MAINTAINERS update
- hugetlbfs enablement (kernel patches pending)
- boot from El Torito iso images on virtio-blk
  (boot from scsi pending)
- cleanup in the ipl device code

There's also a helper function for resetting busless devices in the
qdev core in there.

# gpg: Signature made Wed 11 Nov 2015 17:49:58 GMT using RSA key ID C6F02FAF
# gpg: Good signature from "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"

* remotes/cohuck/tags/s390x-20151111:
  s390: deprecate the non-ccw machine in 2.5
  s390x/ipl: switch error reporting to error_setg
  s390x/ipl: clean up qom definitions and turn into TYPE_DEVICE
  qdev: provide qdev_reset_all_fn()
  pc-bios/s390-ccw: rebuild image
  pc-bios/s390-ccw: El Torito 16-bit boot image size field workaround
  pc-bios/s390-ccw: El Torito s390x boot entry check
  pc-bios/s390-ccw: ISO-9660 El Torito boot implementation
  pc-bios/s390-ccw: Always adjust virtio sector count
  s390x/kvm: don't enable CMMA when hugetlbfs will be used
  s390x: switch to memory_region_allocate_system_memory
  MAINTAINERS: update virtio-ccw/s390 git tree
  MAINTAINERS: update s390 file patterns
  s390x/pci : fix up s390 pci iommu translation function
  s390x/css: sense data endianness

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoerror: More error_setg() usage
Eric Blake [Wed, 11 Nov 2015 06:51:20 +0000 (23:51 -0700)]
error: More error_setg() usage

A few uses of error_set(ERROR_CLASS_GENERIC_ERROR) were missed in
c6bd8c706, or have snuck in since.  Nuke them.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447224690-9743-19-git-send-email-eblake@redhat.com>
Acked-by: Andreas Färber <afaerber@suse.de>
[Indentation tidied up, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Wed, 11 Nov 2015 16:43:19 +0000 (16:43 +0000)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches

# gpg: Signature made Wed 11 Nov 2015 16:03:19 GMT using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream: (41 commits)
  iotests: Check for quorum support in test 139
  qcow2: Fix qcow2_get_cluster_offset() for zero clusters
  iotests: Add tests for the x-blockdev-del command
  block: Add 'x-blockdev-del' QMP command
  block: Add blk_get_refcnt()
  mirror: block all operations on the target image during the job
  qemu-iotests: fix -valgrind option for check
  qemu-iotests: fix cleanup of background processes
  qemu-io: Correct error messages
  qemu-io: Check for trailing chars
  qemu-io: fix cvtnum lval types
  block: test 'blockdev-snapshot' using a file BDS as the overlay
  block: Remove inner quotation marks in iotest 085
  block: Disallow snapshots if the overlay doesn't support backing files
  throttle: Use bs->throttle_state instead of bs->io_limits_enabled
  throttle: Check for pending requests in throttle_group_unregister_bs()
  qemu-img: add check for zero-length job len
  qcow2: avoid misaligned 64bit bswap
  qemu-iotests: Test the reopening of overlay_bs in 'block-commit'
  commit: reopen overlay_bs before base
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agos390: deprecate the non-ccw machine in 2.5
Christian Borntraeger [Fri, 6 Nov 2015 12:07:25 +0000 (13:07 +0100)]
s390: deprecate the non-ccw machine in 2.5

The non-ccw machine for s390 (s390-virtio) is not very well maintained
and caused several issues in the past:
- aliases like virtio-blk did not work for s390
- virtio refactoring failed due to long standing bugs (e.g.see
commit cb927b8a "s390-virtio: Accommodate guests using virtqueues too early")
- some features like memory hotplug will cause trouble due to virtio storage
  being above guest memory
- the boot loader bios no longer seems to work. the source code of that
  loader is also no longer maintained

2.4 changed the default to the ccw machine, let's deprecate the old
machine for 2.5.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Message-Id: <1446811645-25565-1-git-send-email-borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x/ipl: switch error reporting to error_setg
David Hildenbrand [Thu, 8 Oct 2015 10:33:28 +0000 (12:33 +0200)]
s390x/ipl: switch error reporting to error_setg

Now that we can report errors in the realize function, let's replace
the fprintf's and hw_error's with error_setg.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x/ipl: clean up qom definitions and turn into TYPE_DEVICE
David Hildenbrand [Thu, 8 Oct 2015 10:32:13 +0000 (12:32 +0200)]
s390x/ipl: clean up qom definitions and turn into TYPE_DEVICE

Let's move the qom definitions of the ipl device into ipl.h, replace
"s390-ipl" by a proper type define, turn it into a TYPE_DEVICE
and remove the unneeded class definition.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agoqdev: provide qdev_reset_all_fn()
David Hildenbrand [Tue, 21 Jul 2015 06:32:07 +0000 (08:32 +0200)]
qdev: provide qdev_reset_all_fn()

For TYPE_DEVICE, the dc->reset() function is not called on system resets
yet. Until that is changed, we have to manually register a reset handler.
Let's provide qdev_reset_all_fn(), that can directly be used - just like
the reset handler that is already available for qbus.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agopc-bios/s390-ccw: rebuild image
Cornelia Huck [Thu, 5 Nov 2015 12:47:38 +0000 (13:47 +0100)]
pc-bios/s390-ccw: rebuild image

Contains:
  pc-bios/s390-ccw: Always adjust virtio sector count
  pc-bios/s390-ccw: ISO-9660 El Torito boot implementation
  pc-bios/s390-ccw: El Torito s390x boot entry check
  pc-bios/s390-ccw: El Torito 16-bit boot image size field workaround

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agopc-bios/s390-ccw: El Torito 16-bit boot image size field workaround
Maxim Samoylov [Mon, 12 Oct 2015 15:50:20 +0000 (17:50 +0200)]
pc-bios/s390-ccw: El Torito 16-bit boot image size field workaround

Because of El Torito spec flaw boot image size needs to be verified.

Boot catalog entry size field has 16-bit width, and specifies size
in 512-byte units.

Thus, boot image size cannot exceed 32M.

We actually search for the file to get the file size.

This is done by scanning the ISO directory tree for the ISO block number
and reading the file size from the directory entry.

Signed-off-by: Maxim Samoylov <max7255@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agopc-bios/s390-ccw: El Torito s390x boot entry check
Maxim Samoylov [Mon, 12 Oct 2015 15:50:20 +0000 (17:50 +0200)]
pc-bios/s390-ccw: El Torito s390x boot entry check

Boot entry is considered compatible if boot image is Linux kernel
with matching S390 Linux magic string.

Empty boot images with sector_count == 0 are considered broken.

Signed-off-by: Maxim Samoylov <max7255@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agopc-bios/s390-ccw: ISO-9660 El Torito boot implementation
Maxim Samoylov [Mon, 12 Oct 2015 15:50:20 +0000 (17:50 +0200)]
pc-bios/s390-ccw: ISO-9660 El Torito boot implementation

This patch enables boot from media formatted according to
ISO-9660 and El Torito bootable CD specification.

We try to boot from device as ISO-9660 media when SCSI IPL failed.

The first boot catalog entry with bootable flag is used.

ISO-9660 media with default 2048-bytes sector size only is supported.

Signed-off-by: Maxim Samoylov <max7255@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agopc-bios/s390-ccw: Always adjust virtio sector count
Maxim Samoylov [Mon, 12 Oct 2015 15:50:20 +0000 (17:50 +0200)]
pc-bios/s390-ccw: Always adjust virtio sector count

Let's always adjust the sector number to be read using the current
virtio block size value.

This prepares for the implementation of IPL from ISO-9660 media.

Signed-off-by: Maxim Samoylov <max7255@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x/kvm: don't enable CMMA when hugetlbfs will be used
Dominik Dingel [Tue, 11 Aug 2015 09:12:12 +0000 (11:12 +0200)]
s390x/kvm: don't enable CMMA when hugetlbfs will be used

On hugetlbfs CMMA will not be useful as every ESSA instruction will trap.
So don't offer CMMA to guests with a hugepages backing.

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: switch to memory_region_allocate_system_memory
Dominik Dingel [Tue, 12 May 2015 11:21:30 +0000 (13:21 +0200)]
s390x: switch to memory_region_allocate_system_memory

By replacing memory_region_init_ram with memory_region_allocate_system_memory
we gain goodies like mem-path backends. This will allow us to use hugetlbfs
once the kernel supports it.

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agoMAINTAINERS: update virtio-ccw/s390 git tree
Cornelia Huck [Wed, 4 Nov 2015 15:08:20 +0000 (16:08 +0100)]
MAINTAINERS: update virtio-ccw/s390 git tree

Let's reference the git branch I actually use, and add Christian's
git tree.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agoMAINTAINERS: update s390 file patterns
Cornelia Huck [Wed, 4 Nov 2015 14:59:55 +0000 (15:59 +0100)]
MAINTAINERS: update s390 file patterns

We were missing some files, and some files should get an additional
entry to add the people actually looking after the code.

Reported-by: Thomas Huth <thuth@redhat.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x/pci : fix up s390 pci iommu translation function
Yi Min Zhao [Wed, 28 Oct 2015 03:30:23 +0000 (11:30 +0800)]
s390x/pci : fix up s390 pci iommu translation function

On s390x, each pci device has its own iommu, which is only properly
setup in qemu once the mpcifc instruction used to register the
translation table has been intercepted. Therefore, for a pci device that
is not configured or has not been initialized, proper translation is
neither required nor possible. Moreover, we may not have a host bridge
device ready yet.

This was exposed by a recent vfio change that triggers iommu translation
during the initialization of the vfio pci device. Let's do an early exit
in that case.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x/css: sense data endianness
Cornelia Huck [Wed, 4 Nov 2015 17:40:54 +0000 (18:40 +0100)]
s390x/css: sense data endianness

We keep the device's sense data in a byte array (following the
architecture), but the ecws are an array of 32 bit values. If we
just blindly copy the values, the sense data will change from
de-facto BE data to de-facto cpu-endian data, which means we end
up doing an incorrect conversion on LE hosts.

Let's just explicitly convert to cpu-endianness while assembling
the irb.

Reported-by: Andy Lutomirski <luto@kernel.org>
Tested-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
8 years agoqga: fix append file open modes for win32
Kirk Allan [Tue, 10 Nov 2015 23:19:11 +0000 (16:19 -0700)]
qga: fix append file open modes for win32

For append file open modes, use FILE_APPEND_DATA for the desired access
for writing at the end of the file.

Version 2:
For "a+", "ab+", and "a+b" modes use FILE_APPEND_DATA|GENERIC_READ.
ORing in GENERIC_READ starts a read at the begining of the file.  All
writes will append to the end fo the file.

Added white space to maintain the alignment of the guest_file_open_modes[].

Signed-off-by: Kirk Allan <kallan@suse.com>
Cc: qemu-stable@nongnu.org
* use FILE_GENERIC_APPEND macro, which provides same semantics as
  FILE_APPEND_DATA, but retains other flags from GENERIC_WRITE
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoMerge remote-tracking branch 'mreitz/tags/pull-block-for-kevin-2015-11-11' into queue...
Kevin Wolf [Wed, 11 Nov 2015 16:02:02 +0000 (17:02 +0100)]
Merge remote-tracking branch 'mreitz/tags/pull-block-for-kevin-2015-11-11' into queue-block

Block patches from 2015-10-26 until 2015-11-11.

# gpg: Signature made Wed Nov 11 17:00:50 2015 CET using RSA key ID E838ACAD
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>"

* mreitz/tags/pull-block-for-kevin-2015-11-11:
  iotests: Check for quorum support in test 139
  qcow2: Fix qcow2_get_cluster_offset() for zero clusters
  iotests: Add tests for the x-blockdev-del command
  block: Add 'x-blockdev-del' QMP command
  block: Add blk_get_refcnt()
  mirror: block all operations on the target image during the job
  qemu-iotests: fix -valgrind option for check
  qemu-iotests: fix cleanup of background processes

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoiotests: Check for quorum support in test 139
Alberto Garcia [Tue, 10 Nov 2015 16:28:11 +0000 (18:28 +0200)]
iotests: Check for quorum support in test 139

The quorum driver is always built in, but it is disabled during
run-time if there's no SHA256 support available (see commit e94867e).

This patch skips the quorum test in iotest 139 in that case.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: 1447172891-20410-1-git-send-email-berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoqcow2: Fix qcow2_get_cluster_offset() for zero clusters
Kevin Wolf [Wed, 4 Nov 2015 17:16:24 +0000 (18:16 +0100)]
qcow2: Fix qcow2_get_cluster_offset() for zero clusters

When searching for contiguous zero clusters, we only need to check the
cluster type. Before this patch, an increasing offset (L2E_OFFSET_MASK)
was expected, so that the function never returned more than a single
zero cluster in practice. This patch fixes it to actually return as many
contiguous zero clusters as it can.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1446657384-5907-1-git-send-email-kwolf@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoiotests: Add tests for the x-blockdev-del command
Alberto Garcia [Mon, 2 Nov 2015 14:51:56 +0000 (16:51 +0200)]
iotests: Add tests for the x-blockdev-del command

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: 57c3b0d4d0c73ddadd19e5bded9492c359cc4568.1446475331.git.berto@igalia.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Add 'x-blockdev-del' QMP command
Alberto Garcia [Mon, 2 Nov 2015 14:51:55 +0000 (16:51 +0200)]
block: Add 'x-blockdev-del' QMP command

This command is still experimental, hence the name.

This is the companion to 'blockdev-add'. It allows deleting a
BlockBackend with its associated BlockDriverState tree, or a
BlockDriverState that is not attached to any backend.

In either case, the command fails if the reference count is greater
than 1 or the BlockDriverState has any parents.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 6cfc148c77aca1da942b094d811bfa3fcf7ac7bb.1446475331.git.berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Add blk_get_refcnt()
Alberto Garcia [Mon, 2 Nov 2015 14:51:54 +0000 (16:51 +0200)]
block: Add blk_get_refcnt()

This function returns the reference count of a given BlockBackend.
For convenience, it returns 0 if the BlockBackend pointer is NULL.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: dfdd8a17dbe3288842840636d2cfe5bb895abcb0.1446475331.git.berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agomirror: block all operations on the target image during the job
Alberto Garcia [Mon, 2 Nov 2015 14:51:53 +0000 (16:51 +0200)]
mirror: block all operations on the target image during the job

There's nothing preventing the target image from being used by other
operations during the 'drive-mirror' job, so we should block them all
until the job is done.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 82b88fd04cde918a08a6f9a4ab85626d7fd7b502.1446475331.git.berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-iotests: fix -valgrind option for check
Jeff Cody [Fri, 30 Oct 2015 19:25:18 +0000 (15:25 -0400)]
qemu-iotests: fix -valgrind option for check

Commit 934659c switched the iotests to run qemu-io from a bash subshell,
in order to catch segfaults.  This method is incompatible with the
current valgrind_qemu_io() bash function.

Move the valgrind usage into the exec subshell in _qemu_io_wrapper(),
while making sure the original return value is passed back to the
caller.

Update test output for tests 039, 061, and 137 as it looks for the
specific subshell command when the process is terminated.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Message-id: 0066fd85d26ca641a1c25135ff2479b7985701cf.1446232490.git.jcody@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-iotests: fix cleanup of background processes
Jeff Cody [Fri, 30 Oct 2015 19:25:17 +0000 (15:25 -0400)]
qemu-iotests: fix cleanup of background processes

Commit 934659c switched the iotests to run qemu and qemu-nbd from a bash
subshell, in order to catch segfaults.  Unfortunately, this means the
process PID cannot be captured via '$!'. We stopped killing qemu and
qemu-nbd processes, leaving a lot of orphaned, running qemu processes
after executing iotests.

Since the process is using exec in the subshell, the PID is the
same as the subshell PID.

Track these PIDs for cleanup using pidfiles in the $TEST_DIR. Only
track the qemu PID, however, if requested - not all usage requires
killing the process.

Reported-by: John Snow <jsnow@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Message-id: 9e4f958b3895b7259b98d845bb46f000ba362869.1446232490.git.jcody@redhat.com
[mreitz@redhat.com: Replaced '! -z "..."' by '-n "..."']
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agogluster: allocate GlusterAIOCBs on the stack
Paolo Bonzini [Thu, 1 Oct 2015 11:04:38 +0000 (13:04 +0200)]
gluster: allocate GlusterAIOCBs on the stack

This is simpler now that the driver has been converted to coroutines.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-io: Correct error messages
John Snow [Thu, 5 Nov 2015 23:53:04 +0000 (18:53 -0500)]
qemu-io: Correct error messages

Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-io: Check for trailing chars
John Snow [Thu, 5 Nov 2015 23:53:03 +0000 (18:53 -0500)]
qemu-io: Check for trailing chars

Make sure there's not trailing garbage, e.g.
"64k-whatever-i-want-here"

Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-io: fix cvtnum lval types
John Snow [Thu, 5 Nov 2015 23:53:02 +0000 (18:53 -0500)]
qemu-io: fix cvtnum lval types

cvtnum() returns int64_t: we should not be storing this
result inside of an int.

In a few cases, we need an extra sprinkling of error handling
where we expect to pass this number on towards a function that
expects something smaller than int64_t.

Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: test 'blockdev-snapshot' using a file BDS as the overlay
Alberto Garcia [Tue, 3 Nov 2015 10:32:37 +0000 (12:32 +0200)]
block: test 'blockdev-snapshot' using a file BDS as the overlay

This test checks that it is not possible to create a snapshot if the
requested overlay node is a BDS which does not support backing images.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Remove inner quotation marks in iotest 085
Alberto Garcia [Tue, 3 Nov 2015 10:32:36 +0000 (12:32 +0200)]
block: Remove inner quotation marks in iotest 085

This patch removes the inner quotation marks in all cases like this:

   cmd=" ... "${variable}" ... "

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Disallow snapshots if the overlay doesn't support backing files
Alberto Garcia [Tue, 3 Nov 2015 10:32:35 +0000 (12:32 +0200)]
block: Disallow snapshots if the overlay doesn't support backing files

This addresses scenarios like this one:

  { 'execute': 'blockdev-add', 'arguments':
    { 'options': { 'driver': 'qcow2',
                   'node-name': 'new0',
                   'file': { 'driver': 'file',
                             'filename': 'new.qcow2',
                             'node-name': 'file0' } } } }

  { 'execute': 'blockdev-snapshot', 'arguments':
    { 'node': 'virtio0',
      'overlay': 'file0' } }

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agothrottle: Use bs->throttle_state instead of bs->io_limits_enabled
Alberto Garcia [Wed, 4 Nov 2015 13:15:36 +0000 (15:15 +0200)]
throttle: Use bs->throttle_state instead of bs->io_limits_enabled

There are two ways to check for I/O limits in a BlockDriverState:

- bs->throttle_state: if this pointer is not NULL, it means that this
  BDS is member of a throttling group, its ThrottleTimers structure
  has been initialized and its I/O limits are ready to be applied.

- bs->io_limits_enabled: if true it means that the throttle_state
  pointer is valid _and_ the limits are currently enabled.

The latter is used in several places to check whether a BDS has I/O
limits configured, but what it really checks is whether requests
are being throttled or not. For example, io_limits_enabled can be
temporarily set to false in cases like bdrv_read_unthrottled() without
otherwise touching the throtting configuration of that BDS.

This patch replaces bs->io_limits_enabled with bs->throttle_state in
all cases where what we really want to check is the existence of I/O
limits, not whether they are currently enabled or not.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agothrottle: Check for pending requests in throttle_group_unregister_bs()
Alberto Garcia [Wed, 4 Nov 2015 13:15:35 +0000 (15:15 +0200)]
throttle: Check for pending requests in throttle_group_unregister_bs()

throttle_group_unregister_bs() removes a BlockDriverState from its
throttling group and destroys the timers. This means that there must
be no pending throttled requests at that point (because it would be
impossible to complete them), so the caller has to drain them first.

At the moment throttle_group_unregister_bs() is only called from
bdrv_io_limits_disable(), which already takes care of draining the
requests, so there's nothing to worry about, but this patch makes
this invariant explicit in the documentation and adds the relevant
assertions.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-img: add check for zero-length job len
John Snow [Mon, 2 Nov 2015 23:28:20 +0000 (18:28 -0500)]
qemu-img: add check for zero-length job len

The mirror job doesn't update its total length until
it has already started running, so we should translate
a zero-length job-len as meaning 0%.

Otherwise, we may get divide-by-zero faults.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqcow2: avoid misaligned 64bit bswap
John Snow [Mon, 2 Nov 2015 23:32:06 +0000 (18:32 -0500)]
qcow2: avoid misaligned 64bit bswap

If we create a buffer directly on the stack by using 12 bytes, there's
no guarantee the 64bit value we want to swap will be aligned, which
could cause errors with undefined behavior.

Spotted with clang -fsanitize=undefined and observed in iotests 15, 26,
44, 115 and 121.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-iotests: Test the reopening of overlay_bs in 'block-commit'
Alberto Garcia [Wed, 28 Oct 2015 13:43:50 +0000 (15:43 +0200)]
qemu-iotests: Test the reopening of overlay_bs in 'block-commit'

The 'block-commit' command needs the overlay image of 'top' to
be opened in read-write mode in order to update the backing file
string. If 'top' is not the active layer or its backing file then its
overlay needs to be reopened during the block job.

This is a test case for that scenario.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agocommit: reopen overlay_bs before base
Alberto Garcia [Wed, 28 Oct 2015 13:43:49 +0000 (15:43 +0200)]
commit: reopen overlay_bs before base

'block-commit' needs write access to two different nodes of the chain:

- 'base', because that's where the data is written to.
- the overlay of 'top', because it needs to update the backing file
  string to point to 'base' after the operation.

Both images have to be opened in read-write mode, and commit_start()
takes care of reopening them if necessary.

With the current implementation, however, when overlay_bs is reopened
in read-write mode it has the side effect of making 'base' read-only
again, eventually making 'block-commit' fail.

This needs to be fixed in bdrv_reopen(), but until we get to that it
can be worked around simply by swapping the order of base and
overlay_bs in the reopen queue.

In order to reproduce this bug, overlay_bs needs to be initially in
read-only mode. That is: the 'top' parameter of 'block-commit' cannot
be the active layer nor its immediate backing chain.

Cc: qemu-stable@nongnu.org
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: add tests for the 'blockdev-snapshot' command
Alberto Garcia [Mon, 26 Oct 2015 12:27:17 +0000 (14:27 +0200)]
block: add tests for the 'blockdev-snapshot' command

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: add a 'blockdev-snapshot' QMP command
Alberto Garcia [Mon, 26 Oct 2015 12:27:16 +0000 (14:27 +0200)]
block: add a 'blockdev-snapshot' QMP command

One of the limitations of the 'blockdev-snapshot-sync' command is that
it does not allow passing BlockdevOptions to the newly created
snapshots, so they are always opened using the default values.

Extending the command to allow passing options is not a practical
solution because there is overlap between those options and some of
the existing parameters of the command.

This patch introduces a new 'blockdev-snapshot' command with a simpler
interface: it just takes two references to existing block devices that
will be used as the source and target for the snapshot.

Since the main difference between the two commands is that one of them
creates and opens the target image, while the other uses an already
opened one, the bulk of the implementation is shared.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: support passing 'backing': '' to 'blockdev-add'
Alberto Garcia [Mon, 26 Oct 2015 12:27:15 +0000 (14:27 +0200)]
block: support passing 'backing': '' to 'blockdev-add'

Passing an empty string allows opening an image but not its backing
file. This was already described in the API documentation, only the
implementation was missing.

This is useful for creating snapshots using images opened with
blockdev-add, since they are not supposed to have a backing image
before the operation.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: rename BlockdevSnapshot to BlockdevSnapshotSync
Alberto Garcia [Mon, 26 Oct 2015 12:27:14 +0000 (14:27 +0200)]
block: rename BlockdevSnapshot to BlockdevSnapshotSync

We will introduce the 'blockdev-snapshot' command that will require
its own struct for the parameters, so we need to rename this one in
order to avoid name clashes.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: check for existing device IDs in external_snapshot_prepare()
Alberto Garcia [Mon, 26 Oct 2015 12:27:13 +0000 (14:27 +0200)]
block: check for existing device IDs in external_snapshot_prepare()

The 'snapshot-node-name' parameter of blockdev-snapshot-sync allows
setting the node name of the image that is going to be created.

Before creating the image, external_snapshot_prepare() checks that the
name is not already being used. The check is however incomplete since
it only considers existing node names, but node names must not clash
with device IDs either because they share the same namespace.

If the user attempts to create a snapshot using the name of an
existing device for the 'snapshot-node-name' parameter the operation
will eventually fail, but only after the new image has been created.

This patch replaces bdrv_find_node() with bdrv_lookup_bs() to extend
the check to existing device IDs, and thus detect possible name
clashes before the new image is created.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoiotests: Add test for change-related QMP commands
Max Reitz [Mon, 26 Oct 2015 20:39:19 +0000 (21:39 +0100)]
iotests: Add test for change-related QMP commands

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agohmp: Add read-only-mode option to change command
Max Reitz [Mon, 26 Oct 2015 20:39:18 +0000 (21:39 +0100)]
hmp: Add read-only-mode option to change command

Expose the new read-only-mode option of 'blockdev-change-medium' for the
'change' HMP command.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblockdev: read-only-mode for blockdev-change-medium
Max Reitz [Wed, 11 Nov 2015 03:49:44 +0000 (04:49 +0100)]
blockdev: read-only-mode for blockdev-change-medium

Add an option to qmp_blockdev_change_medium() which allows changing the
read-only status of the block device whose medium is changed.

Some drives do not have a inherently fixed read-only status; for
instance, floppy disks can be set read-only or writable independently of
the drive. Some users may find it useful to be able to therefore change
the read-only status of a block device when changing the medium.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agohmp: Use blockdev-change-medium for change command
Max Reitz [Mon, 26 Oct 2015 20:39:16 +0000 (21:39 +0100)]
hmp: Use blockdev-change-medium for change command

Use separate code paths for the two overloaded functions of the 'change'
HMP command, and invoke the 'blockdev-change-medium' QMP command if used
on a block device (by calling qmp_blockdev_change_medium()).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqmp: Introduce blockdev-change-medium
Max Reitz [Fri, 6 Nov 2015 15:27:06 +0000 (16:27 +0100)]
qmp: Introduce blockdev-change-medium

Introduce a new QMP command 'blockdev-change-medium' which is intended
to replace the 'change' command for block devices. The existing function
qmp_change_blockdev() is accordingly renamed to
qmp_blockdev_change_medium().

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Inquire tray state before tray-moved events
Max Reitz [Mon, 26 Oct 2015 20:39:14 +0000 (21:39 +0100)]
block: Inquire tray state before tray-moved events

blk_dev_change_media_cb() is called for all potential tray movements;
however, it is possible to request closing the tray but nothing actually
happening (on a floppy disk drive without a medium).

Thus, the actual tray status should be inquired before sending a
tray-moved event (and an event should be sent whenever the status
changed).

Checking @load is now superfluous; it was necessary because it was
possible to change a medium without having explicitly opened the tray
and closed it again (or it might have been possible, at least). This is
no longer possible, though.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblockdev: Implement change with basic operations
Max Reitz [Mon, 26 Oct 2015 20:39:13 +0000 (21:39 +0100)]
blockdev: Implement change with basic operations

Implement 'change' on block devices by calling blockdev-open-tray,
blockdev-remove-medium, blockdev-insert-medium (a variation of that
which does not need a node-name) and blockdev-close-tray.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>