[Libguestfs] [PATCH v8 2/4] v2v: add function qemu_img_version to utils
Tomáš Golembiovský
tgolembi at redhat.com
Mon Feb 6 18:25:23 UTC 2017
On Mon, 6 Feb 2017 15:25:53 +0000
"Richard W.M. Jones" <rjones at redhat.com> wrote:
> 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 ]
>
Good point. I didn't think this through.
> 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)
No we don't. Something like this also works:
qemu-img info 'json:{ "offset": 0, "file": { "filename": "/dev/null" } }'
Tomas
> 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
--
Tomáš Golembiovský <tgolembi at redhat.com>
More information about the Libguestfs
mailing list