From: Eric Blake <eblake@redhat.com>
To: John Snow <jsnow@redhat.com>, qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qemu-img: Check for backing image if specified during create
Date: Thu, 4 May 2017 14:58:58 -0500 [thread overview]
Message-ID: <d4850849-597b-ed09-ea43-b09621c0f5f0@redhat.com> (raw)
In-Reply-To: <20170504193044.16303-1-jsnow@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4642 bytes --]
On 05/04/2017 02:30 PM, John Snow wrote:
> Or, rather, force the open of a backing image if one was specified
> for creation. Using a similar -unsafe option as rebase, allow qemu-img
> to ignore the backing file validation if possible.
>
> It may not always be possible, as in the existing case of if a filesize
s/of if/when/
> for the new image was not specified.
>
> This is accomplished by shifting around the conditionals in
> bdrv_img_create, such that a backing file is always opened unless we
> provide BDRV_O_NO_BACKING. qemu-img is adjusted to pass this new flag
> when -u is provided to create.
>
> Sorry for the heinous looking diffstat, but it's mostly whitespace.
>
Indeed, reviewing under 'git diff -b' proved fruitful.
> Inspired by: https://bugzilla.redhat.com/show_bug.cgi?id=1213786
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> block.c | 75 +++++++++++++++++++++++-----------------------
> qemu-img-cmds.hx | 4 +--
Conflicts with the documentation patch for [-b backing_file] (already on
PULL request:
https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg05816.html
so you'll have to rebase, but it shouldn't be too difficult.
> qemu-img.c | 15 ++++++----
> tests/qemu-iotests/082 | 4 +--
> tests/qemu-iotests/082.out | 4 +--
> 5 files changed, 54 insertions(+), 48 deletions(-)
>
> diff --git a/block.c b/block.c
> index 5db266b..da28052 100644
> --- a/block.c
> +++ b/block.c
> @@ -4280,38 +4280,38 @@ void bdrv_img_create(const char *filename, const char *fmt,
> // The size for the image must always be specified, with one exception:
> // If we are using a backing file, we can obtain the size from there
> size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0);
> - if (size == -1) {
Wait. How does this even work? qemu_opt_get_size() returns an unsigned
value, either what was specified by the option, or else the default
parameter (which we passed as 0), so how can size ever be -1? It might
make sense if we had called:
size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, -1);
with the intent of allowing an explicit size of 0. But I'm lost as to
how this code ever worked pre-patch...
> +
> + if (size == -1) {
...which therefore carries over to the state of things post-patch.
/me goes and reads code
What?
if (desc && desc->def_value_str) {
parse_option_size(name, desc->def_value_str, &ret, &error_abort);
return ret;
Oh - so THAT's how: qemu_opt_get_size_helper() ignores the 'defval'
input and instead returns a DIFFERENT default associated with the
QemuOpts. UGLY. But not your fault.
> +++ b/qemu-img.c
> @@ -145,9 +145,10 @@ static void QEMU_NORETURN help(void)
> " 'snapshot_id_or_name' is deprecated, use 'snapshot_param'\n"
> " instead\n"
> " '-c' indicates that target image must be compressed (qcow format only)\n"
> - " '-u' enables unsafe rebasing. It is assumed that old and new backing file\n"
> - " match exactly. The image doesn't need a working backing file before\n"
> - " rebasing in this case (useful for renaming the backing file)\n"
> + " '-u' allows unsafe backing chains. For rebasing, it is assumed that old and new \n"
> + " backing file match exactly. The image doesn't need a working backing file \n"
> + " before rebasing in this case (useful for renaming the backing file)\n"
> + " For image creation, allow creating without attempting to open the file.\n"
maybe s/to open the file/to open the backing file/
> +++ b/tests/qemu-iotests/082
> @@ -85,8 +85,8 @@ run_qemu_img create -f $IMGFMT -o cluster_size=4k -o help "$TEST_IMG" $size
> run_qemu_img create -f $IMGFMT -o cluster_size=4k -o \? "$TEST_IMG" $size
>
> # Looks like a help option, but is part of the backing file name
> -run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG",,help "$TEST_IMG" $size
> -run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG",,\? "$TEST_IMG" $size
> +run_qemu_img create -f $IMGFMT -u -o backing_file="$TEST_IMG",,help "$TEST_IMG" $size
> +run_qemu_img create -f $IMGFMT -u -o backing_file="$TEST_IMG",,\? "$TEST_IMG" $size
Nice test of the new usage.
I like where it's headed. It will need a v2 to rebase and fix the
things I pointed out, but I'm looking forward to it.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2017-05-04 19:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 19:30 [Qemu-devel] [PATCH] qemu-img: Check for backing image if specified during create John Snow
2017-05-04 19:58 ` Eric Blake [this message]
2017-05-04 21:02 ` John Snow
2017-05-04 20:00 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d4850849-597b-ed09-ea43-b09621c0f5f0@redhat.com \
--to=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).