mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
blkio: add libblkio block driver
libblkio (https://gitlab.com/libblkio/libblkio/) is a library for high-performance disk I/O. It currently supports io_uring, virtio-blk-vhost-user, and virtio-blk-vhost-vdpa with additional drivers under development. One of the reasons for developing libblkio is that other applications besides QEMU can use it. This will be particularly useful for virtio-blk-vhost-user which applications may wish to use for connecting to qemu-storage-daemon. libblkio also gives us an opportunity to develop in Rust behind a C API that is easy to consume from QEMU. This commit adds io_uring, nvme-io_uring, virtio-blk-vhost-user, and virtio-blk-vhost-vdpa BlockDrivers to QEMU using libblkio. It will be easy to add other libblkio drivers since they will share the majority of code. For now I/O buffers are copied through bounce buffers if the libblkio driver requires it. Later commits add an optimization for pre-registering guest RAM to avoid bounce buffers. The syntax is: --blockdev io_uring,node-name=drive0,filename=test.img,readonly=on|off,cache.direct=on|off --blockdev nvme-io_uring,node-name=drive0,filename=/dev/ng0n1,readonly=on|off,cache.direct=on --blockdev virtio-blk-vhost-vdpa,node-name=drive0,path=/dev/vdpa...,readonly=on|off,cache.direct=on --blockdev virtio-blk-vhost-user,node-name=drive0,path=vhost-user-blk.sock,readonly=on|off,cache.direct=on Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Message-id: 20221013185908.1297568-3-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
@@ -3415,6 +3415,12 @@ L: qemu-block@nongnu.org
|
||||
S: Maintained
|
||||
F: block/vdi.c
|
||||
|
||||
blkio
|
||||
M: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
L: qemu-block@nongnu.org
|
||||
S: Maintained
|
||||
F: block/blkio.c
|
||||
|
||||
iSCSI
|
||||
M: Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
M: Paolo Bonzini <pbonzini@redhat.com>
|
||||
|
||||
+831
File diff suppressed because it is too large
Load Diff
@@ -92,6 +92,7 @@ block_modules = {}
|
||||
|
||||
modsrc = []
|
||||
foreach m : [
|
||||
[blkio, 'blkio', files('blkio.c')],
|
||||
[curl, 'curl', files('curl.c')],
|
||||
[glusterfs, 'gluster', files('gluster.c')],
|
||||
[libiscsi, 'iscsi', [files('iscsi.c'), libm]],
|
||||
|
||||
@@ -771,6 +771,13 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu
|
||||
required: get_option('virglrenderer'),
|
||||
kwargs: static_kwargs)
|
||||
endif
|
||||
blkio = not_found
|
||||
if not get_option('blkio').auto() or have_block
|
||||
blkio = dependency('blkio',
|
||||
method: 'pkg-config',
|
||||
required: get_option('blkio'),
|
||||
kwargs: static_kwargs)
|
||||
endif
|
||||
curl = not_found
|
||||
if not get_option('curl').auto() or have_block
|
||||
curl = dependency('libcurl', version: '>=7.29.0',
|
||||
@@ -1815,6 +1822,7 @@ config_host_data.set('CONFIG_LIBUDEV', libudev.found())
|
||||
config_host_data.set('CONFIG_LZO', lzo.found())
|
||||
config_host_data.set('CONFIG_MPATH', mpathpersist.found())
|
||||
config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
|
||||
config_host_data.set('CONFIG_BLKIO', blkio.found())
|
||||
config_host_data.set('CONFIG_CURL', curl.found())
|
||||
config_host_data.set('CONFIG_CURSES', curses.found())
|
||||
config_host_data.set('CONFIG_GBM', gbm.found())
|
||||
@@ -3869,6 +3877,7 @@ summary_info += {'PAM': pam}
|
||||
summary_info += {'iconv support': iconv}
|
||||
summary_info += {'curses support': curses}
|
||||
summary_info += {'virgl support': virgl}
|
||||
summary_info += {'blkio support': blkio}
|
||||
summary_info += {'curl support': curl}
|
||||
summary_info += {'Multipath support': mpathpersist}
|
||||
summary_info += {'PNG support': png}
|
||||
|
||||
@@ -117,6 +117,8 @@ option('bzip2', type : 'feature', value : 'auto',
|
||||
description: 'bzip2 support for DMG images')
|
||||
option('cap_ng', type : 'feature', value : 'auto',
|
||||
description: 'cap_ng support')
|
||||
option('blkio', type : 'feature', value : 'auto',
|
||||
description: 'libblkio block device driver')
|
||||
option('bpf', type : 'feature', value : 'auto',
|
||||
description: 'eBPF support')
|
||||
option('cocoa', type : 'feature', value : 'auto',
|
||||
|
||||
+73
-4
@@ -2951,11 +2951,18 @@
|
||||
'file', 'snapshot-access', 'ftp', 'ftps', 'gluster',
|
||||
{'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
|
||||
{'name': 'host_device', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
|
||||
'http', 'https', 'iscsi',
|
||||
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
|
||||
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
|
||||
'http', 'https',
|
||||
{ 'name': 'io_uring', 'if': 'CONFIG_BLKIO' },
|
||||
'iscsi',
|
||||
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme',
|
||||
{ 'name': 'nvme-io_uring', 'if': 'CONFIG_BLKIO' },
|
||||
'parallels', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum',
|
||||
'raw', 'rbd',
|
||||
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
|
||||
'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
|
||||
'ssh', 'throttle', 'vdi', 'vhdx',
|
||||
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
|
||||
{ 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' },
|
||||
'vmdk', 'vpc', 'vvfat' ] }
|
||||
|
||||
##
|
||||
# @BlockdevOptionsFile:
|
||||
@@ -3678,6 +3685,58 @@
|
||||
'*debug': 'int',
|
||||
'*logfile': 'str' } }
|
||||
|
||||
##
|
||||
# @BlockdevOptionsIoUring:
|
||||
#
|
||||
# Driver specific block device options for the io_uring backend.
|
||||
#
|
||||
# @filename: path to the image file
|
||||
#
|
||||
# Since: 7.2
|
||||
##
|
||||
{ 'struct': 'BlockdevOptionsIoUring',
|
||||
'data': { 'filename': 'str' },
|
||||
'if': 'CONFIG_BLKIO' }
|
||||
|
||||
##
|
||||
# @BlockdevOptionsNvmeIoUring:
|
||||
#
|
||||
# Driver specific block device options for the nvme-io_uring backend.
|
||||
#
|
||||
# @filename: path to the image file
|
||||
#
|
||||
# Since: 7.2
|
||||
##
|
||||
{ 'struct': 'BlockdevOptionsNvmeIoUring',
|
||||
'data': { 'filename': 'str' },
|
||||
'if': 'CONFIG_BLKIO' }
|
||||
|
||||
##
|
||||
# @BlockdevOptionsVirtioBlkVhostUser:
|
||||
#
|
||||
# Driver specific block device options for the virtio-blk-vhost-user backend.
|
||||
#
|
||||
# @path: path to the vhost-user UNIX domain socket.
|
||||
#
|
||||
# Since: 7.2
|
||||
##
|
||||
{ 'struct': 'BlockdevOptionsVirtioBlkVhostUser',
|
||||
'data': { 'path': 'str' },
|
||||
'if': 'CONFIG_BLKIO' }
|
||||
|
||||
##
|
||||
# @BlockdevOptionsVirtioBlkVhostVdpa:
|
||||
#
|
||||
# Driver specific block device options for the virtio-blk-vhost-vdpa backend.
|
||||
#
|
||||
# @path: path to the vhost-vdpa character device.
|
||||
#
|
||||
# Since: 7.2
|
||||
##
|
||||
{ 'struct': 'BlockdevOptionsVirtioBlkVhostVdpa',
|
||||
'data': { 'path': 'str' },
|
||||
'if': 'CONFIG_BLKIO' }
|
||||
|
||||
##
|
||||
# @IscsiTransport:
|
||||
#
|
||||
@@ -4305,6 +4364,8 @@
|
||||
'if': 'HAVE_HOST_BLOCK_DEVICE' },
|
||||
'http': 'BlockdevOptionsCurlHttp',
|
||||
'https': 'BlockdevOptionsCurlHttps',
|
||||
'io_uring': { 'type': 'BlockdevOptionsIoUring',
|
||||
'if': 'CONFIG_BLKIO' },
|
||||
'iscsi': 'BlockdevOptionsIscsi',
|
||||
'luks': 'BlockdevOptionsLUKS',
|
||||
'nbd': 'BlockdevOptionsNbd',
|
||||
@@ -4312,6 +4373,8 @@
|
||||
'null-aio': 'BlockdevOptionsNull',
|
||||
'null-co': 'BlockdevOptionsNull',
|
||||
'nvme': 'BlockdevOptionsNVMe',
|
||||
'nvme-io_uring': { 'type': 'BlockdevOptionsNvmeIoUring',
|
||||
'if': 'CONFIG_BLKIO' },
|
||||
'parallels': 'BlockdevOptionsGenericFormat',
|
||||
'preallocate':'BlockdevOptionsPreallocate',
|
||||
'qcow2': 'BlockdevOptionsQcow2',
|
||||
@@ -4327,6 +4390,12 @@
|
||||
'throttle': 'BlockdevOptionsThrottle',
|
||||
'vdi': 'BlockdevOptionsGenericFormat',
|
||||
'vhdx': 'BlockdevOptionsGenericFormat',
|
||||
'virtio-blk-vhost-user':
|
||||
{ 'type': 'BlockdevOptionsVirtioBlkVhostUser',
|
||||
'if': 'CONFIG_BLKIO' },
|
||||
'virtio-blk-vhost-vdpa':
|
||||
{ 'type': 'BlockdevOptionsVirtioBlkVhostVdpa',
|
||||
'if': 'CONFIG_BLKIO' },
|
||||
'vmdk': 'BlockdevOptionsGenericCOWFormat',
|
||||
'vpc': 'BlockdevOptionsGenericFormat',
|
||||
'vvfat': 'BlockdevOptionsVVFAT'
|
||||
|
||||
@@ -67,6 +67,7 @@ meson_options_help() {
|
||||
printf "%s\n" ' auth-pam PAM access control'
|
||||
printf "%s\n" ' avx2 AVX2 optimizations'
|
||||
printf "%s\n" ' avx512f AVX512F optimizations'
|
||||
printf "%s\n" ' blkio libblkio block device driver'
|
||||
printf "%s\n" ' bochs bochs image format support'
|
||||
printf "%s\n" ' bpf eBPF support'
|
||||
printf "%s\n" ' brlapi brlapi character device driver'
|
||||
@@ -198,6 +199,8 @@ _meson_option_parse() {
|
||||
--disable-gcov) printf "%s" -Db_coverage=false ;;
|
||||
--enable-lto) printf "%s" -Db_lto=true ;;
|
||||
--disable-lto) printf "%s" -Db_lto=false ;;
|
||||
--enable-blkio) printf "%s" -Dblkio=enabled ;;
|
||||
--disable-blkio) printf "%s" -Dblkio=disabled ;;
|
||||
--block-drv-ro-whitelist=*) quote_sh "-Dblock_drv_ro_whitelist=$2" ;;
|
||||
--block-drv-rw-whitelist=*) quote_sh "-Dblock_drv_rw_whitelist=$2" ;;
|
||||
--enable-block-drv-whitelist-in-tools) printf "%s" -Dblock_drv_whitelist_in_tools=true ;;
|
||||
|
||||
@@ -16,6 +16,9 @@ static void test_modules_load(const void *data)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *modules[] = {
|
||||
#ifdef CONFIG_BLKIO
|
||||
"block-", "blkio",
|
||||
#endif
|
||||
#ifdef CONFIG_CURL
|
||||
"block-", "curl",
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user