Reviewed-by: Raphael Norwitz <[email protected]>

On Thu, Oct 16, 2025 at 7:44 AM Vladimir Sementsov-Ogievskiy
<[email protected]> wrote:
>
> The function does both vhost_dev_init() and vhost_dev_connect().
> Following interface of vhost_dev_init(), and preparing to further
> refactoring, let's rename to _init() and add boolean "connect"
> parameter.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
> ---
>  hw/block/trace-events     |  2 ++
>  hw/block/vhost-user-blk.c | 13 ++++++++-----
>  2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/hw/block/trace-events b/hw/block/trace-events
> index dbaa5ca6cb..9f00412a99 100644
> --- a/hw/block/trace-events
> +++ b/hw/block/trace-events
> @@ -63,6 +63,8 @@ vhost_user_blk_start_in(void *vdev) "vdev %p"
>  vhost_user_blk_start_out(void *vdev) "vdev %p"
>  vhost_user_blk_stop_in(void *vdev) "vdev %p"
>  vhost_user_blk_stop_out(void *vdev) "vdev %p"
> +vhost_user_blk_init_in(void *vdev) "vdev %p"
> +vhost_user_blk_init_out(void *vdev) "vdev %p"
>  vhost_user_blk_connect_in(void *vdev) "vdev %p"
>  vhost_user_blk_connect_out(void *vdev) "vdev %p"
>  vhost_user_blk_device_realize_in(void *vdev) "vdev %p"
> diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
> index f2ecf81e4d..c31c265a0e 100644
> --- a/hw/block/vhost-user-blk.c
> +++ b/hw/block/vhost-user-blk.c
> @@ -344,13 +344,16 @@ static void vhost_user_blk_reset(VirtIODevice *vdev)
>      vhost_dev_free_inflight(s->inflight);
>  }
>
> -static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
> +static int vhost_user_blk_init(DeviceState *dev, bool connect, Error **errp)
>  {
>      VirtIODevice *vdev = VIRTIO_DEVICE(dev);
>      VHostUserBlk *s = VHOST_USER_BLK(vdev);
>      int ret = 0;
>
> -    trace_vhost_user_blk_connect_in(vdev);
> +    trace_vhost_user_blk_init_in(vdev);
> +
> +    /* TODO: implement support for connect=false */
> +    assert(connect);
>
>      assert(!s->connected);
>
> @@ -380,7 +383,7 @@ static int vhost_user_blk_connect(DeviceState *dev, Error 
> **errp)
>          ret = vhost_user_blk_start(vdev, errp);
>      }
>
> -    trace_vhost_user_blk_connect_out(vdev);
> +    trace_vhost_user_blk_init_out(vdev);
>
>      return ret;
>  }
> @@ -415,7 +418,7 @@ static void vhost_user_blk_event(void *opaque, 
> QEMUChrEvent event)
>      switch (event) {
>      case CHR_EVENT_OPENED:
>          if (!s->connected) {
> -            if (vhost_user_blk_connect(dev, &local_err) < 0) {
> +            if (vhost_user_blk_init(dev, true, &local_err) < 0) {
>                  error_report_err(local_err);
>                  qemu_chr_fe_disconnect(&s->chardev);
>                  return;
> @@ -447,7 +450,7 @@ static int vhost_user_blk_realize_connect(VHostUserBlk 
> *s, Error **errp)
>          return ret;
>      }
>
> -    ret = vhost_user_blk_connect(dev, errp);
> +    ret = vhost_user_blk_init(dev, true, errp);
>      if (ret < 0) {
>          qemu_chr_fe_disconnect(&s->chardev);
>          return ret;
> --
> 2.48.1
>
>

Reply via email to