From: Eric Blake <eblake@redhat.com>
To: Klim Kireev <klim.kireev@virtuozzo.com>,
kwolf@redhat.com, mreitz@redhat.com, qemu-block@nongnu.org,
qemu-devel@nongnu.org
Cc: den@openvz.org, vsementsov@virtuozzo.com
Subject: Re: [Qemu-devel] [PATCH] qemu-img: add the simplest format recognition
Date: Fri, 1 Dec 2017 16:12:21 -0600 [thread overview]
Message-ID: <0e8dbd28-a77f-ad9a-201b-fd99e0b824e7@redhat.com> (raw)
In-Reply-To: <20171201200515.9938-1-klim.kireev@virtuozzo.com>
On 12/01/2017 02:05 PM, Klim Kireev wrote:
> Now, if you type something like
>
> qemu-img create disk.qcow2 1G
> or
> qemu-img dd if=/dev/sda of=disk.qcow2
>
> it creates a raw image and if you need you should
> manually specify an image format with -f qcow2. It would
> be more convenient if it could be detected from an extension.
>
> This patch adds a simple heuristic to recognize the image format
> for qcow, qcow2, vmdk, vhdx, vdi
>
> Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.com>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> qemu-img.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
Is it also worth warning the user that we guessed, and that they should
specify -f if our guess was wrong?
> @@ -496,6 +510,9 @@ static int img_create(int argc, char **argv)
>
> /* Get the filename */
> filename = (optind < argc) ? argv[optind] : NULL;
> + if (fmt == NULL) {
> + fmt = get_format(filename);
Particularly if fmt == "raw", because the user typed something like
'foo.img' instead of 'foo.qcow2'. I suspect another common mis-guess
would be users that type .qcow but want qcow2.
The idea makes sense to me, though.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
prev parent reply other threads:[~2017-12-01 22:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 20:05 [Qemu-devel] [PATCH] qemu-img: add the simplest format recognition Klim Kireev
2017-12-01 22:12 ` Eric Blake [this message]
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=0e8dbd28-a77f-ad9a-201b-fd99e0b824e7@redhat.com \
--to=eblake@redhat.com \
--cc=den@openvz.org \
--cc=klim.kireev@virtuozzo.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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).