I'll use qemu-kvm as a name for the executable. If you're using a manually built qemu or a qemu without kvm then just replace qemu-kvm with your own binary. I'll use host# client# guest# shell prompt notations to distinguish where the command should be the command. See section Basic Definitions to be sure that you know difference between the host, client and guest. You can ignore the difference between guest, client and host if they are all running on the same machine.
The first important thing to do is to create a guest image. You can use any raw device such as a clean logical volume, or an iSCSI lun. You may also use a file as the disk image for the guest. I'll use a file created by qemu-img as a demonstration.
The following command will allocate a 10GB file. See qemu-img man page for further information.
host# qemu-img create /path/to/xp.img 10G
Now that we created an image, we can now start with image population. I assume that you have a locally stored ISO of your favourite operating system so you can use it for installation.
host# sudo qemu-kvm -boot order=dc -vga qxl \ -spice port=3001,disable-ticketing -soundhw ac97 \ -device virtio-serial -chardev spicevmc,id=vdagent,debug=0,name=vdagent \ -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \ -cdrom /path/to/your.iso /path/to/your.img
Let's take a brief look at the qemu options that were used. The option -boot order=dc specifies that the guest system should try to boot from the first cdrom and then fallback to the first disk, -vga qxl specifies that qemu should emulate the qxl device adapter.
The Spice port option defines what port will be used for communication with the client. The Spice option disable-ticketing is telling us that ticketing (simple authentication method) is not used. The virtio and chardev devices are required by the guest agent.