The way the virtio-blk driver is implemented in libblkio, it's much easier to use blkio_set_int() instead of blkio_get_int() and have it fail right away to see if `fd` is supported by the transport. See https://gitlab.com/libblkio/libblkio/-/merge_requests/208
Signed-off-by: Stefano Garzarella <sgarz...@redhat.com> --- block/blkio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blkio.c b/block/blkio.c index ca1149042a..719b19324b 100644 --- a/block/blkio.c +++ b/block/blkio.c @@ -665,7 +665,7 @@ static int blkio_virtio_blk_common_open(BlockDriverState *bs, const char *blkio_driver = bs->drv->protocol_name; BDRVBlkioState *s = bs->opaque; bool fd_supported = false; - int fd, ret; + int ret; if (!path) { error_setg(errp, "missing 'path' option"); @@ -678,7 +678,7 @@ static int blkio_virtio_blk_common_open(BlockDriverState *bs, } if (strcmp(blkio_driver, "virtio-blk-vhost-vdpa") == 0 && - blkio_get_int(s->blkio, "fd", &fd) == 0) { + blkio_set_int(s->blkio, "fd", -1) == 0) { fd_supported = true; } @@ -688,7 +688,7 @@ static int blkio_virtio_blk_common_open(BlockDriverState *bs, * layer through the "/dev/fdset/N" special path. */ if (fd_supported) { - int open_flags; + int open_flags, fd; if (flags & BDRV_O_RDWR) { open_flags = O_RDWR; -- 2.41.0