diff mbox

[v5,18/31] vhost-user: add get_vhost_net() assertions

Message ID 20160721085750.30008-19-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 21, 2016, 8:57 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

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>
---
 hw/net/vhost_net.c | 1 +
 net/vhost-user.c   | 2 ++
 2 files changed, 3 insertions(+)
diff mbox

Patch

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 7b76591..4e6495e 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 60fab9a..5e23869 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -257,6 +257,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;
 }