From: Marc-André Lureau <marcandre.lur...@redhat.com> If the client socket has the 'reconnect' option, make sure the 'wait' option is also used. That way, an initial connection will be ensured before the VM start and the virtio device is configured.
Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- net/vhost-user.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/vhost-user.c b/net/vhost-user.c index 1b9e73a..9007d0b 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -27,6 +27,8 @@ typedef struct VhostUserState { typedef struct VhostUserChardevProps { bool is_socket; bool is_unix; + bool is_reconnect; + bool is_wait; } VhostUserChardevProps; VHostNetState *vhost_user_get_vhost_net(NetClientState *nc) @@ -239,6 +241,10 @@ static int net_vhost_chardev_opts(void *opaque, } else if (strcmp(name, "path") == 0) { props->is_unix = true; } else if (strcmp(name, "server") == 0) { + } else if (strcmp(name, "reconnect") == 0) { + props->is_reconnect = true; + } else if (strcmp(name, "wait") == 0) { + props->is_wait = true; } else { error_setg(errp, "vhost-user does not support a chardev with option %s=%s", @@ -271,6 +277,12 @@ static CharDriverState *net_vhost_parse_chardev( return NULL; } + if (props.is_reconnect && !props.is_wait) { + error_setg(errp, "chardev \"%s\" must also 'wait' with 'reconnect'", + opts->chardev); + return NULL; + } + qemu_chr_fe_claim_no_fail(chr); return chr; -- 2.5.5