[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 23/29] vhost-user: wait until backend init is com
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v4 23/29] vhost-user: wait until backend init is completed |
Date: |
Thu, 7 Jul 2016 03:00:47 +0200 |
From: Marc-André Lureau <address@hidden>
The chardev waits for an initial connection before starting qemu, and
vhost-user should wait for the backend negotiation to be completed
before starting qemu too.
vhost-user is started in the net_vhost_user_event callback, which is
synchronously called after the socket is connected. Use a
VhostUserState.started flag to indicate vhost-user init completed
successfully and qemu can be started.
Signed-off-by: Marc-André Lureau <address@hidden>
---
net/vhost-user.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 2442925..207da94 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -23,6 +23,7 @@ typedef struct VhostUserState {
CharDriverState *chr;
VHostNetState *vhost_net;
guint watch;
+ bool started;
} VhostUserState;
typedef struct VhostUserChardevProps {
@@ -218,6 +219,7 @@ static void net_vhost_user_event(void *opaque, int event)
return;
}
qmp_set_link(name, true, &err);
+ s->started = true;
break;
case CHR_EVENT_CLOSED:
qmp_set_link(name, false, &err);
@@ -236,7 +238,7 @@ static int net_vhost_user_init(NetClientState *peer, const
char *device,
const char *name, CharDriverState *chr,
int queues)
{
- NetClientState *nc;
+ NetClientState *nc, *nc0 = NULL;
VhostUserState *s;
int i;
@@ -245,6 +247,9 @@ static int net_vhost_user_init(NetClientState *peer, const
char *device,
for (i = 0; i < queues; i++) {
nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name);
+ if (!nc0) {
+ nc0 = nc;
+ }
snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user%d to %s",
i, chr->label);
@@ -255,7 +260,16 @@ static int net_vhost_user_init(NetClientState *peer, const
char *device,
s->chr = chr;
}
- qemu_chr_add_handlers(chr, NULL, NULL, net_vhost_user_event, nc[0].name);
+ s = DO_UPCAST(VhostUserState, nc, nc0);
+ do {
+ Error *err = NULL;
+ if (qemu_chr_wait_connected(chr, &err) < 0) {
+ error_report_err(err);
+ return -1;
+ }
+ qemu_chr_add_handlers(chr, NULL, NULL,
+ net_vhost_user_event, nc0->name);
+ } while (!s->started);
assert(s->vhost_net != NULL);
--
2.9.0
- [Qemu-devel] [PATCH v4 15/29] vhost-user: check vhost_user_{read, write}() return value, (continued)
- [Qemu-devel] [PATCH v4 15/29] vhost-user: check vhost_user_{read, write}() return value, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 14/29] vhost-user: check qemu_chr_fe_set_msgfds() return value, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 13/29] vhost-user: call set_msgfds unconditionally, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 17/29] vhost-user: add get_vhost_net() assertions, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 16/29] vhost-user: keep vhost_net after a disconnection, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 18/29] Revert "vhost-net: do not crash if backend is not present", marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 19/29] vhost-net: vhost_migration_done is vhost-user specific, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 20/29] vhost: add assert() to check runtime behaviour, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 22/29] char: add and use tcp_chr_wait_connected, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 21/29] char: add chr_wait_connected callback, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 23/29] vhost-user: wait until backend init is completed,
marcandre . lureau <=
- [Qemu-devel] [PATCH v4 24/29] tests: plug some leaks in virtio-net-test, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 25/29] tests: fix vhost-user-test leak, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 26/29] tests: add /vhost-user/connect-fail test, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 27/29] tests: add a simple /vhost-user/multiqueue test, marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 28/29] vhost-user: add error report in vhost_user_write(), marcandre . lureau, 2016/07/06
- [Qemu-devel] [PATCH v4 29/29] vhost: add vhost_net_set_backend(), marcandre . lureau, 2016/07/06
- Re: [Qemu-devel] [PATCH v4 00/29] vhost-user reconnect fixes, Marc-André Lureau, 2016/07/07
- Re: [Qemu-devel] [PATCH v4 00/29] vhost-user reconnect fixes, Michael S. Tsirkin, 2016/07/20