From: "Richard W.M. Jones" <rjones@redhat.com>
To: QEMU Development <qemu-devel@nongnu.org>
Subject: [Qemu-devel] Writing a C library to generate qemu command lines and configuration files
Date: Tue, 2 May 2017 09:35:00 +0100 [thread overview]
Message-ID: <20170502083500.GA27432@redhat.com> (raw)
Firstly, is there such a thing already? (libvirt doesn't count since
it cannot generate -readconfig configuration files)
Well, I have written one. It's in C and doesn't have any dependencies
beyond the standard C library:
https://github.com/rwmjones/libguestfs/tree/max-disks/common/qemuopts
It models command line parameters as either flags (eg. ‘-nodefconfig’),
flags with a single argument (‘-name guest’), or flags taking a list
(eg. ‘-drive file=foo,id=bar’ modeled as a list of strings).
I'm immediately aware that there are shortcomings with this approach
(see below). Is there a better model to use for qemu command line
options that also allows -readconfig config files to be generated?
Some of the more obvious problems:
* I don't know if single flags can be translated into config files.
* Config files treat the "id=.." parameter as special, eg:
‘-drive file=foo,id=bar’ is translated to:
[drive "bar"]
file = "foo"
* There's no clear mapping between some command line parameters and
the config file, eg. ‘-m 2048 -kernel foo’ should be translated into:
[memory]
size = "2048"
[machine]
kernel = "foo"
but my library couldn't do that translation without a look-up table
that would duplicate the internals of qemu.
There are also unknown unknowns:
* Is comma-quoting (ie. doubling any commas) sufficient? Or are there
other forms of quoting? A quick look at options parsing in qemu
doesn't show any.
* From the point of view of a client generating command lines, is there
any significance to dotted names (eg. ‘-drive file.driver=ssh,...’)
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
next reply other threads:[~2017-05-02 8:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-02 8:35 Richard W.M. Jones [this message]
2017-05-02 14:28 ` [Qemu-devel] Writing a C library to generate qemu command lines and configuration files Markus Armbruster
2017-05-02 14:59 ` Richard W.M. Jones
2017-05-02 15:54 ` Paolo Bonzini
2017-05-02 16:37 ` Markus Armbruster
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=20170502083500.GA27432@redhat.com \
--to=rjones@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.