From: Stefan Hajnoczi <stefanha@redhat.com>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: qemu-devel@nongnu.org, Hanna Reitz <hreitz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Qing Wang <qinwang@redhat.com>
Subject: Re: [PATCH 1/2] block/blkio: fix opening virtio-blk drivers
Date: Tue, 25 Jul 2023 16:00:38 -0400 [thread overview]
Message-ID: <20230725200038.GB749269@fedora> (raw)
In-Reply-To: <20230724154611.178858-2-sgarzare@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2633 bytes --]
On Mon, Jul 24, 2023 at 05:46:10PM +0200, Stefano Garzarella wrote:
> 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. Indeed now QEMU is
> failing if used with virtio-blk-vhost-user 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
>
> 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 for those transports that do not support it (all except
> vhost-vdpa for now).
>
> So for now let's also check that the driver is virtio-blk-vhost-vdpa,
> since that's the only one that supports it.
What happens when more virtio-blk-* libblkio drivers gain support for
`fd`? I think we'll be back to the same problem because QEMU will be
unable to distinguish between old and new libraries.
How about retrying with `path` if opening with `fd` fails?
>
> 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>
> ---
> block/blkio.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/block/blkio.c b/block/blkio.c
> index 1798648134..ca1149042a 100644
> --- a/block/blkio.c
> +++ b/block/blkio.c
> @@ -662,6 +662,7 @@ static int blkio_virtio_blk_common_open(BlockDriverState *bs,
> QDict *options, int flags, Error **errp)
> {
> const char *path = qdict_get_try_str(options, "path");
> + const char *blkio_driver = bs->drv->protocol_name;
> BDRVBlkioState *s = bs->opaque;
> bool fd_supported = false;
> int fd, ret;
> @@ -676,7 +677,8 @@ static int blkio_virtio_blk_common_open(BlockDriverState *bs,
> return -EINVAL;
> }
>
> - if (blkio_get_int(s->blkio, "fd", &fd) == 0) {
> + if (strcmp(blkio_driver, "virtio-blk-vhost-vdpa") == 0 &&
> + blkio_get_int(s->blkio, "fd", &fd) == 0) {
> fd_supported = true;
> }
>
> --
> 2.41.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2023-07-25 20:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 15:46 [PATCH 0/2] block/blkio: fix opening virtio-blk drivers Stefano Garzarella
2023-07-24 15:46 ` [PATCH 1/2] " Stefano Garzarella
2023-07-25 20:00 ` Stefan Hajnoczi [this message]
2023-07-26 7:26 ` Stefano Garzarella
2023-07-26 15:32 ` Stefan Hajnoczi
2023-07-26 15:45 ` Stefano Garzarella
2023-07-24 15:46 ` [PATCH 2/2] block/blkio: use blkio_set_int("fd") to check fd support Stefano Garzarella
2023-07-25 20:05 ` Stefan Hajnoczi
2023-07-26 7:28 ` Stefano Garzarella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230725200038.GB749269@fedora \
--to=stefanha@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qinwang@redhat.com \
--cc=sgarzare@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).