* [PULL for-8.1 0/8] Block patches
@ 2023-07-27 20:00 Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 1/8] block/blkio: enable the completion eventfd Stefan Hajnoczi
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2023-07-27 20:00 UTC (permalink / raw)
To: qemu-devel
Cc: Stefan Hajnoczi, Kevin Wolf, Fam Zheng, qemu-block,
Richard Henderson, Hanna Reitz
The following changes since commit 66547f416a61e0cb711dc76821890242432ba193:
block/nvme: invoke blk_io_plug_call() outside q->lock (2023-07-17 09:17:41 -0400)
are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to 1c38fe69e2b8a05c1762b122292fa7e3662f06fd:
block/blkio: use blkio_set_int("fd") to check fd support (2023-07-27 15:51:46 -0400)
----------------------------------------------------------------
Pull request
Please include these bug fixes in QEMU 8.1. Thanks!
----------------------------------------------------------------
Hanna Czenczek (1):
block: Fix pad_request's request restriction
Sam Li (1):
block/file-posix: fix g_file_get_contents return path
Stefano Garzarella (6):
block/blkio: enable the completion eventfd
block/blkio: do not use open flags in qemu_open()
block/blkio: move blkio_connect() in the drivers functions
block/blkio: retry blkio_connect() if it fails using `fd`
block/blkio: fall back on using `path` when `fd` setting fails
block/blkio: use blkio_set_int("fd") to check fd support
block/blkio.c | 132 ++++++++++++++++++++++++++++++---------------
block/file-posix.c | 6 +--
block/io.c | 8 ++-
3 files changed, 97 insertions(+), 49 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PULL for-8.1 1/8] block/blkio: enable the completion eventfd
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
@ 2023-07-27 20:00 ` Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 2/8] block/blkio: do not use open flags in qemu_open() Stefan Hajnoczi
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2023-07-27 20:00 UTC (permalink / raw)
To: qemu-devel
Cc: Stefan Hajnoczi, Kevin Wolf, Fam Zheng, qemu-block,
Richard Henderson, Hanna Reitz, Stefano Garzarella
From: Stefano Garzarella <sgarzare@redhat.com>
Until libblkio 1.3.0, virtio-blk drivers had completion eventfd
notifications enabled from the start, but from the next releases
this is no longer the case, so we have to explicitly enable them.
In fact, the libblkio documentation says they could be disabled,
so we should always enable them at the start if we want to be
sure to get completion eventfd notifications:
By default, the driver might not generate completion events for
requests so it is necessary to explicitly enable the completion
file descriptor before use:
void blkioq_set_completion_fd_enabled(struct blkioq *q, bool enable);
I discovered this while trying a development version of libblkio:
the guest kernel hangs during boot, while probing the device.
Fixes: fd66dbd424f5 ("blkio: add libblkio block driver")
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20230725103744.77343-1-sgarzare@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/blkio.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/blkio.c b/block/blkio.c
index 1798648134..bc1fac48b7 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -845,6 +845,7 @@ static int blkio_file_open(BlockDriverState *bs, QDict *options, int flags,
QLIST_INIT(&s->bounce_bufs);
s->blkioq = blkio_get_queue(s->blkio, 0);
s->completion_fd = blkioq_get_completion_fd(s->blkioq);
+ blkioq_set_completion_fd_enabled(s->blkioq, true);
blkio_attach_aio_context(bs, bdrv_get_aio_context(bs));
return 0;
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL for-8.1 2/8] block/blkio: do not use open flags in qemu_open()
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 1/8] block/blkio: enable the completion eventfd Stefan Hajnoczi
@ 2023-07-27 20:00 ` Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 3/8] block/file-posix: fix g_file_get_contents return path Stefan Hajnoczi
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2023-07-27 20:00 UTC (permalink / raw)
To: qemu-devel
Cc: Stefan Hajnoczi, Kevin Wolf, Fam Zheng, qemu-block,
Richard Henderson, Hanna Reitz, Stefano Garzarella, Qing Wang,
Daniel P . Berrangé
From: Stefano Garzarella <sgarzare@redhat.com>
qemu_open() in blkio_virtio_blk_common_open() is used to open the
character device (e.g. /dev/vhost-vdpa-0 or /dev/vfio/vfio) or in
the future eventually the unix socket.
In all these cases we cannot open the path in read-only mode,
when the `read-only` option of blockdev is on, because the exchange
of IOCTL commands for example will fail.
In order to open the device read-only, we have to use the `read-only`
property of the libblkio driver as we already do in blkio_file_open().
Fixes: cad2ccc395 ("block/blkio: use qemu_open() to support fd passing for virtio-blk")
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2225439
Reported-by: Qing Wang <qinwang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20230726074807.14041-1-sgarzare@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/blkio.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/block/blkio.c b/block/blkio.c
index bc1fac48b7..7eb1b94820 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -686,15 +686,18 @@ static int blkio_virtio_blk_common_open(BlockDriverState *bs,
* layer through the "/dev/fdset/N" special path.
*/
if (fd_supported) {
- int open_flags;
-
- if (flags & BDRV_O_RDWR) {
- open_flags = O_RDWR;
- } else {
- open_flags = O_RDONLY;
- }
-
- fd = qemu_open(path, open_flags, errp);
+ /*
+ * `path` can contain the path of a character device
+ * (e.g. /dev/vhost-vdpa-0 or /dev/vfio/vfio) or a unix socket.
+ *
+ * So, we should always open it with O_RDWR flag, also if BDRV_O_RDWR
+ * is not set in the open flags, because the exchange of IOCTL commands
+ * for example will fail.
+ *
+ * In order to open the device read-only, we are using the `read-only`
+ * property of the libblkio driver in blkio_file_open().
+ */
+ fd = qemu_open(path, O_RDWR, errp);
if (fd < 0) {
return -EINVAL;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL for-8.1 3/8] block/file-posix: fix g_file_get_contents return path
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 1/8] block/blkio: enable the completion eventfd Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 2/8] block/blkio: do not use open flags in qemu_open() Stefan Hajnoczi
@ 2023-07-27 20:00 ` Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 4/8] block: Fix pad_request's request restriction Stefan Hajnoczi
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2023-07-27 20:00 UTC (permalink / raw)
To: qemu-devel
Cc: Stefan Hajnoczi, Kevin Wolf, Fam Zheng, qemu-block,
Richard Henderson, Hanna Reitz, Sam Li, Matthew Rosato,
Daniel P . Berrangé
From: Sam Li <faithilikerun@gmail.com>
The g_file_get_contents() function returns a g_boolean. If it fails, the
returned value will be 0 instead of -1. Solve the issue by skipping
assigning ret value.
This issue was found by Matthew Rosato using virtio-blk-{pci,ccw} backed
by an NVMe partition e.g. /dev/nvme0n1p1 on s390x.
Signed-off-by: Sam Li <faithilikerun@gmail.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20230727115844.8480-1-faithilikerun@gmail.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/file-posix.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 9e8e3d8ca5..b16e9c21a1 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1232,7 +1232,6 @@ static int hdev_get_max_hw_transfer(int fd, struct stat *st)
static int get_sysfs_str_val(struct stat *st, const char *attribute,
char **val) {
g_autofree char *sysfspath = NULL;
- int ret;
size_t len;
if (!S_ISBLK(st->st_mode)) {
@@ -1242,8 +1241,7 @@ static int get_sysfs_str_val(struct stat *st, const char *attribute,
sysfspath = g_strdup_printf("/sys/dev/block/%u:%u/queue/%s",
major(st->st_rdev), minor(st->st_rdev),
attribute);
- ret = g_file_get_contents(sysfspath, val, &len, NULL);
- if (ret == -1) {
+ if (!g_file_get_contents(sysfspath, val, &len, NULL)) {
return -ENOENT;
}
@@ -1253,7 +1251,7 @@ static int get_sysfs_str_val(struct stat *st, const char *attribute,
if (*(p + len - 1) == '\n') {
*(p + len - 1) = '\0';
}
- return ret;
+ return 0;
}
#endif
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL for-8.1 4/8] block: Fix pad_request's request restriction
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
` (2 preceding siblings ...)
2023-07-27 20:00 ` [PULL for-8.1 3/8] block/file-posix: fix g_file_get_contents return path Stefan Hajnoczi
@ 2023-07-27 20:00 ` Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 5/8] block/blkio: move blkio_connect() in the drivers functions Stefan Hajnoczi
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2023-07-27 20:00 UTC (permalink / raw)
To: qemu-devel
Cc: Stefan Hajnoczi, Kevin Wolf, Fam Zheng, qemu-block,
Richard Henderson, Hanna Reitz, Peter Maydell
From: Hanna Czenczek <hreitz@redhat.com>
bdrv_pad_request() relies on requests' lengths not to exceed SIZE_MAX,
which bdrv_check_qiov_request() does not guarantee.
bdrv_check_request32() however will guarantee this, and both of
bdrv_pad_request()'s callers (bdrv_co_preadv_part() and
bdrv_co_pwritev_part()) already run it before calling
bdrv_pad_request(). Therefore, bdrv_pad_request() can safely call
bdrv_check_request32() without expecting error, too.
In effect, this patch will not change guest-visible behavior. It is a
clean-up to tighten a condition to match what is guaranteed by our
callers, and which exists purely to show clearly why the subsequent
assertion (`assert(*bytes <= SIZE_MAX)`) is always true.
Note there is a difference between the interfaces of
bdrv_check_qiov_request() and bdrv_check_request32(): The former takes
an errp, the latter does not, so we can no longer just pass
&error_abort. Instead, we need to check the returned value. While we
do expect success (because the callers have already run this function),
an assert(ret == 0) is not much simpler than just to return an error if
it occurs, so let us handle errors by returning them up the stack now.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
Message-id: 20230714085938.202730-1-hreitz@redhat.com
Fixes: 18743311b829cafc1737a5f20bc3248d5f91ee2a
("block: Collapse padded I/O vecs exceeding IOV_MAX")
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/io.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/block/io.c b/block/io.c
index e8293d6b26..055fcf7438 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1710,7 +1710,11 @@ static int bdrv_pad_request(BlockDriverState *bs,
int sliced_niov;
size_t sliced_head, sliced_tail;
- bdrv_check_qiov_request(*offset, *bytes, *qiov, *qiov_offset, &error_abort);
+ /* Should have been checked by the caller already */
+ ret = bdrv_check_request32(*offset, *bytes, *qiov, *qiov_offset);
+ if (ret < 0) {
+ return ret;
+ }
if (!bdrv_init_padding(bs, *offset, *bytes, write, pad)) {
if (padded) {
@@ -1723,7 +1727,7 @@ static int bdrv_pad_request(BlockDriverState *bs,
&sliced_head, &sliced_tail,
&sliced_niov);
- /* Guaranteed by bdrv_check_qiov_request() */
+ /* Guaranteed by bdrv_check_request32() */
assert(*bytes <= SIZE_MAX);
ret = bdrv_create_padded_qiov(bs, pad, sliced_iov, sliced_niov,
sliced_head, *bytes);
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL for-8.1 5/8] block/blkio: move blkio_connect() in the drivers functions
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
` (3 preceding siblings ...)
2023-07-27 20:00 ` [PULL for-8.1 4/8] block: Fix pad_request's request restriction Stefan Hajnoczi
@ 2023-07-27 20:00 ` Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 6/8] block/blkio: retry blkio_connect() if it fails using `fd` Stefan Hajnoczi
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2023-07-27 20:00 UTC (permalink / raw)
To: qemu-devel
Cc: Stefan Hajnoczi, Kevin Wolf, Fam Zheng, qemu-block,
Richard Henderson, Hanna Reitz, Stefano Garzarella
From: Stefano Garzarella <sgarzare@redhat.com>
This is in preparation for the next patch, where for virtio-blk
drivers we need to handle the failure of blkio_connect().
Let's also rename the *_open() functions to *_connect() to make
the code reflect the changes applied.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20230727161020.84213-2-sgarzare@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/blkio.c | 71 ++++++++++++++++++++++++++++++---------------------
1 file changed, 42 insertions(+), 29 deletions(-)
diff --git a/block/blkio.c b/block/blkio.c
index 7eb1b94820..8ad7c0b575 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -603,8 +603,8 @@ static void blkio_unregister_buf(BlockDriverState *bs, void *host, size_t size)
}
}
-static int blkio_io_uring_open(BlockDriverState *bs, QDict *options, int flags,
- Error **errp)
+static int blkio_io_uring_connect(BlockDriverState *bs, QDict *options,
+ int flags, Error **errp)
{
const char *filename = qdict_get_str(options, "filename");
BDRVBlkioState *s = bs->opaque;
@@ -627,11 +627,18 @@ static int blkio_io_uring_open(BlockDriverState *bs, QDict *options, int flags,
}
}
+ ret = blkio_connect(s->blkio);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "blkio_connect failed: %s",
+ blkio_get_error_msg());
+ return ret;
+ }
+
return 0;
}
-static int blkio_nvme_io_uring(BlockDriverState *bs, QDict *options, int flags,
- Error **errp)
+static int blkio_nvme_io_uring_connect(BlockDriverState *bs, QDict *options,
+ int flags, Error **errp)
{
const char *path = qdict_get_try_str(options, "path");
BDRVBlkioState *s = bs->opaque;
@@ -655,11 +662,18 @@ static int blkio_nvme_io_uring(BlockDriverState *bs, QDict *options, int flags,
return -EINVAL;
}
+ ret = blkio_connect(s->blkio);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "blkio_connect failed: %s",
+ blkio_get_error_msg());
+ return ret;
+ }
+
return 0;
}
-static int blkio_virtio_blk_common_open(BlockDriverState *bs,
- QDict *options, int flags, Error **errp)
+static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
+ int flags, Error **errp)
{
const char *path = qdict_get_try_str(options, "path");
BDRVBlkioState *s = bs->opaque;
@@ -718,6 +732,13 @@ static int blkio_virtio_blk_common_open(BlockDriverState *bs,
}
}
+ ret = blkio_connect(s->blkio);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "blkio_connect failed: %s",
+ blkio_get_error_msg());
+ return ret;
+ }
+
qdict_del(options, "path");
return 0;
@@ -737,16 +758,26 @@ static int blkio_file_open(BlockDriverState *bs, QDict *options, int flags,
return ret;
}
+ if (!(flags & BDRV_O_RDWR)) {
+ ret = blkio_set_bool(s->blkio, "read-only", true);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "failed to set read-only: %s",
+ blkio_get_error_msg());
+ blkio_destroy(&s->blkio);
+ return ret;
+ }
+ }
+
if (strcmp(blkio_driver, "io_uring") == 0) {
- ret = blkio_io_uring_open(bs, options, flags, errp);
+ ret = blkio_io_uring_connect(bs, options, flags, errp);
} else if (strcmp(blkio_driver, "nvme-io_uring") == 0) {
- ret = blkio_nvme_io_uring(bs, options, flags, errp);
+ ret = blkio_nvme_io_uring_connect(bs, options, flags, errp);
} else if (strcmp(blkio_driver, "virtio-blk-vfio-pci") == 0) {
- ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
+ ret = blkio_virtio_blk_connect(bs, options, flags, errp);
} else if (strcmp(blkio_driver, "virtio-blk-vhost-user") == 0) {
- ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
+ ret = blkio_virtio_blk_connect(bs, options, flags, errp);
} else if (strcmp(blkio_driver, "virtio-blk-vhost-vdpa") == 0) {
- ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
+ ret = blkio_virtio_blk_connect(bs, options, flags, errp);
} else {
g_assert_not_reached();
}
@@ -755,24 +786,6 @@ static int blkio_file_open(BlockDriverState *bs, QDict *options, int flags,
return ret;
}
- if (!(flags & BDRV_O_RDWR)) {
- ret = blkio_set_bool(s->blkio, "read-only", true);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "failed to set read-only: %s",
- blkio_get_error_msg());
- blkio_destroy(&s->blkio);
- return ret;
- }
- }
-
- ret = blkio_connect(s->blkio);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "blkio_connect failed: %s",
- blkio_get_error_msg());
- blkio_destroy(&s->blkio);
- return ret;
- }
-
ret = blkio_get_bool(s->blkio,
"needs-mem-regions",
&s->needs_mem_regions);
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL for-8.1 6/8] block/blkio: retry blkio_connect() if it fails using `fd`
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
` (4 preceding siblings ...)
2023-07-27 20:00 ` [PULL for-8.1 5/8] block/blkio: move blkio_connect() in the drivers functions Stefan Hajnoczi
@ 2023-07-27 20:00 ` Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 7/8] block/blkio: fall back on using `path` when `fd` setting fails Stefan Hajnoczi
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2023-07-27 20:00 UTC (permalink / raw)
To: qemu-devel
Cc: Stefan Hajnoczi, Kevin Wolf, Fam Zheng, qemu-block,
Richard Henderson, Hanna Reitz, Stefano Garzarella
From: Stefano Garzarella <sgarzare@redhat.com>
libblkio 1.3.0 added support of "fd" property for virtio-blk-vhost-vdpa
driver. In QEMU, starting from commit cad2ccc395 ("block/blkio: use
qemu_open() to support fd passing for virtio-blk") we are using
`blkio_get_int(..., "fd")` to check if the "fd" property is supported
for all the virtio-blk-* driver.
Unfortunately that property is also available for those driver that do
not support it, such as virtio-blk-vhost-user.
So, `blkio_get_int()` is not enough to check whether the driver supports
the `fd` property or not. This is because the virito-blk common libblkio
driver only checks whether or not `fd` is set during `blkio_connect()`
and fails with -EINVAL for those transports that do not support it
(all except vhost-vdpa for now).
So let's handle the `blkio_connect()` failure, retrying it using `path`
directly.
Fixes: cad2ccc395 ("block/blkio: use qemu_open() to support fd passing for virtio-blk")
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20230727161020.84213-3-sgarzare@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/blkio.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/block/blkio.c b/block/blkio.c
index 8ad7c0b575..60d2d0f129 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -733,6 +733,35 @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
}
ret = blkio_connect(s->blkio);
+ /*
+ * 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`.
+ */
+ if (fd_supported && ret == -EINVAL) {
+ qemu_close(fd);
+
+ /*
+ * We need to clear the `fd` property we set previously by setting
+ * it to -1.
+ */
+ ret = blkio_set_int(s->blkio, "fd", -1);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "failed to set fd: %s",
+ blkio_get_error_msg());
+ return ret;
+ }
+
+ ret = blkio_set_str(s->blkio, "path", path);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "failed to set path: %s",
+ blkio_get_error_msg());
+ return ret;
+ }
+
+ ret = blkio_connect(s->blkio);
+ }
+
if (ret < 0) {
error_setg_errno(errp, -ret, "blkio_connect failed: %s",
blkio_get_error_msg());
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL for-8.1 7/8] block/blkio: fall back on using `path` when `fd` setting fails
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
` (5 preceding siblings ...)
2023-07-27 20:00 ` [PULL for-8.1 6/8] block/blkio: retry blkio_connect() if it fails using `fd` Stefan Hajnoczi
@ 2023-07-27 20:00 ` Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 8/8] block/blkio: use blkio_set_int("fd") to check fd support Stefan Hajnoczi
2023-07-28 12:56 ` [PULL for-8.1 0/8] Block patches Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2023-07-27 20:00 UTC (permalink / raw)
To: qemu-devel
Cc: Stefan Hajnoczi, Kevin Wolf, Fam Zheng, qemu-block,
Richard Henderson, Hanna Reitz, Stefano Garzarella, Qing Wang
From: Stefano Garzarella <sgarzare@redhat.com>
qemu_open() fails if called with an unix domain socket in this way:
-blockdev node-name=drive0,driver=virtio-blk-vhost-user,path=vhost-user-blk.sock,cache.direct=on: Could not open 'vhost-user-blk.sock': No such device or address
Since virtio-blk-vhost-user does not support fd passing, let`s always fall back
on using `path` if we fail the fd passing.
Fixes: cad2ccc395 ("block/blkio: use qemu_open() to support fd passing for virtio-blk")
Reported-by: Qing Wang <qinwang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20230727161020.84213-4-sgarzare@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/blkio.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/block/blkio.c b/block/blkio.c
index 60d2d0f129..72b46d61fd 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -711,19 +711,19 @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
* In order to open the device read-only, we are using the `read-only`
* property of the libblkio driver in blkio_file_open().
*/
- fd = qemu_open(path, O_RDWR, errp);
+ fd = qemu_open(path, O_RDWR, NULL);
if (fd < 0) {
- return -EINVAL;
+ fd_supported = false;
+ } else {
+ ret = blkio_set_int(s->blkio, "fd", fd);
+ if (ret < 0) {
+ fd_supported = false;
+ qemu_close(fd);
+ }
}
+ }
- ret = blkio_set_int(s->blkio, "fd", fd);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "failed to set fd: %s",
- blkio_get_error_msg());
- qemu_close(fd);
- return ret;
- }
- } else {
+ if (!fd_supported) {
ret = blkio_set_str(s->blkio, "path", path);
if (ret < 0) {
error_setg_errno(errp, -ret, "failed to set path: %s",
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL for-8.1 8/8] block/blkio: use blkio_set_int("fd") to check fd support
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
` (6 preceding siblings ...)
2023-07-27 20:00 ` [PULL for-8.1 7/8] block/blkio: fall back on using `path` when `fd` setting fails Stefan Hajnoczi
@ 2023-07-27 20:00 ` Stefan Hajnoczi
2023-07-28 12:56 ` [PULL for-8.1 0/8] Block patches Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2023-07-27 20:00 UTC (permalink / raw)
To: qemu-devel
Cc: Stefan Hajnoczi, Kevin Wolf, Fam Zheng, qemu-block,
Richard Henderson, Hanna Reitz, Stefano Garzarella
From: Stefano Garzarella <sgarzare@redhat.com>
Setting the `fd` property fails with virtio-blk-* libblkio drivers
that do not support fd passing since
https://gitlab.com/libblkio/libblkio/-/merge_requests/208.
Getting the `fd` property, on the other hand, always succeeds for
virtio-blk-* libblkio drivers even when they don't support fd passing.
This patch switches to setting the `fd` property because it is a
better mechanism for probing fd passing support than getting the `fd`
property.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20230727161020.84213-5-sgarzare@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/blkio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/blkio.c b/block/blkio.c
index 72b46d61fd..8e7ce42c79 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -690,7 +690,7 @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
return -EINVAL;
}
- if (blkio_get_int(s->blkio, "fd", &fd) == 0) {
+ if (blkio_set_int(s->blkio, "fd", -1) == 0) {
fd_supported = true;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PULL for-8.1 0/8] Block patches
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
` (7 preceding siblings ...)
2023-07-27 20:00 ` [PULL for-8.1 8/8] block/blkio: use blkio_set_int("fd") to check fd support Stefan Hajnoczi
@ 2023-07-28 12:56 ` Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2023-07-28 12:56 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel
Cc: Kevin Wolf, Fam Zheng, qemu-block, Richard Henderson, Hanna Reitz
On 7/27/23 13:00, Stefan Hajnoczi wrote:
> The following changes since commit 66547f416a61e0cb711dc76821890242432ba193:
>
> block/nvme: invoke blk_io_plug_call() outside q->lock (2023-07-17 09:17:41 -0400)
>
> are available in the Git repository at:
>
> https://gitlab.com/stefanha/qemu.git tags/block-pull-request
>
> for you to fetch changes up to 1c38fe69e2b8a05c1762b122292fa7e3662f06fd:
>
> block/blkio: use blkio_set_int("fd") to check fd support (2023-07-27 15:51:46 -0400)
>
> ----------------------------------------------------------------
> Pull request
>
> Please include these bug fixes in QEMU 8.1. Thanks!
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/8.1 as appropriate.
r~
>
> ----------------------------------------------------------------
>
> Hanna Czenczek (1):
> block: Fix pad_request's request restriction
>
> Sam Li (1):
> block/file-posix: fix g_file_get_contents return path
>
> Stefano Garzarella (6):
> block/blkio: enable the completion eventfd
> block/blkio: do not use open flags in qemu_open()
> block/blkio: move blkio_connect() in the drivers functions
> block/blkio: retry blkio_connect() if it fails using `fd`
> block/blkio: fall back on using `path` when `fd` setting fails
> block/blkio: use blkio_set_int("fd") to check fd support
>
> block/blkio.c | 132 ++++++++++++++++++++++++++++++---------------
> block/file-posix.c | 6 +--
> block/io.c | 8 ++-
> 3 files changed, 97 insertions(+), 49 deletions(-)
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-07-28 13:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-27 20:00 [PULL for-8.1 0/8] Block patches Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 1/8] block/blkio: enable the completion eventfd Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 2/8] block/blkio: do not use open flags in qemu_open() Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 3/8] block/file-posix: fix g_file_get_contents return path Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 4/8] block: Fix pad_request's request restriction Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 5/8] block/blkio: move blkio_connect() in the drivers functions Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 6/8] block/blkio: retry blkio_connect() if it fails using `fd` Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 7/8] block/blkio: fall back on using `path` when `fd` setting fails Stefan Hajnoczi
2023-07-27 20:00 ` [PULL for-8.1 8/8] block/blkio: use blkio_set_int("fd") to check fd support Stefan Hajnoczi
2023-07-28 12:56 ` [PULL for-8.1 0/8] Block patches Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).