From nobody Fri Nov 14 21:04:53 2025 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=1760540752; cv=none; d=zohomail.com; s=zohoarc; b=ZWgyRRTo/MHT6rBrvoZJ26tMPozqrUO3cS4HighmRvY72VW/Ul4LaiYpJfbAapP53+/p4ZTId8ixtjBWlysNEtutR8DVDf8ayggNQMss/wpjNfb5QlYP17wlsT0N/v2hHSIl3gUHFC7HEECJIM2vB/htkolGhsLOwca7s4whT9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760540752; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nzQymKtvEuinC1MLaSekDhWcC59jdFn2tR2BWWdG/ts=; b=jWc2SJK52J4xF8b1sAItM+d5ODsSj5qziR6bFPTcZZQIqw+QKX9N4ast4NIekA31fWdG/HGyhAXslEia6mJRZ0KR7JVawyO9VgbD7tZWx5CVNKymCF2TcaPT5Syf05uBz2iFCkeId7eTjp/DJH+pm/XIYVivEOMW9dgTISPjLWo= 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 1760540752922279.83893797021506; Wed, 15 Oct 2025 08:05:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v92xR-0007fd-8C; Wed, 15 Oct 2025 10:58:29 -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 1v92xP-0007ev-3T for qemu-devel@nongnu.org; Wed, 15 Oct 2025 10:58:27 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v92xH-0000ae-CY for qemu-devel@nongnu.org; Wed, 15 Oct 2025 10:58:26 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 778ADC067B; Wed, 15 Oct 2025 17:58:16 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a94::1:15]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id AwRFIp2FFSw0-W67XlB8z; Wed, 15 Oct 2025 17:58:15 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760540295; bh=nzQymKtvEuinC1MLaSekDhWcC59jdFn2tR2BWWdG/ts=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=di5O7jbpnYyddznFhsfZFFY6Ms1V147VVt/YQ5lfCupcrt1Ks+XuGN99mMBqqVKMl rlgeOXwUUmwW6+GhrUWeEuoQ+xJJ4XBXoo6aFfnbGZTjHgCuNdr9Myj3cDprd+Zgk1 LbklLpVUgqPyN29KQ/0TlcwlBOd9OTQX354VxL74= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: mst@redhat.com Cc: sgarzare@redhat.com, raphael@enfabrica.net, qemu-devel@nongnu.org, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, Raphael Norwitz , "Gonglei (Arei)" , Zhenwei Pi , Jason Wang Subject: [PATCH v3 04/23] vhost: move protocol_features to vhost_user Date: Wed, 15 Oct 2025 17:57:48 +0300 Message-ID: <20251015145808.1112843-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251015145808.1112843-1-vsementsov@yandex-team.ru> References: <20251015145808.1112843-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.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 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760540753850154100 Content-Type: text/plain; charset="utf-8" As comment says: it's only for vhost-user. So, let's move it to corresponding vhost backend realization. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Daniil Tatianin Reviewed-by: Raphael Norwitz --- backends/cryptodev-vhost.c | 1 - hw/net/vhost_net.c | 2 -- hw/virtio/vhost-user.c | 26 +++++++++++++++++++++++--- hw/virtio/virtio-qmp.c | 6 ++++-- include/hw/virtio/vhost-user.h | 3 +++ include/hw/virtio/vhost.h | 8 -------- 6 files changed, 30 insertions(+), 16 deletions(-) diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index abdfce33af..c6069f4e5b 100644 --- a/backends/cryptodev-vhost.c +++ b/backends/cryptodev-vhost.c @@ -60,7 +60,6 @@ cryptodev_vhost_init( =20 crypto->cc =3D options->cc; =20 - crypto->dev.protocol_features =3D 0; crypto->backend =3D -1; =20 /* vhost-user needs vq_index to initiate a specific queue pair */ diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index fda90e231e..ca19983126 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -265,9 +265,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) goto fail; } net->backend =3D r; - net->dev.protocol_features =3D 0; } else { - net->dev.protocol_features =3D 0; net->backend =3D -1; =20 /* vhost-user needs vq_index to initiate a specific queue pair */ diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index b8231dcbcf..3fd11a3b57 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -11,6 +11,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/virtio/virtio-dmabuf.h" +#include "hw/virtio/virtio-qmp.h" #include "hw/virtio/vhost.h" #include "hw/virtio/virtio-crypto.h" #include "hw/virtio/vhost-user.h" @@ -264,6 +265,14 @@ struct vhost_user { /* Our current regions */ int num_shadow_regions; struct vhost_memory_region shadow_regions[VHOST_USER_MAX_RAM_SLOTS]; + + /** + * @protocol_features: the vhost-user protocol feature set by + * VHOST_USER_SET_PROTOCOL_FEATURES. Protocol features are only + * negotiated if VHOST_USER_F_PROTOCOL_FEATURES has been offered + * by the backend (see @features). + */ + uint64_t protocol_features; }; =20 struct scrub_regions { @@ -275,7 +284,8 @@ struct scrub_regions { static bool vhost_user_has_protocol_feature(struct vhost_dev *dev, uint64_t feature) { - return virtio_has_feature(dev->protocol_features, feature); + struct vhost_user *u =3D dev->opaque; + return virtio_has_feature(u->protocol_features, feature); } =20 static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg) @@ -2229,8 +2239,8 @@ static int vhost_user_backend_init(struct vhost_dev *= dev, void *opaque, } =20 /* final set of protocol features */ - dev->protocol_features =3D protocol_features; - err =3D vhost_user_set_protocol_features(dev, dev->protocol_featur= es); + u->protocol_features =3D protocol_features; + err =3D vhost_user_set_protocol_features(dev, u->protocol_features= ); if (err < 0) { error_setg_errno(errp, EPROTO, "vhost_backend_init failed"); return -EPROTO; @@ -3021,6 +3031,16 @@ static int vhost_user_check_device_state(struct vhos= t_dev *dev, Error **errp) return 0; } =20 +void vhost_user_qmp_status(struct vhost_dev *dev, VirtioStatus *status) +{ + struct vhost_user *u =3D dev->opaque; + + assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_USER); + + status->vhost_dev->protocol_features =3D + qmp_decode_protocols(u->protocol_features); +} + const VhostOps user_ops =3D { .backend_type =3D VHOST_BACKEND_TYPE_USER, .vhost_backend_init =3D vhost_user_backend_init, diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c index dd1a38e792..82acb6d232 100644 --- a/hw/virtio/virtio-qmp.c +++ b/hw/virtio/virtio-qmp.c @@ -821,12 +821,14 @@ VirtioStatus *qmp_x_query_virtio_status(const char *p= ath, Error **errp) status->vhost_dev->acked_features =3D qmp_decode_features(vdev->device_id, hdev->acked_features_ex); =20 - status->vhost_dev->protocol_features =3D - qmp_decode_protocols(hdev->protocol_features); status->vhost_dev->max_queues =3D hdev->max_queues; status->vhost_dev->backend_cap =3D hdev->backend_cap; status->vhost_dev->log_enabled =3D hdev->log_enabled; status->vhost_dev->log_size =3D hdev->log_size; + + if (hdev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_USER) { + vhost_user_qmp_status(hdev, status); + } } =20 return status; diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 9a3f238b43..36d96296a3 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -10,6 +10,7 @@ =20 #include "chardev/char-fe.h" #include "hw/virtio/virtio.h" +#include "qapi/qapi-types-virtio.h" =20 enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_MQ =3D 0, @@ -111,4 +112,6 @@ void vhost_user_async_close(DeviceState *d, CharBackend *chardev, struct vhost_dev *vhost, vu_async_close_fn cb); =20 +void vhost_user_qmp_status(struct vhost_dev *dev, VirtioStatus *status); + #endif diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 3e69e47833..e308bc4556 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -104,14 +104,6 @@ struct vhost_dev { VIRTIO_DECLARE_FEATURES(features); VIRTIO_DECLARE_FEATURES(acked_features); =20 - /** - * @protocol_features: is the vhost-user only feature set by - * VHOST_USER_SET_PROTOCOL_FEATURES. Protocol features are only - * negotiated if VHOST_USER_F_PROTOCOL_FEATURES has been offered - * by the backend (see @features). - */ - uint64_t protocol_features; - uint64_t max_queues; uint64_t backend_cap; /* @started: is the vhost device started? */ --=20 2.48.1