qemu

QuickStart

If you are completely new to qemu, you may find the big list of switches a bit confusing. Most users want to install an operating system from a cdrom image to a virtual harddisk. Here is what you need:

$ qemu-img create foo.img 8G
$ wget http://server.com/bar.iso
$ qemu -hda foo.img -cdrom bar.iso

Guest-agent

The guest agent service is started automatically, as long as the qemu-guest subpackage is installed. See here for setup instructions.

Tricks

It worth to read the full documentation at /usr/share/doc/qemu-*/qemu-doc.html, it really worth to do so.

To demonstrate how powerful qemu is, here are a few cheap tricks:

If you want to be able to ssh to the machine, you can use port redirection. For example using the -redir tcp:1022::22 option, qemu:22 will be available at localhost:1022.

Note
This requires root privileges.

You can create a unix socket to control your virtual machine. For example if you are not able to ssh to the machine, you can still properly shut it down:

Use the -monitor unix:/tmp/qemu,server,nowait option, then send the sendkey ctrl-alt-delete string to the socket, for example using python:

python -c "import socket; sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM); \
sock.connect('/tmp/qemu'); \
sock.send('sendkey ctrl-alt-delete\n')"

Finally a trick about vnc: using for example the -vnc 0 option, it’s possible to reach qemu’s display via vnc. This is quite handy if you run qemu on a server (for example in screen), then you can freely attach to and detach from it whenever you want to do so.

Really, read the full documentation! :)