[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 22/23] vhost-user: wait until backend init is com
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v2 22/23] vhost-user: wait until backend init is completed |
Date: |
Fri, 24 Jun 2016 15:51:09 +0200 |
From: Marc-André Lureau <address@hidden>
The chardev waits for an initial connection before starting qemu,
vhost-user wants the backend negotiation to be completed. vhost-user is
started in the net_vhost_user_event callback, which is synchronously
called after the socket is connected.
Signed-off-by: Marc-André Lureau <address@hidden>
---
net/vhost-user.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 95ed2d2..4badd9e 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -24,6 +24,7 @@ typedef struct VhostUserState {
VHostNetState *vhost_net;
int watch;
uint64_t acked_features;
+ bool started;
} VhostUserState;
typedef struct VhostUserChardevProps {
@@ -211,6 +212,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);
@@ -248,7 +250,15 @@ 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);
+ 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, nc[0].name);
+ } while (!s->started);
assert(s->vhost_net != NULL);
--
2.9.0
- [Qemu-devel] [PATCH v2 07/23] vhost: make vhost_dev_cleanup() idempotent, (continued)
- [Qemu-devel] [PATCH v2 07/23] vhost: make vhost_dev_cleanup() idempotent, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 15/23] vhost-user: keep vhost_net after a disconnection, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 09/23] vhost: fix calling vhost_dev_cleanup() after vhost_dev_init(), marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 10/23] vhost: change some assert() for error_report() or silent fail, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 11/23] vhost: use error_report() instead of fprintf(stderr, ...), marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 12/23] vhost-user: check qemu_chr_fe_set_msgfds() return value, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 16/23] Revert "vhost-net: do not crash if backend is not present", marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 14/23] qemu-char: check socket is actually connected, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 18/23] vhost-net: success if backend has no ops->vhost_migration_done, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 17/23] get_vhost_net() should be != null after vhost_user_init, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 22/23] vhost-user: wait until backend init is completed,
marcandre . lureau <=
- [Qemu-devel] [PATCH v2 20/23] char: add chr_wait_connected callback, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 19/23] vhost: add assert() to check runtime behaviour, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 13/23] vhost-user: check vhost_user_{read, write}() return value, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 21/23] char: add and use tcp_chr_wait_connected, marcandre . lureau, 2016/06/24
- [Qemu-devel] [PATCH v2 23/23] tests: add /vhost-user/connect-fail test, marcandre . lureau, 2016/06/24