All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: sgarzare@redhat.com, raphael@enfabrica.net,
	qemu-devel@nongnu.org, yc-core@yandex-team.ru,
	d-tatianin@yandex-team.ru,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	zhenwei pi <zhenwei.pi@linux.dev>, Kevin Wolf <kwolf@redhat.com>,
	Hanna Reitz <hreitz@redhat.com>, Jason Wang <jasowang@redhat.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>
Subject: Re: [PATCH v5 04/23] vhost: move protocol_features to vhost_user
Date: Fri, 20 Feb 2026 11:20:13 -0500	[thread overview]
Message-ID: <20260220111948-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20260206095258.894504-5-vsementsov@yandex-team.ru>

On Fri, Feb 06, 2026 at 12:52:38PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> 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 <vsementsov@yandex-team.ru>


breaks build:

https://gitlab.com/mstredhat/qemu/-/jobs/13201554836

builds/mstredhat/qemu/build/../hw/virtio/virtio-qmp.c:830:(.text+0xd60): undefined reference to `vhost_user_qmp_status'


> ---
>  backends/cryptodev-vhost.c     |  1 -
>  hw/block/vhost-user-blk.c      |  6 ++----
>  hw/net/vhost_net.c             |  2 --
>  hw/virtio/vhost-user.c         | 36 +++++++++++++++++++++++++++-------
>  hw/virtio/virtio-qmp.c         |  6 ++++--
>  include/hw/virtio/vhost-user.h |  4 ++++
>  include/hw/virtio/vhost.h      |  8 --------
>  7 files changed, 39 insertions(+), 24 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(
>  
>      crypto->cc = options->cc;
>  
> -    crypto->dev.protocol_features = 0;
>      crypto->backend = -1;
>  
>      /* vhost-user needs vq_index to initiate a specific queue pair */
> diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
> index dc99de0263..2831f3c053 100644
> --- a/hw/block/vhost-user-blk.c
> +++ b/hw/block/vhost-user-blk.c
> @@ -572,10 +572,8 @@ static bool vhost_user_blk_inflight_needed(void *opaque)
>  {
>      struct VHostUserBlk *s = opaque;
>  
> -    bool inflight_migration = virtio_has_feature(s->dev.protocol_features,
> -                               VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT);
> -
> -    return inflight_migration;
> +    return vhost_user_has_protocol_feature(
> +        &s->dev, VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT);
>  }
>  
>  static const VMStateDescription vmstate_vhost_user_blk_inflight = {
> 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 *options)
>              goto fail;
>          }
>          net->backend = r;
> -        net->dev.protocol_features = 0;
>      } else {
> -        net->dev.protocol_features = 0;
>          net->backend = -1;
>  
>          /* 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 2de82ac466..de8ead3e94 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;
>  };
>  
>  struct scrub_regions {
> @@ -272,10 +281,13 @@ struct scrub_regions {
>      int fd_idx;
>  };
>  
> -static bool vhost_user_has_protocol_feature(struct vhost_dev *dev,
> -                                            uint64_t feature)
> +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 = dev->opaque;
> +
> +    assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
> +
> +    return virtio_has_feature(u->protocol_features, feature);
>  }
>  
>  static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
> @@ -1343,8 +1355,8 @@ static int vhost_set_vring_file(struct vhost_dev *dev,
>      int ret;
>      int fds[VHOST_USER_MAX_RAM_SLOTS];
>      size_t fd_num = 0;
> -    bool reply_supported = virtio_has_feature(dev->protocol_features,
> -                                              VHOST_USER_PROTOCOL_F_REPLY_ACK);
> +    bool reply_supported =
> +        vhost_user_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_REPLY_ACK);
>      VhostUserMsg msg = {
>          .hdr.request = request,
>          .hdr.flags = VHOST_USER_VERSION,
> @@ -2244,8 +2256,8 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque,
>          }
>  
>          /* final set of protocol features */
> -        dev->protocol_features = protocol_features;
> -        err = vhost_user_set_protocol_features(dev, dev->protocol_features);
> +        u->protocol_features = protocol_features;
> +        err = vhost_user_set_protocol_features(dev, u->protocol_features);
>          if (err < 0) {
>              error_setg_errno(errp, EPROTO, "vhost_backend_init failed");
>              return -EPROTO;
> @@ -3036,6 +3048,16 @@ static int vhost_user_check_device_state(struct vhost_dev *dev, Error **errp)
>      return 0;
>  }
>  
> +void vhost_user_qmp_status(struct vhost_dev *dev, VirtioStatus *status)
> +{
> +    struct vhost_user *u = dev->opaque;
> +
> +    assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
> +
> +    status->vhost_dev->protocol_features =
> +        qmp_decode_protocols(u->protocol_features);
> +}
> +
>  const VhostOps user_ops = {
>          .backend_type = VHOST_BACKEND_TYPE_USER,
>          .vhost_backend_init = vhost_user_backend_init,
> diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c
> index 916972e331..5e42b7b540 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 *path, Error **errp)
>          status->vhost_dev->acked_features =
>              qmp_decode_features(vdev->device_id, hdev->acked_features_ex);
>  
> -        status->vhost_dev->protocol_features =
> -            qmp_decode_protocols(hdev->protocol_features);
>          status->vhost_dev->max_queues = hdev->max_queues;
>          status->vhost_dev->backend_cap = hdev->backend_cap;
>          status->vhost_dev->log_enabled = hdev->log_enabled;
>          status->vhost_dev->log_size = hdev->log_size;
> +
> +        if (hdev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER) {
> +            vhost_user_qmp_status(hdev, status);
> +        }
>      }
>  
>      return status;
> diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h
> index 53fe996686..0e576fc538 100644
> --- a/include/hw/virtio/vhost-user.h
> +++ b/include/hw/virtio/vhost-user.h
> @@ -10,6 +10,7 @@
>  
>  #include "chardev/char-fe.h"
>  #include "hw/virtio/virtio.h"
> +#include "qapi/qapi-types-virtio.h"
>  
>  enum VhostUserProtocolFeature {
>      VHOST_USER_PROTOCOL_F_MQ = 0,
> @@ -113,4 +114,7 @@ void vhost_user_async_close(DeviceState *d,
>                              CharFrontend *chardev, struct vhost_dev *vhost,
>                              vu_async_close_fn cb);
>  
> +void vhost_user_qmp_status(struct vhost_dev *dev, VirtioStatus *status);
> +bool vhost_user_has_protocol_feature(struct vhost_dev *dev, uint64_t feature);
> +
>  #endif
> diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
> index e139e05985..4a9bd3effe 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);
>  
> -    /**
> -     * @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? */
> -- 
> 2.52.0



  reply	other threads:[~2026-02-20 16:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06  9:52 [PATCH v5 00/23] vhost refactoring and fixes Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 01/23] vhost-user: rework enabling vrings Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 02/23] vhost: drop backend_features field Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 03/23] vhost-user: introduce vhost_user_has_protocol_feature() helper Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 04/23] vhost: move protocol_features to vhost_user Vladimir Sementsov-Ogievskiy
2026-02-20 16:20   ` Michael S. Tsirkin [this message]
2026-02-20 20:00     ` Vladimir Sementsov-Ogievskiy
2026-02-20 21:17     ` Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 05/23] vhost-user-gpu: drop code duplication Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 06/23] vhost: make vhost_dev.features private Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 07/23] virtio-ccw: virtio_ccw_set_guest_notifier(): fix failure path Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 08/23] virtio: move common part of _set_guest_notifier to generic code Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 09/23] virtio: drop *_set_guest_notifier_fd_handler() helpers Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 10/23] vhost-user: keep QIOChannelSocket for backend channel Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 11/23] vhost: vhost_virtqueue_start(): fix failure path Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 12/23] vhost: make vhost_memory_unmap() null-safe Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 13/23] vhost: simplify calls to vhost_memory_unmap() Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 14/23] vhost: move vrings mapping to the top of vhost_virtqueue_start() Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 15/23] vhost: vhost_virtqueue_start(): drop extra local variables Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 16/23] vhost: final refactoring of vhost vrings map/unmap Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 17/23] vhost: simplify vhost_dev_init() error-path Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 18/23] vhost: move busyloop timeout initialization to vhost_virtqueue_init() Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 19/23] vhost: vhost_dev_init(): simplify features initialization Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 20/23] hw/virtio/virtio-bus: refactor virtio_bus_set_host_notifier() Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 21/23] vhost-user: make trace events more readable Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 22/23] vhost-user-blk: add some useful trace-points Vladimir Sementsov-Ogievskiy
2026-02-06  9:52 ` [PATCH v5 23/23] vhost: " Vladimir Sementsov-Ogievskiy
2026-02-18 17:18 ` [PATCH v5 00/23] vhost refactoring and fixes Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260220111948-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=d-tatianin@yandex-team.ru \
    --cc=hreitz@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael@enfabrica.net \
    --cc=sgarzare@redhat.com \
    --cc=vsementsov@yandex-team.ru \
    --cc=yc-core@yandex-team.ru \
    --cc=zhenwei.pi@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.