qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] resend slave fd to vhost when reconnect to vhost
@ 2020-04-17  5:14 ni.xun.intel
  2020-04-14 10:02 ` Raphael Norwitz
  0 siblings, 1 reply; 3+ messages in thread
From: ni.xun.intel @ 2020-04-17  5:14 UTC (permalink / raw)
  To: raphael.norwitz, mst, kwolf, mreitz, qemu-block
  Cc: Yan Miao, lucascye, Lu Zhigang, qemu-devel, Ni Xun

From: Ni Xun <richardni@tencent.com>

when reconnecting to vhost server, it doesn't send slave fd to vhost
as the slave fd is only sent in vhost_user_init. also resend the slave fd
in vhost reconnect.

Signed-off-by: Ni Xun <richardni@tencent.com>
Signed-off-by: Lu Zhigang <tonnylu@tencent.com>
Signed-off-by: Yan Miao <leomyan@tencent.com>
Signed-off-by: lucascye <lucascye@tencent.com>
---
 hw/block/vhost-user-blk.c | 6 ++++++
 hw/virtio/vhost-user.c    | 2 +-
 include/hw/virtio/vhost.h | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 17df5338e7..59650a570b 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -138,6 +138,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev)
             error_report("Error get inflight: %d", -ret);
             goto err_guest_notifiers;
         }
+    } else {
+        ret = vhost_setup_slave_channel(&s->dev);
+        if (ret < 0) {
+            error_report("Error setting vhost slave channel: %d", -ret);
+            return ret;
+        }
     }
 
     ret = vhost_dev_set_inflight(&s->dev, s->inflight);
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 08e7e63790..0da4a12787 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1115,7 +1115,7 @@ err:
     return;
 }
 
-static int vhost_setup_slave_channel(struct vhost_dev *dev)
+int vhost_setup_slave_channel(struct vhost_dev *dev)
 {
     VhostUserMsg msg = {
         .hdr.request = VHOST_USER_SET_SLAVE_REQ_FD,
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index 085450c6f8..cad60ad521 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -100,6 +100,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
 void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev);
 int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
 void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
+int vhost_setup_slave_channel(struct vhost_dev *hdev);
 
 /* Test and clear masked event pending status.
  * Should be called after unmask to avoid losing events.
-- 
2.24.1 (Apple Git-126)



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-18 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-17  5:14 [PATCH] resend slave fd to vhost when reconnect to vhost ni.xun.intel
2020-04-14 10:02 ` Raphael Norwitz
2020-04-18 10:42   ` xun ni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).