From a463215b087c41d7ca94e51aa347cde523831873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 6 Jun 2016 18:45:05 +0200 Subject: vhost-net: save & restore vhost-user acked features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The initial vhost-user connection sets the features to be negotiated with the driver. Renegotiation isn't possible without device reset. To handle reconnection of vhost-user backend, ensure the same set of features are provided, and reuse already acked features. Signed-off-by: Marc-André Lureau Tested-by: Yuanhan Liu Reviewed-by: Yuanhan Liu Reviewed-by: Victor Kaplansky Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-user.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'net/vhost-user.c') diff --git a/net/vhost-user.c b/net/vhost-user.c index 41ddb4b9ca..d72ce9b490 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -23,6 +23,7 @@ typedef struct VhostUserState { CharDriverState *chr; VHostNetState *vhost_net; int watch; + uint64_t acked_features; } VhostUserState; typedef struct VhostUserChardevProps { @@ -37,6 +38,13 @@ VHostNetState *vhost_user_get_vhost_net(NetClientState *nc) return s->vhost_net; } +uint64_t vhost_user_get_acked_features(NetClientState *nc) +{ + VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc); + assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + return s->acked_features; +} + static int vhost_user_running(VhostUserState *s) { return (s->vhost_net) ? 1 : 0; @@ -56,6 +64,8 @@ static void vhost_user_stop(int queues, NetClientState *ncs[]) } if (s->vhost_net) { + /* save acked features */ + s->acked_features = vhost_net_get_acked_features(s->vhost_net); vhost_net_cleanup(s->vhost_net); s->vhost_net = NULL; } -- cgit v1.2.1