我正在从一台旧机器迁移一堆vms到一个新机器。 旧版本使用一些内部脚本和lvm逻辑卷,新版本使用libvirt和纯文件。 configuration是相当统一的,但一些虚拟机在新机器上完美运行,而我却无法让其他人工作。 症状是加载初始ramdisk后,我看到bios声明“从硬盘启动”的屏幕。
老机器中的好vm:
/usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -name airesisdb -smp 1 -m 1024 -vnc 127.0.0.1:10 -monitor telnet:127.0.0.1:10010,server,nowait -daemonize -localtime -usb -usbdevice tablet -net tap,ifname=vm-airesisdb,script=no -net nic,macaddr=02:13:37:00:00:10,model=virtio -rtc base=utc,clock=host,driftfix=slew -pidfile /var/run/kvm/airesisdb.pid -boot c -drive index=0,media=disk,if=virtio,boot=on,file=/dev/vg/airesisdb,cache=writeback -drive index=1,media=disk,if=virtio,file=/dev/vg/airesisdb_2,cache=writeback
旧机器上的“bad vm”(完美运行):
/usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -name tomcat -smp 1 -m 1024 -vnc 127.0.0.1:12 -monitor telnet:127.0.0.1:10012,server,nowait -daemonize -localtime -usb -usbdevice tablet -net tap,ifname=vm-tomcat,script=no -net nic,macaddr=02:13:37:00:00:12,model=virtio -rtc base=utc,clock=host,driftfix=slew -pidfile /var/run/kvm/tomcat.pid -boot c -drive index=0,media=disk,if=virtio,boot=on,file=/dev/vg/tomcat,cache=writeback
新机器上的好vm的libvirt xml:
<domain type='kvm' id='34'> <name>airesisdb</name> <uuid>c591e02e-44f4-0098-4656-fb0acca557fb</uuid> <memory unit='KiB'>1048576</memory> <currentMemory unit='KiB'>1048576</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type arch='i686' machine='pc-1.1'>hvm</type> <boot dev='cdrom'/> </os> <features> <acpi/> </features> <cpu mode='host-model'> <model fallback='allow'/> </cpu> <clock offset='localtime'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/kvm</emulator> <disk type='block' device='disk'> <driver name='qemu' type='raw' cache='writeback'/> <source dev='/var/vm-storage/airesisdb'/> <target dev='vda' bus='virtio'/> <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk> <disk type='block' device='disk'> <driver name='qemu' type='raw' cache='writeback'/> <source dev='/var/vm-storage/airesisdb_2'/> <target dev='vdb' bus='virtio'/> <alias name='virtio-disk1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </disk> <controller type='usb' index='0'> <alias name='usb0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <interface type='network'> <mac address='52:54:00:74:65:bd'/> <source network='public'/> <target dev='vm-airesisdb'/> <model type='virtio'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <input type='tablet' bus='usb'> <alias name='input0'/> </input> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5905' autoport='yes'/> <video> <model type='cirrus' vram='9216' heads='1'/> <alias name='video0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <alias name='balloon0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </memballoon> </devices> <seclabel type='none'/> </domain>
新机器上的坏vmperformance不好:
<domain type='kvm' id='46'> <name>tomcat</name> <uuid>12059a28-ad19-a4fe-fa71-0af26b8cbb3e</uuid> <memory unit='KiB'>1048576</memory> <currentMemory unit='KiB'>1048576</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type arch='i686' machine='pc-1.1'>hvm</type> <boot dev='cdrom'/> </os> <features> <acpi/> </features> <cpu mode='host-model'> <model fallback='allow'/> </cpu> <clock offset='localtime'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/kvm</emulator> <disk type='block' device='disk'> <driver name='qemu' type='raw' cache='writeback'/> <source dev='/var/vm-storage/tomcat'/> <target dev='vda' bus='virtio'/> <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk> <disk type='block' device='disk'> <driver name='qemu' type='raw' cache='writeback'/> <source dev='/var/vm-storage/tomcat'/> <target dev='vdb' bus='virtio'/> <alias name='virtio-disk1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </disk> <controller type='usb' index='0'> <alias name='usb0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <interface type='network'> <mac address='52:54:00:4b:18:31'/> <source network='private'/> <target dev='vm-tomcat'/> <model type='virtio'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <input type='tablet' bus='usb'> <alias name='input0'/> </input> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5906' autoport='yes'/> <video> <model type='cirrus' vram='9216' heads='1'/> <alias name='video0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <alias name='balloon0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </memballoon> </devices> <seclabel type='none'/> </domain>
好的虚拟机运行在里面:
Linux airesisdb 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
坏的虚拟机在里面运行:
Linux sso.edemokraciagep.org 3.16.0-60-generic #80~14.04.1-Ubuntu SMP Wed Jan 20 13:37:48 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
旧主机运行这个:
Linux 81.7.14.91 4.0.0-sabayon #1 SMP Fri Apr 17 08:09:22 UTC 2015 x86_64 AMD Phenom(tm) II X6 1055T Processor AuthenticAMD GNU/Linux
新的主机运行这个:
Linux adanarancs 3.2.0-4-amd64 #1 SMP Debian 3.2.73-2+deb7u2 x86_64 GNU/Linux ii libvirt-bin 0.9.12.3-1+deb7u1 amd64 programs for the libvirt library ii libvirt0 0.9.12.3-1+deb7u1 amd64 library for interfacing with different virtualization systems
我尝试了不同的function,cpu模式,用不同的选项启动不同的内核,但没有运气。
任何想法可能是什么原因的问题?
在你的文章中,你在旧机器和新机器上都使用了-cpu host 。
虽然在迁移虚拟机时通常不会有问题,特别是如果新机器具有比旧版本更新的相同品牌的CPU。
但是,在某些情况下,这仍然可能导致问题。
您可以尝试手动将新机器上的CPUtypes指定为与旧机器匹配的CPUtypes,或者在旧机器上查找CPUtypes,然后在新机器上使用它。
你不可能以这种方式获得新机器的新硬件的所有好处,但至less虚拟机将在新机器上工作,如果你select正确的CPUtypes,它应该至less是平等的与旧机器。