5

I use libvirt + qemu to boot a VM with a disk with IDE bus

device in 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>

in qemu:

-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

Guest OS is CentOS-7.9-x86_64-DVD-2009

After booting, the display in dmesg shows

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

and shows in 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

Why does CentOS convert the ATA bus to an scsi bus? Where can I see a more relevant description?

1

1 Answer 1

8

This is how the Linux kernel handles Parallel ATA (IDE). Initially, there was a set of IDE-specific drivers, and IDE drives appeared as hda etc. But when Serial ATA came on the scene, Jeff Garzik decided to use the existing SCSI midlayer in the kernel; he gave a number of reasons, notably:

  • Many of the advantages are derived the existence of the scsi mid-layer. It does a lot of work on our behalf, allowing me to focus on the ATA command protocols (PIO-in, PIO-out, DMA, etc.) almost exclusively.

[…]

  • Serial ATA is looming quickly on the horizon. Both device and host controller SATA implementations really lend themselves to behaviors
    that have existed in SCSI for a while. SATA even defines use of SCSI Enclosure Services.

  • The Linux SCSI layer handles hotplugging, and is more modular. It already has refcounted devices and sysfs and such. Creating a new block device driver from scratch means handling all those little details.

  • SCSI has been doing basic error recovery and queue control for a while now. Upcoming SATA2 will benefit greatly from this, as well
    ATA TCQ if I ever get around to implementing the latter.

  • ATAPI is SCSI-like.

The result was libata, which provides support for ATA devices and presents them through the SCSI midlayer, as SCSI drives. Initially this covered SATA devices and a few Intel PATA controllers (although as far as I remember the old IDE device drivers were still used by default for the latter).

A few years later, libata was extended to support most PATA controllers and the majority of IDE devices ended up being handled as SCSI devices. The legacy IDE drivers were removed in 2021.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.