相同的 libvirt 配置,一台机器启动,另一台机器不启动

相同的 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

旧机器上的“坏虚拟机”(运行正常):

/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

新机器中良好虚拟机的 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 模式、使用不同的选项启动不同的内核,但都没有成功。

知道该问题可能是什么原因造成的吗?

答案1

-cpu host在您的帖子中,您同时在新旧机器上使用。
虽然这在迁移虚拟机时通常不会成为问题,尤其是当新机器的 CPU 比旧机器更新时。
但是,在某些情况下,这仍然会导致问题。

您可以尝试手动将新机器上的 CPU 类型指定为与旧机器匹配的 CPU 类型,或者在旧机器上找到可用的 CPU 类型,然后在新机器上使用它。通过
这种方式,您可能无法获得新机器新硬件的所有好处,但至少虚拟机将在新机器上运行,如果您选择正确的 CPU 类型,它至少应该与旧机器相当。

相关内容