From nobody Fri May 17 11:05:46 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1661334752; cv=none; d=zohomail.com; s=zohoarc; b=bhd+aXYqu/c0ILW4Q12sIQ2DshWqV2OsTLNrqHsgLc5dQepdR1z95CQErmhgclqQw2Xjp0Rc1xIQO0MPwOPolHcd+IGqd5+e5JUZINyByeufKA6mIwt4cc/qHgszNzwil7No3BHDCmNlAQQD6pyVkUpH5o3eJJb0i+qMvqw8Rfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661334752; 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=S8xRNNtrItW89TnZMw5hOuJA+1TOPP1JJGpG/Vkw+aU=; b=TS9MVWW0D/GYJdTqOT8PWGhlyaINNFqXTZcJNxi0LUJQq527RBS8x+qfjBjTMyQJ2wH/+jQMUtfT4TvLdv/buuz33FOMNjn4BqpyNAwCmVwjaDcPTY3rItA7XNIAqjR+G+BlnxWBqKS4R2/F8OUgA0U9aoUxy5uCUVjSoy1lND0= 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 1661334751873787.3136428341166; Wed, 24 Aug 2022 02:52:31 -0700 (PDT) Received: from localhost ([::1]:37318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQn3m-00034b-BT for importer@patchew.org; Wed, 24 Aug 2022 05:52:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmgf-0007vK-IT; Wed, 24 Aug 2022 05:28:47 -0400 Received: from forwardcorp1j.mail.yandex.net ([5.45.199.163]:36556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmgd-0007uT-UH; Wed, 24 Aug 2022 05:28:37 -0400 Received: from sas1-c73b4b4f4b95.qloud-c.yandex.net (sas1-c73b4b4f4b95.qloud-c.yandex.net [IPv6:2a02:6b8:c08:12a9:0:640:c73b:4b4f]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id 2D3392E217B; Wed, 24 Aug 2022 12:18:47 +0300 (MSK) Received: from d-tatianin-nix.yandex-team.ru (unknown [2a02:6b8:b081:b4bd::1:34]) by sas1-c73b4b4f4b95.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id YDoXMhagzp-IjOaYkPH; Wed, 24 Aug 2022 12:18:46 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1661332726; bh=S8xRNNtrItW89TnZMw5hOuJA+1TOPP1JJGpG/Vkw+aU=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=B9f7n8kukpIY/0JFXhGdNRvV9LQPCjtybj3s9n9xSM5dWXKEjN/MoW5tD0kSTaZyy XRwAHTUq1QRqKpVluLW/Y/wS67UkCeetoelGDo3BarfOQCO8R5d3xUOA/Z8ifSbfSU 88g57RoOg0WBPtyO9vRn5tioHTTCwuX2MqkK6MLM= Authentication-Results: sas1-c73b4b4f4b95.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Daniil Tatianin To: qemu-devel@nongnu.org Cc: mst@redhat.com, stefanha@redhat.com, raphael.norwitz@nutanix.com, kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH v1 1/5] virtio-blk: decouple config size determination code from VirtIOBlock Date: Wed, 24 Aug 2022 12:18:33 +0300 Message-Id: <20220824091837.301708-2-d-tatianin@yandex-team.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824091837.301708-1-d-tatianin@yandex-team.ru> References: <20220824091837.301708-1-d-tatianin@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.45.199.163; envelope-from=d-tatianin@yandex-team.ru; helo=forwardcorp1j.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 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" X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1661334754131100001 Content-Type: text/plain; charset="utf-8" Make it more stand-alone so that we can reuse it for other virtio-blk devices that are not VirtIOBlock in the future commits. Signed-off-by: Daniil Tatianin --- hw/block/virtio-blk.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index e9ba752f6b..a4162dbbf2 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -49,12 +49,13 @@ static const VirtIOFeature feature_sizes[] =3D { {} }; =20 -static void virtio_blk_set_config_size(VirtIOBlock *s, uint64_t host_featu= res) +static size_t virtio_blk_common_get_config_size(uint64_t host_features) { - s->config_size =3D MAX(VIRTIO_BLK_CFG_SIZE, + size_t config_size =3D MAX(VIRTIO_BLK_CFG_SIZE, virtio_feature_get_config_size(feature_sizes, host_features)); =20 - assert(s->config_size <=3D sizeof(struct virtio_blk_config)); + assert(config_size <=3D sizeof(struct virtio_blk_config)); + return config_size; } =20 static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, @@ -1204,7 +1205,7 @@ static void virtio_blk_device_realize(DeviceState *de= v, Error **errp) return; } =20 - virtio_blk_set_config_size(s, s->host_features); + s->config_size =3D virtio_blk_common_get_config_size(s->host_features); =20 virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size); =20 --=20 2.25.1 From nobody Fri May 17 11:05:46 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1661334427; cv=none; d=zohomail.com; s=zohoarc; b=lNkuneQNh0eNlsHFhsBGBavvuoGkZKv9gMQR3k6Ckvh0wOOF+VpxSxIf2ZIcSvPFLYjrUqr6/XMGGM0cu6YyW1XNcPzF8SZtjfhgDewllVOiIQCbdJaCgTPc3icQBjDhuCFpq9cD0SjbNrldJA4symIf8aPaWrZmsJKM1oMzqIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661334427; 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=il+BoLQupXJ4tRALM2u+9xeU2f6CfGR3cAWaKcPLt2c=; b=Y8teGVeATVjs2D2yS/DFONjDDyMao4lseRGHWX/mb7CZW7iZ5dYHQd5lsx02fg+Qs1PNzf9po9T5jo5Nr36QTEH1j08/Y0E0briVW+tDKmxyXrv0tQB+FNCQbF+1pIz/YTpVSW1/xxNUkD5+rfvShGgPoV+jVHK5O0n8kNiCFPc= 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 1661334427014490.06388864225926; Wed, 24 Aug 2022 02:47:07 -0700 (PDT) Received: from localhost ([::1]:34378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQmyY-0007LP-00 for importer@patchew.org; Wed, 24 Aug 2022 05:47:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmhk-0000fI-Bv; Wed, 24 Aug 2022 05:29:44 -0400 Received: from forwardcorp1p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b6:217]:44980) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmhf-00083Q-IU; Wed, 24 Aug 2022 05:29:44 -0400 Received: from sas1-c73b4b4f4b95.qloud-c.yandex.net (sas1-c73b4b4f4b95.qloud-c.yandex.net [IPv6:2a02:6b8:c08:12a9:0:640:c73b:4b4f]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id A24802E15BB; Wed, 24 Aug 2022 12:18:48 +0300 (MSK) Received: from d-tatianin-nix.yandex-team.ru (unknown [2a02:6b8:b081:b4bd::1:34]) by sas1-c73b4b4f4b95.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id YDoXMhagzp-IlOaJim9; Wed, 24 Aug 2022 12:18:47 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1661332727; bh=il+BoLQupXJ4tRALM2u+9xeU2f6CfGR3cAWaKcPLt2c=; h=Cc:Message-Id:References:Date:In-Reply-To:Subject:To:From; b=Gy7jKfRyJ3UfIt3HolKflCPBU3Fbtadqopvw8vwmiroJ/2+EOB5KcgWojFTaoyQhY zk/m6sgNxNj+BY+RXhBMAMdOQ2uUwTMq0PxoQGybe82xkZ82QX0oyPHL/So+KA5V55 8Abc+eu5cFzoXbF1wZYggYJ/McM89yHEnudn1Knw= Authentication-Results: sas1-c73b4b4f4b95.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Daniil Tatianin To: qemu-devel@nongnu.org Cc: mst@redhat.com, stefanha@redhat.com, raphael.norwitz@nutanix.com, kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH v1 2/5] virtio-blk: move config space sizing code to virtio-blk-common Date: Wed, 24 Aug 2022 12:18:34 +0300 Message-Id: <20220824091837.301708-3-d-tatianin@yandex-team.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824091837.301708-1-d-tatianin@yandex-team.ru> References: <20220824091837.301708-1-d-tatianin@yandex-team.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:0:1472:2741:0:8b6:217; envelope-from=d-tatianin@yandex-team.ru; helo=forwardcorp1p.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 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" X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1661334429068100001 This way we can reuse it for other virtio-blk devices, e.g vhost-user-blk, which currently does not control its config space size dynamically. Signed-off-by: Daniil Tatianin --- MAINTAINERS | 4 +++ hw/block/meson.build | 4 +-- hw/block/virtio-blk-common.c | 42 +++++++++++++++++++++++++++ hw/block/virtio-blk.c | 24 +-------------- include/hw/virtio/virtio-blk-common.h | 21 ++++++++++++++ 5 files changed, 70 insertions(+), 25 deletions(-) create mode 100644 hw/block/virtio-blk-common.c create mode 100644 include/hw/virtio/virtio-blk-common.h diff --git a/MAINTAINERS b/MAINTAINERS index 5ce4227ff6..a7d3914735 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2030,8 +2030,10 @@ virtio-blk M: Stefan Hajnoczi L: qemu-block@nongnu.org S: Supported +F: hw/block/virtio-blk-common.c F: hw/block/virtio-blk.c F: hw/block/dataplane/* +F: include/hw/virtio/virtio-blk-common.h F: tests/qtest/virtio-blk-test.c T: git https://github.com/stefanha/qemu.git block =20 @@ -2271,11 +2273,13 @@ S: Maintained F: contrib/vhost-user-blk/ F: contrib/vhost-user-scsi/ F: hw/block/vhost-user-blk.c +F: hw/block/virtio-blk-common.c F: hw/scsi/vhost-user-scsi.c F: hw/virtio/vhost-user-blk-pci.c F: hw/virtio/vhost-user-scsi-pci.c F: include/hw/virtio/vhost-user-blk.h F: include/hw/virtio/vhost-user-scsi.h +F: include/hw/virtio/virtio-blk-common.h =20 vhost-user-gpu M: Marc-Andr=C3=A9 Lureau diff --git a/hw/block/meson.build b/hw/block/meson.build index 2389326112..1908abd45c 100644 --- a/hw/block/meson.build +++ b/hw/block/meson.build @@ -16,7 +16,7 @@ softmmu_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.= c')) softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c')) softmmu_ss.add(when: 'CONFIG_TC58128', if_true: files('tc58128.c')) =20 -specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c')) -specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-= blk.c')) +specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c', = 'virtio-blk-common.c')) +specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-= blk.c', 'virtio-blk-common.c')) =20 subdir('dataplane') diff --git a/hw/block/virtio-blk-common.c b/hw/block/virtio-blk-common.c new file mode 100644 index 0000000000..ac54568eb6 --- /dev/null +++ b/hw/block/virtio-blk-common.c @@ -0,0 +1,42 @@ +/* + * Virtio Block Device common helpers + * + * Copyright IBM, Corp. 2007 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "standard-headers/linux/virtio_blk.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/virtio-blk-common.h" + +/* Config size before the discard support (hide associated config fields) = */ +#define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \ + max_discard_sectors) + +/* + * Starting from the discard feature, we can use this array to properly + * set the config size depending on the features enabled. + */ +static VirtIOFeature feature_sizes[] =3D { + {.flags =3D 1ULL << VIRTIO_BLK_F_DISCARD, + .end =3D endof(struct virtio_blk_config, discard_sector_alignment)}, + {.flags =3D 1ULL << VIRTIO_BLK_F_WRITE_ZEROES, + .end =3D endof(struct virtio_blk_config, write_zeroes_may_unmap)}, + {} +}; + +size_t virtio_blk_common_get_config_size(uint64_t host_features) +{ + size_t config_size =3D MAX(VIRTIO_BLK_CFG_SIZE, + virtio_feature_get_config_size(feature_sizes, host_features)); + + assert(config_size <=3D sizeof(struct virtio_blk_config)); + return config_size; +} diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index a4162dbbf2..4ca6d0f211 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -32,31 +32,9 @@ #include "hw/virtio/virtio-bus.h" #include "migration/qemu-file-types.h" #include "hw/virtio/virtio-access.h" +#include "hw/virtio/virtio-blk-common.h" #include "qemu/coroutine.h" =20 -/* Config size before the discard support (hide associated config fields) = */ -#define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \ - max_discard_sectors) -/* - * Starting from the discard feature, we can use this array to properly - * set the config size depending on the features enabled. - */ -static const VirtIOFeature feature_sizes[] =3D { - {.flags =3D 1ULL << VIRTIO_BLK_F_DISCARD, - .end =3D endof(struct virtio_blk_config, discard_sector_alignment)}, - {.flags =3D 1ULL << VIRTIO_BLK_F_WRITE_ZEROES, - .end =3D endof(struct virtio_blk_config, write_zeroes_may_unmap)}, - {} -}; - -static size_t virtio_blk_common_get_config_size(uint64_t host_features) -{ - size_t config_size =3D MAX(VIRTIO_BLK_CFG_SIZE, - virtio_feature_get_config_size(feature_sizes, host_features)); - - assert(config_size <=3D sizeof(struct virtio_blk_config)); - return config_size; -} =20 static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, VirtIOBlockReq *req) diff --git a/include/hw/virtio/virtio-blk-common.h b/include/hw/virtio/virt= io-blk-common.h new file mode 100644 index 0000000000..08e9f1ab48 --- /dev/null +++ b/include/hw/virtio/virtio-blk-common.h @@ -0,0 +1,21 @@ +/* + * Virtio Block Device common helpers + * + * Copyright IBM, Corp. 2007 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#ifndef VIRTIO_BLK_COMMON_H +#define VIRTIO_BLK_COMMON_H + +#include +#include + +size_t virtio_blk_common_get_config_size(uint64_t host_features); + +#endif --=20 2.25.1 From nobody Fri May 17 11:05:46 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1661333803; cv=none; d=zohomail.com; s=zohoarc; b=GS6jJMtlflCKm4AOIxAbOeDHM6L7lylwJz23c9h0cUK9V+zMqYSklookWcckchLI+kqzmIsrvEM76FsetNGDVyP8fwIv0h/3YXYIVlevrnIVXq81twBtFQ5OTFHC8Ofag98y+ZXZW/g3Eo2+RWeIQPC5fnmBoWEioTtkOrG6DeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661333803; 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=s6OUV6tSLZUzS4tMAJMp6QEfm6lhaMjVOwAjGV1hW6g=; b=eCVBa/QfDXBdSvdQRGGE+ba/CTX8TrMy9Gsn7mkUbF5ypeLtNSz/292EFlQO08Qihs87RXiewy68BkVsrnqiBf27+E4kmjQDWjQ0jRKEEzPWYAnXuVNPpm5mbC2wDW2ZYzrC8u22fVljvqJwOkH19oqcZumLX0O9SHHAc5Dt+wU= 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 1661333803672240.12823371488787; Wed, 24 Aug 2022 02:36:43 -0700 (PDT) Received: from localhost ([::1]:43894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQmoU-0004Wh-Lf for importer@patchew.org; Wed, 24 Aug 2022 05:36:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmhk-0000gC-RP; Wed, 24 Aug 2022 05:29:44 -0400 Received: from forwardcorp1p.mail.yandex.net ([77.88.29.217]:42358) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmhf-00083U-IV; Wed, 24 Aug 2022 05:29:44 -0400 Received: from sas1-c73b4b4f4b95.qloud-c.yandex.net (sas1-c73b4b4f4b95.qloud-c.yandex.net [IPv6:2a02:6b8:c08:12a9:0:640:c73b:4b4f]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 224AA2E15BA; Wed, 24 Aug 2022 12:18:50 +0300 (MSK) Received: from d-tatianin-nix.yandex-team.ru (unknown [2a02:6b8:b081:b4bd::1:34]) by sas1-c73b4b4f4b95.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id YDoXMhagzp-ImOaTS2I; Wed, 24 Aug 2022 12:18:49 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1661332729; bh=s6OUV6tSLZUzS4tMAJMp6QEfm6lhaMjVOwAjGV1hW6g=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=K17FLd2PFBybNGmSghvHnyjgZkNE+6e5BADPLiEYIJrNdfn/YiiOZwvJK5ufOGIlJ LXy47q8ClLYiLPC3EYViYBsba0+lUk7h3d/FkyEpmEYIZ36soc1uJcicxq+jMpGUiF 1kZ+z/RsSm562DFHZwe5Hk7T6/yYfrCFn3T0Lb+s= Authentication-Results: sas1-c73b4b4f4b95.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Daniil Tatianin To: qemu-devel@nongnu.org Cc: mst@redhat.com, stefanha@redhat.com, raphael.norwitz@nutanix.com, kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH v1 3/5] vhost-user-blk: make it possible to disable write-zeroes/discard Date: Wed, 24 Aug 2022 12:18:35 +0300 Message-Id: <20220824091837.301708-4-d-tatianin@yandex-team.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824091837.301708-1-d-tatianin@yandex-team.ru> References: <20220824091837.301708-1-d-tatianin@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=77.88.29.217; envelope-from=d-tatianin@yandex-team.ru; helo=forwardcorp1p.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 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" X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1661333806603100001 Content-Type: text/plain; charset="utf-8" It is useful to have the ability to disable these features for compatibility with older VMs that don't have these implemented. Signed-off-by: Daniil Tatianin --- hw/block/vhost-user-blk.c | 8 ++++++-- include/hw/virtio/vhost-user-blk.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9117222456..e89164c358 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -251,6 +251,8 @@ static uint64_t vhost_user_blk_get_features(VirtIODevic= e *vdev, { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); =20 + features |=3D s->host_features; + /* Turn on pre-defined features */ virtio_add_feature(&features, VIRTIO_BLK_F_SIZE_MAX); virtio_add_feature(&features, VIRTIO_BLK_F_SEG_MAX); @@ -259,8 +261,6 @@ static uint64_t vhost_user_blk_get_features(VirtIODevic= e *vdev, virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE); virtio_add_feature(&features, VIRTIO_BLK_F_FLUSH); virtio_add_feature(&features, VIRTIO_BLK_F_RO); - virtio_add_feature(&features, VIRTIO_BLK_F_DISCARD); - virtio_add_feature(&features, VIRTIO_BLK_F_WRITE_ZEROES); =20 if (s->config_wce) { virtio_add_feature(&features, VIRTIO_BLK_F_CONFIG_WCE); @@ -592,6 +592,10 @@ static Property vhost_user_blk_properties[] =3D { VHOST_USER_BLK_AUTO_NUM_QUEUES), DEFINE_PROP_UINT32("queue-size", VHostUserBlk, queue_size, 128), DEFINE_PROP_BIT("config-wce", VHostUserBlk, config_wce, 0, true), + DEFINE_PROP_BIT64("discard", VHostUserBlk, host_features, + VIRTIO_BLK_F_DISCARD, true), + DEFINE_PROP_BIT64("write-zeroes", VHostUserBlk, host_features, + VIRTIO_BLK_F_WRITE_ZEROES, true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index 7c91f15040..20573dd586 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -51,6 +51,8 @@ struct VHostUserBlk { bool connected; /* vhost_user_blk_start/vhost_user_blk_stop */ bool started_vu; + + uint64_t host_features; }; =20 #endif --=20 2.25.1 From nobody Fri May 17 11:05:46 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1661333765; cv=none; d=zohomail.com; s=zohoarc; b=TTnjsZRhaR0vu647ex8Dhw24bp7CUb190PlobvNdzANM+x7tyQNEESSexBwsYkWD4egGjPgsuVSTHoiqGT2bvjKzyVMDDtS8igKzTzW2bw6N1+XdMELX8YqUT+i4iwZ7qih1iy5Tc2X+Zdus/zCr+NltvSO+uFJ9JolpAbNj/9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661333765; 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=D3vQptUo8YHFFkPdXKmW88H6BNbQAdOBJ6ZPz17P2Pg=; b=XSpkg8tqxvn58dqYH5h6/Nl9xiZYo7TRcOozUjYWaDUnHhW0QwRulyxuIwkrquThtBErUyNoNAewNJceazH7SAz1dOXMpkMUJgX1zXmi9kR8mFD8KooxFLwXrAxtx/CTl+byZ9aAsjTH4Nhv4zQuZNjfHK/NRguQGtB9HbBojbQ= 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 1661333765399526.9986549827894; Wed, 24 Aug 2022 02:36:05 -0700 (PDT) Received: from localhost ([::1]:36818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQmns-0003jX-2Z for importer@patchew.org; Wed, 24 Aug 2022 05:36:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmgf-0007vG-MQ; Wed, 24 Aug 2022 05:28:47 -0400 Received: from forwardcorp1j.mail.yandex.net ([5.45.199.163]:35784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmgX-0007ti-9I; Wed, 24 Aug 2022 05:28:32 -0400 Received: from sas1-c73b4b4f4b95.qloud-c.yandex.net (sas1-c73b4b4f4b95.qloud-c.yandex.net [IPv6:2a02:6b8:c08:12a9:0:640:c73b:4b4f]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id 175CA2E1EEB; Wed, 24 Aug 2022 12:18:52 +0300 (MSK) Received: from d-tatianin-nix.yandex-team.ru (unknown [2a02:6b8:b081:b4bd::1:34]) by sas1-c73b4b4f4b95.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id YDoXMhagzp-IoOabGgq; Wed, 24 Aug 2022 12:18:51 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1661332731; bh=D3vQptUo8YHFFkPdXKmW88H6BNbQAdOBJ6ZPz17P2Pg=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=1etlH5+pezB+pKjx6qVc5bHIF7PPRBFmb2FX775Ccq7quwvaFU8qF3uiOtL6ZYold x3Y+OpL/LumnUc8K8S4k3jyCUDu3lZXj2vyoERUPJDd3ZEabuhleRvJnuSchQs8I/Q uDtK40r64ZVik98ayP8AEbJkhBrKZVXHV3sk4Sco= Authentication-Results: sas1-c73b4b4f4b95.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Daniil Tatianin To: qemu-devel@nongnu.org Cc: mst@redhat.com, stefanha@redhat.com, raphael.norwitz@nutanix.com, kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH v1 4/5] vhost-user-blk: make 'config_wce' part of 'host_features' Date: Wed, 24 Aug 2022 12:18:36 +0300 Message-Id: <20220824091837.301708-5-d-tatianin@yandex-team.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824091837.301708-1-d-tatianin@yandex-team.ru> References: <20220824091837.301708-1-d-tatianin@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.45.199.163; envelope-from=d-tatianin@yandex-team.ru; helo=forwardcorp1j.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 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" X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1661333767953100001 Content-Type: text/plain; charset="utf-8" No reason to have this be a separate field. This also makes it more akin to what the virtio-blk device does. Signed-off-by: Daniil Tatianin --- hw/block/vhost-user-blk.c | 6 ++---- include/hw/virtio/vhost-user-blk.h | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index e89164c358..64f3457373 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -262,9 +262,6 @@ static uint64_t vhost_user_blk_get_features(VirtIODevic= e *vdev, virtio_add_feature(&features, VIRTIO_BLK_F_FLUSH); virtio_add_feature(&features, VIRTIO_BLK_F_RO); =20 - if (s->config_wce) { - virtio_add_feature(&features, VIRTIO_BLK_F_CONFIG_WCE); - } if (s->num_queues > 1) { virtio_add_feature(&features, VIRTIO_BLK_F_MQ); } @@ -591,7 +588,8 @@ static Property vhost_user_blk_properties[] =3D { DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues, VHOST_USER_BLK_AUTO_NUM_QUEUES), DEFINE_PROP_UINT32("queue-size", VHostUserBlk, queue_size, 128), - DEFINE_PROP_BIT("config-wce", VHostUserBlk, config_wce, 0, true), + DEFINE_PROP_BIT64("config-wce", VHostUserBlk, host_features, + VIRTIO_BLK_F_CONFIG_WCE, true), DEFINE_PROP_BIT64("discard", VHostUserBlk, host_features, VIRTIO_BLK_F_DISCARD, true), DEFINE_PROP_BIT64("write-zeroes", VHostUserBlk, host_features, diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index 20573dd586..6252095c45 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -34,7 +34,6 @@ struct VHostUserBlk { struct virtio_blk_config blkcfg; uint16_t num_queues; uint32_t queue_size; - uint32_t config_wce; struct vhost_dev dev; struct vhost_inflight *inflight; VhostUserState vhost_user; --=20 2.25.1 From nobody Fri May 17 11:05:46 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1661334088; cv=none; d=zohomail.com; s=zohoarc; b=LorqnWJ8hhLypGJn4BV95fKqtK+KuuZL8Qu1fisfEMfsJ8Iekvb3kQYKgPj2GMv5reynUN+9MUz0XqYhDqb0jfQ8llkW1IJ2F8nexo8rOfm7f/BIOPiOnCxEkb3OvcFXnMdO4TDOaJ5WfH1C+vEHBDiHkdTbpEKvr7f39CegjxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661334088; 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=+LXH894BMzuy8kXkeIyHEdZ7bh+EDQ1M88NPpjSLgdg=; b=oI/u1DGJzrlP3yV41BScZFWXbWu5ffVhM6Zc3uCRzjN4mL7oKQwU+7mb3uX8X+2QAKJkOII0CMKWDdglI8Nw2348namua4Wv/pGfRRpMGqJZiEFNm5ZBaXqe83QVl4+GJkVMBrCdLiOLnf504X+kdiZK5ssLlLfte7K41VFz6C0= 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 1661334088677883.4081677119782; Wed, 24 Aug 2022 02:41:28 -0700 (PDT) Received: from localhost ([::1]:38398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQmt4-00014q-M3 for importer@patchew.org; Wed, 24 Aug 2022 05:41:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmhi-0000bt-PH; Wed, 24 Aug 2022 05:29:42 -0400 Received: from forwardcorp1p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b6:217]:44984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmhb-00083R-Jz; Wed, 24 Aug 2022 05:29:41 -0400 Received: from sas1-c73b4b4f4b95.qloud-c.yandex.net (sas1-c73b4b4f4b95.qloud-c.yandex.net [IPv6:2a02:6b8:c08:12a9:0:640:c73b:4b4f]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 692C92E15B9; Wed, 24 Aug 2022 12:18:53 +0300 (MSK) Received: from d-tatianin-nix.yandex-team.ru (unknown [2a02:6b8:b081:b4bd::1:34]) by sas1-c73b4b4f4b95.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id YDoXMhagzp-IqOahjb9; Wed, 24 Aug 2022 12:18:52 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1661332732; bh=+LXH894BMzuy8kXkeIyHEdZ7bh+EDQ1M88NPpjSLgdg=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=XoSp7DXqybZ6GnvWb3PRkcv2nF5seVuIp3BpB/U7yMVtRODNmqHRF4jxTPBbdbttb Zm0GekEBGCCjaS1xcrJeEWv3L7jjuEnU7dXzuMlJ7CHQo/QHdO4QxMOmAXE8aQIRat 87VI/Sa29yqaX0I4ZOdgY0IlsunW0lhj2Zmg4uXA= Authentication-Results: sas1-c73b4b4f4b95.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Daniil Tatianin To: qemu-devel@nongnu.org Cc: mst@redhat.com, stefanha@redhat.com, raphael.norwitz@nutanix.com, kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH v1 5/5] vhost-user-blk: dynamically resize config space based on features Date: Wed, 24 Aug 2022 12:18:37 +0300 Message-Id: <20220824091837.301708-6-d-tatianin@yandex-team.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824091837.301708-1-d-tatianin@yandex-team.ru> References: <20220824091837.301708-1-d-tatianin@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:0:1472:2741:0:8b6:217; envelope-from=d-tatianin@yandex-team.ru; helo=forwardcorp1p.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 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" X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1661334091528100001 Content-Type: text/plain; charset="utf-8" Make vhost-user-blk backwards compatible when migrating from older VMs running with modern features turned off, the same way it was done for virtio-blk in 20764be0421c ("virtio-blk: set config size depending on the f= eatures enabled") It's currently impossible to migrate from an older VM with vhost-user-blk (with disable-legacy=3Doff) because of errors like this: qemu-system-x86_64: get_pci_config_device: Bad config data: i=3D0x10 read: = 41 device: 1 cmask: ff wmask: 80 w1cmask:0 qemu-system-x86_64: Failed to load PCIDevice:config qemu-system-x86_64: Failed to load virtio-blk:virtio qemu-system-x86_64: error while loading state for instance 0x0 of device '0= 000:00:05.0:00.0:02.0/virtio-blk' qemu-system-x86_64: load of migration failed: Invalid argument This is caused by the newer (destination) VM requiring a bigger BAR0 alignment because it has to cover a bigger configuration space, which isn't actually needed since those additional config fields are not active (write-zeroes/discard). Signed-off-by: Daniil Tatianin --- hw/block/vhost-user-blk.c | 15 ++++++++------- include/hw/virtio/vhost-user-blk.h | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 64f3457373..d18a7a2cd4 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -23,6 +23,7 @@ #include "hw/qdev-core.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" +#include "hw/virtio/virtio-blk-common.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user-blk.h" #include "hw/virtio/virtio.h" @@ -63,7 +64,7 @@ static void vhost_user_blk_update_config(VirtIODevice *vd= ev, uint8_t *config) /* Our num_queues overrides the device backend */ virtio_stw_p(vdev, &s->blkcfg.num_queues, s->num_queues); =20 - memcpy(config, &s->blkcfg, sizeof(struct virtio_blk_config)); + memcpy(config, &s->blkcfg, s->config_size); } =20 static void vhost_user_blk_set_config(VirtIODevice *vdev, const uint8_t *c= onfig) @@ -96,8 +97,7 @@ static int vhost_user_blk_handle_config_change(struct vho= st_dev *dev) Error *local_err =3D NULL; =20 ret =3D vhost_dev_get_config(dev, (uint8_t *)&blkcfg, - sizeof(struct virtio_blk_config), - &local_err); + s->config_size, &local_err); if (ret < 0) { error_report_err(local_err); return ret; @@ -106,7 +106,7 @@ static int vhost_user_blk_handle_config_change(struct v= host_dev *dev) /* valid for resize only */ if (blkcfg.capacity !=3D s->blkcfg.capacity) { s->blkcfg.capacity =3D blkcfg.capacity; - memcpy(dev->vdev->config, &s->blkcfg, sizeof(struct virtio_blk_con= fig)); + memcpy(dev->vdev->config, &s->blkcfg, s->config_size); virtio_notify_config(dev->vdev); } =20 @@ -444,7 +444,7 @@ static int vhost_user_blk_realize_connect(VHostUserBlk = *s, Error **errp) assert(s->connected); =20 ret =3D vhost_dev_get_config(&s->dev, (uint8_t *)&s->blkcfg, - sizeof(struct virtio_blk_config), errp); + s->config_size, errp); if (ret < 0) { qemu_chr_fe_disconnect(&s->chardev); vhost_dev_cleanup(&s->dev); @@ -489,8 +489,9 @@ static void vhost_user_blk_device_realize(DeviceState *= dev, Error **errp) return; } =20 - virtio_init(vdev, VIRTIO_ID_BLOCK, - sizeof(struct virtio_blk_config)); + s->config_size =3D virtio_blk_common_get_config_size(s->host_features); + + virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size); =20 s->virtqs =3D g_new(VirtQueue *, s->num_queues); for (i =3D 0; i < s->num_queues; i++) { diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index 6252095c45..b7810360b9 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -52,6 +52,7 @@ struct VHostUserBlk { bool started_vu; =20 uint64_t host_features; + size_t config_size; }; =20 #endif --=20 2.25.1