[Top][All Lists]

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

Re: Making QEMU easier for management tools and applications

From: Markus Armbruster
Subject: Re: Making QEMU easier for management tools and applications
Date: Tue, 04 Feb 2020 10:58:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Andrea Bolognani <address@hidden> writes:

> On Fri, 2020-01-31 at 07:50 +0100, Markus Armbruster wrote:
>> Kevin Wolf <address@hidden> writes:
>> > Much of this threads plays with the though that maybe we don't need any
>> > compatibility and make the radical conclusion that we don't need any
>> > human-friendly interface at all. Keeping full compatibility is the other
>> > extreme.
>> > 
>> > There might be some middle ground where we break compatibility where the
>> > old way can't easily be maintained with the new infrastructure, but
>> > don't give up on the idea of being used by humans.
>> I'm not sure the connection between maintaining compatibility and
>> supporting human use is as strong as you seem to imply.
>> As far as I can tell, the "maybe we don't need any compatibility"
>> discussion is about the CLI.  I'd rephrase it as "maybe we need a
>> machine-friendly CLI on par with QMP more than we need compatibility to
>> the current CLI".
>> "We don't need any human-friendly interface at all" comes in not because
>> machine-friendly necessarily precludes human-friendly, but only if we're
>> unwilling (unable?) to do the extra work for it.
>> Compare the monitor:
>> * QMP is primarily for machines.  We promise stability: no incompatible
>>   changes without clear communicaton of intent and a grace period.  We
>>   provide machine clients tools to deal with the interface evolution,
>>   e.g. query-qmp-schema.
>> * HMP is exclusively for humans.  It may change at any time.
>> For the CLI, we don't have such a separation, and our offerings for
>> dealing with interface evolution are wholly inadequate.  We *need* to do
>> better for machines.
>> Now, the monitor also informs us about the cost of providing a
>> completely separate interface for humans.
>> Elsewhere in this thread, we discussed layering (a replacement for) HMP
>> on top of QMP cleanly, possibly in a separate process, possibly written
>> in a high-level language like Python.
>> HMP predates QMP.  We reworked it so the HMP commands are implemented on
>> top of the QMP commands, or at least on top of common helpers.  But this
>> is not quite the same as layering HMP on top of QMP.
>> If we decide to radically break the CLI so we can start over, we get to
>> decide whether and how to do a human-friendly CLI, in particular how it
>> relates to the machine-friendly CLI.
> Does a machine-friendly CLI need to exist at all? Once you decide
> that throwing away the current one is acceptable, you might as well
> reduce the maintainance burden by requiring that software only
> communicates with QEMU via QMP.

We need to provide a machine-friendly interface for initial

To provide it, we can extend machine-friendly QMP, or make CLI
machine-friendly like QMP.

In both cases, we need to QAPIfy initial configuration.  I believe
that's going to be a big chunk of the work.

To extend QMP, we wrap the QAPIfied initial configuration in QMP
commands.  Many of them will only make sense during initial
configuration.  We'll want to express that in the schema, and enforce it
in the QMP core.

To improve the CLI, we wrap them in CLI options.  We'll want some
infrastructure to generate the boilerplate, just like we generate QMP
command boilerplate.

With an improved CLI, configuration files are just CLI options read from
a file instead of argv[].  We'll want a more suitable concrete syntax
there, of course.

With extended QMP, configuration files are just QMP commands from the
initial configuration subset read from a file instead of a chardev.
Again, we'll likely want more suitable concrete syntax there.

With an improved CLI, I'd expect machines to use configuration files so
they don't have to mess with shell quoting.  With extended QMP, they'd
perhaps rather reuse their existing QMP code to send the configuration
down a socket.  Less efficient, but I doubt it'll matter.

> Does a human-friendly CLI need to be part of QEMU? We have built so
> much amazing infrastructure on top of QEMU, and as of today none of
> that work is benefiting people who run it directly.

I think we do, for developers and for users who don't need the amazing
infrastructure we built on top of QEMU.  When you use QEMU for
virtualization in production, you generally need it, but there are
other, simpler uses, e.g. certain hardware emulation uses.

A human-friendly CLI can be built both as a wrapper around the
machine-friendly CLI and as a wrapper around the initial configuration
subset of QMP.

Once a machine-friendly replacement for the current CLI is in place, we
can relax the current CLI's compatibility requirements.  I figure we
need this to be able to turn it into a wrapper with reasonable effort.
Hopefully, we can generate much of the wrapping boilerplate.

> As a proof of concept, I have spent a couple of hours writing the
> attached shell script, which I hope will illustrate my point.
> Usage is extremely simple: just do something like
>   $ ./virt-run debian-10-openstack-amd64.qcow2
> and after a few seconds the guest display will appear on your screen.
> Behind the scenes, it uses a number of existing high-level tools:
>   * virt-inspector, to figure out what guest OS is installed in the
>     image;
>   * virt-install, to produce a domain XML tailored to that specific
>     guest OS and to create the corresponding libvirt domain;
>   * virt-viewer, to provide the UI.
> All these tools use libvirt under the hood, and additionally
> virt-install uses libosinfo to obtain information about the guest
> OS, such as whether or not it supports Virtio devices and how much
> memory it needs to run smoothly.
> The result is that, if you run
>   $ qemu-system-x86_64 -hda debian-10-openstack-amd64.qcow2
> you will get
>   * a single CPU emulated with TCG;
>   * 128 MiB of memory;
>   * emulated I/O devices;
> whereas the script will give you
>   * 2 CPUs accelerated with KVM;
>   * 1 GiB of memory;
>   * Virtio devices for pretty much everything, including a
>     virtio-rng device that will for example speed up the first boot
>     significantly if SSH keys need to be (re)created.
> Unsurprisingly, performance is different: when QEMU is invoked
> directly, the login prompt for this specific image shows up after
> ~40 seconds, whereas when we use the script it only takes ~13 seconds
> to get there. And the command line is just as simple, if not more so!
> All of the above was obtained by hastily cobbling together existing
> tools with <100 lines of shell scripting. Imagine how much better it
> could be if we actually put some serious work in!

I don't doubt that many, many users of QEMU are better off consuming it
via libvirt.  I've told a few of them over the years :)

> With my argument hopefully demonstrated: I think an architecture akin
> to the one Dan has outlined earlier[1] would be a great direction to
> take. QEMU can continue to focus on its core competency, that is,
> virtual hardware, and leave most of the user interaction up to the
> software interacting with its JSON-based API.
> Obviously QEMU developers, for their own use, could still benefit
> from having access to a user interface that doesn't require either
> rigging up libvirt support or messing with JSON directly, and such
> an interface could even look very similarly to the current CLI, but
> it could simply not be made user-facing and thus not subject to any
> compatibility concerns.

"Not user-facing" only for a particular value of "user".  But your point
is well taken: only the machine-friendly initial configuration interface
needs to be subject to a compatibility promise.

I believe the difference between providing it in QMP and providing it
separately isn't all that great.

> [1] https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg06034.html

reply via email to

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