Revision 1 as of 2011-07-22 13:42:12

Clear message

Sometimes to reproduce a bug or verify a fix to libvirt, you want to just be able to start a qemu VM under KVM, not really caring what it does. These instructions will get you there, assuming you are on a standard Ubuntu ec2 image, as user ubuntu with libvirt and qemu installed.

This will attach to a bridge called br0. Change that name if you need to.

  • Start by creating a file 'cdboot.xml', with the following contents:

<domain type='qemu'>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <boot dev='hd'/>
  <clock offset='utc'/>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/home/ubuntu/cdboot.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    <disk type='file' device='cdrom'>
      <source file='/home/ubuntu/debian-'/>
      <target dev='hdc' bus='ide'/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    <interface type='bridge'>
      <source bridge='br0'/>
    <serial type='pty'>
      <target port='0'/>
    <console type='pty'>
      <target type='serial' port='0'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
    <sound model='ac97'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
      <model type='cirrus' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
  • Create the disk image:

qemu-img create cdboot.img 1G
  • Get a tiny bootable iso:

  • Define the vm:

virsh define cdboot.xml
  • Now the vm should be able to start

virsh start cdboot
virsh list
  # this should show cdboot running.  you can connect probably as 'gvncviewer :0'
virsh destroy cdboot
  • To make this vm autostart,

virsh autostart cdboot