Skip to content

Commit

Permalink
block/blkio: Make driver nvme-io_uring take a "path" instead of a "fi…
Browse files Browse the repository at this point in the history
…lename"

The nvme-io_uring driver expects a character special file such as
/dev/ng0n1. Follow the convention of having a "filename" option when a
regular file is expected, and a "path" option otherwise.

This makes io_uring the only libblkio-based driver with a "filename"
option, as it accepts a regular file (even though it can also take a
block special file).

Signed-off-by: Alberto Faria <afaria@redhat.com>
Message-id: 20221028233854.839933-1-afaria@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
albertofaria authored and stefanhaRH committed Oct 31, 2022
1 parent 4c8f4fd commit 6c32fc0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions block/blkio.c
Expand Up @@ -640,12 +640,17 @@ static int blkio_io_uring_open(BlockDriverState *bs, QDict *options, int flags,
static int blkio_nvme_io_uring(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
const char *filename = qdict_get_str(options, "filename");
const char *path = qdict_get_try_str(options, "path");
BDRVBlkioState *s = bs->opaque;
int ret;

ret = blkio_set_str(s->blkio, "path", filename);
qdict_del(options, "filename");
if (!path) {
error_setg(errp, "missing 'path' option");
return -EINVAL;
}

ret = blkio_set_str(s->blkio, "path", path);
qdict_del(options, "path");
if (ret < 0) {
error_setg_errno(errp, -ret, "failed to set path: %s",
blkio_get_error_msg());
Expand Down Expand Up @@ -1016,7 +1021,6 @@ static BlockDriver bdrv_io_uring = BLKIO_DRIVER(

static BlockDriver bdrv_nvme_io_uring = BLKIO_DRIVER(
DRIVER_NVME_IO_URING,
.bdrv_needs_filename = true,
);

static BlockDriver bdrv_virtio_blk_vfio_pci = BLKIO_DRIVER(
Expand Down
4 changes: 2 additions & 2 deletions qapi/block-core.json
Expand Up @@ -3704,12 +3704,12 @@
#
# Driver specific block device options for the nvme-io_uring backend.
#
# @filename: path to the image file
# @path: path to the image file
#
# Since: 7.2
##
{ 'struct': 'BlockdevOptionsNvmeIoUring',
'data': { 'filename': 'str' },
'data': { 'path': 'str' },
'if': 'CONFIG_BLKIO' }

##
Expand Down

0 comments on commit 6c32fc0

Please sign in to comment.