From nobody Tue Feb 10 04:58:36 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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1667242480; cv=none; d=zohomail.com; s=zohoarc; b=A69JnstL8sn+pREWBZot0EjyPHv7tSG9OCxYchjJd/EWC1Wga3lL23ryyT0v8IYh8SWyBDOp7tWY8Xn7NKGr2aNtQC4doSKZimh9LTM1VDApfqnLwACRUQ9K6xoaxpLAKWCpXPbBO6MIBiSKugTtBBr8wCWc3eMpw3Ru2zDHjB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667242480; 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=nept1vz0xFGBfbWxI6LwgrRFU33FqGdn272TWraXgRU=; b=mp5Ori9MYZdhQTdkB3G1/Lau3RgJ7d4AsBWqIbzftuhDHiIm9EfbZyswx5IFuXTUhM7bibDM4LpvPpR8oz9xvaI/EQ2B6mrnun3bCscY+cVvGkvzkvGMU3ykoSianp9u8+6hYcWGuo49VEKUrezT3M0zea+xeClTTBKy76g8FJc= 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+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 166724248001626.55659297910165; Mon, 31 Oct 2022 11:54:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opZuf-0001cG-TF; Mon, 31 Oct 2022 14:53:33 -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 1opZu5-0001Cp-K9 for qemu-devel@nongnu.org; Mon, 31 Oct 2022 14:52:58 -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 1opZu3-0003ku-SN for qemu-devel@nongnu.org; Mon, 31 Oct 2022 14:52:57 -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-495-rlWDRHWMO4aNlSDkk6mKSQ-1; Mon, 31 Oct 2022 14:52:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0ED2988434A; Mon, 31 Oct 2022 18:52:53 +0000 (UTC) Received: from localhost (unknown [10.39.192.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F53340C6EC6; Mon, 31 Oct 2022 18:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667242375; 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=nept1vz0xFGBfbWxI6LwgrRFU33FqGdn272TWraXgRU=; b=ei9W3nreYeddNo74Mf0sCsBKAcfJUfGRoJMziQNO8eZRqFXOyvm7icuy2vnm6aIK8P2cwJ sT7Vs9WwugxhiOJw4siiXAO8m9jiCHToB+3nnTO7AltDhLRramVuZvw6zRRMuq/UO+0YuP lynajd9SCj4g+wYIywRoRQm4vrK5M1s= X-MC-Unique: rlWDRHWMO4aNlSDkk6mKSQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Eric Blake , Hanna Reitz , Stefan Hajnoczi , Markus Armbruster , qemu-block@nongnu.org, Kevin Wolf , Alberto Faria Subject: [PULL 1/3] block/blkio: Add virtio-blk-vfio-pci BlockDriver Date: Mon, 31 Oct 2022 14:51:04 -0400 Message-Id: <20221031185106.28245-2-stefanha@redhat.com> In-Reply-To: <20221031185106.28245-1-stefanha@redhat.com> References: <20221031185106.28245-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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+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: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.048, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1667242480445100001 Content-Type: text/plain; charset="utf-8" From: Alberto Faria libblkio 1.1.0 [1] introduces a virtio-blk-vfio-pci driver, which accesses a virtio-blk PCI device using VFIO. Add a corresponding BlockDriver. [1] https://gitlab.com/libblkio/libblkio/-/tree/v1.1.0 Signed-off-by: Alberto Faria Message-id: 20221028131635.710267-1-afaria@redhat.com Signed-off-by: Stefan Hajnoczi --- qapi/block-core.json | 18 ++++++++++++++++++ block/blkio.c | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index cb5079e645..81bbb0b893 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2960,6 +2960,7 @@ 'raw', 'rbd', { 'name': 'replication', 'if': 'CONFIG_REPLICATION' }, 'ssh', 'throttle', 'vdi', 'vhdx', + { 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' }, { 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' }, { 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' }, 'vmdk', 'vpc', 'vvfat' ] } @@ -3711,6 +3712,20 @@ 'data': { 'filename': 'str' }, 'if': 'CONFIG_BLKIO' } =20 +## +# @BlockdevOptionsVirtioBlkVfioPci: +# +# Driver specific block device options for the virtio-blk-vfio-pci backend. +# +# @path: path to the PCI device's sysfs directory (e.g. +# /sys/bus/pci/devices/0000:00:01.0). +# +# Since: 7.2 +## +{ 'struct': 'BlockdevOptionsVirtioBlkVfioPci', + 'data': { 'path': 'str' }, + 'if': 'CONFIG_BLKIO' } + ## # @BlockdevOptionsVirtioBlkVhostUser: # @@ -4390,6 +4405,9 @@ 'throttle': 'BlockdevOptionsThrottle', 'vdi': 'BlockdevOptionsGenericFormat', 'vhdx': 'BlockdevOptionsGenericFormat', + 'virtio-blk-vfio-pci': + { 'type': 'BlockdevOptionsVirtioBlkVfioPci', + 'if': 'CONFIG_BLKIO' }, 'virtio-blk-vhost-user': { 'type': 'BlockdevOptionsVirtioBlkVhostUser', 'if': 'CONFIG_BLKIO' }, diff --git a/block/blkio.c b/block/blkio.c index 82f26eedd2..f55eb774b4 100644 --- a/block/blkio.c +++ b/block/blkio.c @@ -25,6 +25,7 @@ */ #define DRIVER_IO_URING "io_uring" #define DRIVER_NVME_IO_URING "nvme-io_uring" +#define DRIVER_VIRTIO_BLK_VFIO_PCI "virtio-blk-vfio-pci" #define DRIVER_VIRTIO_BLK_VHOST_USER "virtio-blk-vhost-user" #define DRIVER_VIRTIO_BLK_VHOST_VDPA "virtio-blk-vhost-vdpa" =20 @@ -704,6 +705,8 @@ static int blkio_file_open(BlockDriverState *bs, QDict = *options, int flags, ret =3D blkio_io_uring_open(bs, options, flags, errp); } else if (strcmp(blkio_driver, DRIVER_NVME_IO_URING) =3D=3D 0) { ret =3D blkio_nvme_io_uring(bs, options, flags, errp); + } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VFIO_PCI) =3D=3D 0) { + ret =3D blkio_virtio_blk_common_open(bs, options, flags, errp); } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_USER) =3D=3D 0= ) { ret =3D blkio_virtio_blk_common_open(bs, options, flags, errp); } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_VDPA) =3D=3D 0= ) { @@ -989,6 +992,10 @@ static BlockDriver bdrv_nvme_io_uring =3D BLKIO_DRIVER( .bdrv_needs_filename =3D true, ); =20 +static BlockDriver bdrv_virtio_blk_vfio_pci =3D BLKIO_DRIVER( + DRIVER_VIRTIO_BLK_VFIO_PCI +); + static BlockDriver bdrv_virtio_blk_vhost_user =3D BLKIO_DRIVER( DRIVER_VIRTIO_BLK_VHOST_USER ); @@ -1001,6 +1008,7 @@ static void bdrv_blkio_init(void) { bdrv_register(&bdrv_io_uring); bdrv_register(&bdrv_nvme_io_uring); + bdrv_register(&bdrv_virtio_blk_vfio_pci); bdrv_register(&bdrv_virtio_blk_vhost_user); bdrv_register(&bdrv_virtio_blk_vhost_vdpa); } --=20 2.38.1 From nobody Tue Feb 10 04:58:36 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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1667242515; cv=none; d=zohomail.com; s=zohoarc; b=AWM/a6XfC/1s+esTl1/T+7gQudlGLm/knBb86ZPZgG5F/Agv83QK3sYU/U9DaxC6D2JCSJjpMLlpRO0wGdfpTpd6+m4SdOChCAeCH/1WDy6BbeEqQ7vCkRTQUGu9/I73KXyln/XFacjk6K52cDltX9oQUgEbSUaEv/s0GAyz6kY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667242515; 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=CQlhnItX9YyJv1NaFthXUfWY9srsADrlsPISjWkQdzc=; b=N0RncAcvtPLt2vnaFRLAX5fItKM0dsATVDe7KDKRfvWRhdzDJFVmlLqvc3hluVDekn5EPhOmrYWf01kgikDURHeXhTHMAKjNjbd909bgSqLj2FRj39AUUAQ8D4Q30HbtVj6f0tWsrsnzcfZ8y6KpOcRPmTBNWodznqCb1S5+Un8= 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+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 1667242515511491.6791205023045; Mon, 31 Oct 2022 11:55:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opZui-0001kK-Iw; Mon, 31 Oct 2022 14:53:36 -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 1opZu8-0001Gc-0K for qemu-devel@nongnu.org; Mon, 31 Oct 2022 14:53:00 -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 1opZu6-0003lF-Eq for qemu-devel@nongnu.org; Mon, 31 Oct 2022 14:52:59 -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-471-Pz3aAVcxPM6jjf5bzcoBqQ-1; Mon, 31 Oct 2022 14:52:56 -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 E09A1101A528; Mon, 31 Oct 2022 18:52:55 +0000 (UTC) Received: from localhost (unknown [10.39.192.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4782B40C2089; Mon, 31 Oct 2022 18:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667242377; 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=CQlhnItX9YyJv1NaFthXUfWY9srsADrlsPISjWkQdzc=; b=akoiEZQuYpxH9MkxzNlwalOz+2QUGUV48HKiLMdPIbakFXxONFRJq9xK04YIko9pjUuJ1J pDi2+Lc+IPSy1jsPL1NykXyUwj5icEr6NgoUuQHr1IvaGftZ+4zbiAn9at1WaXiRhV4rcD WElnuygtnX7qaOO7r2GcCWx7YnOvpjo= X-MC-Unique: Pz3aAVcxPM6jjf5bzcoBqQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Eric Blake , Hanna Reitz , Stefan Hajnoczi , Markus Armbruster , qemu-block@nongnu.org, Kevin Wolf , Alberto Faria Subject: [PULL 2/3] block/blkio: Tolerate device size changes Date: Mon, 31 Oct 2022 14:51:05 -0400 Message-Id: <20221031185106.28245-3-stefanha@redhat.com> In-Reply-To: <20221031185106.28245-1-stefanha@redhat.com> References: <20221031185106.28245-1-stefanha@redhat.com> MIME-Version: 1.0 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+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: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.048, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1667242516530100003 Content-Type: text/plain; charset="utf-8" From: Alberto Faria Some libblkio drivers may be able to work with regular files (e.g., io_uring) or otherwise resizable devices. Conservatively set BlockDriver::has_variable_length to true to ensure bdrv_nb_sectors() always gives up-to-date results. Also implement BlockDriver::bdrv_co_truncate for the case where no preallocation is needed and the device already has a size compatible with what was requested. Signed-off-by: Alberto Faria Message-id: 20221029122031.975273-1-afaria@redhat.com Signed-off-by: Stefan Hajnoczi --- block/blkio.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/block/blkio.c b/block/blkio.c index f55eb774b4..d850506acd 100644 --- a/block/blkio.c +++ b/block/blkio.c @@ -848,6 +848,31 @@ static int64_t blkio_getlength(BlockDriverState *bs) return capacity; } =20 +static int coroutine_fn blkio_truncate(BlockDriverState *bs, int64_t offse= t, + bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **err= p) +{ + int64_t current_length; + + if (prealloc !=3D PREALLOC_MODE_OFF) { + error_setg(errp, "Unsupported preallocation mode '%s'", + PreallocMode_str(prealloc)); + return -ENOTSUP; + } + + current_length =3D blkio_getlength(bs); + + if (offset > current_length) { + error_setg(errp, "Cannot grow device"); + return -EINVAL; + } else if (exact && offset !=3D current_length) { + error_setg(errp, "Cannot resize device"); + return -ENOTSUP; + } + + return 0; +} + static int blkio_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { return 0; @@ -963,10 +988,12 @@ static void blkio_refresh_limits(BlockDriverState *bs= , Error **errp) { \ .format_name =3D name, \ .protocol_name =3D name, \ + .has_variable_length =3D true, \ .instance_size =3D sizeof(BDRVBlkioState), \ .bdrv_file_open =3D blkio_file_open, \ .bdrv_close =3D blkio_close, \ .bdrv_getlength =3D blkio_getlength, \ + .bdrv_co_truncate =3D blkio_truncate, \ .bdrv_get_info =3D blkio_get_info, \ .bdrv_attach_aio_context =3D blkio_attach_aio_context, \ .bdrv_detach_aio_context =3D blkio_detach_aio_context, \ --=20 2.38.1 From nobody Tue Feb 10 04:58:36 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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1667242521; cv=none; d=zohomail.com; s=zohoarc; b=mWUC72bkHHagZcx1jbzQ0ViSx7EzCX54oUG97gYyp3k3fP2hvimxMfhs3n4FFywueQ7pP+LynTpQCB4a0lF6StvfWnOJq+R8KkpdYOOx7b4ZbPhcja9IWegKicj0XC9Ljv+Dozvd2h+Jf2/NLwvtvwF+zjEgdmucb/hsweBcwsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667242521; 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=ENGLvObqx80YmZgnW75fG0LaHePxu8XW6R6sQiADBlA=; b=ltsPv6w0i9Xh2sI0strmMxNA2sCZEdl/Vmhj061IRFIUJNFMpmuPCidND1IDZVJ/oOhVgXzW/w5hkEvG/C9u6S4YXY4A6BALWvE9LAQnNPPiLFamE7ArnH0rxsPkXS/rV08HMbQUk1y2rIrQUM5WL01Vf4MNBGSS7cHoKuG0+jo= 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+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 1667242521813434.9275052402579; Mon, 31 Oct 2022 11:55:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opZuj-0001nj-SX; Mon, 31 Oct 2022 14:53: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 1opZu9-0001HX-UI for qemu-devel@nongnu.org; Mon, 31 Oct 2022 14:53:08 -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 1opZu8-0003lc-Ex for qemu-devel@nongnu.org; Mon, 31 Oct 2022 14:53:01 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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-64-CLNYU9KHNb6oR3e7M5IJRg-1; Mon, 31 Oct 2022 14:52:58 -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 4D0D829DD9A0; Mon, 31 Oct 2022 18:52:58 +0000 (UTC) Received: from localhost (unknown [10.39.192.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id B64C1140EBF5; Mon, 31 Oct 2022 18:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667242379; 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=ENGLvObqx80YmZgnW75fG0LaHePxu8XW6R6sQiADBlA=; b=NCB0ZLH6zGr0dfy1muKzSzdIon8BTiI5/0KPXoA0T0UtDDBm6YEov3A4idMnjVO2uKDWey O3nhxYw4bBurX7hNZmZoCQqOO8NTYUAqx8YyAylYfny8kax3fDdwRl/nYATadqsdJYhvDj xPRVTNGxMg3U1WqvpwzA47Xj7u9siPQ= X-MC-Unique: CLNYU9KHNb6oR3e7M5IJRg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Eric Blake , Hanna Reitz , Stefan Hajnoczi , Markus Armbruster , qemu-block@nongnu.org, Kevin Wolf , Alberto Faria Subject: [PULL 3/3] block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename" Date: Mon, 31 Oct 2022 14:51:06 -0400 Message-Id: <20221031185106.28245-4-stefanha@redhat.com> In-Reply-To: <20221031185106.28245-1-stefanha@redhat.com> References: <20221031185106.28245-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+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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.048, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1667242522602100001 Content-Type: text/plain; charset="utf-8" From: Alberto Faria The nvme-io_uring driver expects a character special file such as /dev/ng0n1. Follow the convention of having a "filename" option when a regular file is expected, and a "path" option otherwise. This makes io_uring the only libblkio-based driver with a "filename" option, as it accepts a regular file (even though it can also take a block special file). Signed-off-by: Alberto Faria Message-id: 20221028233854.839933-1-afaria@redhat.com Signed-off-by: Stefan Hajnoczi --- qapi/block-core.json | 4 ++-- block/blkio.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 81bbb0b893..6d904004f8 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3704,12 +3704,12 @@ # # Driver specific block device options for the nvme-io_uring backend. # -# @filename: path to the image file +# @path: path to the image file # # Since: 7.2 ## { 'struct': 'BlockdevOptionsNvmeIoUring', - 'data': { 'filename': 'str' }, + 'data': { 'path': 'str' }, 'if': 'CONFIG_BLKIO' } =20 ## diff --git a/block/blkio.c b/block/blkio.c index d850506acd..620fab28a7 100644 --- a/block/blkio.c +++ b/block/blkio.c @@ -640,12 +640,17 @@ static int blkio_io_uring_open(BlockDriverState *bs, = QDict *options, int flags, static int blkio_nvme_io_uring(BlockDriverState *bs, QDict *options, int f= lags, Error **errp) { - const char *filename =3D qdict_get_str(options, "filename"); + const char *path =3D qdict_get_try_str(options, "path"); BDRVBlkioState *s =3D bs->opaque; int ret; =20 - ret =3D blkio_set_str(s->blkio, "path", filename); - qdict_del(options, "filename"); + if (!path) { + error_setg(errp, "missing 'path' option"); + return -EINVAL; + } + + ret =3D blkio_set_str(s->blkio, "path", path); + qdict_del(options, "path"); if (ret < 0) { error_setg_errno(errp, -ret, "failed to set path: %s", blkio_get_error_msg()); @@ -1016,7 +1021,6 @@ static BlockDriver bdrv_io_uring =3D BLKIO_DRIVER( =20 static BlockDriver bdrv_nvme_io_uring =3D BLKIO_DRIVER( DRIVER_NVME_IO_URING, - .bdrv_needs_filename =3D true, ); =20 static BlockDriver bdrv_virtio_blk_vfio_pci =3D BLKIO_DRIVER( --=20 2.38.1