[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 12/22] block: Allow recursive "file"s
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH v5 12/22] block: Allow recursive "file"s |
Date: |
Fri, 13 Dec 2013 21:19:58 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Am 13.12.2013 um 18:10 hat Max Reitz geschrieben:
> It should be possible to use a format as a driver for a file which in
> turn requires another file, i.e., nesting file formats.
>
> Signed-off-by: Max Reitz <address@hidden>
Hm, does this do what I think it does?
$ ./qemu-img convert -O qcow2 /home/kwolf/images/hd.img /tmp/hd.qcow2
$ ./qemu-img convert -f raw -O qcow2 /tmp/hd.qcow2 /tmp/hd.qcow2.qcow2
$ x86_64-softmmu/qemu-system-x86_64 -drive
driver=qcow2,file.driver=qcow2,file.file.driver=file,file.file.filename=/tmp/hd.qcow2.qcow2
I can't decide whether this is awesomeness or insanity, but in any case
it works with this patch. :-)
Worth a qemu-iotests case, I think.
> block.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/block.c b/block.c
> index 9659eb5..9222669 100644
> --- a/block.c
> +++ b/block.c
> @@ -948,14 +948,19 @@ int bdrv_file_open(BlockDriverState **pbs, const char
> *filename,
> goto fail;
> }
>
> - ret = bdrv_open_common(bs, NULL, options, flags, drv, &local_err);
> + if (!drv->bdrv_file_open) {
> + ret = bdrv_open(bs, filename, options, flags, drv, &local_err);
> + options = NULL;
> + } else {
> + ret = bdrv_open_common(bs, NULL, options, flags, drv, &local_err);
> + }
> if (ret < 0) {
> error_propagate(errp, local_err);
> goto fail;
> }
>
> /* Check if any unknown options were used */
> - if (qdict_size(options) != 0) {
> + if (options && (qdict_size(options) != 0)) {
> const QDictEntry *entry = qdict_first(options);
> error_setg(errp, "Block protocol '%s' doesn't support the option
> '%s'",
> drv->format_name, entry->key);
> @@ -970,10 +975,12 @@ int bdrv_file_open(BlockDriverState **pbs, const char
> *filename,
>
> fail:
> QDECREF(options);
> - if (!bs->drv) {
> - QDECREF(bs->options);
> + if (bs) {
> + if (!bs->drv) {
> + QDECREF(bs->options);
> + }
> + bdrv_unref(bs);
> }
> - bdrv_unref(bs);
> return ret;
> }
Not sure why this hunk is needed, but anyway:
Reviewed-by: Kevin Wolf <address@hidden>
[Qemu-devel] [PATCH v5 13/22] qemu-iotests: Fix output of test 051, Max Reitz, 2013/12/13
[Qemu-devel] [PATCH v5 14/22] blockdev: Move "file" to legacy_opts, Max Reitz, 2013/12/13
[Qemu-devel] [PATCH v5 15/22] blkdebug: Allow command-line file configuration, Max Reitz, 2013/12/13