aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorStefano Garzarella <sgarzare@redhat.com>2023-08-03 10:28:25 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2023-08-03 11:28:43 -0400
commit9b06d0d076271d76e5384d767ef94a676f0a9efd (patch)
treebb288f9a924193fee5802caa2bc882c1226eaed4 /block
parent0b054b4c82ebad6e90111e3ffa3514f841dbb1d0 (diff)
downloadqemu-9b06d0d076271d76e5384d767ef94a676f0a9efd.zip
qemu-9b06d0d076271d76e5384d767ef94a676f0a9efd.tar.gz
qemu-9b06d0d076271d76e5384d767ef94a676f0a9efd.tar.bz2
block/blkio: add more comments on the fd passing handling
As Hanna pointed out, it is not clear in the code why qemu_open() can fail, and why blkio_set_int("fd") is not enough to discover the `fd` property support. Let's fix them by adding more details in the code comments. Suggested-by: Hanna Czenczek <hreitz@redhat.com> Reviewed-by: Hanna Czenczek <hreitz@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Message-id: 20230803082825.25293-3-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/blkio.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/block/blkio.c b/block/blkio.c
index baba2f0..1dd4956 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -713,6 +713,12 @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
*/
fd = qemu_open(path, O_RDWR, NULL);
if (fd < 0) {
+ /*
+ * qemu_open() can fail if the user specifies a path that is not
+ * a file or device, for example in the case of Unix Domain Socket
+ * for the virtio-blk-vhost-user driver. In such cases let's have
+ * libblkio open the path directly.
+ */
fd_supported = false;
} else {
ret = blkio_set_int(s->blkio, "fd", fd);
@@ -741,9 +747,12 @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
}
/*
- * If the libblkio driver doesn't support the `fd` property, blkio_connect()
- * will fail with -EINVAL. So let's try calling blkio_connect() again by
- * directly setting `path`.
+ * Before https://gitlab.com/libblkio/libblkio/-/merge_requests/208
+ * (libblkio <= v1.3.0), setting the `fd` property is not enough to check
+ * whether the driver supports the `fd` property or not. In that case,
+ * blkio_connect() will fail with -EINVAL.
+ * So let's try calling blkio_connect() again by directly setting `path`
+ * to cover this scenario.
*/
if (fd_supported && ret == -EINVAL) {
/*