将已有KVM虚拟机的配置转换成ConVirt 2 可读格式
13 Dec 2011使用convirt 2 管理虚拟机的时候,一般被管理的机器上已经有虚拟好的机器,如果我们想把她导入convirt 2 中,就需要先转换一下她的配置,在XEN虚拟机中是不需要转换的,但是如果你使用kvm的话就需要转换了。
比如在KVM虚拟机中己经有了vm test1,她的配置如下<!-- more -->
[root@centos6-kvm qemu]# cat /etc/libvirt/qemu/test1.xml
<domain type='kvm'>
<name>test1</name>
<uuid>6f3c7c45-fa73-061b-f95b-caf83568e387</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686' machine='rhel6.0.0'>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/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source file='/var/lib/libvirt/images/test1-1.img'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<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'>
<mac address='52:54:00:6b:77:6e'/>
<source bridge='br0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target 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>
[root@centos6-kvm qemu]# cat /etc/libvirt/qemu/test1.xml
<domain type='kvm'>
<name>test1</name>
<uuid>6f3c7c45-fa73-061b-f95b-caf83568e387</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686' machine='rhel6.0.0'>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/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source file='/var/lib/libvirt/images/test1-1.img'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<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'>
<mac address='52:54:00:6b:77:6e'/>
<source bridge='br0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target 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>
转换完后变成以下文件 test1
$cat test1
# Automtically generated by ConVirt
kernel = '/usr/lib/xen/boot/hvmloader'
vif = ['mac=52:54:00:6b:77:6e,bridge=br0']
on_shutdown = 'destroy'
disk = ['qemu:raw:/var/lib/libvirt/images/test1-1.img,hda,w', 'qemu:raw:None,hdc:cdrom,r']
vncunused = 1
apci = 0
uuid = '6f3c7c45-fa73-061b-f95b-caf83568e387'
os_version = '1.0'
on_reboot = 'restart'
boot = 'c'
platform = 'kvm'
pae = 1
memory = 512
acpi = 1
os_name = 'Linux'
vnc = 1
on_crash = 'restart'
network_mode = 'tap'
os_flavor = 'Linux'
bootloader = ''
arch = 'i686'
soundhw = 'ac97'
name = 'test1'
usbdevice = 'tablet'
device_model = '/usr/libexec/qemu-kvm'
builder = 'hvm'
template_version = '1.0'
vfb = ['type=vnc,vncunused=1']
vcpus = 1
usb = 1
脚本下载地址:1.