vhost-user: add get_vhost_net() assertions
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 26 Jul 2016 21:15:13 +0000 (01:15 +0400)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 28 Jul 2016 21:33:48 +0000 (00:33 +0300)
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>
hw/net/vhost_net.c
net/vhost-user.c

index 7b76591409b882c557b2f69f15775e3099f19411..4e6495e0699ac2c2798f09e3aa499a6a7384cc93 100644 (file)
@@ -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;
index d2a984d767b39d8f6aa9d96bf8679163aa9a2f2a..39987a3c8a15a2f0329a6bb28d6b7c3a55e7399b 100644 (file)
@@ -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;
 }