From: "Daniel P. Berrange" <berrange@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
Kevin Wolf <kwolf@redhat.com>, Eric Blake <eblake@redhat.com>,
Fam Zheng <famz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 5/6] qemu-img: introduce --target-image-opts for 'convert' command
Date: Mon, 20 Feb 2017 12:44:23 +0000 [thread overview]
Message-ID: <20170220124423.GN15874@redhat.com> (raw)
In-Reply-To: <30f30db6-2bf4-44c6-5267-cd98e8d99bca@redhat.com>
On Fri, Feb 03, 2017 at 11:32:13PM +0100, Max Reitz wrote:
> On 03.02.2017 13:02, Daniel P. Berrange wrote:
> > The '--image-opts' flags indicates whether the source filename
> > includes options. The target filename has to remain in the
> > plain filename format though, since it needs to be passed to
> > bdrv_create(). When using --skip-create though, it would be
> > possible to use image-opts syntax. This adds --target-image-opts
> > to indicate that the target filename includes options. Currently
> > this mandates use of the --skip-create flag too.
> >
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > ---
> > qemu-img-cmds.hx | 6 +--
> > qemu-img.c | 131 ++++++++++++++++++++++++++++++++++++-------------------
> > qemu-img.texi | 12 ++++-
> > 3 files changed, 98 insertions(+), 51 deletions(-)
>
> Apart from what the commit message says, it also introduces that switch
> for dd, which I again don't like too much (quelle surprise), if only
> because it requires conv=nocreat and thus patch 5 to be useful.
Once again, I'll drop the 'dd' parts of this patch.
> > @@ -1918,7 +1933,7 @@ static int img_convert(int argc, char **argv)
> > bs_n = argc - optind - 1;
> > out_filename = bs_n >= 1 ? argv[argc - 1] : NULL;
> >
> > - if (options && has_help_option(options)) {
> > + if (out_fmt && options && has_help_option(options)) {
>
> "!out_fmt && options && has_help_option(options)" should probably be an
> error.
Ok.
> > @@ -1987,22 +2002,22 @@ static int img_convert(int argc, char **argv)
> > goto out;
> > }
> >
> > - /* Find driver and parse its options */
> > - drv = bdrv_find_format(out_fmt);
> > - if (!drv) {
> > - error_report("Unknown file format '%s'", out_fmt);
> > - ret = -1;
> > - goto out;
> > - }
> > + if (!skip_create) {
> > + /* Find driver and parse its options */
> > + drv = bdrv_find_format(out_fmt);
> > + if (!drv) {
> > + error_report("Unknown file format '%s'", out_fmt);
> > + ret = -1;
> > + goto out;
> > + }
> >
> > - proto_drv = bdrv_find_protocol(out_filename, true, &local_err);
> > - if (!proto_drv) {
> > - error_report_err(local_err);
> > - ret = -1;
> > - goto out;
> > - }
> > + proto_drv = bdrv_find_protocol(out_filename, true, &local_err);
> > + if (!proto_drv) {
> > + error_report_err(local_err);
> > + ret = -1;
> > + goto out;
> > + }
> >
> > - if (!skip_create) {
> > if (!drv->create_opts) {
> > error_report("Format driver '%s' does not support image creation",
> > drv->format_name);
>
> Compression may be used with -n. This involves the check whether
> drv->bdrv_co_pwritev_compressed is NULL or not -- which is bad if drv is
> still NULL:
>
> $ ./qemu-img create -f qcow2 foo.qcow2 64M
> Formatting 'foo.qcow2', fmt=qcow2 size=67108864 encryption=off
> cluster_size=65536 lazy_refcounts=off refcount_bits=16
> $ ./qemu-img convert -c -O qcow2 -n null-co:// foo.qcow2
> [1] 17179 segmentation fault (core dumped) ./qemu-img convert -c -O
> qcow2 -n null-co:// foo.qcow
>
> Therefore, you should probably only do the check whether compression is
> supported if drv is non-NULL; and if it is NULL, do the check again
> after the target image has been opened and its driver is known.
Oh, yes, that's a fun combination. I'll do that.
> > diff --git a/qemu-img.texi b/qemu-img.texi
> > index 01acfb8..bda3cc3 100644
> > --- a/qemu-img.texi
> > +++ b/qemu-img.texi
> > @@ -45,9 +45,17 @@ keys.
> >
> > @item --image-opts
> >
> > -Indicates that the @var{filename} parameter is to be interpreted as a
> > +Indicates that the source @var{filename} parameter is to be interpreted as a
> > full option string, not a plain filename. This parameter is mutually
> > -exclusive with the @var{-f} and @var{-F} parameters.
> > +exclusive with the @var{-f} parameter.
>
> -F is correct, that's the one for qemu-img compare, after all (which
> takes two source filenames).
>
> > +
> > +@item --target-image-opts
> > +
> > +Indicates that the target @var{filename} parameter(s) are to be interpreted a
> > +a full option string, not a plain filename. This parameter is mutually
> > +exclusive with the @var{-F} or @var{-O} parameters. It is currently required
>
> -F is unrelated to a target ("output") file.
Opps, yes.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
next prev parent reply other threads:[~2017-02-20 12:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 12:02 [Qemu-devel] [PATCH v2 0/6] qemu-img: improve convert & dd commands Daniel P. Berrange
2017-02-03 12:02 ` [Qemu-devel] [PATCH v2 1/6] qemu-img: add support for --object with 'dd' command Daniel P. Berrange
2017-02-03 21:01 ` Max Reitz
2017-02-20 12:32 ` Daniel P. Berrange
2017-02-03 12:02 ` [Qemu-devel] [PATCH v2 2/6] qemu-img: fix --image-opts usage with dd command Daniel P. Berrange
2017-02-03 21:08 ` Max Reitz
2017-02-03 12:02 ` [Qemu-devel] [PATCH v2 3/6] qemu-img: add support for conv=nocreat, notrunc args to " Daniel P. Berrange
2017-02-03 21:44 ` Max Reitz
2017-02-20 12:33 ` Daniel P. Berrange
2017-02-03 12:02 ` [Qemu-devel] [PATCH v2 4/6] qemu-img: add support for -o arg " Daniel P. Berrange
2017-02-03 22:07 ` Max Reitz
2017-02-20 12:33 ` Daniel P. Berrange
2017-02-03 12:02 ` [Qemu-devel] [PATCH v2 5/6] qemu-img: introduce --target-image-opts for 'convert' command Daniel P. Berrange
2017-02-03 22:32 ` Max Reitz
2017-02-20 12:44 ` Daniel P. Berrange [this message]
2017-02-03 12:02 ` [Qemu-devel] [PATCH v2 6/6] qemu-img: copy *key-secret opts when opening newly created files Daniel P. Berrange
2017-02-03 22:39 ` Max Reitz
2017-02-20 12:46 ` Daniel P. Berrange
2017-02-20 15:13 ` Daniel P. Berrange
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=20170220124423.GN15874@redhat.com \
--to=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=famz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.