qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vfio-pci: unparent BAR subregions
@ 2015-01-30 23:55 Alex Williamson
  2015-01-31  8:43 ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Williamson @ 2015-01-30 23:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Alex Williamson, qemu-stable

Commit d8d95814609e replaced a number of memory_region_destroy()
calls with object_unparent() calls.  The logic appears to be that
subregions need to be unparented, but the base region is destroyed
with the device object.  Doing hotplug testing with vfio-pci I
occasionally get a segfault from object_finalize_child_property()
due to completely bogus class pointers on the child Object.  Adding
the explicit object_unparent() for these subregions resolves the
problem, however I question the sanity of the Memory API now where
we sometimes need to destroy MemoryRegions, but the rules aren't
clear and there's no longer a memory_region_destroy() function, so
we need to reach over to some other random QEMU API and unparent
an object that we barely know about and certainly didn't explicitly
parent previously.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-stable@nongnu.org
---

 hw/vfio/pci.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 014a92c..c71499e 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2294,10 +2294,12 @@ static void vfio_unmap_bar(VFIOPCIDevice *vdev, int nr)
 
     memory_region_del_subregion(&bar->region.mem, &bar->region.mmap_mem);
     munmap(bar->region.mmap, memory_region_size(&bar->region.mmap_mem));
+    object_unparent(OBJECT(&bar->region.mmap_mem));
 
     if (vdev->msix && vdev->msix->table_bar == nr) {
         memory_region_del_subregion(&bar->region.mem, &vdev->msix->mmap_mem);
         munmap(vdev->msix->mmap, memory_region_size(&vdev->msix->mmap_mem));
+        object_unparent(OBJECT(&vdev->msix->mmap_mem));
     }
 }
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-01 16:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-30 23:55 [Qemu-devel] [PATCH] vfio-pci: unparent BAR subregions Alex Williamson
2015-01-31  8:43 ` Paolo Bonzini
2015-01-31 15:10   ` Alex Williamson
2015-01-31 20:47     ` Paolo Bonzini
2015-02-01 16:14       ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).