From nobody Mon Feb 9 08:37:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1690213643; cv=none; d=zohomail.com; s=zohoarc; b=I1oehSty4rsJci9B+uKMHk2l4sVeaqQC2gCz/Y/LnCKSFJQ8aFYI+Ea5/rqUnRqdwKVb/PmkqvankwniZHEiQy1whK1dGSMpRfoPpw/c4up/Ythl4U8ClV6OfUSEgVYLGA/rQTUI5boYemo8P2/LS4FDn1d86+B5Aky+pIue7cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690213643; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZTZDcbYTrt9yo1zwCVODNFBUI8LfoL6/Mfzp+qj134o=; b=B8wxUEK72r+FNFFOiNaU0lhEaX+QNbx2QIDQa/HyjXujLZxaC4yRpM/bEBNCao+BAOZepAdp308gFCumG1B24fr62jG++Co8PhBRaRa/tcJfyhOYcAIvaXN93goPLjQtn1/qTKV4OsMmeP3rKabUQ7XrohUS5XwuLA7pYTMNg3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690213643465697.5291378798768; Mon, 24 Jul 2023 08:47:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNxld-00068s-Gz; Mon, 24 Jul 2023 11:46:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qNxla-00066g-H2 for qemu-devel@nongnu.org; Mon, 24 Jul 2023 11:46:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qNxlY-0007iK-O6 for qemu-devel@nongnu.org; Mon, 24 Jul 2023 11:46:34 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-344-7HXf7LFMOkuKATd67jNAGA-1; Mon, 24 Jul 2023 11:46:27 -0400 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7659cb9c3b3so477493385a.1 for ; Mon, 24 Jul 2023 08:46:27 -0700 (PDT) Received: from step1.redhat.com ([5.77.105.74]) by smtp.gmail.com with ESMTPSA id z4-20020a05622a124400b004054b7cc490sm2672771qtx.73.2023.07.24.08.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 08:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690213591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZTZDcbYTrt9yo1zwCVODNFBUI8LfoL6/Mfzp+qj134o=; b=QXgSUGlTTWHjLY1WM3VIvM2eJ3HPjN6LJ4QrVTqIBGmfbtVjhnDR+zkpuqu9z1RXnZFHW+ lF9aKNtSBVESDFf+8nAhIR3eun1KOCw0etf+0nsUc4F0rq40NMJ/mvo5w4ktni5+g33H+H K+bVwhhgbgt4r5PeST2YAB0bCG4SjAM= X-MC-Unique: 7HXf7LFMOkuKATd67jNAGA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690213586; x=1690818386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZTZDcbYTrt9yo1zwCVODNFBUI8LfoL6/Mfzp+qj134o=; b=UK05VlYkRiKy4XIBnygLSeKnWA4eAnaknoRYL6NvCZZEcmgqhKArd6GskJ9tKfKsBq vdA6mi9Mvr0/2gg6UC4F9OSHVceJ6JUsmJKN8MHcPhqReuVxQ8eXhOoturJUa02GOJoe 1lQiuni82MAKISgVsJfrl0qhEny/RB3YasxtgZhh+GqY9e1uONpVPYhpWzy+GbxTGv4k +05mBfVkhx9u6dOiWGSiEq5j9INEU6dt+NKLOmyccOuGVMSuP9BAGqWqOnOroKB4Oxl7 xqo+t5fsoc8ER17+kWwhS6Av82scs4iZRdvBkgMGFte1ywu2y7eW8eeeW+eTIbMMHO7J kTww== X-Gm-Message-State: ABy/qLZA+h6PlMRZ1ZdMVy39jSqIvDrXTXbi8NcYOn+to7L35jYcYfAY dGKmBlL+rt7dxmE9XuBTJBptaFOwnZixCRtW3VHGAviESgdrjKqyB+5X/eeAt4vRzWn3pv3v0D4 JYBhndlVa+xfbzcshBBB5INC0f8l8QIOR7scfvHz0u0GXWRY8amMJ7NTc8GD5Zo5cqjq5FOJyKA g= X-Received: by 2002:ac8:5c94:0:b0:403:2dc0:e895 with SMTP id r20-20020ac85c94000000b004032dc0e895mr101694qta.59.1690213586669; Mon, 24 Jul 2023 08:46:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlEIrUVPKupAqKb7Fqjab1IekwS/69TFy8WIq+FOAy6VKpb0LXQzisVY2o4fnX6GGf6oU45YyQ== X-Received: by 2002:ac8:5c94:0:b0:403:2dc0:e895 with SMTP id r20-20020ac85c94000000b004032dc0e895mr101676qta.59.1690213586403; Mon, 24 Jul 2023 08:46:26 -0700 (PDT) From: Stefano Garzarella To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org, Stefano Garzarella , Qing Wang Subject: [PATCH 1/2] block/blkio: fix opening virtio-blk drivers Date: Mon, 24 Jul 2023 17:46:10 +0200 Message-ID: <20230724154611.178858-2-sgarzare@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724154611.178858-1-sgarzare@redhat.com> References: <20230724154611.178858-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=sgarzare@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1690213645207100003 Content-Type: text/plain; charset="utf-8" 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=3Ddrive0,driver=3Dvirtio-blk-vhost-user,path=3Dvhost= -user-blk.sock,cache.direct=3Don: 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. Fixes: cad2ccc395 ("block/blkio: use qemu_open() to support fd passing for = virtio-blk") Reported-by: Qing Wang Signed-off-by: Stefano Garzarella --- 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(BlockDriverStat= e *bs, QDict *options, int flags, Error **errp) { const char *path =3D qdict_get_try_str(options, "path"); + const char *blkio_driver =3D bs->drv->protocol_name; BDRVBlkioState *s =3D bs->opaque; bool fd_supported =3D false; int fd, ret; @@ -676,7 +677,8 @@ static int blkio_virtio_blk_common_open(BlockDriverStat= e *bs, return -EINVAL; } =20 - if (blkio_get_int(s->blkio, "fd", &fd) =3D=3D 0) { + if (strcmp(blkio_driver, "virtio-blk-vhost-vdpa") =3D=3D 0 && + blkio_get_int(s->blkio, "fd", &fd) =3D=3D 0) { fd_supported =3D true; } =20 --=20 2.41.0 From nobody Mon Feb 9 08:37:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1690213658; cv=none; d=zohomail.com; s=zohoarc; b=iNEMB4ARz+5kZbzNM9mWVLl0AdmX2SxgBcB7L2+2JEy8sUXwNG9DnK1ccjfjvNCHKrh0IzBHNMNKeqEaiccsc4ygU+sLq//ZxgEgRBsC95Dqrl2CXjaJI9iEpTwgeNB8mq1omaN3Hz7WrdgNu49HSMf7yDSrKxSq0AA7t3eny0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690213658; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AQ1pGchcZ7QxprONjlqMwSa2shwVZtdSYF8r13BgIXw=; b=Nyp5FZbi8LAE/fECOxkhDM+dnFwJ8BZcbhNuXX1MSTCnPxUqApeao6l9b6lmH7PNCPx4j7M2uEtpPdLZAJ1855HjkX5CKuXLiGJCTi5Kr+N58EHwuEcurUO+VGqfPusgiz6f/0VQPC6yY8UO4YKfvsN6BmxGGtKyQ6L8GPh4Yh8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690213658187121.97586011640556; Mon, 24 Jul 2023 08:47:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNxm0-0006BP-Qh; Mon, 24 Jul 2023 11:47:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qNxlq-00069c-VW for qemu-devel@nongnu.org; Mon, 24 Jul 2023 11:46:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qNxle-0007jB-6A for qemu-devel@nongnu.org; Mon, 24 Jul 2023 11:46:39 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-146-Z4Iof87-PJOiS9JDLHUo5g-1; Mon, 24 Jul 2023 11:46:36 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-63c566512c0so44636856d6.1 for ; Mon, 24 Jul 2023 08:46:36 -0700 (PDT) Received: from step1.redhat.com ([5.77.105.74]) by smtp.gmail.com with ESMTPSA id h5-20020a0cf445000000b0063004b5482csm3647709qvm.92.2023.07.24.08.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 08:46:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690213597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AQ1pGchcZ7QxprONjlqMwSa2shwVZtdSYF8r13BgIXw=; b=h+jl55uCC5zL8iymM7JYLGbl3QdLIVDXEQ14vFZlbJ+8Zn3zA9yB5BjWUFzBldl/H+e25U UWxyzRisVywpSABKpIgpjYPqToEy+hCTZR1Q9pqhBvFBC/tEgkIro9IsCGtr90hJbxOPDc 90zl6OKRxY3a2E/+ys0cBvLaOTnjcso= X-MC-Unique: Z4Iof87-PJOiS9JDLHUo5g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690213595; x=1690818395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AQ1pGchcZ7QxprONjlqMwSa2shwVZtdSYF8r13BgIXw=; b=cHZU1UTzmstqYQSxJ/S22OEnz+Md2WSrrUlMy0pc5b9GUmWvRPHyrL3P6Ow0GwmRY3 +FGLUlTXGv/WiE4jBNY/Z3zfseJvC8ZQq1P0DLbhJFCEcGgNaWJhkqSxzX9M2KT+4cto 4jNc6GeoHUzZJVrcQ0vjOMjWw5I8UUc8+4MMP/k/qD4dpyTAc13z1ySEEoisG5MNX6+y BMO2UJEF9xy6wSNlHZl/dLPAMkaBRFZAq3j4i8QFC++LkUoZzEH/Brx+TGNJ2Vjkc23D Dkzc+l1c1Z8931m+2JlK9F1474nT2Q1sj5pJhL9QZpMJUlSUICBU+iG0VTNsYOzJwdWG i0gA== X-Gm-Message-State: ABy/qLYESA1uf6vqPF2Bx5H5PxKgdqmSQll2bgoK/QSmzgf81TzGECwD 3QJvvx0HV7YwPk/TH2DFzk9y/3KkJQynrcXdx5m1QxI39KWij0S+TW4ggF9n76iA9F2uiEPHPaS PuEDy6AkvPYLCJ5xQ/MNumwlimSV20XJGMqfiBjg103mpLx0IdH8oq3pZrFYTgECWfh6QKMqriO A= X-Received: by 2002:a05:6214:da9:b0:63c:97df:f6da with SMTP id h9-20020a0562140da900b0063c97dff6damr175374qvh.25.1690213595453; Mon, 24 Jul 2023 08:46:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlGutVBLQ9M013UyT5pB5PuNbSHMyTkK5JYjONcEUuEYdHgp4HZ9XzoF0deMyFMIcMX6iG6Q6g== X-Received: by 2002:a05:6214:da9:b0:63c:97df:f6da with SMTP id h9-20020a0562140da900b0063c97dff6damr175351qvh.25.1690213595086; Mon, 24 Jul 2023 08:46:35 -0700 (PDT) From: Stefano Garzarella To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org, Stefano Garzarella Subject: [PATCH 2/2] block/blkio: use blkio_set_int("fd") to check fd support Date: Mon, 24 Jul 2023 17:46:11 +0200 Message-ID: <20230724154611.178858-3-sgarzare@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724154611.178858-1-sgarzare@redhat.com> References: <20230724154611.178858-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=sgarzare@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1690213658748100003 Content-Type: text/plain; charset="utf-8" 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 --- 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(BlockDriverStat= e *bs, const char *blkio_driver =3D bs->drv->protocol_name; BDRVBlkioState *s =3D bs->opaque; bool fd_supported =3D false; - int fd, ret; + int ret; =20 if (!path) { error_setg(errp, "missing 'path' option"); @@ -678,7 +678,7 @@ static int blkio_virtio_blk_common_open(BlockDriverStat= e *bs, } =20 if (strcmp(blkio_driver, "virtio-blk-vhost-vdpa") =3D=3D 0 && - blkio_get_int(s->blkio, "fd", &fd) =3D=3D 0) { + blkio_set_int(s->blkio, "fd", -1) =3D=3D 0) { fd_supported =3D true; } =20 @@ -688,7 +688,7 @@ static int blkio_virtio_blk_common_open(BlockDriverStat= e *bs, * layer through the "/dev/fdset/N" special path. */ if (fd_supported) { - int open_flags; + int open_flags, fd; =20 if (flags & BDRV_O_RDWR) { open_flags =3D O_RDWR; --=20 2.41.0