SergeHallyn_libvirtnest

Differences between revisions 1 and 2
Revision 1 as of 2011-07-22 13:42:12
Size: 2845
Editor: serge-hallyn
Comment:
Revision 2 as of 2011-10-11 14:59:15
Size: 2971
Editor: serge-hallyn
Comment:
Deletions are marked like this. Additions are marked like this.
Line 83: Line 83:
or
wget http://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/amd64/iso-cd/debian-testing-amd64-businesscard.iso

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'>
  <name>cdboot</name>
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu</emulator>
    <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>
    <disk type='file' device='cdrom'>
      <source file='/home/ubuntu/debian-6.0.2.1-amd64-businesscard.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <source bridge='br0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <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'/>
    </sound>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
</domain>
  • Create the disk image:

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

wget http://cdimage.debian.org/debian-cd/6.0.2.1/amd64/iso-cd/debian-6.0.2.1-amd64-businesscard.iso
or
wget http://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/amd64/iso-cd/debian-testing-amd64-businesscard.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

SergeHallyn_libvirtnest (last edited 2012-07-16 14:34:50 by serge-hallyn)