我使用 libvirt + qemu 用带有 IDE 总线的磁盘启动虚拟机
libvirt 中的设备:
<disk type='network' device='disk'>
<driver name='qemu' type='raw' cache='none' io='native'/>
<source protocol='iscsi' name='xxx'>
<host name='127.0.0.1' port='xxx'/>
</source>
<target dev='hdb' bus='ide'/>
<boot order='3'/>
<alias name='ide0-0-1'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
在qem中:
-drive file.driver=iscsi,file.portal=127.0.0.1:xxx,file.target=xxx,file.lun=xxx,file.transport=tcp,format=raw,if=none,id=drive-ide0-0-1,cache=none,aio=native
-device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,bootindex=3,write-cache=on
来宾操作系统是 CentOS-7.9-x86_64-DVD-2009
开机后,dmesg中的显示显示
May 18 06:07:37 localhost kernel: ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xd120 irq 14
May 18 06:07:37 localhost kernel: ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xd128 irq 15
May 18 09:15:54 localhost kernel: ata1.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
May 18 09:15:54 localhost kernel: ata1.01: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100
May 18 09:15:54 localhost kernel: ata1.01: 6291456 sectors, multi 16: LBA48
May 18 09:15:54 localhost kernel: ata1.00: configured for MWDMA2
May 18 09:15:54 localhost kernel: ata1.01: configured for MWDMA2
May 18 09:15:54 localhost kernel: scsi 0:0:0:0: CD-ROM QEMU QEMU DVD-ROM 2.5+ PQ: 0 ANSI: 5
May 18 09:15:54 localhost kernel: scsi 0:0:1:0: Direct-Access ATA QEMU HARDDISK 2.5+ PQ: 0 ANSI: 5
May 18 09:15:54 localhost kernel: sr 0:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
May 18 09:15:54 localhost kernel: cdrom: Uniform CD-ROM driver Revision: 3.20
May 18 09:15:54 localhost kernel: sd 0:0:1:0: [sda] 6291456 512-byte logical blocks: (3.22 GB/3.00 GiB)
May 18 09:15:54 localhost kernel: sd 0:0:1:0: [sda] Write Protect is off
May 18 09:15:54 localhost kernel: sd 0:0:1:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
May 18 09:15:54 localhost kernel: sd 0:0:1:0: [sda] Attached SCSI disk
并在 lshw 中显示
[root@localhost ~]# lshw -class disk
*-cdrom
description: DVD reader
product: QEMU DVD-ROM
vendor: QEMU
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/cdrom
logical name: /dev/sr0
version: 2.5+
capabilities: removable audio dvd
configuration: ansiversion=5 status=ready
*-medium
physical id: 0
logical name: /dev/cdrom
capabilities: partitioned partitioned:dos
configuration: signature=6b8b4567
*-disk
description: ATA Disk
product: QEMU HARDDISK
physical id: 0.1.0
bus info: scsi@0:0.1.0
logical name: /dev/sda
version: 2.5+
serial: 918a6997-1928-38a1-9
size: 3GiB (3221MB)
configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512
为什么 CentOS 将 ATA 总线转换为 scsi 总线?我在哪里可以看到更相关的描述?
这就是 Linux 内核处理并行 ATA (IDE) 的方式。最初,有一套 IDE 特定的驱动程序,IDE 驱动程序以
hda
etc 出现。但是当 Serial ATA 出现时,Jeff Garzik 决定使用内核中现有的 SCSI中间层;他给出了一些理由,特别是:结果是
libata
,它为 ATA 设备提供支持,并通过 SCSI 中间层将它们呈现为 SCSI 驱动器。最初,这包括 SATA 设备和一些 Intel PATA 控制器(尽管据我记得旧的 IDE 设备驱动程序仍默认用于后者)。几年后,libata 被扩展为支持大多数 PATA 控制器,并且大多数 IDE 设备最终都被当作 SCSI 设备来处理。2021 年删除了旧版 IDE 驱动程序。