simple solution to control QEMU virtual machines..


    vmninja <command> <name> [additional sub commands]


   start <vmname>      - start given virtual machine.
   stop <vmname>       - stop given virtual machine.
   reset <vmname>      - reset given virtual machine.
   shutdown <vmname>   - send acpi power button event to given virtual machine.
   freeze <vmname>     - pause given virtual machine.
   unfreeze <vmname>   - resume given virtual machine.
   local-vnc <vmname>  - spawn ssvncviewer for given virtual machine.
   list                - list all virtual machines.
   dump-config         - Print configs of all VMs and the vmninja itself.
   cleanup-sockets     - Delete socket files that are no longer in use.
   gen-mac             - print random mac address.

   device-add <vmname> <device_name>
                       - Add specified device to given virtual machine.

   device-del <vmname> <device_name>
                       - Remove specified device.

   cdrom <vmname>        - List whatever is connected as optical device to VM.
   cdrom <vmname> eject  - Eject image from virtual machine.
   cdrom <vmname> change <path> 
                         - Connect image to VM, can be relative path.

Devices that can be used with device-add/del:

    usb-tablet - Absolute pointing device, for VNC access when mouse required.
                 Will utilize some CPU cycles thus not added by default.


    Getting system on new VM:

    First one need to provide configuration of virtual machine new-vm.conf 
    in machines/ directory that is located in the same dir as vmninja script.

    $ vmninja start new-vm
    $ vmninja cdrom new-vm change iso/debian-7.3.0-amd64-i386-netinst.iso
    $ vmninja reset new-vm
    $ vmninja local-vnc new-vm

    First, it will start 'new-vm' virtual machine, then it will hook iso image
    into the virtual machine, next reset it, to boot from the iso and last one
    will spawn vnc client connected to VM to perform installation process.

    After installation, one should remove the iso image from virtual machine
    as by default it will try to boot from cdrom, if possible.

    $ vmninja cdrom new-vm eject

Virtual Machine configuration file:

    The name of virtual machine is taken from name of configuration file.

        <key name> = <value>    - set key to given value.
        <feature>               - equals to 'feature = 1'.

    Config file options:
        memory = <uint>           - Megabytes of RAM memory assigned to VM.
        cpus = <uint>             - Amount of CPUs QEMU will advertise to VM.
        network-bridge = <name>   - Bridge device to bind to newly created tap devices.
        nic-model = <name>        - Network card model
        mac = <address>           - Mac address to use on network interface.
        block-storage = <path>    - full path for image or block device, can 
                                    can be specified multiple times.

        block-cache = <writethrough|writeback|none|directsync|unsafe>
                                  - Choose cache for block devices, needed
                                    only if block-storage were used.

        block-limit-mbps = <int>  - Limit storage bandwidth to <int> MB/s
                                    The limit works on per block-storage basis.

        block-interface = <name>  - Type of device to handle storage.

        kernel-image = <path>     - Load kernel from outside of the VM,
                                    Skips VM's bootloader. (Optional)
        kernel-cmdline = <string> - Arguments passed to kernel.
                                    Use only if kernel-image specified.

        initramfs-image = <path>  - Specify which initramfs image load.
                                    Use only if kernel-image specified.
        vhost-net                 - Enable vhost-net feature.

Devices for nic-model and block-interface

        To check what your QEMU version support as nic-model, run:

        $ qemu-system-x86_64  -device '?' 2>&1 \
           | awk -v RS='' '$1 ~ /Network/'

        And for block-interface:

        $ qemu-system-x86_64  -device '?' 2>&1 \
           | awk -v RS='' '$1 ~ /Storage/'

Example configuration 'alpine_x86.conf'

        memory = 512
        block-interface = virtio
        block-cache = writeback
        block-storage = /home/piotr/virt/kvm/alpine_x86.raw
        block-storage = /home/piotr/virt/kvm/alpine_x86-home.raw
        network-bridge = lebridge0
        nic-model = virtio-net
        mac = de:3a:7e:fa:e7:01
        cpus = 2

Code provided under Simplified BSD license as written in LICENSE file.