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

    -readconfig    [drive]
    file =
    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 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.