* [PATCH] device-assignment: Cleanup on exit
@ 2010-06-10 19:27 Alex Williamson
2010-06-11 17:14 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Alex Williamson @ 2010-06-10 19:27 UTC (permalink / raw)
To: kvm
close() the resource fd when we're done with it. Unregister and munmap the
anonymous memory for the MSIX table.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/device-assignment.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 2b963b5..d2c5fbb 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -60,6 +60,8 @@
static void assigned_dev_load_option_rom(AssignedDevice *dev);
+static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev);
+
static uint32_t guest_to_host_ioport(AssignedDevRegion *region, uint32_t addr)
{
return region->u.r_baseport + (addr - region->e_physbase);
@@ -783,10 +785,14 @@ static void free_assigned_device(AssignedDevice *dev)
fprintf(stderr,
"Failed to unmap assigned device region: %s\n",
strerror(errno));
+ close(pci_region->resource_fd);
}
}
}
+ if (dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX)
+ assigned_dev_unregister_msix_mmio(dev);
+
if (dev->real_device.config_fd) {
close(dev->real_device.config_fd);
dev->real_device.config_fd = 0;
@@ -1370,6 +1376,21 @@ static int assigned_dev_register_msix_mmio(AssignedDevice *dev)
return 0;
}
+static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
+{
+ if (!dev->msix_table_page)
+ return;
+
+ cpu_unregister_io_memory(dev->mmio_index);
+ dev->mmio_index = 0;
+
+ if (munmap(dev->msix_table_page, 0x1000) == -1) {
+ fprintf(stderr, "error unmapping msix_table_page! %s\n",
+ strerror(errno));
+ }
+ dev->msix_table_page = NULL;
+}
+
static int assigned_initfn(struct PCIDevice *pci_dev)
{
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] device-assignment: Cleanup on exit
2010-06-10 19:27 [PATCH] device-assignment: Cleanup on exit Alex Williamson
@ 2010-06-11 17:14 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2010-06-11 17:14 UTC (permalink / raw)
To: Alex Williamson; +Cc: kvm
On Thu, Jun 10, 2010 at 01:27:15PM -0600, Alex Williamson wrote:
> close() the resource fd when we're done with it. Unregister and munmap the
> anonymous memory for the MSIX table.
>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>
> hw/device-assignment.c | 21 +++++++++++++++++++++
> 1 files changed, 21 insertions(+), 0 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-11 17:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-10 19:27 [PATCH] device-assignment: Cleanup on exit Alex Williamson
2010-06-11 17:14 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox