Linux

KVM 上的 SLES 11 PV 虛擬機

  • August 10, 2021

我有 SUSE 11 SP4 VM,最初它在 PV 模式下在 Xen 上工作。現在我將其移至 KVM。我常用的方法是在目標 VM 中啟動任何 Linux,掛載目標作業系統的根目錄,chroot 並重建 initramfs,然後將 VM 重新啟動到目標作業系統。

SLES 11 SP4 似乎缺少一些東西,因為在那之後 initramfs 找不到任何 vbd 設備來掛載 root。但是,我已經設法通過 KVM 主機上的直接 qemu 命令執行它:

qemu-kvm -m 32768 -smp 8 -device virtio-net-pci,mac=42:5f:96:48:39:fa,netdev=vmnic -netdev tap,id=vmnic,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -nographic -serial mon:stdio -drive file=/dev/lvm/vm,if=none,id=drive0,format=raw  -device virtio-blk-pci,drive=drive0,scsi=off

它工作正常。

KVM 配置(與磁碟相關)如下所示:

<devices>
 <emulator>/usr/bin/qemu-system-x86_64</emulator>
 <disk type="block" device="disk">
   <driver name="qemu" type="raw" cache="none" io="native"/>
   <source dev="/dev/lvm/vm"/>
   <target dev="vda" bus="virtio"/>
   <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
 </disk>
 <controller type="pci" index="3" model="pcie-root-port">
   <model name="pcie-root-port"/>
   <target chassis="3" port="0xa"/>
   <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x2"/>
 </controller>

而且我的 virt-manager 不允許我在這裡進行重大更改。

我在這裡可能錯了,但我認為主要區別在於 PCI 設備結構,因此 initramfs 以一種方式工作,而不是另一種工作方式。我比較了 PCI 設備:

在通過 qemu 命令直接執行的 VM 上找到的設備樹:

00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:02.0 VGA compatible controller: Device 1234:1111 (rev 02)
00:03.0 Ethernet controller: Red Hat, Inc Virtio network device
00:04.0 SCSI storage controller: Red Hat, Inc Virtio block device

在任何其他 KVM 虛擬機(同一主機)上找到的設備樹:

00:00.0 Host bridge: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller
00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.1 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.2 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.3 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.4 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.5 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.6 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.7 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:1f.0 ISA bridge: Intel Corporation 82801IB (ICH9) LPC Interface Controller (rev 02)
00:1f.2 SATA controller: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] (rev 02)
00:1f.3 SMBus: Intel Corporation 82801I (ICH9 Family) SMBus Controller (rev 02)
01:00.0 Ethernet controller: Red Hat, Inc. Virtio network device (rev 01)
02:00.0 USB controller: Red Hat, Inc. QEMU XHCI Host Controller (rev 01)
03:00.0 SCSI storage controller: Red Hat, Inc. Virtio block device (rev 01)
04:00.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon (rev 01)
05:00.0 Unclassified device [00ff]: Red Hat, Inc. Virtio RNG (rev 01)
08:00.0 SCSI storage controller: Red Hat, Inc. Virtio block device (rev 01)

在這裡我看到了不同之處:qemu 允許將儲存連接到根 PCI 主機橋,但在 KVM 中它始終連接到 QEMU PCIe 根埠。

我的問題是:

  1. SLES 11 是否可能太舊而無法支持 QEMU PCIe Root 埠?
  2. 是否可以簡化 VM 配置以將儲存直接附加到主機橋?
  3. 我在目標環境中重建 initramfs,不向配置文件添加任何內容。重建 initramfs 時我是否遺漏了某些東西(掛鉤或驅動程序)?

您使用 i440fx 機器類型創建了 VM。使用 q35 機器類型重試,這是您的其他 VM 使用的機器類型。

引用自:https://serverfault.com/questions/1073911