[Qemu-block] [PATCH v5 3/3] qemu-iotests: Test unaligned sub-block zero write

2015-05-04 Thread Fam Zheng
Test zero write in byte range 512~1024 for 4k alignment. Signed-off-by: Fam Zheng --- tests/qemu-iotests/033 | 13 + tests/qemu-iotests/033.out | 30 ++ 2 files changed, 43 insertions(+) diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033 ind

[Qemu-block] [PATCH v5 2/3] block: Fix NULL deference for unaligned write if qiov is NULL

2015-05-04 Thread Fam Zheng
For zero write, qiov passed by callers (qemu-io "write -z" and scsi-disk "write same") is NULL. Commit fc3959e466 fixed bdrv_co_write_zeroes which is the common case for this bug, but it still exists in bdrv_aio_write_zeroes. A simpler fix would be in bdrv_co_do_pwritev which is the NULL dereferen

[Qemu-block] [PATCH v5 1/3] Revert "block: Fix unaligned zero write"

2015-05-04 Thread Fam Zheng
This reverts commit fc3959e4669a1c2149b91ccb05101cfc7ae1fc05. The core write code already handles the case, so remove this duplication. Because commit 61007b316 moved the touched code from block.c to block/io.c, the change is manually reverted. Signed-off-by: Fam Zheng --- block/io.c | 45

[Qemu-block] [PATCH v5 0/3] block: Fix unaligned bdrv_aio_write_zeroes

2015-05-04 Thread Fam Zheng
An unaligned zero write causes NULL deferencing in bdrv_co_do_pwritev. That path is reachable from bdrv_co_write_zeroes and bdrv_aio_write_zeroes. You can easily trigger through the former with qemu-io, as the test case added by 61815d6e0aa. For bdrv_aio_write_zeroes, in common cases there's alway

Re: [Qemu-block] [Qemu-devel] [PATCH v4 0/3] block: Fix unaligned bdrv_aio_write_zeroes

2015-05-04 Thread Fam Zheng
On Thu, 04/30 15:34, Kevin Wolf wrote: > Am 27.04.2015 um 15:18 hat Fam Zheng geschrieben: > > An unaligned zero write causes NULL deferencing in bdrv_co_do_pwritev. That > > path is reachable from bdrv_co_write_zeroes and bdrv_aio_write_zeroes. > > > > You can easily trigger through the former wi

Re: [Qemu-block] [PATCH v4 16/17] qapi: Expose new qcow2 overlap check options

2015-05-04 Thread Eric Blake
On 05/04/2015 01:15 PM, Max Reitz wrote: > Expose the two new options for controlling the memory usage of the > overlap check implementation via QAPI. > > Signed-off-by: Max Reitz > --- > qapi/block-core.json | 37 + > 1 file changed, 37 insertions(+) > > dif

Re: [Qemu-block] [PATCH v4 13/17] qcow2/overlaps: Add "memory limit reached" event

2015-05-04 Thread Eric Blake
On 05/04/2015 01:15 PM, Max Reitz wrote: > Later, a mechanism to set a limit on how much memory may be used for the > overlap prevention structures will be introduced. If that limit is about > to be exceeded, a QMP event should be emitted. This very event is > specified by this patch. > > Signed-o

[Qemu-block] [PATCH v4 16/17] qapi: Expose new qcow2 overlap check options

2015-05-04 Thread Max Reitz
Expose the two new options for controlling the memory usage of the overlap check implementation via QAPI. Signed-off-by: Max Reitz --- qapi/block-core.json | 37 + 1 file changed, 37 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index

[Qemu-block] [PATCH v4 17/17] iotests: Test qcow2's overlap check memory limit

2015-05-04 Thread Max Reitz
This patch adds some test cases for the memory limit concerning the in-memory structures used to detect and prevent accidental metadata overlaps. Signed-off-by: Max Reitz --- tests/qemu-iotests/060 | 222 + tests/qemu-iotests/060.out | 47

[Qemu-block] [PATCH v4 14/17] qcow2/overlaps: Add memory usage limit

2015-05-04 Thread Max Reitz
This adds an adjustable limit for the total memory usage of the overlap prevention structures. Signed-off-by: Max Reitz --- block/qcow2-overlap.c | 145 +++--- block/qcow2.c | 2 +- block/qcow2.h | 2 +- 3 files changed, 139 inserti

[Qemu-block] [PATCH v4 12/17] qcow2: Use new metadata overlap check function

2015-05-04 Thread Max Reitz
Make the static new overlap check function global and drop the old function. Signed-off-by: Max Reitz --- block/qcow2-overlap.c | 8 +--- block/qcow2-refcount.c | 120 - 2 files changed, 2 insertions(+), 126 deletions(-) diff --git a/block/qcow

[Qemu-block] [PATCH v4 06/17] qcow2/overlaps: Protect refcount blocks

2015-05-04 Thread Max Reitz
Keep track of the refcount blocks in the metadata list to protect them against accidental modifications. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/qcow2-refcount.c | 38 +- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/block/q

[Qemu-block] [PATCH v4 07/17] qcow2/overlaps: Protect active L1 table

2015-05-04 Thread Max Reitz
Keep track of the active L1 table in the metadata list to protect it against accidental modifications. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/qcow2-cluster.c | 11 +++ block/qcow2-snapshot.c | 10 ++ block/qcow2.c | 4 3 files changed, 25 inse

[Qemu-block] [PATCH v4 13/17] qcow2/overlaps: Add "memory limit reached" event

2015-05-04 Thread Max Reitz
Later, a mechanism to set a limit on how much memory may be used for the overlap prevention structures will be introduced. If that limit is about to be exceeded, a QMP event should be emitted. This very event is specified by this patch. Signed-off-by: Max Reitz --- docs/qmp/qmp-events.txt | 28 +

[Qemu-block] [PATCH v4 09/17] qcow2/overlaps: Protect snapshot table

2015-05-04 Thread Max Reitz
Keep track of the snapshot table in the metadata list to protect it against accidental modifications. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/qcow2-snapshot.c | 10 ++ block/qcow2.c | 6 ++ 2 files changed, 16 insertions(+) diff --git a/block/qcow2-snap

[Qemu-block] [PATCH v4 15/17] qcow2: Add overlap structure memory size options

2015-05-04 Thread Max Reitz
Add runtime options to qcow2 to control the size of the structures used for metadata overlap prevention (one option to control the size of the bitmap cache, another one to control the total memory size limit). Signed-off-by: Max Reitz --- block/qcow2.c | 35 +-- b

[Qemu-block] [PATCH v4 11/17] qcow2/overlaps: Protect inactive L2 tables

2015-05-04 Thread Max Reitz
Keep track of the inactive L2 tables in the metadata list to protect them against accidental modifications. Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 20 block/qcow2-snapshot.c | 43 --- 2 files changed, 60 insertions(+), 3

[Qemu-block] [PATCH v4 08/17] qcow2/overlaps: Protect active L2 tables

2015-05-04 Thread Max Reitz
Keep track of the active L2 tables in the metadata list to protect them against accidental modifications. Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 2 ++ block/qcow2-refcount.c | 6 ++ block/qcow2-snapshot.c | 21 + block/qcow2.c | 8 +++- 4 fi

[Qemu-block] [PATCH v4 05/17] qcow2/overlaps: Protect refcount table

2015-05-04 Thread Max Reitz
Keep track of the refcount table in the metadata list to protect it against accidental modifications. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/qcow2-refcount.c | 18 ++ block/qcow2.c | 4 2 files changed, 22 insertions(+) diff --git a/block/qcow

[Qemu-block] [PATCH v4 10/17] qcow2/overlaps: Protect inactive L1 tables

2015-05-04 Thread Max Reitz
Keep track of the inactive L1 tables in the metadata list to protect them against accidental modifications. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/qcow2-snapshot.c | 25 + 1 file changed, 25 insertions(+) diff --git a/block/qcow2-snapshot.c b/block/q

[Qemu-block] [PATCH v4 04/17] qcow2/overlaps: Protect image header

2015-05-04 Thread Max Reitz
Enter the image header into the metadata list to protect it against accidental modifications. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/qcow2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index b15a612..fc53b34 100644 --- a/block/qcow2.c

[Qemu-block] [PATCH v4 02/17] qcow2: Pull up overlap check option evaluation

2015-05-04 Thread Max Reitz
Pull up the absorption of the qcow2-relevant command line options and the evaluation of the overlap check options in qcow2_open(). Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/qcow2.c | 96 +-- 1 file changed, 48 insertions(+

[Qemu-block] [PATCH v4 03/17] qcow2: Create metadata list

2015-05-04 Thread Max Reitz
Create and destroy the metadata list on creation and destruction of a qcow2 BDS, respectively. Skip creation if no overlap checks should be performed. Signed-off-by: Max Reitz --- block/qcow2.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index c

[Qemu-block] [PATCH v4 00/17] qcow2: Add new overlap check functions

2015-05-04 Thread Max Reitz
This is a continuation of previous versions of this series. v2's cover letter was the most elaborate, which you can find here (includes benchmarks): http://lists.nongnu.org/archive/html/qemu-devel/2014-11/msg03430.html See patch 1 for an explanation of why this series exists and what it does. Patc

[Qemu-block] [PATCH v4 01/17] qcow2: Add new overlap check functions

2015-05-04 Thread Max Reitz
The existing qcow2 metadata overlap detection function used existing structures to determine the location of the image metadata, from plain fields such as l1_table_offset and l1_size in the BDRVQcowState, over image structures in memory such as the L1 table for the L2 tables' positions, or it even

Re: [Qemu-block] [Qemu-devel] [PATCH v3 3/9] libqos: Add migration helpers

2015-05-04 Thread John Snow
On 05/04/2015 08:07 AM, Kevin Wolf wrote: Am 30.04.2015 um 20:07 hat John Snow geschrieben: libqos.c: -set_context for addressing which commands go where -migrate performs the actual migration malloc.c: - Structure of the allocator is adjusted slightly with a second-tier

Re: [Qemu-block] [PATCH v3 0/9] ahci: enable migration

2015-05-04 Thread John Snow
On 05/04/2015 08:29 AM, Kevin Wolf wrote: Am 30.04.2015 um 20:07 hat John Snow geschrieben: The day we all feared is here, and I am proposing we allow the migration of the AHCI device tentatively for the 2.4 development window. There are some more NCQ migration tests are needed, but I felt th

Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] vl.c: Since the help says that 'disk_image' is a raw hard disk image, pass format=raw

2015-05-04 Thread Kevin Wolf
Am 04.05.2015 um 15:39 hat Markus Armbruster geschrieben: > Kevin Wolf writes: > > > Am 01.05.2015 um 01:28 hat Don Slutz geschrieben: > [...] > >> So do you want a more complex patch that allows the format to be > >> specified? > >> > >> Only for 'disk_image'? > >> > >> Include -hd* ? > > > >

[Qemu-block] [PATCH 2/2] block: align bounce buffers to page

2015-05-04 Thread Denis V. Lunev
The following sequence int fd = open(argv[1], O_RDWR | O_CREAT | O_DIRECT, 0644); for (i = 0; i < 10; i++) write(fd, buf, 4096); performs 5% better if buf is aligned to 4096 bytes. The difference is quite reliable. On the other hand we do not want at the moment to enforce

[Qemu-block] [PATCH 1/2] block: minimal bounce buffer alignment

2015-05-04 Thread Denis V. Lunev
The patch introduces new concept: minimal memory alignment for bounce buffers. Original so called "optimal" value is actually minimal required value for aligment. It should be used for validation that the IOVec is properly aligned and bounce buffer is not required. Though, from the performance poi

[Qemu-block] [PATCH v5 0/2] block: enforce minimal 4096 alignment in qemu_blockalign

2015-05-04 Thread Denis V. Lunev
The following sequence int fd = open(argv[1], O_RDWR | O_CREAT | O_DIRECT, 0644); for (i = 0; i < 10; i++) write(fd, buf, 4096); iperforms 5% better if buf is aligned to 4096 bytes rather then to 512 bytes. I have used the following program to test #define _GNU_SOURCE #inc

Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] vl.c: Since the help says that 'disk_image' is a raw hard disk image, pass format=raw

2015-05-04 Thread Markus Armbruster
Kevin Wolf writes: > Am 01.05.2015 um 01:28 hat Don Slutz geschrieben: [...] >> So do you want a more complex patch that allows the format to be >> specified? >> >> Only for 'disk_image'? >> >> Include -hd* ? > > I'm afraid that there is no nice way to improve the plain 'disk_image' > case. You

Re: [Qemu-block] [PATCH v3 0/9] ahci: enable migration

2015-05-04 Thread Kevin Wolf
Am 30.04.2015 um 20:07 hat John Snow geschrieben: > The day we all feared is here, and I am proposing we allow the migration > of the AHCI device tentatively for the 2.4 development window. > > There are some more NCQ migration tests are needed, but I felt that it was > important to get migration

Re: [Qemu-block] [PATCH v3 3/9] libqos: Add migration helpers

2015-05-04 Thread Kevin Wolf
Am 30.04.2015 um 20:07 hat John Snow geschrieben: > libqos.c: > -set_context for addressing which commands go where > -migrate performs the actual migration > > malloc.c: > - Structure of the allocator is adjusted slightly with > a second-tier malloc to make swapping around the a

Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] vl.c: Since the help says that 'disk_image' is a raw hard disk image, pass format=raw

2015-05-04 Thread Kevin Wolf
Am 01.05.2015 um 01:28 hat Don Slutz geschrieben: > On 04/30/15 16:15, Kevin Wolf wrote: > > Am 30.04.2015 um 21:15 hat Eric Blake geschrieben: > >> [adding qemu-block] > >> > >> On 04/30/2015 12:23 PM, Don Slutz wrote: > >>> ~/qemu/out/master/x86_64-softmmu/qemu-system-x86_64 -h | head > >>> QEM

Re: [Qemu-block] [PATCH 1/6] qcow2: use one single memory block for the L2/refcount cache tables

2015-05-04 Thread Kevin Wolf
Am 01.05.2015 um 16:23 hat Stefan Hajnoczi geschrieben: > On Thu, Apr 30, 2015 at 01:11:40PM +0300, Alberto Garcia wrote: > > Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables) > > { > > BDRVQcowState *s = bs->opaque; > > Qcow2Cache *c; > > -int i; > > > > c