aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-07-27 01:15:13 +0400
committerMichael S. Tsirkin <mst@redhat.com>2016-07-29 00:33:48 +0300
commit1a5b68cee8a2b165ffd61b2e0641a4da3990f242 (patch)
tree8ffd2cf6d7e4dda9b09310953c2ee6f8fbc1d10d
parente6bcb1b61782cefacecc8b9ee7a5f782373dab2d (diff)
vhost-user: add get_vhost_net() assertions
Add a few assertions to be more explicit about the runtime behaviour after the previous patch: get_vhost_net() is non-null after net_vhost_user_init(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--hw/net/vhost_net.c1
-rw-r--r--net/vhost-user.c2
2 files changed, 3 insertions, 0 deletions
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 7b76591409..4e6495e069 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -417,6 +417,7 @@ VHostNetState *get_vhost_net(NetClientState *nc)
break;
case NET_CLIENT_DRIVER_VHOST_USER:
vhost_net = vhost_user_get_vhost_net(nc);
+ assert(vhost_net);
break;
default:
break;
diff --git a/net/vhost-user.c b/net/vhost-user.c
index d2a984d767..39987a3c8a 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -259,6 +259,8 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
qemu_chr_add_handlers(chr, NULL, NULL, net_vhost_user_event, nc[0].name);
+ assert(s->vhost_net);
+
return 0;
}