diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2015-07-27 11:06:17 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-07-27 18:11:53 +0300 |
commit | 27462695cde2a2208b1ff8074c2e917b8203590b (patch) | |
tree | f936457fe780757365ae084e9c24f386c1d9942d /hw/virtio | |
parent | 09999a5f7fc8e3636feda4358a79a25a09467594 (diff) |
virtio-pci: fix memory MR cleanup for modern
Each memory_region_add_subregion must be paired with
memory_region_del_subregion.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r-- | hw/virtio/virtio-pci.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index db8f27c100..c024161f59 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1414,6 +1414,13 @@ static void virtio_pci_modern_region_map(VirtIOPCIProxy *proxy, virtio_pci_add_mem_cap(proxy, cap); } +static void virtio_pci_modern_region_unmap(VirtIOPCIProxy *proxy, + VirtIOPCIRegion *region) +{ + memory_region_del_subregion(&proxy->modern_bar, + ®ion->mr); +} + /* This is called by virtio-bus just after the device is plugged. */ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) { @@ -1520,8 +1527,16 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) static void virtio_pci_device_unplugged(DeviceState *d) { VirtIOPCIProxy *proxy = VIRTIO_PCI(d); + bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN); virtio_pci_stop_ioeventfd(proxy); + + if (modern) { + virtio_pci_modern_region_unmap(proxy, &proxy->common); + virtio_pci_modern_region_unmap(proxy, &proxy->isr); + virtio_pci_modern_region_unmap(proxy, &proxy->device); + virtio_pci_modern_region_unmap(proxy, &proxy->notify); + } } static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) |