提交 27462695 编写于 作者: M Michael S. Tsirkin

virtio-pci: fix memory MR cleanup for modern

Each memory_region_add_subregion must be paired with
memory_region_del_subregion.
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 09999a5f
......@@ -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,
&region->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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册