From nobody Wed May 15 18:50:31 2024 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=1690488404; cv=none; d=zohomail.com; s=zohoarc; b=d7E87Wcbcd69KyDPJOJlGCa0ukEQWAAHKJV8S8MklUhQR9eP/K4YoXyoGBy2UjQkmn+nobCcLrMLzmrqYrH0rs0h4mVhhSeYi0xwXWSrPnFjJpRHt7bpbdv69n/O9WssjVvqTxegJJN+lZmSxaHnIDLuSUWD73zcKoz24TmudvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690488404; h=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=EJCKaXx2reEQv2jkA9KLDOTxJPVAu6k6sc0PzTJpPbY=; b=YIQyavpz5gZbUi8mP58OZMA5Z2llbVbTukL18DjGTdQPFfSnmpRi5/r0EtfD0kf6AFvk0vIWWS4vNQitD3CU8j3SD184YF19m/5pXYCPLFAZNqoHeCKdfKtrRnZiQwdrape1zDELpvo9EGIsz6rx8uKXac8OzfELUtCeSEsmekw= 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 169048840476820.204897863183305; Thu, 27 Jul 2023 13:06:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP7Ag-0000ep-7V; Thu, 27 Jul 2023 16:01:14 -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 1qP7Ac-0000db-7m for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:10 -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 1qP7AZ-0002fl-Sh for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-126-2a7PcnEoON6gcp39mIFEkQ-1; Thu, 27 Jul 2023 16:01:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4878802A7D; Thu, 27 Jul 2023 20:01:03 +0000 (UTC) Received: from localhost (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 207CB1454147; Thu, 27 Jul 2023 20:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690488066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EJCKaXx2reEQv2jkA9KLDOTxJPVAu6k6sc0PzTJpPbY=; b=DX0aa1lnfzXhjS1gLJlk5rnF+FzwcLVO3MuMEQp11bEUvzPTvc+bKgGxNf4U2bAS3vIQgE O4DtacGRQ5Zq7hh3XQWoRxnOCmYmN3OUADIe2OhPxBOvqNC0/cOWOnzMQ92LRwwvlFtSZX 9yvkYGpZ2ZuY4E1AHvZVOgDbKy/SFLY= X-MC-Unique: 2a7PcnEoON6gcp39mIFEkQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Richard Henderson , Hanna Reitz , Stefano Garzarella Subject: [PULL for-8.1 1/8] block/blkio: enable the completion eventfd Date: Thu, 27 Jul 2023 16:00:51 -0400 Message-ID: <20230727200058.1071776-2-stefanha@redhat.com> In-Reply-To: <20230727200058.1071776-1-stefanha@redhat.com> References: <20230727200058.1071776-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=stefanha@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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1690488405409100001 Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella 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 Message-id: 20230725103744.77343-1-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi --- 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 =3D blkio_get_queue(s->blkio, 0); s->completion_fd =3D blkioq_get_completion_fd(s->blkioq); + blkioq_set_completion_fd_enabled(s->blkioq, true); =20 blkio_attach_aio_context(bs, bdrv_get_aio_context(bs)); return 0; --=20 2.41.0 From nobody Wed May 15 18:50:31 2024 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=1690489046; cv=none; d=zohomail.com; s=zohoarc; b=H/Mqxo+WleVLSGJgx/01596G+0RSJArLkasJNJnCqEp3D7jj1tyQ2dfEb/p1nIidQhovh3Q/Fc7Fr7iodClxX9U3KnefFINiCInM+dvAWIrW2fn86EbE5EtKn7+5M4rfJN54TIUV65p8kBYdCvMrEne9BgTgYQvoRk8TUuU5xcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690489046; 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=qBxH1iRanqco3HtF82nh9FMyY8AR3YyxU+2pBdaif24=; b=gPE0H8zsotO28DFqPzULTAumUBgjRg74+oNbE714ugvbpymmYdpTI1BvhdF87YEbJ8SaAUS+/r0VW7QimhGxd5I7CWmzUL+j2gA2S1SS7hUAjQN8RHsMoIOK2ipPAdXOB1pj5P7yfM3VJ8T10UBM1C2ozdL4xgfnJzOTo24FytY= 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 1690489045840533.6245261259652; Thu, 27 Jul 2023 13:17:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP7Am-0000fZ-3i; Thu, 27 Jul 2023 16:01:20 -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 1qP7Ag-0000ez-8l for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01: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 1qP7Ae-0002ie-IQ for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:13 -0400 Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-f5ICcI7kMFG2uOf07W61wg-1; Thu, 27 Jul 2023 16:01:08 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A9C5938149B8; Thu, 27 Jul 2023 20:01:06 +0000 (UTC) Received: from localhost (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE2C2C57964; Thu, 27 Jul 2023 20:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690488071; 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=qBxH1iRanqco3HtF82nh9FMyY8AR3YyxU+2pBdaif24=; b=KjBFYZPPaxHjTzAmFduMurtJEC1wSZiJD5Lq+NU8kmWQE/lSaWnqCUHALd9J783y+Qoe+h Q2IyEydltL8DgU2o/V7v7u8nLY75/YngYES6QMaxtadG40mO+rNDit/hqscE+wwC5Q/D9h 4XjjOoAcrPgQGu5XpMac5aWo663byz8= X-MC-Unique: f5ICcI7kMFG2uOf07W61wg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Richard Henderson , Hanna Reitz , Stefano Garzarella , Qing Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PULL for-8.1 2/8] block/blkio: do not use open flags in qemu_open() Date: Thu, 27 Jul 2023 16:00:52 -0400 Message-ID: <20230727200058.1071776-3-stefanha@redhat.com> In-Reply-To: <20230727200058.1071776-1-stefanha@redhat.com> References: <20230727200058.1071776-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=stefanha@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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1690489046573100001 From: Stefano Garzarella 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=3D2225439 Reported-by: Qing Wang Signed-off-by: Stefano Garzarella Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20230726074807.14041-1-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi --- 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(BlockDriverSt= ate *bs, * layer through the "/dev/fdset/N" special path. */ if (fd_supported) { - int open_flags; - - if (flags & BDRV_O_RDWR) { - open_flags =3D O_RDWR; - } else { - open_flags =3D O_RDONLY; - } - - fd =3D 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_R= DWR + * is not set in the open flags, because the exchange of IOCTL com= mands + * for example will fail. + * + * In order to open the device read-only, we are using the `read-o= nly` + * property of the libblkio driver in blkio_file_open(). + */ + fd =3D qemu_open(path, O_RDWR, errp); if (fd < 0) { return -EINVAL; } --=20 2.41.0 From nobody Wed May 15 18:50:31 2024 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=1690488670; cv=none; d=zohomail.com; s=zohoarc; b=eootqo6AtYn5nNUT9nKYAh5lNEl1iP8Em+oKtHYXmVo5tUtUfyuy2Vgl7lktCiI7wysgPnZXh8c8kegut1Z0dy5blwVoDXQbr9XUB4Rd+ujQbb6e5iPmcvHpTqX9JWhyJ90YczGN1yKuCT4S8alUTnKo7Mj46eDDFI5cR3unc28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690488670; 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=tsxiWqVUN4b/jGAtlTYnRiq+MCbYH2vLoTyH/YKZ3Gc=; b=EdVR4KjBO3q9uW6MUxtX5asx6pbE4m0hlD2Dy+glMRswJKI2TVzc2vTusYdl106TVs++aDxUfwO1Zw3Zw3yL1iDQLZkkFJcnin0JJsfXnj5MXYh+ZmOsGCUN1rXlrj21hwJqZRa5IwcW9W0rXHK2Yg+X6MIfZtpBPYwNUtTZr8M= 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 1690488670428409.0245250932787; Thu, 27 Jul 2023 13:11:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP7BC-0000nm-EK; Thu, 27 Jul 2023 16:01:46 -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 1qP7Ao-0000gC-Aa for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:31 -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 1qP7Ak-0002jV-Br for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:21 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-SZ-bJ80iPMCPYhZZSr-Efw-1; Thu, 27 Jul 2023 16:01:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D5469185A78F; Thu, 27 Jul 2023 20:01:09 +0000 (UTC) Received: from localhost (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FAD540C2063; Thu, 27 Jul 2023 20:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690488076; 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=tsxiWqVUN4b/jGAtlTYnRiq+MCbYH2vLoTyH/YKZ3Gc=; b=dH3gkSq1ZnQmgs/vWoKFPYnyfwRyhy9MRJX+NUdz+yjwN/OOUHJK/rZ7g6CyT29sa+ncpW fmn8CLNDImX8Hki+6xotO7wbi+0LGaMS5161ZZEzVMCHAFdxdvcud/ZXAlmuJpBfjfiRan EcPkOFmdCCgomKAkx5cPjTR3Cy21mmM= X-MC-Unique: SZ-bJ80iPMCPYhZZSr-Efw-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Richard Henderson , Hanna Reitz , Sam Li , Matthew Rosato , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PULL for-8.1 3/8] block/file-posix: fix g_file_get_contents return path Date: Thu, 27 Jul 2023 16:00:53 -0400 Message-ID: <20230727200058.1071776-4-stefanha@redhat.com> In-Reply-To: <20230727200058.1071776-1-stefanha@redhat.com> References: <20230727200058.1071776-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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.129.124; envelope-from=stefanha@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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1690488671060100003 From: Sam Li 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 Reviewed-by: Matthew Rosato Reviewed-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20230727115844.8480-1-faithilikerun@gmail.com Signed-off-by: Stefan Hajnoczi --- 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 st= at *st) static int get_sysfs_str_val(struct stat *st, const char *attribute, char **val) { g_autofree char *sysfspath =3D NULL; - int ret; size_t len; =20 if (!S_ISBLK(st->st_mode)) { @@ -1242,8 +1241,7 @@ static int get_sysfs_str_val(struct stat *st, const c= har *attribute, sysfspath =3D g_strdup_printf("/sys/dev/block/%u:%u/queue/%s", major(st->st_rdev), minor(st->st_rdev), attribute); - ret =3D g_file_get_contents(sysfspath, val, &len, NULL); - if (ret =3D=3D -1) { + if (!g_file_get_contents(sysfspath, val, &len, NULL)) { return -ENOENT; } =20 @@ -1253,7 +1251,7 @@ static int get_sysfs_str_val(struct stat *st, const c= har *attribute, if (*(p + len - 1) =3D=3D '\n') { *(p + len - 1) =3D '\0'; } - return ret; + return 0; } #endif =20 --=20 2.41.0 From nobody Wed May 15 18:50:31 2024 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=1690488904; cv=none; d=zohomail.com; s=zohoarc; b=nQZgamOabYKXnXTF6mulE+hQCyUeFhR1GgoT0eQlxQWd9JFP/IO+gDrDUqNasdfvoTIQ0eDbKcs7M1DtikFSqwXMhYsgEsR3XVpndERfCZPmvw+c5xm6NBS24kGsCNpquXi77GmXbifrBfcq9JKNpzfHspm239zlQGEUyEM+558= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690488904; h=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=z2XcPBhRtlf4rI2SPwIwNo+yPFXbfQemEPEauxege4k=; b=d5dLXWEDWDs8GbBf70NVMo/ezPFU77fO6zQLNSZd52h5hIF+bpRVMrqUsmuWyXZyAY4pFNsIkuwUjO7ow2QddIiqp4CDQkofIredgloPUQbcxhOjyzChNqeO4SgueIJ99bvweqEwWWNvAokO0mI+ooO0gv9LRTa6i+LaK0pO4Oc= 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 1690488904172844.8132615619609; Thu, 27 Jul 2023 13:15:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP7BE-0000pX-Ga; Thu, 27 Jul 2023 16:01:48 -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 1qP7Aw-0000ht-SN for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:33 -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 1qP7As-0002kF-B4 for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:28 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-573-fKJLDxhsMWmBfi4aujgOSg-1; Thu, 27 Jul 2023 16:01:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1043F8028B2; Thu, 27 Jul 2023 20:01:18 +0000 (UTC) Received: from localhost (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82E0F2166B25; Thu, 27 Jul 2023 20:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690488081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z2XcPBhRtlf4rI2SPwIwNo+yPFXbfQemEPEauxege4k=; b=gYxvXK5Q0PEvxlPuJT14AI2y7toYOIWJ1f+bRwtIdqTz5y3eG+c98fKVb/lUBU/S/M1yhp HS9INDy+SeoY+pmU/MeWMpidADe0dNx8sFPWV0kE7ok0342xkjnTyrVE5UScNjdzcVb12N Ps2AKWgAndF+r7VFjHr4qosKEjHCELk= X-MC-Unique: fKJLDxhsMWmBfi4aujgOSg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Richard Henderson , Hanna Reitz , Peter Maydell Subject: [PULL for-8.1 4/8] block: Fix pad_request's request restriction Date: Thu, 27 Jul 2023 16:00:54 -0400 Message-ID: <20230727200058.1071776-5-stefanha@redhat.com> In-Reply-To: <20230727200058.1071776-1-stefanha@redhat.com> References: <20230727200058.1071776-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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.129.124; envelope-from=stefanha@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: 1690488905977100001 Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek 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 <=3D 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 =3D=3D 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 Signed-off-by: Hanna Czenczek Message-id: 20230714085938.202730-1-hreitz@redhat.com Fixes: 18743311b829cafc1737a5f20bc3248d5f91ee2a ("block: Collapse padded I/O vecs exceeding IOV_MAX") Signed-off-by: Hanna Czenczek Signed-off-by: Stefan Hajnoczi --- 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; =20 - bdrv_check_qiov_request(*offset, *bytes, *qiov, *qiov_offset, &error_a= bort); + /* Should have been checked by the caller already */ + ret =3D bdrv_check_request32(*offset, *bytes, *qiov, *qiov_offset); + if (ret < 0) { + return ret; + } =20 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); =20 - /* Guaranteed by bdrv_check_qiov_request() */ + /* Guaranteed by bdrv_check_request32() */ assert(*bytes <=3D SIZE_MAX); ret =3D bdrv_create_padded_qiov(bs, pad, sliced_iov, sliced_niov, sliced_head, *bytes); --=20 2.41.0 From nobody Wed May 15 18:50:31 2024 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=1690490441; cv=none; d=zohomail.com; s=zohoarc; b=mAQvCRFl0+y6cxtWyL9/jXqrNY29nIUIMzHnSHyrnMdhcRJsn/cVzCCWvi4A/bClwu0mhc4SCzTkj9MA5TEq/aYXMsHlR11sHKRl2pQrCp+DdBd0YgrKRQuma644EJNkYsgcz9X59/29q9Iu+6Z2WzzFryHOqx6AaQpuk+y7AaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690490441; h=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=H3+AAufHnWErj5VG+DPHAeiau76Tcpt2M705gGpBbEk=; b=MJaFe+F/LVHaX1yR+FDMUyhJQ1LThlDUIPqKykFbmivSuO5FQvfB9zYklRkOYLqxl/mCsWYPaNvSpd8RZ1gHkE0T96jKI4dttHme7nfsW8uJaMsY9huIzL08Ufimy8oW/o6nUAXdLIzpnnf58n+AkXe/i590GBL8GJ3HHXCqQgU= 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 1690490441855463.6278864146533; Thu, 27 Jul 2023 13:40:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP7BF-0000qS-A8; Thu, 27 Jul 2023 16:01: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 1qP7Au-0000gO-5z for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:33 -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 1qP7As-0002kb-8V for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:27 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-mwJ4Yi3BP4et9knOizb37Q-1; Thu, 27 Jul 2023 16:01:21 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9819180027F; Thu, 27 Jul 2023 20:01:20 +0000 (UTC) Received: from localhost (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id F28391121330; Thu, 27 Jul 2023 20:01:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690488083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H3+AAufHnWErj5VG+DPHAeiau76Tcpt2M705gGpBbEk=; b=Ems8JvefWOlxz2TXiBHKcvO7eyDswXix+kkume3eUx1yjRNSvVbeF4nmrr7wTaHx0NI2/p MApa1GE7zH4rs4yALsdg6m98reGU5OslkGZaMSeRI10CVbj8jVC73DndWnLbZnoxjWVJWn EcGgV/6I/l190elKttKJk9rQAAD5Atg= X-MC-Unique: mwJ4Yi3BP4et9knOizb37Q-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Richard Henderson , Hanna Reitz , Stefano Garzarella Subject: [PULL for-8.1 5/8] block/blkio: move blkio_connect() in the drivers functions Date: Thu, 27 Jul 2023 16:00:55 -0400 Message-ID: <20230727200058.1071776-6-stefanha@redhat.com> In-Reply-To: <20230727200058.1071776-1-stefanha@redhat.com> References: <20230727200058.1071776-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=stefanha@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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1690490444236100001 Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella 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 Message-id: 20230727161020.84213-2-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi --- 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) } } =20 -static int blkio_io_uring_open(BlockDriverState *bs, QDict *options, int f= lags, - Error **errp) +static int blkio_io_uring_connect(BlockDriverState *bs, QDict *options, + int flags, Error **errp) { const char *filename =3D qdict_get_str(options, "filename"); BDRVBlkioState *s =3D bs->opaque; @@ -627,11 +627,18 @@ static int blkio_io_uring_open(BlockDriverState *bs, = QDict *options, int flags, } } =20 + ret =3D blkio_connect(s->blkio); + if (ret < 0) { + error_setg_errno(errp, -ret, "blkio_connect failed: %s", + blkio_get_error_msg()); + return ret; + } + return 0; } =20 -static int blkio_nvme_io_uring(BlockDriverState *bs, QDict *options, int f= lags, - Error **errp) +static int blkio_nvme_io_uring_connect(BlockDriverState *bs, QDict *option= s, + int flags, Error **errp) { const char *path =3D qdict_get_try_str(options, "path"); BDRVBlkioState *s =3D bs->opaque; @@ -655,11 +662,18 @@ static int blkio_nvme_io_uring(BlockDriverState *bs, = QDict *options, int flags, return -EINVAL; } =20 + ret =3D blkio_connect(s->blkio); + if (ret < 0) { + error_setg_errno(errp, -ret, "blkio_connect failed: %s", + blkio_get_error_msg()); + return ret; + } + return 0; } =20 -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 =3D qdict_get_try_str(options, "path"); BDRVBlkioState *s =3D bs->opaque; @@ -718,6 +732,13 @@ static int blkio_virtio_blk_common_open(BlockDriverSta= te *bs, } } =20 + ret =3D 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"); =20 return 0; @@ -737,16 +758,26 @@ static int blkio_file_open(BlockDriverState *bs, QDic= t *options, int flags, return ret; } =20 + if (!(flags & BDRV_O_RDWR)) { + ret =3D 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") =3D=3D 0) { - ret =3D blkio_io_uring_open(bs, options, flags, errp); + ret =3D blkio_io_uring_connect(bs, options, flags, errp); } else if (strcmp(blkio_driver, "nvme-io_uring") =3D=3D 0) { - ret =3D blkio_nvme_io_uring(bs, options, flags, errp); + ret =3D blkio_nvme_io_uring_connect(bs, options, flags, errp); } else if (strcmp(blkio_driver, "virtio-blk-vfio-pci") =3D=3D 0) { - ret =3D blkio_virtio_blk_common_open(bs, options, flags, errp); + ret =3D blkio_virtio_blk_connect(bs, options, flags, errp); } else if (strcmp(blkio_driver, "virtio-blk-vhost-user") =3D=3D 0) { - ret =3D blkio_virtio_blk_common_open(bs, options, flags, errp); + ret =3D blkio_virtio_blk_connect(bs, options, flags, errp); } else if (strcmp(blkio_driver, "virtio-blk-vhost-vdpa") =3D=3D 0) { - ret =3D blkio_virtio_blk_common_open(bs, options, flags, errp); + ret =3D 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; } =20 - if (!(flags & BDRV_O_RDWR)) { - ret =3D 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 =3D 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 =3D blkio_get_bool(s->blkio, "needs-mem-regions", &s->needs_mem_regions); --=20 2.41.0 From nobody Wed May 15 18:50:31 2024 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=1690488550; cv=none; d=zohomail.com; s=zohoarc; b=jphGPnVa9ATChFGP5jaF7IZ+ODpahi33eEJKysvCLb+wkMipXMkJvelLMiMCflPT0p37YFYhjCynlmX+gI+K/6rwSd4QMJA2O2VlrF/JNr+0pwq51Gq8g8QugDSIuO2fVFA7EzpRqHdnBx26KiUe9v6fNc5GWAI6yOXJlrIhB70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690488550; h=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=FuwXOvKeRHEancDJS8OkcP0iOKy6UX86GAg2J5w7NHE=; b=gfLo8cdB38pRKng4S29nraLgXsAumjQbQg9Bl11BbfHPwvC0MqmixOhxLayPOvP2ofBedN3qpIDmGnX9FBIM21LRpA4TQKxkDH8Rh17FKyLTS9b5CnS9R8gYuht4s5cv0yMuDBRj6pQeyR7+YKQoHhB+q7TCycTANKTx8Hq/0qA= 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 1690488550336943.7974230578506; Thu, 27 Jul 2023 13:09:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP7BE-0000pf-Pv; Thu, 27 Jul 2023 16:01:48 -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 1qP7B1-0000l4-Dh for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:37 -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 1qP7Ay-0002lp-Pv for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:34 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-460-tXjbP1HXPpekAzV8j3GmDA-1; Thu, 27 Jul 2023 16:01:24 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 62FDA185A7A3; Thu, 27 Jul 2023 20:01:23 +0000 (UTC) Received: from localhost (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB32B492B02; Thu, 27 Jul 2023 20:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690488090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FuwXOvKeRHEancDJS8OkcP0iOKy6UX86GAg2J5w7NHE=; b=eeWZXL+KqYzp5MpSclWtm6tRvMG9It5j4Yoxp0LSzx87AUzccLq1wnjjI05BClHuri91a8 i6CQl4CeVGOJ3ryH57hA+LkHgFHo3UWkXfob4s1ivCA9r7DPyyaXd8ORGToJSoyXofaR/A BUzh1WOB30NhXxMYIEwKOomOH8PDNLw= X-MC-Unique: tXjbP1HXPpekAzV8j3GmDA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Richard Henderson , Hanna Reitz , Stefano Garzarella Subject: [PULL for-8.1 6/8] block/blkio: retry blkio_connect() if it fails using `fd` Date: Thu, 27 Jul 2023 16:00:56 -0400 Message-ID: <20230727200058.1071776-7-stefanha@redhat.com> In-Reply-To: <20230727200058.1071776-1-stefanha@redhat.com> References: <20230727200058.1071776-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=stefanha@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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1690488552282100003 Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella 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 Message-id: 20230727161020.84213-3-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi --- 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, } =20 ret =3D blkio_connect(s->blkio); + /* + * If the libblkio driver doesn't support the `fd` property, blkio_con= nect() + * will fail with -EINVAL. So let's try calling blkio_connect() again = by + * directly setting `path`. + */ + if (fd_supported && ret =3D=3D -EINVAL) { + qemu_close(fd); + + /* + * We need to clear the `fd` property we set previously by setting + * it to -1. + */ + ret =3D 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 =3D 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 =3D blkio_connect(s->blkio); + } + if (ret < 0) { error_setg_errno(errp, -ret, "blkio_connect failed: %s", blkio_get_error_msg()); --=20 2.41.0 From nobody Wed May 15 18:50:31 2024 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=1690490478; cv=none; d=zohomail.com; s=zohoarc; b=XpzGitx9QoxXlRDIHUxJvwtq3Gr2uUINFQ81nwbnsSFxCNkAVRlEDZOk0XLa0HfJDTjKqcBvukAETPHOhFI3YpeXb6rwoagNpH9TwKl7r1CkdtiovqU45G5znHbvSiZ/f0CyZTLiZTbEuLRGFGao/cW9/qNOpMquluAKWMxTLHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690490478; h=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=Hz9W4uu3OMb54XF8JKznaOXgNmLIjjW6sqlVLyyADKY=; b=h6QYPzUkfzTxpVGDa3iMYQJAQN9J0xAkZDqPUBB6JPtUonDn1fwgTLjMG+F6uYUVdhKiOxDuOidJPupY7r/3o6bvXobDhJ124EoA2IypfhHrbj9YrqvT8nC0jEQ6Qw6gXXyQhss4UqBTOaNYF3Eqdo6nrIyVFFvgTXBcpt6N/3w= 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 1690490478629159.19330464413747; Thu, 27 Jul 2023 13:41:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP7BF-0000qf-Gx; Thu, 27 Jul 2023 16:01: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 1qP7Az-0000jM-J4 for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:37 -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 1qP7Ax-0002lj-RU for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-VbPgJ9CWNaGnMVgbk2PYTA-1; Thu, 27 Jul 2023 16:01:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CFC54856F67; Thu, 27 Jul 2023 20:01:25 +0000 (UTC) Received: from localhost (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3528C1121330; Thu, 27 Jul 2023 20:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690488089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hz9W4uu3OMb54XF8JKznaOXgNmLIjjW6sqlVLyyADKY=; b=IrOyRLmGCyHA0/ZaAlUMHxnfqJXa/l4ou9HIF/Kyhj3wBvMU47MTekXTC8nZCpzfgz8U6a cuoI5fghYs8TbGyel4g61Fptin37TYkW0gUfM4Z2d2xM8FNnIxYikmubrI5cbITkQBdIAg 97vB9PPEMAe6VobsNip+aza2YzlBqZk= X-MC-Unique: VbPgJ9CWNaGnMVgbk2PYTA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Richard Henderson , Hanna Reitz , Stefano Garzarella , Qing Wang Subject: [PULL for-8.1 7/8] block/blkio: fall back on using `path` when `fd` setting fails Date: Thu, 27 Jul 2023 16:00:57 -0400 Message-ID: <20230727200058.1071776-8-stefanha@redhat.com> In-Reply-To: <20230727200058.1071776-1-stefanha@redhat.com> References: <20230727200058.1071776-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=stefanha@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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1690490479578100003 Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella qemu_open() fails if called with an unix domain socket in this way: -blockdev node-name=3Ddrive0,driver=3Dvirtio-blk-vhost-user,path=3Dvhos= t-user-blk.sock,cache.direct=3Don: 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 Message-id: 20230727161020.84213-4-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi --- 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-o= nly` * property of the libblkio driver in blkio_file_open(). */ - fd =3D qemu_open(path, O_RDWR, errp); + fd =3D qemu_open(path, O_RDWR, NULL); if (fd < 0) { - return -EINVAL; + fd_supported =3D false; + } else { + ret =3D blkio_set_int(s->blkio, "fd", fd); + if (ret < 0) { + fd_supported =3D false; + qemu_close(fd); + } } + } =20 - ret =3D 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 =3D blkio_set_str(s->blkio, "path", path); if (ret < 0) { error_setg_errno(errp, -ret, "failed to set path: %s", --=20 2.41.0 From nobody Wed May 15 18:50:31 2024 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=1690488995; cv=none; d=zohomail.com; s=zohoarc; b=BUrkj+AatbsO+5bK8KeX8Ny2RalK8L81BQlTFjXS7aKH6Z0fmuSgpmuZOSuD7DcR/cphjQRe14KVOi1G98AWbFElf7f8USxjVkoHTNWzdGVLudBzWt4Y+YMY/HJwOSoKC825fWwLUjaAvWydHo0Vl59lZNlISM6zgkcTxjpdN1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690488995; h=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=KW/dec1j/setmZe1D7OoJVA6gf1hHhrxrVymaFzSgtQ=; b=Ek53gc3lgBWhsnJHPivbywWGpXKuMSBMmMyzlcDFiZL7EG00yFqP1AfxekQUpvl+2VQELB/qeIMuLgT0ebB9Vxsj69jUh64OE/drsZGeXMTUquno2rXxU8RUZLCyMnSSt206DkQsxonCw36PSSRq3Mkz8T/zAQWCRIhF5HQFb8A= 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 1690488995548831.7773016994989; Thu, 27 Jul 2023 13:16:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP7BG-0000ql-Bp; Thu, 27 Jul 2023 16:01:50 -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 1qP7B3-0000li-4j for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:40 -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 1qP7B1-0002mn-6R for qemu-devel@nongnu.org; Thu, 27 Jul 2023 16:01:36 -0400 Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-286-WIJuX5zDMdK5RzE8GnsgJg-1; Thu, 27 Jul 2023 16:01:29 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 31F7F29A9CA9; Thu, 27 Jul 2023 20:01:28 +0000 (UTC) Received: from localhost (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BD611454147; Thu, 27 Jul 2023 20:01:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690488093; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KW/dec1j/setmZe1D7OoJVA6gf1hHhrxrVymaFzSgtQ=; b=CNmPV6MbQtJM/2qwHNaz2jS10BGcqSNVKb9yfFbWuWC+8MH5TDMcAFVi8beGSiVa/W98EB omADHrJvSKwarFeRa64QFR8sHQStCGCmCncSPCs6uyufIma3IL8+pO1ButpteH+R1uK04G cTVWJM1q77IMze42ekEJasAHMYI7Bwk= X-MC-Unique: WIJuX5zDMdK5RzE8GnsgJg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Richard Henderson , Hanna Reitz , Stefano Garzarella Subject: [PULL for-8.1 8/8] block/blkio: use blkio_set_int("fd") to check fd support Date: Thu, 27 Jul 2023 16:00:58 -0400 Message-ID: <20230727200058.1071776-9-stefanha@redhat.com> In-Reply-To: <20230727200058.1071776-1-stefanha@redhat.com> References: <20230727200058.1071776-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=stefanha@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: 1690488996687100001 Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella 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 Message-id: 20230727161020.84213-5-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi --- 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 *b= s, QDict *options, return -EINVAL; } =20 - if (blkio_get_int(s->blkio, "fd", &fd) =3D=3D 0) { + if (blkio_set_int(s->blkio, "fd", -1) =3D=3D 0) { fd_supported =3D true; } =20 --=20 2.41.0