[Libguestfs] [PATCH v8 2/4] v2v: add function qemu_img_version to utils

Richard W.M. Jones rjones at redhat.com
Mon Feb 6 15:25:53 UTC 2017


On Mon, Feb 06, 2017 at 11:06:46AM +0300, Roman Kagan wrote:
> On Sat, Feb 04, 2017 at 03:10:44PM +0100, Tomáš Golembiovský wrote:
> > The function returns version of qemu-img as a tuple (major, minor), or
> > the value (0,9) in case there was an error detecting the version.
> 
> Depending on QEMU version is extremly unreliable.  Vendors often stick
> with fairly old versions but backport important features (you at RedHat
> know that, don't you ;)  So it's not unlikely that e.g. a number of
> future RHEV/RHEL releases won't use this new feature even though the
> included QEMU already supports it.
> 
> IMO a simpler and more reliable check is to construct a command line for
> qemu-img that is lightweight to execute and succeeds if the option is
> supported or fails otherwise.
> 
> [ sorry for being so late with this ]

Yes, I agree.  My quick testing shows that the following command
should be sufficent to test for the "offset" parameter:

$ truncate -s1024 /tmp/test2
$ qemu-img create /tmp/test -f qcow2 -b 'json:{"offset":512,"file":{"filename":"/tmp/test2"}}'

On RHEL 7.3 it fails with:

qemu-img: /tmp/test: Block format 'raw' used by device '' doesn't support the option 'offset'

and return code 1.

(Obviously we'd have to use real temporary files)

I'll see if I can make a patch ...

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list