xref: /spdk/doc/virtio.md (revision 1e1fd9ac219da3e52bc166c9d2bb2376c62c113d)
1# Virtio driver {#virtio}
2
3## Introduction {#virtio_intro}
4
5SPDK Virtio driver is a C library that allows communicating with Virtio devices.
6It allows any SPDK application to become an initiator for (SPDK) vhost targets.
7
8The driver supports two different usage models:
9
10* PCI - This is the standard mode of operation when used in a guest virtual
11  machine, where QEMU has presented the virtio controller as a virtual PCI device.
12* vhost-user - Can be used to connect to a vhost socket directly on the same host.
13
14The driver, just like the SPDK @ref vhost, is using pollers instead of standard
15interrupts to check for an I/O response. If used inside a VM, it bypasses interrupt
16and context switching overhead of QEMU and guest kernel, significantly boosting
17the overall I/O performance.
18
19This Virtio library is currently used to implement two bdev modules:
20@ref bdev_config_virtio_scsi and @ref bdev_config_virtio_blk.
21These modules will export generic SPDK block devices usable by any SPDK application.
22
23## 2MB hugepages {#virtio_2mb}
24
25vhost-user specification puts a limitation on the number of "memory regions" used (8).
26Each region corresponds to one file descriptor, and DPDK - as SPDK's memory allocator -
27uses one file per hugepage by default. So *by default* this makes SPDK Virtio practical
28with only 1GB hugepages. To run an SPDK app using Virtio initiator with 2MB hugepages
29it is required to pass '-g' command-line option . This forces DPDK to create a single
30non-physically-contiguous hugetlbfs file for all its memory.
31