@@ -1206,9 +1206,14 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOBlock *s = VIRTIO_BLK(dev);
+ VirtIOBlkConf *conf = &s->conf;
+ unsigned i;
virtio_blk_data_plane_destroy(s->dataplane);
s->dataplane = NULL;
+ for (i = 0; i < conf->num_queues; i++) {
+ virtio_del_queue(vdev, i);
+ }
qemu_del_vm_change_state_handler(s->change);
blockdev_mark_auto_del(s->blk);
virtio_cleanup(vdev);
@@ -238,6 +238,7 @@ static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp)
qemu_del_vm_change_state_handler(vrng->vmstate);
timer_del(vrng->rate_limit_timer);
timer_free(vrng->rate_limit_timer);
+ virtio_del_queue(vdev, 0);
virtio_cleanup(vdev);
}
The function virtio_del_queue was not called at these devices unrealize() callbacks. This was detected due to add an allocated element on the next commit (used_elems) and running address sanitizer memory leak detector. Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com> --- hw/block/virtio-blk.c | 5 +++++ hw/virtio/virtio-rng.c | 1 + 2 files changed, 6 insertions(+)