[Avocado-devel] RFC: qemu command line creation via templates

Ademar Reis areis at redhat.com
Tue Sep 23 17:15:09 UTC 2014


Hello.

We've been using Trello[1] as a planning board for the sprints
and the specification of features, but I want to raise awareness
of our work and encourage discussion by sending RFCs to this
list. The version on trello will be updated based on the
discussions and feedback we get.

 1. https://trello.com/b/WbqPNl2S/avocado

So here is one such RFC:

"""
https://trello.com/c/C0bcopTU/204-avocado-virt-poc-for-qemu-command-line-creation-via-templates

One complex part of the current virt API (in autotest/virt-test,
and WiP in avocado) is the creation of the qemu command line to
be used in tests.

In a nutshell:

 * The qemu command line is very complex and usually spawns many
   lines;
 * Things change over time: even though most of qemu's command
   line is stable, new options appear with new features and some
   options become obsolete in favor or more modern ones;
 * There's a qemu config file format, but it's not
   feature-complete (on par with the command line). It's
   relatively new and is mostly undocumented;

Requirements:

 * Powerfulness: users want to create and manipulate a complex
   command line. When combined with the multiplexer, it's easy to
   imagine that it should be possible to start qemu with a myriad
   of combinations of variables such as machine type, CPU model,
   RAM size, clock source, network configuration, devices
   enabled/disabled, etc.
 * Control: at the same time, users don't want the framework
   adding options behind their backs that they don't have control
   on. To reproduce a bug, users want the exact command line used
   by the reporter.
 * Convenience: users should be able to quickly create a command
   line based on their current output from "ps -auxw" (or from a
   bug report log).

Given that, here's my suggestion:

Instead of constructing the command line via API calls, allow the
user to specify the whole command line replacing a few parts of
it with variables. 

Users would have at their disposal a set of templates to use
(which they could extend) or they could provide a command line
that uses just a few variables, or even no variables at all
(everything hardcoded, for a quick and dirty test, during test
development or to reproduce a bug).

This RFC is about the implementation of such mechanism:

 * API for providing a file to be used as a template;
 * API for providing a string to be used as a template;
 * The format for the template (how variables are specified);
 * The specification and documentation of a few initial variables;
 * The API for setting such variables;
 * A few (2+) different reference templates. Suggestion:
   * standard.qemu
   * minimal.qemu
   * user-level-networking.qemu
   * migration.qemu
   * ...
 * A few APIs to enable configuration of the command line
   (append, or APIs to manipulate variables which are complex).

We should expand the idea in the future with more complex APIs
for manipulating the template and/or small parts of it.

For reference, here's a typical (but arbitrary) qemu command line
used in virt-test these days:

    /bin/qemu-kvm \
        -S  \
        -name 'virt-tests-vm1'  \
        -sandbox on  \
        -M pc  \
        -nodefaults  \
        -vga std  \
        -chardev socket,id=hmp_id_hmp1,path=/tmp/monitor-hmp1-20140905-114839-20x7lRBJ,server,nowait \
        -mon chardev=hmp_id_hmp1,mode=readline  \
        -chardev socket,id=serial_id_serial0,path=/tmp/serial-serial0-20140905-114839-20x7lRBJ,server,nowait \
        -device isa-serial,chardev=serial_id_serial0  \
        -chardev socket,id=seabioslog_id_20140905-114839-20x7lRBJ,path=/tmp/seabios-20140905-114839-20x7lRBJ,server,nowait \
        -device isa-debugcon,chardev=seabioslog_id_20140905-114839-20x7lRBJ,iobase=0x402 \
        -device ich9-usb-uhci1,id=usb1,bus=pci.0,addr=03 \
        -drive id=drive_image1,if=none,file=/home/ademar/redhat/projects/virt-test/shared/data/images/jeos-20-64.qcow2 \
        -device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=0,bus=pci.0,addr=04 \
        -device virtio-net-pci,mac=9a:e1:e2:e3:e4:e5,id=idaffuzU,vectors=4,netdev=idLbtD9t,bus=pci.0,addr=05  \
        -netdev user,id=idLbtD9t,hostfwd=tcp::5000-:22  \
        -m 1024  \
        -smp 2,maxcpus=2,cores=1,threads=1,sockets=2  \
        -cpu 'SandyBridge' \
        -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1  \
        -vnc :0  \
        -rtc base=utc,clock=host,driftfix=none  \
        -boot order=cdn,once=c,menu=off \
        -enable-kvm
"""

-- 
Ademar de Souza Reis Jr.
Red Hat

^[:wq!




More information about the Avocado-devel mailing list