[Qemu-block] [PATCH v3 39/44] nbd: Implement NBD_OPT_GO on server

2016-04-22 Thread Eric Blake
NBD_OPT_EXPORT_NAME is lousy: it requires us to close the connection rather than report an error. Upstream NBD recently added NBD_OPT_GO as the improved version of the option that does what we want, along with NBD_OPT_INFO that returns the same information but does not transition to transmission

[Qemu-block] [PATCH v3 41/44] nbd: Implement NBD_CMD_WRITE_ZEROES on server

2016-04-22 Thread Eric Blake
Upstream NBD protocol recently added the ability to efficiently write zeroes without having to send the zeroes over the wire, along with a flag to control whether the client wants a hole. Signed-off-by: Eric Blake --- v3: abandon NBD_CMD_CLOSE extension, rebase to use

[Qemu-block] [PATCH v3 30/44] nbd: Treat flags vs. command type as separate fields

2016-04-22 Thread Eric Blake
Current upstream NBD documents that requests have a 16-bit flags, followed by a 16-bit type integer; although older versions mentioned only a 32-bit field with masking to find flags. Since the protocol is in network order (big-endian over the wire), the ABI is unchanged; but dealing with the

[Qemu-block] [PATCH v3 34/44] nbd: Less allocation during NBD_OPT_LIST

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

[Qemu-block] [PATCH v3 40/44] nbd: Implement NBD_OPT_GO on client

2016-04-22 Thread Eric Blake
NBD_OPT_EXPORT_NAME is lousy: it doesn't have any sane error reporting. Upstream NBD recently added NBD_OPT_GO as the improved version of the option that does what we want: it reports sane errors on failures (including when a server requires TLS but does not have NBD_OPT_GO!), and on success it

[Qemu-block] [PATCH v3 33/44] nbd: Let client skip portions of server reply

2016-04-22 Thread Eric Blake
The server has a nice helper function nbd_negotiate_drop_sync() which lets it easily ignore fluff from the client (such as the payload to an unknown option request). We can't quite make it common, since it depends on nbd_negotiate_read() which handles coroutine magic, but we can copy the idea

[Qemu-block] [PATCH v3 38/44] block: Add blk_get_opt_transfer_length()

2016-04-22 Thread Eric Blake
The NBD protocol would like to advertise the optimal I/O size to the client; but it would be a layering violation to peek into blk_bs(blk)->bl, when we only have a BB. I just copied the existing blk_get_max_transfer_length() in reading a value from the top BDS; I have no idea if

[Qemu-block] [PATCH v3 43/44] nbd: Implement NBD_OPT_BLOCK_SIZE on server

2016-04-22 Thread Eric Blake
The upstream NBD Protocol has defined a new extension to allow the server to advertise block sizes to the client, as well as a way for the client to inform the server that it intends to obey block sizes. Thanks to a recent fix, our minimum transfer size is always 1 (the block layer takes care of

[Qemu-block] [PATCH v3 35/44] nbd: Support shorter handshake

2016-04-22 Thread Eric Blake
The NBD Protocol allows the server and client to mutually agree on a shorter handshake (omit the 124 bytes of reserved 0), via the server advertising NBD_FLAG_NO_ZEROES and the client acknowledging with NBD_FLAG_C_NO_ZEROES (only possible in newstyle, whether or not it is fixed newstyle). It

[Qemu-block] [PATCH v3 36/44] nbd: Improve handling of shutdown requests

2016-04-22 Thread Eric Blake
NBD commit 6d34500b clarified how clients and servers are supposed to behave before closing a connection. It added NBD_REP_ERR_SHUTDOWN (for the server to announce it is about to go away during option haggling, so the client should quit sending NBD_OPT_* other than NBD_OPT_ABORT) and ESHUTDOWN

[Qemu-block] [PATCH v3 27/44] nbd: Use BDRV_REQ_FUA for better FUA where supported

2016-04-22 Thread Eric Blake
Rather than always flushing ourselves, let the block layer forward the FUA on to the underlying device - where all layers understand FUA, we are now more efficient; and where the underlying layer doesn't understand it, now the block layer takes care of the full flush fallback on our behalf.

[Qemu-block] [PATCH v3 20/44] block: Switch blk_read_unthrottled() to byte interface

2016-04-22 Thread Eric Blake
Sector-based blk_read() should die; convert the one-off variant blk_read_unthrottled(). Signed-off-by: Eric Blake --- include/sysemu/block-backend.h | 4 ++-- block/block-backend.c | 8 hw/block/hd-geometry.c | 2 +- 3 files changed, 7 insertions(+),

[Qemu-block] [PATCH v3 29/44] nbd: Avoid magic number for NBD max name size

2016-04-22 Thread Eric Blake
Declare a constant and use that when determining if an export name fits within the constraints we are willing to support. Note that upstream NBD recently documented that clients MUST support export names of 256 bytes (not including trailing NUL), and SHOULD support names up to 4096 bytes. 4096

[Qemu-block] [PATCH v3 28/44] nbd: Detect servers that send unexpected error values

2016-04-22 Thread Eric Blake
Add some debugging to flag servers that are not compliant to the NBD protocol. This would have flagged the server bug fixed in commit c0301fcc. Signed-off-by: Eric Blake Reviewed-by: Alex Bligh --- v3: later in series, but no change --- nbd/client.c | 4

[Qemu-block] [PATCH v3 24/44] qemu-io: Add 'write -f' to test FUA flag

2016-04-22 Thread Eric Blake
Make it easier to test block drivers with BDRV_REQ_FUA in .supported_write_flags, by adding a flag to qemu-io to conditionally pass the flag through to specific writes. You'll want to use 'qemu-io -t none' to actually make -f useful (as otherwise, the default writethrough mode automatically sets

[Qemu-block] [PATCH v3 23/44] qemu-io: Add missing option documentation

2016-04-22 Thread Eric Blake
Commit 499afa2 added --image-opts, but forgot to document it in --help. Likewise for commit 9e8f183 and -d/--discard. Finally, commit 10d9d75 removed -g/--growable, but forgot to cull it from the valid short options. Signed-off-by: Eric Blake --- qemu-io.c | 4 +++- 1 file

[Qemu-block] [PATCH v3 25/44] qemu-io: Add 'open -u' to set BDRV_O_UNMAP after the fact

2016-04-22 Thread Eric Blake
When opening a file from the command line, qemu-io defaults to BDRV_O_UNMAP but allows -d to give full control to disable unmaps. But when opening via the 'open' command, qemu-io did not set BDRV_O_UNMAP, and had no way to allow it. Make it at least possible to symmetrically test things: 'qemu-io

[Qemu-block] [PATCH v3 19/44] qemu-io: Switch to byte-based block access

2016-04-22 Thread Eric Blake
blk_write() and blk_read() are now very simple wrappers around blk_pwrite() and blk_pread(). There's no reason to require the user to pass in aligned numbers. Keep 'read -p' and 'write -p' so that I don't have to hunt down and update all users of qemu-io, but make the default 'read' and 'write'

[Qemu-block] [PATCH v3 22/44] block: Kill blk_write(), blk_read()

2016-04-22 Thread Eric Blake
Now that there are no remaining clients, we can drop these functions, to ensure that all future users get the byte-based interfaces. Sadly, there are still remaining sector-based interfaces, such as blk_aio_writev; those will have to wait for another day. Signed-off-by: Eric Blake

[Qemu-block] [PATCH v3 21/44] block: Switch blk_write_zeroes() to byte interface

2016-04-22 Thread Eric Blake
Sector-based blk_write() should die; convert the one-off variant blk_write_zeroes(). Signed-off-by: Eric Blake --- include/sysemu/block-backend.h | 4 ++-- block/block-backend.c | 8 block/parallels.c | 3 ++- qemu-img.c | 3

[Qemu-block] [PATCH v3 18/44] qemu-img: Switch to byte-based block access

2016-04-22 Thread Eric Blake
Sector-based blk_write() should die; switch to byte-based blk_pwrite() instead. Likewise for blk_read(). Signed-off-by: Eric Blake --- qemu-img.c | 28 +++- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index

[Qemu-block] [PATCH v3 17/44] nbd: Switch to byte-based block access

2016-04-22 Thread Eric Blake
Sector-based blk_read() should die; switch to byte-based blk_pread() instead. Signed-off-by: Eric Blake --- qemu-nbd.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index a85e98f..01eb7e4 100644 --- a/qemu-nbd.c +++

[Qemu-block] [PATCH v3 10/44] fdc: Switch to byte-based block access

2016-04-22 Thread Eric Blake
Sector-based blk_write() should die; switch to byte-based blk_pwrite() instead. Likewise for blk_read(). Signed-off-by: Eric Blake --- hw/block/fdc.c | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/hw/block/fdc.c

[Qemu-block] [PATCH v3 13/44] pflash: Switch to byte-based block access

2016-04-22 Thread Eric Blake
Sector-based blk_write() should die; switch to byte-based blk_pwrite() instead. Likewise for blk_read(). Signed-off-by: Eric Blake --- hw/block/pflash_cfi01.c | 12 ++-- hw/block/pflash_cfi02.c | 12 ++-- 2 files changed, 12 insertions(+), 12 deletions(-)

[Qemu-block] [PATCH v3 16/44] atapi: Switch to byte-based block access

2016-04-22 Thread Eric Blake
Sector-based blk_read() should die; switch to byte-based blk_pread() instead. Signed-off-by: Eric Blake --- hw/ide/atapi.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 2bb606c..81000d8 100644 ---

[Qemu-block] [PATCH v3 12/44] onenand: Switch to byte-based block access

2016-04-22 Thread Eric Blake
Sector-based blk_write() should die; switch to byte-based blk_pwrite() instead. Likewise for blk_read(). Signed-off-by: Eric Blake --- hw/block/onenand.c | 36 ++-- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git

[Qemu-block] [PATCH v3 09/44] block: Allow BDRV_REQ_FUA through blk_pwrite()

2016-04-22 Thread Eric Blake
We have several block drivers that understand BDRV_REQ_FUA, and emulate it in the block layer for the rest by a full flush. But without a way to actually request BDRV_REQ_FUA during a pass-through blk_pwrite(), FUA-aware block drivers like NBD are forced to repeat the emulation logic of a full

[Qemu-block] [PATCH v3 07/44] nbd: Limit nbdflags to 16 bits

2016-04-22 Thread Eric Blake
Rather than asserting that nbdflags is within range, just give it the correct type to begin with :) nbdflags corresponds to the per-export portion of NBD Protocol "transmission flags", which is 16 bits in response to NBD_OPT_EXPORT_NAME and NBD_OPT_GO. Furthermore, upstream NBD has never passed

[Qemu-block] [PATCH v3 11/44] nand: Switch to byte-based block access

2016-04-22 Thread Eric Blake
Sector-based blk_write() should die; switch to byte-based blk_pwrite() instead. Likewise for blk_read(). This file is doing some complex computations to map various flash page sizes (256, 512, and 2048) atop generic uses of 512-byte sector operations. Perhaps someone will want to tidy up the

[Qemu-block] [PATCH v3 04/44] nbd: Reject unknown request flags

2016-04-22 Thread Eric Blake
The NBD protocol says that clients should not send a command flag that has not been negotiated (whether by the client requesting an option during a handshake, or because we advertise support for the flag in response to NBD_OPT_EXPORT_NAME), and that servers should reject invalid flags with EINVAL.

[Qemu-block] [PATCH v3 02/44] nbd: Quit server after any write error

2016-04-22 Thread Eric Blake
We should never ignore failure from nbd_negotiate_send_rep(); if we are unable to write to the client, then it is not worth trying to continue the negotiation. Fortunately, the problem is not too severe - chances are that the errors being ignored here (mainly inability to write the reply to the

[Qemu-block] [PATCH v3 01/44] nbd: More debug typo fixes, use correct formats

2016-04-22 Thread Eric Blake
Clean up some debug message oddities missed earlier; this includes both typos, and recognizing that %d is not necessarily compatible with uint32_t. Signed-off-by: Eric Blake Reviewed-by: Alex Bligh --- v3: rebase --- nbd/client.c | 41

[Qemu-block] [PATCH v3 05/44] nbd: Group all Linux-specific ioctl code in one place

2016-04-22 Thread Eric Blake
NBD ioctl()s are used to manage an NBD client session where initial handshake is done in userspace, but then the transmission phase is handed off to the kernel through a /dev/nbdX device. As such, all ioctls sent to the kernel on the /dev/nbdX fd belong in client.c; nbd_disconnect() was

[Qemu-block] [PATCH v3 03/44] nbd: Improve server handling of bogus commands

2016-04-22 Thread Eric Blake
We have a few bugs in how we handle invalid client commands: - A client can send an NBD_CMD_DISC where from + len overflows, convincing us to reply with an error and stay connected, even though the protocol requires us to silently disconnect. Fix by hoisting the special case sooner. - A client

[Qemu-block] [PATCH v3 00/44] NBD protocol additions

2016-04-22 Thread Eric Blake
This series is for qemu 2.7, and is a bit more stable this time (upstream NBD extensions have been reaching some consensus based on feedback I've made while implementing this series). Included are some interoperability bug fixes, code cleanups, then added support both client-side and server-side

[Qemu-block] [PATCH v2 09/13] block: Drain throttling queue with BdrvChild callback

2016-04-22 Thread Kevin Wolf
This removes the last part of I/O throttling from block/io.c and moves it to the BlockBackend. Instead of having knowledge about throttling inside io.c, we can call a BdrvChild callback .drained_begin/end, which happens to drain the throttled requests for BlockBackend parents. Signed-off-by:

[Qemu-block] [PATCH v2 11/13] block: Remove bdrv_move_feature_fields()

2016-04-22 Thread Kevin Wolf
bdrv_move_feature_fields() and swap_feature_fields() are empty now, they can be removed. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block.c | 30 -- 1 file changed, 30 deletions(-) diff --git a/block.c b/block.c index

[Qemu-block] [PATCH v2 10/13] block: Decouple throttling from BlockDriverState

2016-04-22 Thread Kevin Wolf
This moves the throttling related part of the BDS life cycle management to BlockBackend. The throttling group reference is now kept even when no medium is inserted. With this commit, throttling isn't disabled and then re-enabled any more during graph reconfiguration. This fixes the temporary

[Qemu-block] [PATCH v2 12/13] Revert "block: Forbid I/O throttling on nodes with multiple parents for 2.6"

2016-04-22 Thread Kevin Wolf
This reverts commit 76b223200ef4fb09dd87f0e213159795eb68e7a5. Now that I/O throttling is fully done on the BlockBackend level, there is no reason any more to block I/O throttling for nodes with multiple parents as the parents don't influence each other any more. Conflicts: block.c

[Qemu-block] [PATCH v2 13/13] block: Don't check throttled reqs in bdrv_requests_pending()

2016-04-22 Thread Kevin Wolf
Checking whether there are throttled requests requires going to the associated BlockBackend, which we want to avoid. All users of bdrv_requests_pending() already call bdrv_parent_drained_begin() first, which restarts all throttled requests, so no throttled requests can be left here and this is

[Qemu-block] [PATCH v2 08/13] block: Introduce BdrvChild.opaque

2016-04-22 Thread Kevin Wolf
BlockBackends use it to get a back pointer from BdrvChild to BlockBackend in any BdrvChildRole callbacks. Signed-off-by: Kevin Wolf --- block/block-backend.c | 2 ++ include/block/block_int.h | 1 + 2 files changed, 3 insertions(+) diff --git a/block/block-backend.c

[Qemu-block] [PATCH v2 06/13] block: Move actual I/O throttling to BlockBackend

2016-04-22 Thread Kevin Wolf
Signed-off-by: Kevin Wolf --- block/block-backend.c | 10 ++ block/io.c | 10 -- block/throttle-groups.c | 5 ++--- include/block/throttle-groups.h | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git

[Qemu-block] [PATCH v2 04/13] block: Convert throttle_group_get_name() to BlockBackend

2016-04-22 Thread Kevin Wolf
Signed-off-by: Kevin Wolf --- block/block-backend.c | 2 +- block/io.c | 2 +- block/qapi.c| 2 +- block/throttle-groups.c | 12 ++-- include/block/throttle-groups.h | 2 +- tests/test-throttle.c |

[Qemu-block] [PATCH v2 07/13] block: Move I/O throttling configuration functions to BlockBackend

2016-04-22 Thread Kevin Wolf
Signed-off-by: Kevin Wolf --- block.c | 2 +- block/block-backend.c | 43 +++-- block/io.c | 41 --- block/qapi.c| 2 +-

[Qemu-block] [PATCH v2 01/13] block: Make sure throttled BDSes always have a BB

2016-04-22 Thread Kevin Wolf
It was already true in principle that a throttled BDS always has a BB attached, except that the order of operations while attaching or detaching a BDS to/from a BB wasn't careful enough. This commit breaks graph manipulations while I/O throttling is enabled. It would have been possible to keep

[Qemu-block] [PATCH v2 02/13] block: Introduce BlockBackendPublic

2016-04-22 Thread Kevin Wolf
Some features, like I/O throttling, are implemented outside block-backend.c, but still want to keep information in BlockBackend, e.g. list entries that allow keeping a list of BlockBackends. In order to avoid exposing the whole struct layout in the public header file, this patch introduces an

[Qemu-block] [PATCH v2 00/13] block: Move I/O throttling to BlockBackend

2016-04-22 Thread Kevin Wolf
This is another feature that was "logically" part of the BlockBackend, but implemented as a BlockDriverState feature. It was always kept on top using swap_feature_fields(). This series moves it to be actually implemented in the BlockBackend, removing another obstacle for removing bs->blk and

[Qemu-block] [PATCH v2 03/13] block: throttle-groups: Use BlockBackend pointers internally

2016-04-22 Thread Kevin Wolf
As a first step towards moving I/O throttling to the BlockBackend level, this patch changes all pointers in struct ThrottleGroup from referencing a BlockDriverState to referencing a BlockBackend. This change is valid because we made sure that throttling can only be enabled on BDSes which have a

[Qemu-block] [PATCH v2 05/13] block: Move throttling fields from BDS to BB

2016-04-22 Thread Kevin Wolf
This patch changes where the throttling state is stored (used to be the BlockDriverState, now it is the BlockBackend), but it doesn't actually make it a BB level feature yet. For example, throttling is still disabled when the BDS is detached from the BB. Signed-off-by: Kevin Wolf

Re: [Qemu-block] [PULL 0/5] Mirror block job fixes for 2.6.0-rc4

2016-04-22 Thread Peter Maydell
On 22 April 2016 at 16:05, Kevin Wolf wrote: > The following changes since commit ee1e0f8e5d3682c561edcdceccff72b9d9b16d8b: > > util: align memory allocations to 2M on AArch64 (2016-04-22 12:26:01 +0100) > > are available in the git repository at: > >

Re: [Qemu-block] [PATCH v3 for-2.6 0/5] block: Fix assertion failure at mirror exit

2016-04-22 Thread Kevin Wolf
Am 22.04.2016 um 15:53 hat Fam Zheng geschrieben: > v3: 04: Add check in aio_pending. [Kevin] > > I tested this series survives the "snapshot + commit" loop reproducer with > both > bonnie++ and RHEL installation in the guest. > > This supersedes the "virtio: Register host notifier handler as

[Qemu-block] [PULL 5/5] mirror: Workaround for unexpected iohandler events during completion

2016-04-22 Thread Kevin Wolf
From: Fam Zheng Commit 5a7e7a0ba moved mirror_exit to a BH handler but didn't add any protection against new requests that could sneak in just before the BH is dispatched. For example (assuming a code base at that commit): main_loop_wait # 1

[Qemu-block] [PULL 4/5] aio-posix: Skip external nodes in aio_dispatch

2016-04-22 Thread Kevin Wolf
From: Fam Zheng aio_poll doesn't poll the external nodes so this should never be true, but aio_ctx_dispatch may get notified by the events from GSource. To make bdrv_drained_begin effective in main loop, we should check the is_external flag here too. Also do the check in

[Qemu-block] [PULL 1/5] iohandler: Introduce iohandler_get_aio_context

2016-04-22 Thread Kevin Wolf
From: Fam Zheng Signed-off-by: Fam Zheng Reviewed-by: Michael S. Tsirkin Signed-off-by: Kevin Wolf --- include/qemu/main-loop.h | 1 + iohandler.c | 6 ++ stubs/Makefile.objs | 1 + stubs/iohandler.c

[Qemu-block] [PULL 3/5] virtio: Mark host notifiers as external

2016-04-22 Thread Kevin Wolf
From: Fam Zheng The effect of this change is the block layer drained section can work, for example when mirror job is being completed. Signed-off-by: Fam Zheng Reviewed-by: Michael S. Tsirkin Signed-off-by: Kevin Wolf ---

[Qemu-block] [PULL 2/5] event-notifier: Add "is_external" parameter

2016-04-22 Thread Kevin Wolf
From: Fam Zheng All callers pass "false" keeping the old semantics. The windows implementation doesn't distinguish the flag yet. On posix, it is passed down to the underlying aio context. Signed-off-by: Fam Zheng Reviewed-by: Michael S. Tsirkin

Re: [Qemu-block] [PATCH for-2.6] block: add an 'iscsi-id' value to match -drive with -iscsi opts

2016-04-22 Thread Peter Lieven
Am 22.04.2016 um 12:59 schrieb Kevin Wolf: > Am 22.04.2016 um 12:24 hat Daniel P. Berrange geschrieben: >> The iSCSI block driver has ability to lookup various options, in >> particular authentication info, specified by the separate -iscsi >> argument. It currently uses the iSCSI IQN as the ID

Re: [Qemu-block] [PATCH v3 for-2.6 0/5] block: Fix assertion failure at mirror exit

2016-04-22 Thread Jeff Cody
On Fri, Apr 22, 2016 at 09:53:51PM +0800, Fam Zheng wrote: > v3: 04: Add check in aio_pending. [Kevin] > > I tested this series survives the "snapshot + commit" loop reproducer with > both > bonnie++ and RHEL installation in the guest. > > This supersedes the "virtio: Register host notifier

Re: [Qemu-block] [PATCH v3 for-2.6 0/5] block: Fix assertion failure at mirror exit

2016-04-22 Thread Kevin Wolf
Am 22.04.2016 um 15:53 hat Fam Zheng geschrieben: > v3: 04: Add check in aio_pending. [Kevin] > > I tested this series survives the "snapshot + commit" loop reproducer with > both > bonnie++ and RHEL installation in the guest. > > This supersedes the "virtio: Register host notifier handler as

Re: [Qemu-block] [PATCH v3 for-2.6 0/5] block: Fix assertion failure at mirror exit

2016-04-22 Thread Michael S. Tsirkin
On Fri, Apr 22, 2016 at 09:53:51PM +0800, Fam Zheng wrote: > v3: 04: Add check in aio_pending. [Kevin] > > I tested this series survives the "snapshot + commit" loop reproducer with > both > bonnie++ and RHEL installation in the guest. > > This supersedes the "virtio: Register host notifier

Re: [Qemu-block] [PATCH v2 for-2.6 0/5] block: Fix assertion failure at mirror exit

2016-04-22 Thread Fam Zheng
On Fri, 04/22 16:49, Michael S. Tsirkin wrote: > On Fri, Apr 22, 2016 at 06:55:59PM +0800, Fam Zheng wrote: > > v2: Go along the is_external appraoch. [Kevin] > > > > I tested this series survives the "snapshot + commit" loop reproducer with > > both > > bonnie++ and RHEL installation in the

Re: [Qemu-block] [PATCH v2 for-2.6 0/5] block: Fix assertion failure at mirror exit

2016-04-22 Thread Kevin Wolf
Am 22.04.2016 um 15:49 hat Michael S. Tsirkin geschrieben: > On Fri, Apr 22, 2016 at 06:55:59PM +0800, Fam Zheng wrote: > > v2: Go along the is_external appraoch. [Kevin] > > > > I tested this series survives the "snapshot + commit" loop reproducer with > > both > > bonnie++ and RHEL

[Qemu-block] [PATCH v3 for-2.6 2/5] event-notifier: Add "is_external" parameter

2016-04-22 Thread Fam Zheng
All callers pass "false" keeping the old semantics. The windows implementation doesn't distinguish the flag yet. On posix, it is passed down to the underlying aio context. Signed-off-by: Fam Zheng --- hw/usb/ccid-card-emulated.c | 2 +- hw/virtio/virtio.c| 8

[Qemu-block] [PATCH v3 for-2.6 4/5] aio-posix: Skip external nodes in aio_dispatch

2016-04-22 Thread Fam Zheng
aio_poll doesn't poll the external nodes so this should never be true, but aio_ctx_dispatch may get notified by the events from GSource. To make bdrv_drained_begin effective in main loop, we should check the is_external flag here too. Also do the check in aio_pending so aio_dispatch is not called

[Qemu-block] [PATCH v3 for-2.6 5/5] mirror: Workaround for unexpected iohandler events during completion

2016-04-22 Thread Fam Zheng
Commit 5a7e7a0ba moved mirror_exit to a BH handler but didn't add any protection against new requests that could sneak in just before the BH is dispatched. For example (assuming a code base at that commit): main_loop_wait # 1 os_host_main_loop_wait

[Qemu-block] [PATCH v3 for-2.6 3/5] virtio: Mark host notifiers as external

2016-04-22 Thread Fam Zheng
The effect of this change is the block layer drained section can work, for example when mirror job is being completed. Signed-off-by: Fam Zheng --- hw/virtio/virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c

[Qemu-block] [PATCH v3 for-2.6 0/5] block: Fix assertion failure at mirror exit

2016-04-22 Thread Fam Zheng
v3: 04: Add check in aio_pending. [Kevin] I tested this series survives the "snapshot + commit" loop reproducer with both bonnie++ and RHEL installation in the guest. This supersedes the "virtio: Register host notifier handler as external" patch from yesterday. The bug was initially reported by

Re: [Qemu-block] [PATCH v2 for-2.6 0/5] block: Fix assertion failure at mirror exit

2016-04-22 Thread Michael S. Tsirkin
On Fri, Apr 22, 2016 at 06:55:59PM +0800, Fam Zheng wrote: > v2: Go along the is_external appraoch. [Kevin] > > I tested this series survives the "snapshot + commit" loop reproducer with > both > bonnie++ and RHEL installation in the guest. > > This supersedes the "virtio: Register host

Re: [Qemu-block] [PATCH v2 for-2.6 1/5] iohandler: Introduce iohandler_get_aio_context

2016-04-22 Thread Michael S. Tsirkin
On Fri, Apr 22, 2016 at 06:56:00PM +0800, Fam Zheng wrote: > Signed-off-by: Fam Zheng Reviewed-by: Michael S. Tsirkin > --- > include/qemu/main-loop.h | 1 + > iohandler.c | 6 ++ > stubs/Makefile.objs | 1 + > stubs/iohandler.c|

Re: [Qemu-block] [PATCH v2 for-2.6 2/5] event-notifier: Add "is_external" parameter

2016-04-22 Thread Michael S. Tsirkin
On Fri, Apr 22, 2016 at 06:56:01PM +0800, Fam Zheng wrote: > All callers pass "false" keeping the old semantics. The windows > implementation doesn't distinguish the flag yet. On posix, it is passed > down to the underlying aio context. > > Signed-off-by: Fam Zheng Reviewed-by:

Re: [Qemu-block] [PATCH v2 for-2.6 3/5] virtio: Mark host notifiers as external

2016-04-22 Thread Michael S. Tsirkin
On Fri, Apr 22, 2016 at 06:56:02PM +0800, Fam Zheng wrote: > The effect of this change is the block layer drained section can work, > for example when mirror job is being completed. > > Signed-off-by: Fam Zheng Reviewed-by: Michael S. Tsirkin > --- >

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6] block: add an 'iscsi-id' value to match -drive with -iscsi opts

2016-04-22 Thread Daniel P. Berrange
On Fri, Apr 22, 2016 at 01:10:40PM +0100, Peter Maydell wrote: > On 22 April 2016 at 12:55, Daniel P. Berrange wrote: > > On Fri, Apr 22, 2016 at 01:53:47PM +0200, Kevin Wolf wrote: > >> -iscsi is a weird thing anyway. We should do things the usual way, with > >> a proper

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6] block: add an 'iscsi-id' value to match -drive with -iscsi opts

2016-04-22 Thread Peter Maydell
On 22 April 2016 at 12:55, Daniel P. Berrange wrote: > On Fri, Apr 22, 2016 at 01:53:47PM +0200, Kevin Wolf wrote: >> -iscsi is a weird thing anyway. We should do things the usual way, with >> a proper BlockdevOptionsIscsi QAPI structure. Introducing a new API in >> 2.6 when

Re: [Qemu-block] [PATCH for-2.6] block: add an 'iscsi-id' value to match -drive with -iscsi opts

2016-04-22 Thread Kevin Wolf
Am 22.04.2016 um 13:43 hat Daniel P. Berrange geschrieben: > On Fri, Apr 22, 2016 at 01:13:42PM +0200, Peter Lieven wrote: > > Am 22.04.2016 um 12:59 schrieb Kevin Wolf: > > > Am 22.04.2016 um 12:24 hat Daniel P. Berrange geschrieben: > > >> The iSCSI block driver has ability to lookup various

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6] block: add an 'iscsi-id' value to match -drive with -iscsi opts

2016-04-22 Thread Markus Armbruster
Kevin Wolf writes: > Am 22.04.2016 um 12:24 hat Daniel P. Berrange geschrieben: >> The iSCSI block driver has ability to lookup various options, in >> particular authentication info, specified by the separate -iscsi >> argument. It currently uses the iSCSI IQN as the ID value

Re: [Qemu-block] [PATCH v2 for-2.6 4/5] aio-posix: Skip external nodes in aio_dispatch

2016-04-22 Thread Kevin Wolf
Am 22.04.2016 um 12:56 hat Fam Zheng geschrieben: > aio_poll doesn't poll the external nodes so this should never be true, > but aio_ctx_dispatch may get notified by the events from GSource. To > make bdrv_drained_begin effective in main loop, we should check the > is_external flag here too. > >

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6?] nbd: Don't mishandle unaligned client requests

2016-04-22 Thread Peter Maydell
On 22 April 2016 at 11:19, Kevin Wolf wrote: > Am 22.04.2016 um 11:29 hat Peter Maydell geschrieben: >> On 22 April 2016 at 08:03, Kevin Wolf wrote: >> > Peter, do you want a pull request (which I would have to do because >> > Paolo is away) or are you going

[Qemu-block] [PATCH v2 for-2.6 4/5] aio-posix: Skip external nodes in aio_dispatch

2016-04-22 Thread Fam Zheng
aio_poll doesn't poll the external nodes so this should never be true, but aio_ctx_dispatch may get notified by the events from GSource. To make bdrv_drained_begin effective in main loop, we should check the is_external flag here too. This could result in a few busy polls because the fd is left

Re: [Qemu-block] [PATCH for-2.6] block: add an 'iscsi-id' value to match -drive with -iscsi opts

2016-04-22 Thread Kevin Wolf
Am 22.04.2016 um 12:24 hat Daniel P. Berrange geschrieben: > The iSCSI block driver has ability to lookup various options, in > particular authentication info, specified by the separate -iscsi > argument. It currently uses the iSCSI IQN as the ID value for this > lookup, however, this does not

[Qemu-block] [PATCH v2 for-2.6 5/5] mirror: Workaround for unexpected iohandler events during completion

2016-04-22 Thread Fam Zheng
Commit 5a7e7a0ba moved mirror_exit to a BH handler but didn't add any protection against new requests that could sneak in just before the BH is dispatched. For example (assuming a code base at that commit): main_loop_wait # 1 os_host_main_loop_wait

[Qemu-block] [PATCH v2 for-2.6 2/5] event-notifier: Add "is_external" parameter

2016-04-22 Thread Fam Zheng
All callers pass "false" keeping the old semantics. The windows implementation doesn't distinguish the flag yet. On posix, it is passed down to the underlying aio context. Signed-off-by: Fam Zheng --- hw/usb/ccid-card-emulated.c | 2 +- hw/virtio/virtio.c| 8

[Qemu-block] [PATCH v2 for-2.6 3/5] virtio: Mark host notifiers as external

2016-04-22 Thread Fam Zheng
The effect of this change is the block layer drained section can work, for example when mirror job is being completed. Signed-off-by: Fam Zheng --- hw/virtio/virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c

[Qemu-block] [PATCH v2 for-2.6 0/5] block: Fix assertion failure at mirror exit

2016-04-22 Thread Fam Zheng
v2: Go along the is_external appraoch. [Kevin] I tested this series survives the "snapshot + commit" loop reproducer with both bonnie++ and RHEL installation in the guest. This supersedes the "virtio: Register host notifier handler as external" patch from yesterday. The bug was initially

[Qemu-block] [PATCH v2 for-2.6 1/5] iohandler: Introduce iohandler_get_aio_context

2016-04-22 Thread Fam Zheng
Signed-off-by: Fam Zheng --- include/qemu/main-loop.h | 1 + iohandler.c | 6 ++ stubs/Makefile.objs | 1 + stubs/iohandler.c| 8 4 files changed, 16 insertions(+) create mode 100644 stubs/iohandler.c diff --git a/include/qemu/main-loop.h

Re: [Qemu-block] I/O errors reported to guest for raw-image-file backed /dev/vda - but host sees no I/O errors

2016-04-22 Thread Lutz Vieweg
On 04/21/2016 05:54 PM, Lutz Vieweg wrote: And indeed, the errors occured exactly at the time a backup procedure was preparing a read-only snapshot with "btrfs subvolume snapshot -r" - so until I can upgrade to a mainline kernel including the fix, I'll pause the qemu process while the "btrfs

Re: [Qemu-block] [Qemu-devel] I/O errors reported to guest for raw-image-file backed /dev/vda - but host sees no I/O errors

2016-04-22 Thread Lutz Vieweg
On 04/22/2016 03:16 AM, Fam Zheng wrote: On Thu, 04/21 17:54, Lutz Vieweg wrote: Nevertheless, I think qemu could be somewhat more verbose, reporting when and why it stops emulation. Something like a message to the monitor or to standard out would be helpful to start with... QEMU does report

[Qemu-block] [PATCH for-2.6] block: add an 'iscsi-id' value to match -drive with -iscsi opts

2016-04-22 Thread Daniel P. Berrange
The iSCSI block driver has ability to lookup various options, in particular authentication info, specified by the separate -iscsi argument. It currently uses the iSCSI IQN as the ID value for this lookup, however, this does not work for common iSCSI IQNs as they contain characters such as ':'

[Qemu-block] [PATCH for-2.6] Fix association of -drive & -iscsi args

2016-04-22 Thread Daniel P. Berrange
The iSCSI block driver is a bit strange in that it requires a separate -iscsi arg to pass various values, instead of accepting them directly with the -drive argument. Pino is working on fixing that for 2.7: https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg02011.html The problem with

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6?] nbd: Don't mishandle unaligned client requests

2016-04-22 Thread Kevin Wolf
Am 22.04.2016 um 11:29 hat Peter Maydell geschrieben: > On 22 April 2016 at 08:03, Kevin Wolf wrote: > > Am 21.04.2016 um 18:28 hat Peter Maydell geschrieben: > >> On 21 April 2016 at 15:42, Eric Blake wrote: > >> > The NBD protocol does not (yet) force any

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6 2/3] mirror: Skip BH for mirror_exit if in main loop

2016-04-22 Thread Fam Zheng
On Fri, 04/22 14:35, Fam Zheng wrote: > As a bandage, this patch undoes the change of 5a7e7a0bad17 in > non-dataplane case, and calls mirror_replace directly in mirror_run. mirror_exit minus mirror_replace was kept in the BH because it's not safe to call in coroutine. After discussing with kwolf

Re: [Qemu-block] [PATCH V2 RFC] fixup! virtio: convert to use DMA api

2016-04-22 Thread Stefan Hajnoczi
On Thu, Apr 21, 2016 at 06:11:40PM +0300, Michael S. Tsirkin wrote: > On Thu, Apr 21, 2016 at 03:56:53PM +0100, Stefan Hajnoczi wrote: > > On Thu, Apr 21, 2016 at 04:43:45PM +0300, Michael S. Tsirkin wrote: > > > This adds a flag to enable/disable bypassing the IOMMU by > > > virtio devices. > > >

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6?] nbd: Don't mishandle unaligned client requests

2016-04-22 Thread Fam Zheng
On Thu, 04/21 08:42, Eric Blake wrote: > The NBD protocol does not (yet) force any alignment constraints > on clients. Even though qemu NBD clients always send requests > that are aligned to 512 bytes, we must be prepared for non-qemu > clients that don't care about alignment (even if it means

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6?] nbd: Don't mishandle unaligned client requests

2016-04-22 Thread Kevin Wolf
Am 21.04.2016 um 18:28 hat Peter Maydell geschrieben: > On 21 April 2016 at 15:42, Eric Blake wrote: > > The NBD protocol does not (yet) force any alignment constraints > > on clients. Even though qemu NBD clients always send requests > > that are aligned to 512 bytes, we must

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6 0/3] block: Fix assertion failure at mirror exit

2016-04-22 Thread Fam Zheng
On Fri, 04/22 14:35, Fam Zheng wrote: > This supersedes the "virtio: Register host notifier handler as external" patch > from yesterday. > > The bug was initially reported by Matthew Schumacher as LaunchPad Bug 1570134, > and nicely bisected by Max Reitz. See patch 2 for the analysis. > > We are

[Qemu-block] [PATCH for-2.6 1/3] mirror: Extract mirror_replace

2016-04-22 Thread Fam Zheng
Move the BDS replacing code to a separate function so that it can be used in the next patch. A new field "should_replace" is added and set to true so the function is always called for now. Signed-off-by: Fam Zheng --- block/mirror.c | 36 +++- 1

[Qemu-block] [PATCH for-2.6 0/3] block: Fix assertion failure at mirror exit

2016-04-22 Thread Fam Zheng
This supersedes the "virtio: Register host notifier handler as external" patch from yesterday. The bug was initially reported by Matthew Schumacher as LaunchPad Bug 1570134, and nicely bisected by Max Reitz. See patch 2 for the analysis. We are late for 2.6 so the fix is done locally in

[Qemu-block] [PATCH for-2.6 2/3] mirror: Skip BH for mirror_exit if in main loop

2016-04-22 Thread Fam Zheng
Commit 5a7e7a0ba moved mirror_exit to a BH handler but didn't add any protection against guest requests that could sneak in before the BH is dispatched. For example, this could happen (assuming a code base at that commit): main_loop_wait # 1 os_host_main_loop_wait