Kvm-Virtualization
相同的 libvirt 配置,一台機器啟動,另一台不啟動
我正在將一堆虛擬機從舊機器遷移到新機器。舊的使用一些內部腳本和 lvm 邏輯卷,新的使用 libvirt 和普通文件。配置相當統一,但一些虛擬機在新機器上執行完美,而我無法讓其他虛擬機工作。症狀是在載入初始 ramdisk 後,我看到 bios 顯示“從硬碟引導”的螢幕。
舊機器上的好虛擬機:
/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
舊機器中的“壞 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>
新機器上的壞虛擬機,表現不佳:
<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
我嘗試了不同的功能、cpu 模式、使用不同的選項啟動不同的核心,但沒有運氣。
知道問題的原因是什麼嗎?
在您的文章中,您
-cpu host
在舊機器和新機器上都使用。雖然在遷移 VM 時這通常不成問題,尤其是在新機器具有比舊機器更新的同品牌 CPU 時。
但是,在某些情況下,這仍然會導致問題。
您可以嘗試手動將新機器上的CPU類型指定為與舊機器匹配的CPU類型,或者在舊機器上找到可以工作的CPU類型,然後在新機器上使用。
您可能無法通過這種方式獲得新機器的新硬體的所有好處,但至少 VM 將在新機器上執行,並且如果您選擇正確的 CPU 類型,它至少應該是相同的用舊機器。