Idea: use virtio for mounting disks

As I noticed recently, LXD uses SATA interface to connect disks to QEMU VMs. Because SATA interface is emulated, it is much slower than virtio, which is virtualized. Is it possible to add an option (or replace completely) to use virtio instead of SATA interface. All other interfaces (like PCI and nic) already use virtio, but not the disk interface.

Seems weird, because LXD should only use paravirtualized VirtIO interfaces for everything regarding virtual machines :thinking: I don’t have access to my homelab machine so can’t confirm for now.

@ruskofd this is the output of lscpi command on my VM:

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:02.0 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 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon (rev 01)
01:00.1 Unclassified device [00ff]: Red Hat, Inc. Virtio RNG (rev 01)
01:00.2 Keyboard controller: Red Hat, Inc. Virtio input (rev 01)
01:00.3 Input device controller: Red Hat, Inc. Virtio input (rev 01)
01:00.4 Communication controller: Red Hat, Inc. Virtio socket (rev 01)
01:00.5 Communication controller: Red Hat, Inc. Virtio console (rev 01)
01:00.6 USB controller: Red Hat, Inc. QEMU XHCI Host Controller (rev 01)
02:00.0 SCSI storage controller: Red Hat, Inc. Virtio SCSI (rev 01)
03:00.0 Unclassified device [0002]: Red Hat, Inc. Virtio filesystem (rev 01)
03:00.1 Mass storage controller: Red Hat, Inc. Device 105a (rev 01)
04:00.0 VGA compatible controller: Red Hat, Inc. Virtio GPU (rev 01)
05:00.0 Ethernet controller: Red Hat, Inc. Virtio network device (rev 01)

Notice the device 00:1f.2. Also, this is an output of df command:

Filesystem      Size  Used Avail Use% Mounted on
udev            973M     0  973M   0% /dev
tmpfs           198M  584K  198M   1% /run
/dev/sda2       5.7G 1002M  4.7G  18% /
tmpfs           990M     0  990M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            50M   14M   37M  27% /run/lxd_agent
/dev/sda1        99M   12M   88M  12% /boot/efi

/dev/sda means that this is SATA interface, not VirtIO.
I’m not sure, but this can probably be caused by the fact that my LXD daemon itself is running inside libvirt/QEMU VM, but it has enabled KVM nesting and uses all VirtIO devices (I decided to learn LXD, so I installed it in VM, rather than on host). Currently I have no access to any other LXD daemons to double-check that, but I will post if I get ones.

UPD. Checked on another LXD, which installed natively - same problem, I see /dev/sda instead of /dev/vda

For VirtIO, you have 2 possible interfaces :

  • VirtIO BLK (block), therefore the block device inside the VM is shown as /dev/vdX
  • VirtIO SCSI, therefore the block device inside the VM is shown as /dev/sdX (because it’s a SCSI type device)

Configuring virtio-blk and virtio-scsi Devices - QEMU

If you look closer in your output you see this :

...
02:00.0 SCSI storage controller: Red Hat, Inc. Virtio SCSI (rev 01)
...

So my guess, it’s probably related to QEMU which expose a SATA controller for whatever reason but it’s not used for block storage (or maybe by a CDROM device).

1 Like

Ok, thank you for explanation

1 Like