diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 303447a68e..3421b552d2 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -157,6 +157,14 @@ static void vhost_vdpa_cleanup(NetClientState *nc) VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); struct vhost_dev *dev = &s->vhost_net->dev; + /* + * 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->cvq_cmd_in_buffer); if (dev->vq_index + dev->nvqs == dev->vq_index_end) {