VMwareの仮想マシンをKVMに変換する
VMwareで動いていたWindows VistaをKVMのイメージに変換したV2Vの時のメモです。
元々は自作マシン上でWindows XPで動いていたのですが、マシンに依存するサービスを利用し始めたために物理マシンの限界になった時点でP2Vを行いVMwareで動くようにしました。
今回はVMwareを動かしているマシンのリソースが厳しくなってきたので、比較的リソースの残っているdebianのファイルサーバ上に移設します。
何はなくてもディスクイメージの変換です。
VMwareのvmdkファイルは2GBごとに分割される設定で使用していましたが、代表となるvmdkを指定すればちゃんと変換してくれるようです。
# qemu-img convert -f vmdk %Path to vmdk% -O raw %Path to New Image%
続いて、既存のWindowsイメージを元に適当なXMLファイルを作成します。
virt-managerのvirt-installで作成されたXMLファイルです。HDDやネットワークのドライバーがvirtioでない設定ファイルを選びました、spice関係はvirtioになっていますが…。
address要素は仮想マシン依存じゃないかなーと思って全部削除しました。
# cp /etc/libvirt/qemu/windows.xml /etc/libvirt/qemu/win7.xml
<domain type='kvm'>
<name>win7</name>
<memory unit='KiB'>2621440</memory>
<currentMemory unit='KiB'>2621440</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-2.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<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='raw'/>
<source file='%Path to ImageFile%'/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='%Path to ISO File%'/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<controller type='usb' index='0'>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
</controller>
<controller type='virtio-serial' index='0'>
</controller>
<interface type='bridge'>
<source bridge='br0'/>
</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'/>
</channel>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='spice' port='5920' tlsPort='-1' autoport='no' listen='0.0.0.0' keymap='ja'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<video>
<model type='qxl' ram='65536' vram='65536' heads='1'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>XMLの用意ができたらvirshに登録して起動させます。
# virsh define /etc/libvirt/qemu/win7.xml # virsh start win7