An example XML file to install an operating system from an ISO p_w_picpath

 

The following example XML file can be modified to create a KVM and boot to any operating system from an ISO p_w_picpath or a CD-ROM drive.

  1. 1  <domain type='kvm'> 
  2. 2    <name>kvm4</name> 
  3. 3    <uuid>85badf15-244d-4719-a2da-8c3de0641373</uuid> 
  4. 4    <memory>1677721</memory> 
  5. 5    <currentMemory>1677721</currentMemory> 
  6. 6    <vcpu>1</vcpu> 
  7. 7    <os> 
  8. 8      <type arch='x86_64' machine='pc'>hvm</type> 
  9. 9      <boot dev='cdrom'/> 
  10. 10   </os> 
  11. 11   <features> 
  12. 12     <acpi/> 
  13. 13     <apic/> 
  14. 14     <pae/> 
  15. 15   </features> 
  16. 16   <clock offset='localtime'/> 
  17. 17   <on_poweroff>destroy</on_poweroff> 
  18. 18   <on_reboot>destroy</on_reboot> 
  19. 19   <on_crash>destroy</on_crash> 
  20. 20   <devices> 
  21. 21     <emulator>/usr/libexec/qemu-kvm</emulator> 
  22. 22     <disk type='file' device='disk'> 
  23. 23       <source file='/var/lib/libvirt/p_w_picpaths/kvm4.img'/> 
  24. 24       <target dev='hda' bus='ide'/> 
  25. 25     </disk> 
  26. 26     <disk type='file' device='cdrom'> 
  27. 27       <source file='/tmp/SLES-11-DVD-i586-GM-DVD1.iso'/> 
  28. 28       <target dev='hdb' bus='ide'/> 
  29. 29       <readonly/> 
  30. 30     </disk> 
  31. 31     <disk type='file' device='cdrom'> 
  32. 32       <source file='/tmp/SLES-11-DVD-i586-GM-DVD2.iso'/> 
  33. 33       <target dev='hdc' bus='ide'/> 
  34. 34       <readonly/> 
  35. 35     </disk> 
  36. 36     <interface type='bridge'> 
  37. 37       <source bridge='br0'/> 
  38. 38       <mac address="0E:1F:35:AB:45:0C"/> 
  39. 39     </interface> 
  40. 40     <input type='mouse' bus='ps2'/> 
  41. 41     <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/> 
  42. 42   </devices> 
  43. 43 </domain> 

Compared to the previous example, you can see that if you want to boot from a CD or ISO p_w_picpath, you must first specify that you want to boot from the CD-ROM drive:

  1. 7    <os> 
  2. 8      <type arch='x86_64' machine='pc'>hvm</type> 
  3. 9      <boot dev='cdrom'/> 
  4. 10   </os> 

Then you need to specify the location of the ISO device in the host system. Also, this definition suggests it to be assigned as the hdb device inside the KVM guest:

  1. 26   <disk type='file' device='cdrom'> 
  2. 27     <source file='/tmp/SLES-11-DVD-i586-GM-DVD1.iso'/> 
  3. 28     <target dev='hdb' bus='ide'/> 
  4. 29     <readonly/> 
  5. 30   </disk> 
In this example, the CD-ROM drive is the host's /dev/sde (block) device, in which this definition suggests it to be assigned as the hdc inside the KVM guest:

  1. <disk type='block' device='cdrom'> 
  2.   <source dev='/dev/sde'> 
  3.   <target dev='hdc'/> 
  4.   <readonly/> 
  5. </disk> 
If your host has SELinux enabled, you must re-label the security context of the ISO or CD-ROM device so that libvirtd is eligible to use the device file:
#chcon -t virt_p_w_picpath_t /tmp/SLES-11-DVD-i586-GM-DVD*
Check the labels by running the following command:
  1. #ls -Z /tmp/ 
  2. -rw-r--r--  root root system_u:object_r:virt_p_w_picpath_t   SLES-11-DVD-i586-GM-DVD1.iso  
  3. -rw-r--r--  root root system_u:object_r:virt_p_w_picpath_t   SLES-11-DVD-i586-GM-DVD2.iso