qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qemu-img: add the simplest format recognition


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] qemu-img: add the simplest format recognition
Date: Fri, 1 Dec 2017 16:12:21 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

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 <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
  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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]