Re: xbd attach as ada

From: Roger Pau Monné <roger.pau_at_citrix.com>
Date: Tue, 21 Mar 2023 10:37:20 UTC
On Fri, Jan 20, 2023 at 12:21:36AM +0000, Daugherity, Andrew W wrote:
> On Jan 19, 2023, at 1:48 AM, Echo Nar <echo@lethedata.com> wrote:
> > Hello,
> > 
> > I've been trying to understand a bit more about how FreeBSD handles xvd (xbd)
> > disks due to Bug 269023. I was wondering why does xbd blocks attach as ada
> > devices rather than just act as xbd devices directly.
> > 
> > 
> > dmesg snipit:
> > xbd0: 16384MB <Virtual Block Device> at device/vbd/768 on xenbusb_front0
> > xbd0: attaching as ada0
> > xbd0: features: write_barrier
> > xbd0: synchronize cache commands enabled.
> 
> 
> I can’t speak to that — it’s probably related to how emulated ATA devices get “taken over” by the blkfront (xbd) driver — but one detail I can provide is that depending on how you configure the VM, it is possible for the device to show up as _only_ an xbd device and not adaN.
> 
> For example, from one of my VMs (Linux Dom0, FreeBSD 12.3 VM), using the xl.cfg(5)/xl-disk-configuration(5) syntax:
> # hda/ada0: LV in xen_san VG
> # xvdb/xbd1: permanent device ID (rather than sdc) for LUN 2 from SAN
> disk=[ 'phy:/dev/xen_san/backup,hda,w', 'phy:/dev/disk/by-id/wwn-0x60004d9...,xvdb,w', ]
> 
> Inside the VM, they show up like this:
> xbd0: 12288MB <Virtual Block Device> at device/vbd/768 on xenbusb_front0
> xbd0: attaching as ada0
> xbd0: features: flush, write_barrier
> xbd0: synchronize cache commands enabled.
> xbd1: 1933233MB <Virtual Block Device> at device/vbd/51728 on xenbusb_front0
> xbd1: features: flush, write_barrier
> xbd1: synchronize cache commands enabled.
> 
> Note that xbd1 does not attach as an ada device.
> 
> When I upgraded the OS on the Dom0 (which included upgrading Xen from 4.4 to 4.12; there was no change inside the VM at this time), one change was that I could no longer attach different virtual disks as 'hda' and 'xvda' (aka ada0 and xbd0) or I’d get a similar issue to what you’re experiencing.  I had to change the VM config to use xvdb instead.

The reason for attaching as 'adaX' when using the 'hdX' notation in
the guest config files is for compatibility with the emulated disk
drives provided by QEMU.

There was a time when Xen support was not compiled in the GENERIC
kernel, so you would first install a plain FreeBSD guest using the
emulated disks provided by QEMU, and after install you would build a
XEN kernel to replace the GENERIC one.  It was important that the disk
names stayed the same when switching between the emulated devices and
the para-virtualized ones, or else you would need to change fstab and
any references to the emulated disks.

Roger.