Just a tracepoint suggestion. Otherwise LGTM.

On Thu, Oct 16, 2025 at 7:46 AM Vladimir Sementsov-Ogievskiy
<[email protected]> wrote:
>
> Split vhost_dev_init() so that the first part will do early
> initialization of QEMU structures, but don't communicate with backend,
> and the second part will do backend communication.
>
> We need this for future support for backend-transfer migration support
> for vhost-user-blk (backend will not be available in the early
> initialization point).
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
> ---
>  hw/virtio/vhost.c         | 27 +++++++++++++++++++++------
>  include/hw/virtio/vhost.h |  2 ++
>  2 files changed, 23 insertions(+), 6 deletions(-)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index f733e98b4a..09d00e4d98 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1619,7 +1619,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>                     VhostBackendType backend_type, uint32_t busyloop_timeout,
>                     bool connect, Error **errp)
>  {
> -    int i, r, n_initialized_vqs = 0;
> +    int i, r;
>
>      trace_vhost_dev_init_in(hdev);
>
> @@ -1640,9 +1640,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>       */
>      assert(connect || hdev->vhost_ops->vhost_backend_connect);
>
> -    /* TDDO: support connect=false */
> -    assert(connect);
> -
>      r = hdev->vhost_ops->vhost_backend_init(hdev, opaque, errp);
>      if (r < 0) {
>          goto fail;
> @@ -1678,6 +1675,26 @@ int vhost_dev_init(struct vhost_dev *hdev, void 
> *opaque,
>      memory_listener_register(&hdev->memory_listener, &address_space_memory);
>      QLIST_INSERT_HEAD(&vhost_devices, hdev, entry);
>
> +    trace_vhost_dev_init_out(hdev);
> +
> +    return connect ? vhost_dev_connect(hdev, errp) : 0;
> +
> +fail:
> +    vhost_dev_cleanup(hdev);
> +    return r;
> +}
> +
> +int vhost_dev_connect(struct vhost_dev *hdev, Error **errp)
> +{
> +    int i, r, n_initialized_vqs = 0;
> +

Let's add tracepoints for connect here?

> +    if (hdev->vhost_ops->vhost_backend_connect) {
> +        r = hdev->vhost_ops->vhost_backend_connect(hdev, errp);
> +        if (r < 0) {
> +            goto fail;
> +        }
> +    }
> +
>      r = hdev->vhost_ops->vhost_set_owner(hdev);
>      if (r < 0) {
>          error_setg_errno(errp, -r, "vhost_set_owner failed");
> @@ -1720,8 +1737,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>          goto fail;
>      }
>
> -    trace_vhost_dev_init_out(hdev);
> -
>      return 0;
>
>  fail:
> diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
> index 74ed24232e..af46d4b5f2 100644
> --- a/include/hw/virtio/vhost.h
> +++ b/include/hw/virtio/vhost.h
> @@ -158,6 +158,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>                     uint32_t busyloop_timeout,
>                     bool connect, Error **errp);
>
> +int vhost_dev_connect(struct vhost_dev *hdev, Error **errp);
> +
>  /**
>   * vhost_dev_cleanup() - tear down and cleanup vhost interface
>   * @hdev: the common vhost_dev structure
> --
> 2.48.1
>
>

Reply via email to