diff --git a/devicemodel/hw/pci/virtio/virtio_audio.c b/devicemodel/hw/pci/virtio/virtio_audio.c index 0af263890..975cb9a03 100644 --- a/devicemodel/hw/pci/virtio/virtio_audio.c +++ b/devicemodel/hw/pci/virtio/virtio_audio.c @@ -372,6 +372,7 @@ virtio_audio_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) close(virt_audio->vbs_k.audio_fd); virt_audio->vbs_k.audio_fd = -1; } + virtio_audio_reset(virt_audio); pthread_mutex_destroy(&virt_audio->mtx); DPRINTF(("%s: free struct virtio_audio!\n", __func__)); free((struct virtio_audio *)dev->arg); diff --git a/devicemodel/hw/pci/virtio/virtio_block.c b/devicemodel/hw/pci/virtio/virtio_block.c index bb01d9a06..cc48b99ea 100644 --- a/devicemodel/hw/pci/virtio/virtio_block.c +++ b/devicemodel/hw/pci/virtio/virtio_block.c @@ -482,6 +482,7 @@ virtio_blk_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) WPRINTF(("vrito_blk:" "Failed to flush before close\n")); blockif_close(bctxt); + virtio_reset_dev(&blk->base); free(blk); } } diff --git a/devicemodel/hw/pci/virtio/virtio_console.c b/devicemodel/hw/pci/virtio/virtio_console.c index 01460a257..77bebfc13 100644 --- a/devicemodel/hw/pci/virtio/virtio_console.c +++ b/devicemodel/hw/pci/virtio/virtio_console.c @@ -740,6 +740,7 @@ static void virtio_console_destroy(struct virtio_console *console) { if (console) { + virtio_console_reset(console); if (console->config) free(console->config); free(console); diff --git a/devicemodel/hw/pci/virtio/virtio_coreu.c b/devicemodel/hw/pci/virtio/virtio_coreu.c index 1c2353fca..07a4fb07b 100644 --- a/devicemodel/hw/pci/virtio/virtio_coreu.c +++ b/devicemodel/hw/pci/virtio/virtio_coreu.c @@ -341,6 +341,7 @@ virtio_coreu_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) pthread_cond_destroy(&vcoreu->rx_cond); pthread_join(vcoreu->rx_tid, NULL); + virtio_coreu_reset(vcoreu); free(vcoreu); } diff --git a/devicemodel/hw/pci/virtio/virtio_hdcp.c b/devicemodel/hw/pci/virtio/virtio_hdcp.c index 3e44a93d6..1054dadf6 100644 --- a/devicemodel/hw/pci/virtio/virtio_hdcp.c +++ b/devicemodel/hw/pci/virtio/virtio_hdcp.c @@ -466,6 +466,7 @@ virtio_hdcp_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) if (vhdcp) { DPRINTF(("free struct virtio_hdcp\n")); + virtio_hdcp_reset(vhdcp); free(vhdcp); } } diff --git a/devicemodel/hw/pci/virtio/virtio_hyper_dmabuf.c b/devicemodel/hw/pci/virtio/virtio_hyper_dmabuf.c index cf470b3b4..580227d11 100644 --- a/devicemodel/hw/pci/virtio/virtio_hyper_dmabuf.c +++ b/devicemodel/hw/pci/virtio/virtio_hyper_dmabuf.c @@ -348,8 +348,10 @@ virtio_hyper_dmabuf_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) vbs_k_hyper_dmabuf_fd = -1; } - if (dev->arg) + if (dev->arg) { + virtio_hyper_dmabuf_reset(dev->arg); free((struct virtio_hyper_dmabuf *)dev->arg); + } } struct pci_vdev_ops pci_ops_virtio_hyper_dmabuf = { diff --git a/devicemodel/hw/pci/virtio/virtio_input.c b/devicemodel/hw/pci/virtio/virtio_input.c index 9dd9deffd..02f27bc6c 100644 --- a/devicemodel/hw/pci/virtio/virtio_input.c +++ b/devicemodel/hw/pci/virtio/virtio_input.c @@ -559,6 +559,8 @@ virtio_input_teardown(void *param) free(vi->evdev); if (vi->serial) free(vi->serial); + + virtio_input_reset(vi); free(vi); vi = NULL; } diff --git a/devicemodel/hw/pci/virtio/virtio_ipu.c b/devicemodel/hw/pci/virtio/virtio_ipu.c index 31dfdb980..4229bc148 100644 --- a/devicemodel/hw/pci/virtio/virtio_ipu.c +++ b/devicemodel/hw/pci/virtio/virtio_ipu.c @@ -379,6 +379,7 @@ virtio_ipu_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) close(ipu->vbs_k.ipu_fd); ipu->vbs_k.ipu_fd = -1; } + virtio_ipu_reset(ipu); pthread_mutex_destroy(&ipu->mtx); free(ipu); } diff --git a/devicemodel/hw/pci/virtio/virtio_mei.c b/devicemodel/hw/pci/virtio/virtio_mei.c index 8eae6487b..752f7e7e0 100644 --- a/devicemodel/hw/pci/virtio/virtio_mei.c +++ b/devicemodel/hw/pci/virtio/virtio_mei.c @@ -976,6 +976,7 @@ vmei_reset_teardown(void *param) vmei->reset_mevp = NULL; pthread_mutex_destroy(&vmei->mutex); + virtio_reset_dev(&vmei->base); free(vmei->config); free(vmei); } diff --git a/devicemodel/hw/pci/virtio/virtio_net.c b/devicemodel/hw/pci/virtio/virtio_net.c index 5eb853c24..4e8ba54e7 100644 --- a/devicemodel/hw/pci/virtio/virtio_net.c +++ b/devicemodel/hw/pci/virtio/virtio_net.c @@ -975,6 +975,7 @@ virtio_net_teardown(void *param) } else fprintf(stderr, "net->tapfd is -1!\n"); + virtio_reset_dev(&net->base); free(net); } diff --git a/devicemodel/hw/pci/virtio/virtio_rnd.c b/devicemodel/hw/pci/virtio/virtio_rnd.c index 894c2764c..4ee3be8ce 100644 --- a/devicemodel/hw/pci/virtio/virtio_rnd.c +++ b/devicemodel/hw/pci/virtio/virtio_rnd.c @@ -492,6 +492,7 @@ virtio_rnd_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) assert(rnd->fd >= 0); close(rnd->fd); DPRINTF(("%s: free struct virtio_rnd!\n", __func__)); + virtio_rnd_reset(rnd); free(rnd); } diff --git a/devicemodel/hw/pci/virtio/virtio_rpmb.c b/devicemodel/hw/pci/virtio/virtio_rpmb.c index 7c3ed6c90..851a9a19e 100644 --- a/devicemodel/hw/pci/virtio/virtio_rpmb.c +++ b/devicemodel/hw/pci/virtio/virtio_rpmb.c @@ -777,6 +777,7 @@ virtio_rpmb_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) { if (dev->arg) { DPRINTF(("virtio_rpmb_be_deinit: free struct virtio_rpmb!\n")); + virtio_rpmb_reset(dev->arg); free((struct virtio_rpmb *)dev->arg); } }