[Qemu-block] [PATCH v3 37/38] iotests: More options for VM.add_drive()

2015-06-03 Thread Max Reitz
This patch allows specifying the interface to be used for the drive, and makes specifying a path optional (if the path is None, the file option will be omitted, thus creating an empty drive). Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com ---

[Qemu-block] [PATCH v8 08/10] qcow2: Invoke refcount order amendment function

2015-06-03 Thread Max Reitz
Make use of qcow2_change_refcount_order() to support changing the refcount order with qemu-img amend. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.c | 44 +++- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c

[Qemu-block] [PATCH v8 04/10] qcow2: Use abort() instead of assert(false)

2015-06-03 Thread Max Reitz
Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com Reviewed-by: Stefan Hajnoczi stefa...@redhat.com --- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 0b514f9..c444960 100644 ---

[Qemu-block] [PATCH v8 05/10] qcow2: Split upgrade/downgrade paths for amend

2015-06-03 Thread Max Reitz
If the image version should be upgraded, that is the first we should do; if it should be downgraded, that is the last we should do. So split the version change block into an upgrade part at the start and a downgrade part at the end. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric

[Qemu-block] [PATCH v3 06/38] block: Make bdrv_is_inserted() recursive

2015-06-03 Thread Max Reitz
If bdrv_is_inserted() is called on the top level BDS, it should make sure all nodes in the BDS tree are actually inserted. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- block.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git

[Qemu-block] [PATCH v3 01/38] block: Remove host floppy support

2015-06-03 Thread Max Reitz
It has been deprecated as of 2.3, so we can now remove it. Signed-off-by: Max Reitz mre...@redhat.com --- block/raw-posix.c| 228 ++- qapi/block-core.json | 9 +- 2 files changed, 11 insertions(+), 226 deletions(-) diff --git

[Qemu-block] [PATCH v3 17/38] block: Make some BB functions fall back to BBRS

2015-06-03 Thread Max Reitz
If there is no BDS tree attached to a BlockBackend, functions that can do so should fall back to the BlockBackendRootState structure (which are blk_is_read_only() and blk_get_flags(), because the read-only status and the open flags are part of the BBRS). Signed-off-by: Max Reitz mre...@redhat.com

[Qemu-block] [PATCH v3 26/38] blockdev: Add blockdev-open-tray

2015-06-03 Thread Max Reitz
Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- blockdev.c | 48 qapi/block-core.json | 23 +++ qmp-commands.hx | 39 +++ 3 files

[Qemu-block] [PATCH v3 05/38] block: Add blk_is_available()

2015-06-03 Thread Max Reitz
blk_is_available() returns true iff the BDS is inserted (which means blk_bs() is not NULL and bdrv_is_inserted() returns true) and if the tray of the guest device is closed. blk_is_inserted() is changed to return true only if blk_bs() is not NULL. Signed-off-by: Max Reitz mre...@redhat.com

[Qemu-block] [PATCH v3 33/38] qmp: Introduce blockdev-change-medium

2015-06-03 Thread Max Reitz
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 mre...@redhat.com Reviewed-by: Eric Blake

[Qemu-block] [PATCH v3 14/38] block: Move BlockAcctStats into BlockBackend

2015-06-03 Thread Max Reitz
As the comment above bdrv_get_stats() says, BlockAcctStats is something which belongs to the device instead of each BlockDriverState. This patch therefore moves it into the BlockBackend. Signed-off-by: Max Reitz mre...@redhat.com --- block.c | 11 ---

[Qemu-block] [PATCH v8 06/10] qcow2: Use intermediate helper CB for amend

2015-06-03 Thread Max Reitz
If there is more than one time-consuming operation to be performed for qcow2_amend_options(), we need an intermediate CB which coordinates the progress of the individual operations and passes the result to the original status callback. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric

Re: [Qemu-block] [PATCH v3 08/38] block: Invoke change media CB before NULLing drv

2015-06-03 Thread Eric Blake
On 06/03/2015 01:43 PM, Max Reitz wrote: In order to handle host device passthrough, some guest device models may call blk_is_inserted() to check whether the medium is inserted on the host, when checking the guest tray status. This tray status is inquired by blk_dev_change_media_cb();

[Qemu-block] [PATCH v3 03/38] iotests: Only create BB if necessary

2015-06-03 Thread Max Reitz
Tests 071 and 081 test giving references in blockdev-add. It is not necessary to create a BlockBackend here, so omit it. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- tests/qemu-iotests/071 | 50 ++

[Qemu-block] [PATCH v3 32/38] block: Inquire tray state before tray-moved events

2015-06-03 Thread Max Reitz
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

Re: [Qemu-block] [PATCH v3 13/38] block: Remove wr_highest_sector from BlockAcctStats

2015-06-03 Thread Eric Blake
On 06/03/2015 01:43 PM, Max Reitz wrote: BlockAcctStats contains statistics about the data transferred from and to the device; wr_highest_sector does not fit in with the rest. Furthermore, those statistics are supposed to be specific for a certain device and not necessarily for a BDS (see

[Qemu-block] [PATCH v8 02/10] block: Add opaque value to the amend CB

2015-06-03 Thread Max Reitz
Add an opaque value which is to be passed to the bdrv_amend_options() status callback. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com Reviewed-by: Stefan Hajnoczi stefa...@redhat.com --- block.c | 4 ++-- block/qcow2-cluster.c | 14

Re: [Qemu-block] [PATCH v3 18/38] block: Fail requests to empty BlockBackend

2015-06-03 Thread Eric Blake
On 06/03/2015 01:43 PM, Max Reitz wrote: If there is no BlockDriverState in a BlockBackend or if the tray of the guest device is open, fail all requests (where that is possible) with -ENOMEDIUM. The reason the status of the guest device is taken into account is because once the guest

[Qemu-block] [PATCH v3 00/38] blockdev: BlockBackend and media

2015-06-03 Thread Max Reitz
This series reworks a lot regarding BlockBackend and media. Basically, it allows empty BlockBackends, that is BBs without a BDS tree. Before this series, empty drives are represented by a BlockBackend with an empty BDS attached to it (a BDS with a NULL driver). However, now we have BlockBackends,

[Qemu-block] [PATCH v3 20/38] block: Add blk_insert_bs()

2015-06-03 Thread Max Reitz
This function associates the given BlockDriverState with the given BlockBackend. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- block/block-backend.c | 16 include/sysemu/block-backend.h | 1 + 2 files changed, 17 insertions(+)

[Qemu-block] [PATCH v8 07/10] qcow2: Add function for refcount order amendment

2015-06-03 Thread Max Reitz
Add a function qcow2_change_refcount_order() which allows changing the refcount order of a qcow2 image. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2-refcount.c | 447 + block/qcow2.h | 4 + 2 files changed, 451

[Qemu-block] [PATCH v3 07/38] block/quorum: Implement bdrv_is_inserted()

2015-06-03 Thread Max Reitz
bdrv_is_inserted() should be invoked recursively on the children of quorum. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- block/quorum.c | 16 1 file changed, 16 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index

[Qemu-block] [PATCH v3 08/38] block: Invoke change media CB before NULLing drv

2015-06-03 Thread Max Reitz
In order to handle host device passthrough, some guest device models may call blk_is_inserted() to check whether the medium is inserted on the host, when checking the guest tray status. This tray status is inquired by blk_dev_change_media_cb(); because bdrv_is_inserted() (invoked by

[Qemu-block] [PATCH v3 31/38] blockdev: Implement change with basic operations

2015-06-03 Thread Max Reitz
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 mre...@redhat.com --- blockdev.c | 185

[Qemu-block] [PATCH v3 35/38] blockdev: read-only-mode for blockdev-change-medium

2015-06-03 Thread Max Reitz
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

[Qemu-block] [PATCH v3 29/38] blockdev: Add blockdev-insert-medium

2015-06-03 Thread Max Reitz
And a helper function for that, which directly takes a pointer to the BDS to be inserted instead of its node-name (which will be used for implementing 'change' using blockdev-insert-medium). Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- blockdev.c

[Qemu-block] [PATCH v3 16/38] block: Add BlockBackendRootState

2015-06-03 Thread Max Reitz
This structure will store some of the state of the root BDS if the BDS tree is removed, so that state can be restored once a new BDS tree is inserted. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- block/block-backend.c | 26

[Qemu-block] [PATCH v3 04/38] block: Make bdrv_is_inserted() return a bool

2015-06-03 Thread Max Reitz
Make bdrv_is_inserted(), blk_is_inserted(), and the callback BlockDriver.bdrv_is_inserted() return a bool. Suggested-by: Eric Blake ebl...@redhat.com Signed-off-by: Max Reitz mre...@redhat.com --- block.c| 12 +++- block/block-backend.c | 2 +-

Re: [Qemu-block] [PATCH v3 10/38] hw/usb-storage: Check whether BB is inserted

2015-06-03 Thread Eric Blake
On 06/03/2015 01:43 PM, Max Reitz wrote: Only call bdrv_add_key() on the BlockDriverState if it is not NULL. Signed-off-by: Max Reitz mre...@redhat.com --- hw/usb/dev-storage.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git

[Qemu-block] [PATCH v3 13/38] block: Remove wr_highest_sector from BlockAcctStats

2015-06-03 Thread Max Reitz
BlockAcctStats contains statistics about the data transferred from and to the device; wr_highest_sector does not fit in with the rest. Furthermore, those statistics are supposed to be specific for a certain device and not necessarily for a BDS (see the comment above bdrv_get_stats()); on the

[Qemu-block] [PATCH v3 36/38] hmp: Add read-only-mode option to change command

2015-06-03 Thread Max Reitz
Expose the new read-only-mode option of 'blockdev-change-medium' for the 'change' HMP command. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- hmp-commands.hx | 20 +--- hmp.c | 22 +- 2 files changed, 38

[Qemu-block] [PATCH v8 10/10] iotests: Extend test 112 for qemu-img amend

2015-06-03 Thread Max Reitz
Add tests for conversion between different refcount widths. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- tests/qemu-iotests/112 | 109 + tests/qemu-iotests/112.out | 71 + 2

Re: [Qemu-block] [PATCH v3 04/38] block: Make bdrv_is_inserted() return a bool

2015-06-03 Thread Eric Blake
On 06/03/2015 01:43 PM, Max Reitz wrote: Make bdrv_is_inserted(), blk_is_inserted(), and the callback BlockDriver.bdrv_is_inserted() return a bool. Suggested-by: Eric Blake ebl...@redhat.com Signed-off-by: Max Reitz mre...@redhat.com --- block.c| 12 +++-

[Qemu-block] [PATCH v3 24/38] blockdev: Allow more options for BB-less BDS tree

2015-06-03 Thread Max Reitz
Most of the options which blockdev_init() parses for both the BlockBackend and the root BDS are valid for just the root BDS as well (e.g. read-only). This patch allows specifying these options even if not creating a BlockBackend. Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake

Re: [Qemu-block] [PATCH v3 01/38] block: Remove host floppy support

2015-06-03 Thread Eric Blake
On 06/03/2015 01:43 PM, Max Reitz wrote: It has been deprecated as of 2.3, so we can now remove it. Signed-off-by: Max Reitz mre...@redhat.com --- block/raw-posix.c| 228 ++- qapi/block-core.json | 9 +- 2 files changed, 11

[Qemu-block] [PATCH v8 09/10] qcow2: Point to amend function in check

2015-06-03 Thread Max Reitz
If a reference count is not representable with the current refcount order, the image check should point to qemu-img amend for increasing the refcount order. However, qemu-img amend needs write access to the image which cannot be provided if the image is marked corrupt; and the image check will not

Re: [Qemu-block] [PATCH v3 02/38] blockdev: Allow creation of BDS trees without BB

2015-06-03 Thread Eric Blake
On 06/03/2015 01:43 PM, Max Reitz wrote: If the id field is missing from the options given to blockdev-add, just omit the BlockBackend and create the BlockDriverState tree alone. However, if id is missing, node-name must be specified; otherwise, the BDS tree would no longer be accessible.

Re: [Qemu-block] [PATCH v3 09/38] hw/block/fdc: Implement tray status

2015-06-03 Thread Eric Blake
On 06/03/2015 01:43 PM, Max Reitz wrote: The tray of an FDD is open iff there is no medium inserted (there are only two states for an FDD: medium inserted or no medium inserted). This results in the tray being reported as open if qemu has been started with the default floppy drive, which

Re: [Qemu-block] [PATCH v3 26/38] blockdev: Add blockdev-open-tray

2015-06-03 Thread Eric Blake
On 06/03/2015 01:44 PM, Max Reitz wrote: Signed-off-by: Max Reitz mre...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- blockdev.c | 48 qapi/block-core.json | 23 +++ qmp-commands.hx | 39

Re: [Qemu-block] [PATCH v3 33/38] qmp: Introduce blockdev-change-medium

2015-06-03 Thread Eric Blake
On 06/03/2015 01:44 PM, Max Reitz wrote: 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

Re: [Qemu-block] [PATCH v8 07/10] qcow2: Add function for refcount order amendment

2015-06-03 Thread Eric Blake
On 06/03/2015 02:13 PM, Max Reitz wrote: Add a function qcow2_change_refcount_order() which allows changing the refcount order of a qcow2 image. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2-refcount.c | 447 + block/qcow2.h

Re: [Qemu-block] [PATCH v3 38/38] iotests: Add test for change-related QMP commands

2015-06-03 Thread Eric Blake
On 06/03/2015 01:44 PM, Max Reitz wrote: Signed-off-by: Max Reitz mre...@redhat.com --- tests/qemu-iotests/118 | 638 + tests/qemu-iotests/118.out | 5 + tests/qemu-iotests/group | 1 + 3 files changed, 644 insertions(+) create mode

Re: [Qemu-block] [PATCH v3 31/38] blockdev: Implement change with basic operations

2015-06-03 Thread Eric Blake
On 06/03/2015 01:44 PM, Max Reitz wrote: 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 mre...@redhat.com ---

Re: [Qemu-block] [PATCH v8 08/10] qcow2: Invoke refcount order amendment function

2015-06-03 Thread Eric Blake
On 06/03/2015 02:13 PM, Max Reitz wrote: Make use of qcow2_change_refcount_order() to support changing the refcount order with qemu-img amend. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.c | 44 +++- 1 file changed, 35 insertions(+),

Re: [Qemu-block] [PATCH v8 0/8] Block Throttle Group Support

2015-06-03 Thread Stefan Hajnoczi
On Tue, May 19, 2015 at 03:24:28PM +0300, Alberto Garcia wrote: The previous series no longer applies after all the code that was moved to block/io.c in 61007b316c, so I rebased it. Other than that there are no changes. V8: - Rebased against the current master. V7:

Re: [Qemu-block] RFC block/iscsi command timeout

2015-06-03 Thread Paolo Bonzini
On 02/06/2015 18:43, ronnie sahlberg wrote: If we change this to iSCSI, we can actually avoid this by using task management functions: guest - QEMUwrite A to sector 1 QEMU - iSCSIwrite A to sector 1 ... timeout... QEMU - iSCSI task management:

Re: [Qemu-block] [PATCH v6 2/8] qmp: Add optional bool unmap to drive-mirror

2015-06-03 Thread Fam Zheng
On Tue, 06/02 11:28, Eric Blake wrote: On 05/27/2015 11:29 PM, Fam Zheng wrote: If specified as true, it allows discarding on target sectors where source is not allocated. Signed-off-by: Fam Zheng f...@redhat.com --- +++ b/qapi/block-core.json @@ -954,6 +954,11 @@ #

Re: [Qemu-block] [Qemu-devel] [PATCH v3 06/13] tap: Drop tap_can_send

2015-06-03 Thread Fam Zheng
On Tue, 06/02 17:21, Stefan Hajnoczi wrote: On Tue, May 19, 2015 at 10:51:03AM +, Fam Zheng wrote: -while (qemu_can_send_packet(s-nc)) { +while (true) { +bool can_send; uint8_t *buf = s-buf; +can_send = qemu_can_send_packet(s-nc); +

Re: [Qemu-block] [Qemu-devel] [PATCH 8/8] qemu-iotests: expand test 093 to support group throttling

2015-06-03 Thread Stefan Hajnoczi
On Fri, May 29, 2015 at 03:29:57PM +0200, Alberto Garcia wrote: On Fri 29 May 2015 02:32:45 PM CEST, Stefan Hajnoczi stefa...@gmail.com wrote: def setUp(self): -self.vm = iotests.VM().add_drive(self.test_img) +self.vm = iotests.VM() +for i in range(0,

Re: [Qemu-block] [PATCH 2/2] block: Let bdrv_drain_all() to call aio_poll() for each AioContext

2015-06-03 Thread Christian Borntraeger
Am 03.06.2015 um 15:46 schrieb Alexander Yarygin: After the commit 9b536adc (block: acquire AioContext in bdrv_drain_all()) the aio_poll() function got called for every BlockDriverState, in assumption that every device may have its own AioContext. If we have thousands of disks attached, there

Re: [Qemu-block] [PATCH 1/2] block-backend: Introduce blk_drain() and replace blk_drain_all()

2015-06-03 Thread Christian Borntraeger
Am 03.06.2015 um 15:46 schrieb Alexander Yarygin: Each call of the virtio_blk_reset() function calls blk_drain_all(), which works for all existing BlockDriverStates, while only one BlockDriverState needs to be drained. This patch introduces the blk_drain() function and replaces

Re: [Qemu-block] [PATCH 1/2] block-backend: Introduce blk_drain() and replace blk_drain_all()

2015-06-03 Thread Paolo Bonzini
On 03/06/2015 15:46, Alexander Yarygin wrote: Each call of the virtio_blk_reset() function calls blk_drain_all(), which works for all existing BlockDriverStates, while only one BlockDriverState needs to be drained. This patch introduces the blk_drain() function and replaces

Re: [Qemu-block] I/O accounting overhaul

2015-06-03 Thread Eric Blake
On 06/03/2015 07:40 AM, Alberto Garcia wrote: Hello, I would like to retake the work that Benoît was about to start last year and extend the I/O accounting in QEMU. I was reading the past discussions and I will try to summarize all the ideas. The current accounting code collects the

[Qemu-block] I/O accounting overhaul

2015-06-03 Thread Alberto Garcia
Hello, I would like to retake the work that Benoît was about to start last year and extend the I/O accounting in QEMU. I was reading the past discussions and I will try to summarize all the ideas. The current accounting code collects the following information: typedef struct BlockAcctStats {

[Qemu-block] [PATCH 1/2] block-backend: Introduce blk_drain() and replace blk_drain_all()

2015-06-03 Thread Alexander Yarygin
Each call of the virtio_blk_reset() function calls blk_drain_all(), which works for all existing BlockDriverStates, while only one BlockDriverState needs to be drained. This patch introduces the blk_drain() function and replaces blk_drain_all() on it in virtio_blk_reset(). Cc: Christian