Our code was already checking that we did not attempt to
allocate more clusters than what would fit in an INT64 (the
physical maximimum if we can access a full off_t's worth of
data). But this does not catch smaller limits enforced by
various spots in the qcow2 image description: L1 and normal
When reading a compressed image, we were allocating s->cluster_data
to 32*cluster_size + 512 (possibly over 64 megabytes, for an image
with 2M clusters). Let's check out the history:
Back when qcow2 was first written, we used s->cluster_data for
everything, including copy_sectors() and
Updates to v1:
- fix whitespace [Berto]
- fix g_try_malloc usage [Berto, Kevin]
- improve comments [Berto, Kevin]
- add a patch to avoid overflow on 512TB images with 2M clusters
Eric Blake (3):
qcow2: Prefer byte-based calls into bs->file
qcow2: Don't allow overflow during cluster allocation
On 02/21/2018 08:08 AM, Alberto Garcia wrote:
This patch fixes several mistakes in the documentation of the
compressed cluster descriptor:
More things to consider, as followup patches:
Note that both the L1 table, and the standard L2 descriptors, have a cap
on bit 55 as the maximum host
On 02/21/2018 11:39 AM, Kevin Wolf wrote:
See my commit message comment - we have other spots in the code base that
blindly g_malloc(2 * s->cluster_size).
Though is that a reason to do the same in new code or to phase out such
allocations whenever you touch them?
Touché.
And I intended
On 02/21/2018 07:53 AM, Kevin Wolf wrote:
Signed-off-by: Kevin Wolf
---
tests/test-qemu-opts.c | 125 +
1 file changed, 125 insertions(+)
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index
On 02/21/2018 07:53 AM, Kevin Wolf wrote:
Basic test for merging two QemuOptsLists.
Signed-off-by: Kevin Wolf
---
tests/test-qemu-opts.c | 128 +
1 file changed, 128 insertions(+)
Reviewed-by: Eric Blake
Am 19.02.2018 um 15:54 hat Alberto Garcia geschrieben:
> This patch updates docs/qcow2-cache.txt explaining how to use the new
> l2-cache-entry-size parameter.
>
> Here's a more detailed technical description of this feature:
>
>
On 02/21/2018 07:53 AM, Kevin Wolf wrote:
This allows, given a QemuOpts for a QemuOptsList that was merged from
multiple QemuOptsList, to only consider those options that exist in one
specific list. Block drivers need this to separate format-layer create
options from protocol-level options.
On 02/21/2018 10:59 AM, Eric Blake wrote:
> On 02/21/2018 09:00 AM, Eric Blake wrote:
>> On 02/21/2018 04:04 AM, Alberto Garcia wrote:
>>> On Tue 20 Feb 2018 11:24:59 PM CET, Eric Blake wrote:
>>>
>>> I was also preparing a patch to change this, but you arrived first :-)
>>>
So, it's time
Am 21.02.2018 um 17:59 hat Eric Blake geschrieben:
> On 02/21/2018 10:51 AM, Kevin Wolf wrote:
> > Am 20.02.2018 um 23:24 hat Eric Blake geschrieben:
> > > When reading a compressed image, we were allocating s->cluster_data
> > > to 32*cluster_size + 512 (possibly over 64 megabytes, for an image
>
Am 21.02.2018 um 15:08 hat Alberto Garcia geschrieben:
> This patch fixes several mistakes in the documentation of the
> compressed cluster descriptor:
>
> 1) the documentation claims that the cluster descriptor contains the
>number of sectors used to store the compressed data, but what it
>
On 02/21/2018 10:51 AM, Kevin Wolf wrote:
Am 20.02.2018 um 23:24 hat Eric Blake geschrieben:
When reading a compressed image, we were allocating s->cluster_data
to 32*cluster_size + 512 (possibly over 64 megabytes, for an image
with 2M clusters). Let's check out the history:
Much later, in
Am 20.02.2018 um 23:24 hat Eric Blake geschrieben:
> When reading a compressed image, we were allocating s->cluster_data
> to 32*cluster_size + 512 (possibly over 64 megabytes, for an image
> with 2M clusters). Let's check out the history:
>
> Back when qcow2 was first written, we used
On 02/21/2018 04:29 AM, Kevin Wolf wrote:
+++ b/include/block/block_int.h
@@ -130,6 +130,8 @@ struct BlockDriver {
int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags,
Error **errp);
void (*bdrv_close)(BlockDriverState *bs);
+int
On Wed 21 Feb 2018 05:10:30 PM CET, Eric Blake wrote:
>> Compressed Clusters Descriptor (x = 62 - (cluster_bits - 8)):
>>
>> -Bit 0 - x:Host cluster offset. This is usually _not_ aligned to a
>> -cluster boundary!
>> +Bit 0 - x-1: Host cluster offset. This
CC: qemu-sta...@nongnu.org
Incorrect docs make for difficult interoperability.
On 02/21/2018 08:08 AM, Alberto Garcia wrote:
This patch fixes several mistakes in the documentation of the
compressed cluster descriptor:
1) the documentation claims that the cluster descriptor contains the
On 02/21/2018 08:08 AM, Alberto Garcia wrote:
This patch fixes several mistakes in the documentation of the
compressed cluster descriptor:
1) the documentation claims that the cluster descriptor contains the
number of sectors used to store the compressed data, but what it
actually
On 02/21/2018 09:00 AM, Eric Blake wrote:
On 02/21/2018 04:04 AM, Alberto Garcia wrote:
On Tue 20 Feb 2018 11:24:59 PM CET, Eric Blake wrote:
I was also preparing a patch to change this, but you arrived first :-)
So, it's time to cut back on the waste. A compressed cluster
will NEVER occupy
On Wed 21 Feb 2018 04:00:54 PM CET, Eric Blake wrote:
>> - Solution b: the width of the 'compressed cluster size' field is
>>(cluster_bits - 8), that's (cluster_size / 256) sectors.
>
> Not true. It is (cluster_bits - 9) or (cluster_size / 512).
It's not, it's (cluster_bits - 8), the
On 02/21/2018 04:04 AM, Alberto Garcia wrote:
On Tue 20 Feb 2018 11:24:59 PM CET, Eric Blake wrote:
I was also preparing a patch to change this, but you arrived first :-)
So, it's time to cut back on the waste. A compressed cluster
will NEVER occupy more than an uncompressed cluster (okay,
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
tests/qemu-iotests/207 | 261 +
tests/qemu-iotests/207.out | 75 +
tests/qemu-iotests/group | 1 +
3 files changed, 337 insertions(+)
Create a BlockdevOptionsSsh object in connect_to_ssh() and take the
options from there. 'host_key_check' is still processed separately
because it's not in the schema yet.
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
block/ssh.c | 136
This adds the .bdrv_co_create driver callback to ssh, which enables
image creation over QMP.
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
qapi/block-core.json | 16 -
block/ssh.c | 92
This adds the .bdrv_co_create driver callback to nfs, which enables
image creation over QMP.
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
qapi/block-core.json | 16 +++-
block/nfs.c | 74
This patch fixes several mistakes in the documentation of the
compressed cluster descriptor:
1) the documentation claims that the cluster descriptor contains the
number of sectors used to store the compressed data, but what it
actually contains is the number of sectors *minus one* or, in
Using the QAPI visitor to turn all options into QAPI BlockdevOptionsNfs
simplifies the code a lot. It will also be useful for implementing the
QAPI based .bdrv_co_create callback.
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
block/nfs.c | 176
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
tests/qemu-iotests/206 | 436 +
tests/qemu-iotests/206.out | 209 ++
tests/qemu-iotests/group | 1 +
3 files changed, 646
If bdrv_truncate() is called, but the requested size is the same as
before, don't call posix_fallocate(), which returns -EINVAL for length
zero and would therefore make bdrv_truncate() fail.
The problem can be triggered by creating a zero-sized raw image with
'falloc' preallocation mode.
Move the parsing of the QDict options up to the callers, in preparation
for the .bdrv_co_create implementation that directly gets a QAPI type.
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
block/ssh.c | 34 +-
1 file
With the conversion to a QAPI options object, the function is now
prepared to be used in a .bdrv_co_create implementation.
Signed-off-by: Kevin Wolf
---
block/rbd.c | 102 +++-
1 file changed, 52 insertions(+), 50
Most callers have their own checks, but something like this should also
be checked centrally. As it happens, x-blockdev-create can pass negative
image sizes to format drivers (because there is no QAPI type that would
reject negative numbers) and triggers the check added by this patch.
This makes the host-key-check option available in blockdev-add.
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
qapi/block-core.json | 63 +++--
block/ssh.c | 88
This is almost exactly the same code. The differences are that
qemu_rbd_connect() supports BlockdevOptionsRbd.server and that the cache
mode is set explicitly.
Supporting 'server' is a welcome new feature for image creation.
Caching is disabled by default, so leave it that way.
Signed-off-by:
If we want to include the invalid option name in the error message, we
can't free the string earlier than that.
Signed-off-by: Kevin Wolf
---
block/rbd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/rbd.c b/block/rbd.c
index
This adds the .bdrv_co_create driver callback to sheepdog, which enables
image creation over QMP.
Signed-off-by: Kevin Wolf
---
qapi/block-core.json | 24 +-
block/sheepdog.c | 240 +++
2 files changed, 189
Now that the options are already available in qemu_rbd_open() and not
only parsed in qemu_rbd_connect(), we can assign s->snap and
s->image_name there instead of passing the fields by reference to
qemu_rbd_connect().
Signed-off-by: Kevin Wolf
---
block/rbd.c | 14
This adds the .bdrv_co_create driver callback to file-win32, which
enables image creation over QMP.
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
block/file-win32.c | 45 +
1 file changed, 37 insertions(+),
The "redundacy" option for Sheepdog image creation is currently a string
that can encode one or two integers depending on its format, which at
the same time implicitly selects a mode.
This patch turns it into a QAPI union and converts the string into such
a QAPI object before interpreting the
This adds the .bdrv_co_create driver callback to file, which enables
image creation over QMP.
Signed-off-by: Kevin Wolf
Reviewed-by: Max Reitz
---
qapi/block-core.json | 20 +-
block/file-posix.c | 77
We'll use a separate source file for image creation, and we need to
check there whether the requested driver is whitelisted.
Signed-off-by: Kevin Wolf
---
include/block/block.h | 1 +
block.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git
This adds the .bdrv_co_create driver callback to gluster, which enables
image creation over QMP.
Signed-off-by: Kevin Wolf
---
qapi/block-core.json | 18 ++-
block/gluster.c | 135 ++-
2 files changed, 108
Instead of the QemuOpts in qemu_rbd_connect(), we want to use QAPI
objects. As a preparation, fetch those options directly from the QDict
that .bdrv_open() supports in the rbd driver and that are not in the
schema.
Signed-off-by: Kevin Wolf
---
block/rbd.c | 55
A few block drivers will need to rename .bdrv_create options for their
QAPIfication, so let's have a helper function for that.
Signed-off-by: Kevin Wolf
---
include/qapi/qmp/qdict.h | 6 +++
qobject/qdict.c | 34 ++
tests/check-qdict.c | 113
Instead of manually creating the BlockdevCreateOptions object, use a
visitor to parse the given options into the QAPI object.
This involves translation from the old command line syntax to the syntax
mandated by the QAPI schema. Option names are still checked against
qcow2_create_opts, so only the
Basic test for merging two QemuOptsLists.
Signed-off-by: Kevin Wolf
---
tests/test-qemu-opts.c | 128 +
1 file changed, 128 insertions(+)
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index 5d5a3daa7b..6c3183390b
Instead of passing a separate BlockDriverState* into qcow2_create2(),
make use of the BlockdevRef that is included in BlockdevCreateOptions.
Signed-off-by: Kevin Wolf
Reviewed-by: Eric Blake
Reviewed-by: Max Reitz
---
Once qcow2_create2() can be called directly on an already existing node,
we must provide the 'full' and 'falloc' preallocation modes outside of
creating the image on the protocol layer. Fortunately, we have
preallocated truncate now which can provide this functionality.
Signed-off-by: Kevin Wolf
This allows, given a QemuOpts for a QemuOptsList that was merged from
multiple QemuOptsList, to only consider those options that exist in one
specific list. Block drivers need this to separate format-layer create
options from protocol-level options.
Signed-off-by: Kevin Wolf
This creates a BlockdevCreateOptions union type that will contain all of
the options for image creation. We'll start out with an empty struct
type BlockdevCreateNotSupported for all drivers.
Signed-off-by: Kevin Wolf
Reviewed-by: Eric Blake
Reviewed-by: Max
Signed-off-by: Kevin Wolf
Reviewed-by: Eric Blake
Reviewed-by: Max Reitz
---
qapi/block-core.json | 45 -
1 file changed, 44 insertions(+), 1 deletion(-)
diff --git a/qapi/block-core.json
Currently, qcow2_create() only parses the QemuOpts and then calls
qcow2_create2() for the actual image creation, which includes both the
creation of the actual file on the file system and writing a valid empty
qcow2 image into that file.
The plan is that qcow2_create2() becomes the function that
This series implements a minimal QMP command that allows to create an
image file on the protocol level or an image format on a given block
node.
Eventually, the interface is going to change to some kind of an async
command (possibly a (non-)block job), but that will require more work on
the job
On Tue 20 Feb 2018 08:40:43 PM CET, Eric Blake wrote:
>> Compressed Clusters Descriptor (x = 62 - (cluster_bits - 8)):
>
> I'm looking at how this works for different cluster sizes. If we have
> 512-byte clusters, x is 61, and we DON'T have the 'number sectors'
> field at all!
Well, you can
On Tue, Feb 20, 2018 at 04:10:03PM +0100, Peter Lieven wrote:
> this patch makes the bulk phase of a block migration to take
> place before we start transferring ram. As the bulk block migration
> can take a long time its pointless to transfer ram during that phase.
>
> Signed-off-by: Peter
Am 15.02.2018 um 20:58 hat Eric Blake geschrieben:
> On 02/08/2018 01:23 PM, Kevin Wolf wrote:
> > This adds a synchronous x-blockdev-create QMP command that can create
> > qcow2 images on a given node name.
> >
> > We don't want to block while creating an image, so this is not the final
> >
On Tue 20 Feb 2018 11:24:59 PM CET, Eric Blake wrote:
I was also preparing a patch to change this, but you arrived first :-)
> So, it's time to cut back on the waste. A compressed cluster
> will NEVER occupy more than an uncompressed cluster (okay, gzip
> DOES document that because the
On Tue 20 Feb 2018 11:24:58 PM CET, Eric Blake wrote:
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index d46b69d7f34..3fefeb3dc50 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -2310,8 +2310,8 @@ write_refblocks:
> on_disk_refblock = (void
58 matches
Mail list logo