mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
vhost-user: fix lost reconnect again
When the vhost-user is reconnecting to the backend, and if the vhost-user fails
at the get_features in vhost_dev_init(), then the reconnect will fail
and it will not be retriggered forever.
The reason is:
When the vhost-user fail at get_features, the vhost_dev_cleanup will be called
immediately.
vhost_dev_cleanup calls 'memset(hdev, 0, sizeof(struct vhost_dev))'.
The reconnect path is:
vhost_user_blk_event
vhost_user_async_close(.. vhost_user_blk_disconnect ..)
qemu_chr_fe_set_handlers <----- clear the notifier callback
schedule vhost_user_async_close_bh
The vhost->vdev is null, so the vhost_user_blk_disconnect will not be
called, then the event fd callback will not be reinstalled.
We need to ensure that even if vhost_dev_init initialization fails, the event
handler still needs to be reinstalled when s->connected is false.
All vhost-user devices have this issue, including vhost-user-blk/scsi.
Fixes: 71e076a07d
("hw/virtio: generalise CHR_EVENT_CLOSED handling")
Signed-off-by: Li Feng <fengli@smartx.com>
Message-Id: <20240516025753.130171-3-fengli@smartx.com>
Reviewed-by: Raphael Norwitz <raphael@enfabrica.net>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
9569fe0aac
commit
6eaf0e612b
4 changed files with 7 additions and 12 deletions
|
@ -225,13 +225,14 @@ static void vub_disconnect(DeviceState *dev)
|
|||
VHostUserBase *vub = VHOST_USER_BASE(vdev);
|
||||
|
||||
if (!vub->connected) {
|
||||
return;
|
||||
goto done;
|
||||
}
|
||||
vub->connected = false;
|
||||
|
||||
vub_stop(vdev);
|
||||
vhost_dev_cleanup(&vub->vhost_dev);
|
||||
|
||||
done:
|
||||
/* Re-instate the event handler for new connections */
|
||||
qemu_chr_fe_set_handlers(&vub->chardev,
|
||||
NULL, NULL, vub_event,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue