On 9/21/18 9:10 AM, Markus Armbruster wrote:
Eric Blake <ebl...@redhat.com> writes:
[adding Markus, because of an interesting observation about
--image-opts vs. JSON null - search for [1] below]
There are four instances of [1], and my eyes glazed over before I
reached the first. May I have a summary of the interesting observation?
My command line marked [1] was:
$ qemu-io -c 'discard 0 1m' --image-opts
driver=qcow2,backing=,file.driver=file,file.filename=img.003
warning: Use of "backing": "" is deprecated; use "backing": null instead
I wanted to specifically treat a qcow2 file that has a backing file in
its metadata as temporarily having no backing file, so I had to override
the backing file on the command line. Since I used dotted-key syntax, I
couldn't spell it 'backing=null' (because that would try to find a node
named "null", rather than treating 'null' as a JSON object different
from a string), so I had to use 'backing=' with an empty string, which
triggers a deprecation warning.
I also tried:
$ qemu-io -c 'discard 0 1m' --image-opts '{"driver":"qcow2",
"backing":null, "file":{"driver":"file", "filename":"img.003"}}'
except THAT doesn't work yet (we haven't converted all our command line
arguments to taking JSON yet; --image-opts is one of those that does not
yet understand leading '{' as meaning a JSON parse instead of a
dotted-key parse).
Then Max figured out that we can do:
$ qemu-io -c 'discard 0 1m' \
"json:{'driver':'qcow2','backing':null,
'file':{'driver':'file','filename':'img.003'}}"
But I thought you'd be interested in that, since we ARE trying to make
the command line more uniform (and convert to allowing JSON syntax in
more spots without having to use the block layer "json:{}"
pseudo-protocol), and as a justification for an example of where we
either need to document that dotted-key syntax can't do everything (and
in those cases you have to use JSON), or else come up with the syntactic
sugar to let dotted-key pass in a null without triggering the warning of
an empty string being deprecated in favor of an actual null.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org