From patchwork Thu Jul 27 16:10:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 13330491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3ADD3C00528 for ; Thu, 27 Jul 2023 17:52:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP3Zh-0008MY-Aq; Thu, 27 Jul 2023 12:10:49 -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 1qP3Ze-0008M8-Az for qemu-devel@nongnu.org; Thu, 27 Jul 2023 12:10:47 -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 1qP3Zc-0003TG-OF for qemu-devel@nongnu.org; Thu, 27 Jul 2023 12:10:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690474244; 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=jqeG9yHjAZRo995Zo9p4ae7SEMnzY0vCfyw0QCThnX8=; b=SJwcR+azxck1eSpZEmT+KXcbhfoMKFLitdMsa0C2OyGzixBS642yB1koM9nnRbGyvfSuhV ZlMgS/En0qvi+bOG6xN+1FJTnB2mSDQ1tZPtR+dfeyUMG2qXvIRRe/vI9emlt/4xslK7R+ fK6+NMePL1PsUKDoXVqgO0GsLNB1GR4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-teRgy_WiOFOyIslLN3p2pg-1; Thu, 27 Jul 2023 12:10:42 -0400 X-MC-Unique: teRgy_WiOFOyIslLN3p2pg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-30793c16c78so672501f8f.3 for ; Thu, 27 Jul 2023 09:10:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690474241; x=1691079041; 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=jqeG9yHjAZRo995Zo9p4ae7SEMnzY0vCfyw0QCThnX8=; b=ZkZHpvqqmC7BJMsiF3cIqFdI2d4afeiu44W6xkfcfwGBmAA0iWExpBEU4GJp3MqdYy pP/hpggdBtQEjEPAwSnl/UvE28swJjI9bwqkOnqAx2TytrXhaAGn7q6ynWqvZpxjJRKx 1NoJetv9ve/gbGEqgOclhlAQA34NPfbXu2e9uwoEhkpS2VP33DESN7jeEYu0GysxwG29 DErSFzfMRN7baCz7+tHlrDrbQne1Ay8kwiMMWyNkM04FmY/6xqCq00U66M93vPIdF/jS oj095S9rNCy6plf0IyGwZ87f1Bhl5f/w6C1Dx7gpY5gWMG3O382klTg7uZa5beOKNJMe vQgw== X-Gm-Message-State: ABy/qLbpU+pm9YmXRUxbmNhuVbOaO5Dhif2mUYNEwodSUt5i4H0Tvrbb 8Lqs6otowPLxTPPEZsOLeDhOoC94RP7dQkbuTFXBDs211SfEVVApmpPq1nxjjLrvQdnIP7/r/7S WdxcmMw9riA+v4sP7gXbfA0it1h1rb4G7Xk3DGuCX6sR7xfTM7sK9krq0vGbqfILGlN4rlNMKnX M= X-Received: by 2002:adf:dec1:0:b0:317:61af:d64a with SMTP id i1-20020adfdec1000000b0031761afd64amr2413232wrn.3.1690474241094; Thu, 27 Jul 2023 09:10:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlH9KkPEhif4cJq6kfNeGpkr0ct4rzMdspxy9Y6mMBPUlpPW+fLwETRRSybkO122bqRP5Q9dEg== X-Received: by 2002:adf:dec1:0:b0:317:61af:d64a with SMTP id i1-20020adfdec1000000b0031761afd64amr2413202wrn.3.1690474240724; Thu, 27 Jul 2023 09:10:40 -0700 (PDT) Received: from step1.redhat.com ([193.207.170.163]) by smtp.gmail.com with ESMTPSA id h16-20020adffa90000000b0031423a8f4f7sm2427734wrr.56.2023.07.27.09.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 09:10:40 -0700 (PDT) From: Stefano Garzarella To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, Stefano Garzarella Subject: [PATCH v2 1/4] block/blkio: move blkio_connect() in the drivers functions Date: Thu, 27 Jul 2023 18:10:17 +0200 Message-ID: <20230727161020.84213-2-sgarzare@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727161020.84213-1-sgarzare@redhat.com> References: <20230727161020.84213-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-type: text/plain 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 --- block/blkio.c | 67 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 27 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,24 +758,6 @@ static int blkio_file_open(BlockDriverState *bs, QDict *options, int flags, return ret; } - if (strcmp(blkio_driver, "io_uring") == 0) { - ret = blkio_io_uring_open(bs, options, flags, errp); - } else if (strcmp(blkio_driver, "nvme-io_uring") == 0) { - ret = blkio_nvme_io_uring(bs, options, flags, errp); - } else if (strcmp(blkio_driver, "virtio-blk-vfio-pci") == 0) { - ret = blkio_virtio_blk_common_open(bs, options, flags, errp); - } else if (strcmp(blkio_driver, "virtio-blk-vhost-user") == 0) { - ret = blkio_virtio_blk_common_open(bs, options, flags, errp); - } else if (strcmp(blkio_driver, "virtio-blk-vhost-vdpa") == 0) { - ret = blkio_virtio_blk_common_open(bs, options, flags, errp); - } else { - g_assert_not_reached(); - } - if (ret < 0) { - blkio_destroy(&s->blkio); - return ret; - } - if (!(flags & BDRV_O_RDWR)) { ret = blkio_set_bool(s->blkio, "read-only", true); if (ret < 0) { @@ -765,10 +768,20 @@ static int blkio_file_open(BlockDriverState *bs, QDict *options, int flags, } } - ret = blkio_connect(s->blkio); + if (strcmp(blkio_driver, "io_uring") == 0) { + ret = blkio_io_uring_connect(bs, options, flags, errp); + } else if (strcmp(blkio_driver, "nvme-io_uring") == 0) { + ret = blkio_nvme_io_uring_connect(bs, options, flags, errp); + } else if (strcmp(blkio_driver, "virtio-blk-vfio-pci") == 0) { + ret = blkio_virtio_blk_connect(bs, options, flags, errp); + } else if (strcmp(blkio_driver, "virtio-blk-vhost-user") == 0) { + ret = blkio_virtio_blk_connect(bs, options, flags, errp); + } else if (strcmp(blkio_driver, "virtio-blk-vhost-vdpa") == 0) { + ret = blkio_virtio_blk_connect(bs, options, flags, errp); + } else { + g_assert_not_reached(); + } if (ret < 0) { - error_setg_errno(errp, -ret, "blkio_connect failed: %s", - blkio_get_error_msg()); blkio_destroy(&s->blkio); return ret; } From patchwork Thu Jul 27 16:10:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 13330405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B69AC0015E for ; Thu, 27 Jul 2023 17:06:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP3Zq-0008Sz-N0; Thu, 27 Jul 2023 12:10:58 -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 1qP3Zp-0008SF-7n for qemu-devel@nongnu.org; Thu, 27 Jul 2023 12:10:57 -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 1qP3Zn-0003Vg-NO for qemu-devel@nongnu.org; Thu, 27 Jul 2023 12:10:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690474255; 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=h/gg+RbKBeeQMtBE1iLrClo2NCkAFcmUaOrV45LPbjM=; b=NmA1lWQpz0LcOI3iXYN3j2sgNa5UcUxMVUuDmXt3Qp5gGicdwqTvHioXnL7Q5GsdyweWU8 hHAIcRZwBV/EfNRESflS4OhNA27ggO0NN9tLz9zXP20ixUqR0vxxyUmR0JxtVXDEUrshMA fyVpEa4ujGngJ4zoucEYvxqcUXYk8j8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-ql7huGlCNkOpR2BfHSZ6RQ-1; Thu, 27 Jul 2023 12:10:51 -0400 X-MC-Unique: ql7huGlCNkOpR2BfHSZ6RQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-30e3ee8a42eso606770f8f.1 for ; Thu, 27 Jul 2023 09:10:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690474250; x=1691079050; 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=h/gg+RbKBeeQMtBE1iLrClo2NCkAFcmUaOrV45LPbjM=; b=NsN5ndWM/qthP5ZCQc5Ws3kQkKNmUF7ps+HMlZwsnYToA8UF5rcnOyQpvU/qSrpNtl sFWC4hTesIR3RovMVBcaItA1b+wJxppwYO5S+Cs2biOy4yA4yOShk4mrvI0PvjSZ+dew 83lzMkcwIi3FTpdYhpV+7soZHURs4mVIBa4gfNVtp03nZHnvPe2NOmyWhwdkdbextvrv C/c/PADGBqpPi8H47of8e2/iJXcFu1IY3EDRAM1wOR5nkjWbEkQ+5WVk0m9JWdaGv7Ln eC+VHPFZ3PxzXW8ackuPyc/rzTDUqmvgajKsKEicgobbCLJMK8QutnhDAGqZiCxImBq1 5tpw== X-Gm-Message-State: ABy/qLYZxqFNqpRZJp0m1+FvO00ub1Ob+8dFPEiy+MS5PCCGnmWOx/U0 3YUKVwZYX9A08rsnJX0fPHebjggGCIFrbVg1K0jbL4USNK3C+WVJ6/jw/QkDXYR7nUXZRCDHdbr RGHn+tYxMoJ1O4zTHNA/AZdBwc0QqEhaE3tUDNvKhehMNL2yI/ic6Vg+/jY9TILf87WjjWl5cFF U= X-Received: by 2002:a05:6000:1146:b0:316:f5b1:98c with SMTP id d6-20020a056000114600b00316f5b1098cmr2104237wrx.24.1690474250102; Thu, 27 Jul 2023 09:10:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlHh1jpgH47RbF/5wD7KFPg4htWAQYmjvR0cJngReSpTeQPsoeTTgsh/y7jgVuLL/Hf5VCPHCQ== X-Received: by 2002:a05:6000:1146:b0:316:f5b1:98c with SMTP id d6-20020a056000114600b00316f5b1098cmr2104216wrx.24.1690474249801; Thu, 27 Jul 2023 09:10:49 -0700 (PDT) Received: from step1.redhat.com ([193.207.170.163]) by smtp.gmail.com with ESMTPSA id z7-20020a5d4407000000b0031766e99429sm2398506wrq.115.2023.07.27.09.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 09:10:49 -0700 (PDT) From: Stefano Garzarella To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, Stefano Garzarella Subject: [PATCH v2 2/4] block/blkio: retry blkio_connect() if it fails using `fd` Date: Thu, 27 Jul 2023 18:10:18 +0200 Message-ID: <20230727161020.84213-3-sgarzare@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727161020.84213-1-sgarzare@redhat.com> References: <20230727161020.84213-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-type: text/plain 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 Signed-off-by: Stefano Garzarella --- Notes: v2: - reworked retrying blkio_connect() [Stefan] 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()); From patchwork Thu Jul 27 16:10:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 13330408 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A949EC001E0 for ; Thu, 27 Jul 2023 17:09:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP3Zy-0008Vg-RN; Thu, 27 Jul 2023 12:11:06 -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 1qP3Zx-0008Us-1o for qemu-devel@nongnu.org; Thu, 27 Jul 2023 12:11:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP3Zv-0003Yc-Jj for qemu-devel@nongnu.org; Thu, 27 Jul 2023 12:11:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690474262; 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=yY0mIuMY/oj77dWAV1QfGssmJeEQkLaFlBf8TdE2K+M=; b=aG0IYRoXraA+bGH83WALePznYhJpOEiydpYQAlV8Q+wLXqFtgzqHQ+CaHZx68ZhYIFL+pr ByXSfQcBz/R227/Db+pytfQCdJ1bnu/SSfFUlN5UxWPLDzL18xMpbt3AZH+hoVhO/W4Fdn eg3zchsW/yuEmc5PWuM3fZy4cDgTAM4= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-651-VFvo0EXqN2mfXTXAqP0lWQ-1; Thu, 27 Jul 2023 12:11:00 -0400 X-MC-Unique: VFvo0EXqN2mfXTXAqP0lWQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fbb0fdd060so6869375e9.0 for ; Thu, 27 Jul 2023 09:11:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690474259; x=1691079059; 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=yY0mIuMY/oj77dWAV1QfGssmJeEQkLaFlBf8TdE2K+M=; b=SBcWWjq9wnn0TPCAAvH4dm/JQuWcgUp5SHjvw5Ktdhtbd805WwsXPC8RKTar8Kf1YC jSodOoaN28Qxk2uJJnPOflNHMjA5TAbMf8UfCT2qyoEvZZ7CyvYK3j6f1qi5ukLMZBrM Sxlk549w7dmnJE2xTqiWuq4K/AkMkG5J/LRfz6xzsZdBlCK/4yDblSfSnY7a/AQIpnTR wq4s6oOBrFirdx4l92fZWFYZhZNm/rNcwTzY7DcFtMYzLnWZvHEEh3khLFiPp+waJmIj Uf6QF5iSuQEWpuiqQdafcC7uiDTu2kemHSX9PrpmsHHmCSBlQfj+lsyyW4ZVAu9vJ0C8 zJaA== X-Gm-Message-State: ABy/qLaJuT5biIXMqAEUzZZP55fnVsllXi3A2eic0M6c0mZaf+VSYKtc Kctcuxhb6xlkQnwb2UjOUlsEHh8P+li/K81g08o/yWz/M+jSfrzrMABY3/uxAx4jHKTAtcr8jM8 Vjcf331dkqKpBvEe7IkYNbjgGNmcBDa36rD8oeeyR6b+gmtCKrtxav2/TzSZsCLYx6vr7L0rvuR E= X-Received: by 2002:a5d:690d:0:b0:314:a3f:9c08 with SMTP id t13-20020a5d690d000000b003140a3f9c08mr2203670wru.39.1690474259418; Thu, 27 Jul 2023 09:10:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlFuOMsUPGVbQByuKZ/t23QPV1F/YF7YWiQ7eS97LOMECuahhGTDBi1e8IGJwqEInBHajgrYwQ== X-Received: by 2002:a5d:690d:0:b0:314:a3f:9c08 with SMTP id t13-20020a5d690d000000b003140a3f9c08mr2203652wru.39.1690474259142; Thu, 27 Jul 2023 09:10:59 -0700 (PDT) Received: from step1.redhat.com ([193.207.170.163]) by smtp.gmail.com with ESMTPSA id m12-20020adff38c000000b00313f031876esm2459803wro.43.2023.07.27.09.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 09:10:58 -0700 (PDT) From: Stefano Garzarella To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, Stefano Garzarella , Qing Wang Subject: [PATCH v2 3/4] block/blkio: fall back on using `path` when `fd` setting fails Date: Thu, 27 Jul 2023 18:10:19 +0200 Message-ID: <20230727161020.84213-4-sgarzare@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727161020.84213-1-sgarzare@redhat.com> References: <20230727161020.84213-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-type: text/plain Received-SPF: pass client-ip=170.10.129.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=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 Signed-off-by: Stefano Garzarella --- 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", From patchwork Thu Jul 27 16:10:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 13330390 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00DAAC001E0 for ; Thu, 27 Jul 2023 16:42:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP3a7-0008WA-W1; Thu, 27 Jul 2023 12:11:16 -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 1qP3a6-0008Vz-8M for qemu-devel@nongnu.org; Thu, 27 Jul 2023 12:11:14 -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 1qP3a4-0003Zv-Pr for qemu-devel@nongnu.org; Thu, 27 Jul 2023 12:11:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690474272; 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=V5xCvY8FMsjvIKpr8rv2B4p4oWtKvFI4eWZNtN5mtzU=; b=c4+eCtth9XaVc4H1ISDqxu17T+JQVv3/u4REdRBHZa0a1RjBdVJE0FhYmIO11Toz74ul4r jthT1+kyW5XoZTNX5iYW5X+HxtM7ZWjDnKiYGdW0LKuWeFh+wiCCYj7Kq8Yj5OxDn0pSun xXvyY8GnVKp4QEnSP3uO8cZb+3RjKpQ= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-LYeSPoOsMWyJiYquyEuhQw-1; Thu, 27 Jul 2023 12:11:11 -0400 X-MC-Unique: LYeSPoOsMWyJiYquyEuhQw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-315a03cae87so1185591f8f.0 for ; Thu, 27 Jul 2023 09:11:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690474269; x=1691079069; 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=V5xCvY8FMsjvIKpr8rv2B4p4oWtKvFI4eWZNtN5mtzU=; b=UXjAgpZ9ttXCkctDqJUMrHz0XRwLuYN3dUZmb9apbBB/9Z74wy0MTF9ALJK8jK7Ie/ KllqMMRN1z7z9aTNUqFa+Nrtr+QCXNWqLQXJ8U7Gx7AhUF8NN6UpWaMNAYErGKbjoOh/ A4eWXpBsfPKKGLtCDA5lo/1+1/4KZ1JvPtzDUh+j+1/z8WiHLARvIujPOt7AkLk0u/Rf XPByrdeyYgkw4sA8x8Mcc2AXqxCf3d1BaqHJl/bozP6xrwfqBa5ko8j8nsGcvWMEYbDj tbCdhCSu0O9NAGtStPFtR/lsvYXGnuUN7tdLDqbqtdYzAVvDSA5be5Zn+F7qnU0Op9TG R4vw== X-Gm-Message-State: ABy/qLbPjOPmUliGmw7W5PmLOw7hIK/L6+zKN4RFHTH1pXe2kiHnKeZt XqIME8VMwti4QsaOp6OOelwxjd9jWla5JUV1T+NiDR/6IY7TCV5BqE+l4lun8rQKKl1G/xxi8og iybTSx1NkIE8iTj79R08y9dUn3e3/0snSvWyts0s01n2YDdMEUJNa4F0TeUwjs1T8REc9/2hV2x w= X-Received: by 2002:adf:ecd1:0:b0:317:67fa:eea6 with SMTP id s17-20020adfecd1000000b0031767faeea6mr2238715wro.22.1690474269683; Thu, 27 Jul 2023 09:11:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlHlq8KbgUobuvtPe6jcRbF6T2bxOhrW7cjvH7mpOarLqvZNZgvkrfV1UC7VLCju9FTHyiLhhQ== X-Received: by 2002:adf:ecd1:0:b0:317:67fa:eea6 with SMTP id s17-20020adfecd1000000b0031767faeea6mr2238694wro.22.1690474269447; Thu, 27 Jul 2023 09:11:09 -0700 (PDT) Received: from step1.redhat.com ([193.207.170.163]) by smtp.gmail.com with ESMTPSA id r1-20020a5d4941000000b00314427091a2sm2401190wrs.98.2023.07.27.09.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 09:11:08 -0700 (PDT) From: Stefano Garzarella To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, Stefano Garzarella Subject: [PATCH v2 4/4] block/blkio: use blkio_set_int("fd") to check fd support Date: Thu, 27 Jul 2023 18:10:20 +0200 Message-ID: <20230727161020.84213-5-sgarzare@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727161020.84213-1-sgarzare@redhat.com> References: <20230727161020.84213-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-type: text/plain 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=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 --- Notes: v2: - changed commit description [Stefan] 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; }