Q35+uefi or bios+legacy // PCI | PCIE

1:首先统一可扩展固件接口(UEFI)是一种规范定义操作系统和平台固件之间的软件接口。
UEFI旨在替代基本输入/输出系统(BIOS)固件接口。(legacy)
硬件平台厂商越来越多地采用UEFI管理其引导固件开发的规范。


2:OVMF(Open Virtual机器固件),X64虚拟机的支持。

The following guest OSes were tested with OVMF:
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- Fedora 18
- Fedora 19
- Fedora 20
- Windows Server 2008 R2 SP1
- Windows Server 2012

- Windows 8

3:  virtio 是QEMU 为 I/O 提供便利。QEMU 是一个系统模拟器,它不仅提供guest操作系统虚拟化平台,还提供整个系统(PCI 主机控制器、磁盘、网络、视频硬件、USB 控制器和其他硬件元素)的模拟。

virtio-blk,virtio-net,virtio-pci,virtio-balloon,virtio-console


4.PCI 和PCIE

 PCIE(PCI Express)和PCI不同的是实现了传输方式从并行到串行的转变。PCI Express是采用点对点的串行连接方式,这个和以前的并行通道大为不同,它允许和每个设备建立独立的数据传输通道。不用再向整个系统请求带宽,这样也就轻松的到达了其他接口设备可望而不可及的高带宽。


5:Q35 和i440fx 机器类型。

Q35 支持默认的是pcie slot槽位。而ovmf就是uefi目前是支持Q35模式的开发包.(Q35默认支持uefi ,当然也是支持传统bios(这种情况虚拟机有问题)),i440支持的是PCI的设备,支持传统bios。

下表是qemu支持的machine type.

# /usr/libexec/qemu-kvm -M help
Supported machines are:
pc                   RHEL 7.4.0 PC (i440FX + PIIX, 1996) (alias of pc-i440fx-rhel7.4.0)
pc-i440fx-rhel7.4.0  RHEL 7.4.0 PC (i440FX + PIIX, 1996) (default)
pc-i440fx-rhel7.3.0  RHEL 7.3.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.2.0  RHEL 7.2.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.1.0  RHEL 7.1.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.0.0  RHEL 7.0.0 PC (i440FX + PIIX, 1996)
rhel6.6.0            RHEL 6.6.0 PC
rhel6.5.0            RHEL 6.5.0 PC
rhel6.4.0            RHEL 6.4.0 PC
rhel6.3.0            RHEL 6.3.0 PC
rhel6.2.0            RHEL 6.2.0 PC
rhel6.1.0            RHEL 6.1.0 PC
rhel6.0.0            RHEL 6.0.0 PC
q35                  RHEL-7.4.0 PC (Q35 + ICH9, 2009) (alias of pc-q35-rhel7.4.0)
pc-q35-rhel7.4.0     RHEL-7.4.0 PC (Q35 + ICH9, 2009)
pc-q35-rhel7.3.0     RHEL-7.3.0 PC (Q35 + ICH9, 2009)
none                 empty machine


5:关于rhel6 虚拟机 virtio disk失败的情况。

5.1: RHEL-6 guest,仅有virtio-legacy的驱动程序,并且没有virtio1.0

5.2:modern-only  virtio设备(就是virtio-1.0 devices 没有legacy接口选项)

当你创建一个Q35类型guest的virt-manager中,该设备的Virtio将放入PCI Express端口(不是传统的PCI插槽)。这又使得设备的成为“modern-only”device。 

$ virsh qemu-monitor-command ovmf.rhel6.q35 --hmp 'info qtree'
          dev: virtio-scsi-pci, id "scsi0"
            disable-legacy = "on"
          dev: virtio-balloon-pci, id "balloon0"
            disable-legacy = "on"
          dev: virtio-blk-pci, id "virtio-disk0"
            disable-legacy = "on"
          dev: virtio-serial-pci, id "virtio-serial0"
            disable-legacy = "on"
          dev: virtio-net-pci, id "net0"
            disable-legacy = "on"  

     一个virtio设备的表现是是(a)modern-only  或(b)transitional(=modern+legacy)取决于virtio设备在PCI Express层次结构中的位置。 如果device被放置在XML中的PCI Express根端口或下游端口中,则设备的行为就像modern的。 如果将该设备作为集成设备放置在pcie.0 root上,那么它将作为transitional。

Virtio设备插入PCI层次结构或集成端点将保持PCI,并具有默认的Transitional行为。Transitional virtio设备可以在IO和MMIO模式下工作,具体取决于guest支持。guest固件将分配IO和MMIO资源Transitional device。插入PCI Express端口的Virtio设备是PCI Express设备默认情况下具有“1.0”行为,不支持IO。在这两种情况下,可以使用disable-legacy和disable-modern属覆盖行为。请注意,disable-legacy = off设置将启用传统模式(启用)传统行为)为PCI Express virtio设备导致他们需要IO空间,由于可用的IO空间有限,可能会很快导致资源枯竭,因此非常不鼓励。

UEFI在这里是相关的,因为UEFI在运送时需要Q35(最低pc-q35-rhel7.3.0,最优选pc-q35-rhel7.4.0或更高版本)。 如果你有Q35,那么你会遇到上述的问题。



6:Q35 和i440 默认工作情况
     6.1 :I440FX - (pc): devices are PCI, transitional
                created by: disable-legacy=auto,disable-modern=off
                 - in virtio_pci_realize disable-legacy: auto => off
     6.2:   Q35 - on root bus - devices are PCI, transitional
                  - other buses - devices are PCIe, modern
                    created by: disable-legacy=auto,disable-modern=off
                 - in virtio_pci_dc_realize:
                   if disable-modern=off -> pcie
                 - in virtio_pci_realize:
                   if on pcie root port -> disable-legacy: auto => on
                   otherwise ->    disable-legacy: auto => off



原文地址:https://www.cnblogs.com/weikunzz/p/6857977.html