diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1c3086c892..8670dbf23f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -184,6 +184,14 @@ static void vhost_vdpa_cleanup(NetClientState *nc) { VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); + /* + * If a peer NIC is attached, do not cleanup anything. + * Cleanup will happen as a part of qemu_cleanup() -> net_cleanup() + * when the guest is shutting down. + */ + if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_NIC) { + return; + } qemu_vfree(s->cvq_cmd_out_buffer); qemu_vfree(s->status); if (s->vhost_net) {