Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kylechase/cc6e0199878133b0481f6b3e80095932 to your computer and use it in GitHub Desktop.
Save kylechase/cc6e0199878133b0481f6b3e80095932 to your computer and use it in GitHub Desktop.
Windows7 Libvirt xml.

converted Virtualbox Win7 VM to KVM. (KVM on Ubuntu 14.04)

  • Shutdown Virtualbox VM.

  • Convert the vdi to a raw disk images. Note: vdi are compressed and raw images are not and so you will need to leave enough disk space for entire uncompressed disk.

VBoxManage clonehd --format RAW win7.vdi win7.img
  • Then on your KVM host:
qemu-img convert -f raw win7.img -O qcow2 win7.qcow2
  • Imported win7.qcow2 into libvirt
virt-install --import --name win7 --ram 2048 --disk path=$HOME/imgs/cumulus_windows.qcow2,format=qcow2,device=disk --arch=i686
  • download latest virtio drivers.

  • create a 2nd disk in a tmp directory this is going to be used to properly install virtio drivers.

qemu-img create- -f qcow2 /home/stanleyk/Downloads test.qcow2

  • download virt-manager
apt-get install virt-manager
  • using virt-manager, confirm that the following options are there. If not set it.
  • Video set to QXL
  • Console/Serial set to Spice not VNC
  • NIC set to virtio
  • memory set to 2GB
  • first disk set to IDE
  • second disk (test.qcow2) set to Virtio disk
  • start the vm
virsh start 
  • Use the redhat virtio howto to install the balloon driver, net virtio driver, virtio storage driver and virtual serial driver

  • after drivers are installed, go to power options and set desired action on power button been pressed to 'shutdown'. This will make the virsh shutdown command work.

  • shutdown the vm

virsh shutdown win7
  • go to virt-manager and delete the test disk and change the ide setting on first disk to virtio disk.

  • install virt-viewer

apt-get install virt-viewer
  • Use virt-viewer to access windows7 console
<domain type='kvm'>
<name>win7</name>
<uuid>a0dc1844-6a10-52d2-2bb1-ef27de3b047f</uuid>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686' machine='pc-i440fx-trusty'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<cpu mode='custom' match='exact'>
<model fallback='allow'>SandyBridge</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='dtes64'/>
<feature policy='require' name='vmx'/>
<feature policy='require' name='erms'/>
<feature policy='require' name='xtpr'/>
<feature policy='require' name='smep'/>
<feature policy='require' name='pcid'/>
<feature policy='require' name='est'/>
<feature policy='require' name='monitor'/>
<feature policy='require' name='tm'/>
<feature policy='require' name='acpi'/>
<feature policy='require' name='osxsave'/>
<feature policy='require' name='ht'/>
<feature policy='require' name='pdcm'/>
<feature policy='require' name='fsgsbase'/>
<feature policy='require' name='f16c'/>
<feature policy='require' name='ds'/>
<feature policy='require' name='tm2'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='pbe'/>
<feature policy='require' name='ds_cpl'/>
<feature policy='require' name='rdrand'/>
</cpu>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/home/stanleyk/imgs/cumulus_windows.qcow2'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<source dev='/home/stanleyk/Downloads/virtio-win-0.1-74.iso'/>
<target dev='hdd' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' target='0' unit='1'/>
</disk>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source dev="/home/stanleyk/Downloads/test.qcow2'/>
<target dev='vdb' bus='virtio'/>
</disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</controller>
<interface type='network'>
<mac address='52:54:00:96:23:0b'/>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='spice' autoport='yes'/>
<sound model='ac97'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</sound>
<video>
<model type='qxl' ram='65536' vram='65536' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment