Artifact ID: | 34a08bef57adad402e3ae4a434c1085bf987a874 |
---|---|
Page Name: | QEMU as script interpreter |
Date: | 2015-07-17 18:35:49 |
Original User: | vitus |
Mimetype: | text/x-markdown |
Typically, any program which can read something from file specified in the commandline, and recognizes # at the beginning of the line as comment sign, can be script interprerter. You mark this file as executable and specify command to append file name to in the first line.
In case of QEMU script would look like
#`!/usr/bin/qemu-system-x86_64 -readconfig [drive]
file = "/home/virtual/images/Asta.qcow2"
if = "ide"
media = "disk"
[chardev "compat_monitor0"]
backend = "stdio"
[chardev "vdagent"]
backend = "spicevmc"
name = "vdagent"
[device]
driver = "virtio-serial"
[device]
driver = "virtserialport"
chardev = "vdagent"
name = "com.redhat.spice.0"
...
Such config can be created using qemu -writeconfig option. Just specify options as usially, and finish them with -writeconfig filename and qemu would write its configuration into this file.
File seems to be readable and editable with python ConfigParser module.
Unfortunately in practice I was unsuccessful trying to start virtual machine using such file. It seems that at least version of qemu in Debian jessie is unable to completely record its state.
QEMU Wiki tells:
The config file doesn't cover all the command line options so far, only the ones implemented with QemuOpts.
Moreover, some QEMU options such as sound backend are passed via environment, So we were unable to use these config files as executable virtual machine description, and have to resort to usial shell scripts.
May be next versions of QEMU would improve this feature.