Both virtio-blk and virtio-scsi are type of para-virtualization then what’s the exact difference between them I was having this question in my mind for sometime. As readers may already know, by default we are assigning a virtio-blk disk to openstack instance that’s why it shows inside the instance as vd*, we do have the option to assign a scsi disk to instance by setting the metadata properties on glance image which is going to used to spawning an instance, once the instance is spawned it will show the disk name as sd*.
Major advantages of providing the virtio-scsi over virtio-blk is having multiple block devices per virtual SCSI adapter. It’s not like that virtio-scsi is the replacement for virtio-blk. Development work for virtio-blk is also going on.
- Three types of storage can be attached to a guest machine using virtio-blk.
Let’s understand the I/O path for virtio-blk and what improvements are coming it in near future.
App –> VFS/Filesystem –> Generic Block Layer –> IO scheduler –> virtio-blk.ko
QEMU (user space) –> VFS/Filesystem –> Generic Block Layer –> IO Scheduler –> Block Device Layer –> Hard Disk.
We can see that in above flow two IO scheduler are coming into picture which doesn’t make sense for all kind of I/O patterns hence in “Guests” flow scheduler is going to be replaced with BIO based virtio-blk. Also, scheduler option will also be available just in case if some applications takes the advantage of scheduler.
Eventually it would be like :
- struct request based [Using IO scheduler in guest]
- struct bio based [Not using IO scheduler in guest]
It’s merged in Kernel 3.7
Add ‘virtio_blk.use_bio=1’ to kernel cmdline of guest no change is needed in host machine. it’s not enabled by default.
Kernel developers are planning to increase the intelligence of this feature by deciding to enable this depending upon underlying device and choosing the best I/O path according to workload.
Host side virtio-blk implementation include.
- Qemu Current : global mutex which is main source of bottleneck because only thread can submit an I/O
- Qemu data plane : Each virtio-blk device has thread dedicated to handle request. Requests are processes without going through the QEMU block layer using Linux AIO directly.vhost-blk
- vhost-blk is an in-kernel virtio-blk device accelerator, similar to vhost-net. it’s skipping host user space involvement which help us to avoid the context switching.
It mainly lacks the following capability because it’s not based on scsi model :
- Thin-provisioned Storage for manageability
- HA cluster on virtual machines.
- Backup server for reliability.
As it’s not based on scsi protocol hence lacks the capabilities like Persistence Reservation scsi which is required if we are running disks attached to VM while running in cluster environment, it helps to avoid the data corruption on shared devices.
Exception : In case of virtio-blk scsi commands works when storage is attached as LUN to guest.
- It has mainly three kind of configurations.
- Qemu [User space target]
- LUN << SCSI command compatible.
- LIO target [Kernel space target]
- libiscsi [User Space iscsi initiator] << SCSI command compatible.
- Qemu [User space target]
It can support thousands of disks per PCI device True SCSI devices, as the naming convention in guest is showing as sd* hence it’s good for p2v/v2v migration.