Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- hw/isa/isa-bus.c | 2 ++ include/exec/ioport.h | 3 +++ ioport.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 7860b17..d263d0f 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -100,6 +100,7 @@ static inline void isa_init_ioport(ISADevice *dev, uint16_t ioport) void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start) { + memory_region_set_owner(io, OBJECT(dev)); memory_region_add_subregion(isabus->address_space_io, start, io); isa_init_ioport(dev, start); } @@ -116,6 +117,7 @@ void isa_register_portio_list(ISADevice *dev, uint16_t start, isa_init_ioport(dev, start); portio_list_init(piolist, pio_start, opaque, name); + portio_list_set_owner(piolist, OBJECT(dev)); portio_list_add(piolist, isabus->address_space_io, start); } diff --git a/include/exec/ioport.h b/include/exec/ioport.h index fc28350..5fe0d99 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -62,6 +62,7 @@ typedef struct PortioList { unsigned nr; struct MemoryRegion **regions; struct MemoryRegion **aliases; + struct Object *owner; void *opaque; const char *name; } PortioList; @@ -69,6 +70,8 @@ typedef struct PortioList { void portio_list_init(PortioList *piolist, const struct MemoryRegionPortio *callbacks, void *opaque, const char *name); +void portio_list_set_owner(PortioList *piolist, + struct Object *owner); void portio_list_destroy(PortioList *piolist); void portio_list_add(PortioList *piolist, struct MemoryRegion *address_space, diff --git a/ioport.c b/ioport.c index a0ac2a0..1cccd70 100644 --- a/ioport.c +++ b/ioport.c @@ -347,6 +347,12 @@ void portio_list_init(PortioList *piolist, piolist->address_space = NULL; piolist->opaque = opaque; piolist->name = name; + piolist->owner = NULL; +} + +void portio_list_set_owner(PortioList *piolist, Object *owner) +{ + piolist->owner = owner; } void portio_list_destroy(PortioList *piolist) @@ -386,8 +392,12 @@ static void portio_list_add_1(PortioList *piolist, */ memory_region_init_io(region, ops, piolist->opaque, piolist->name, INT64_MAX); + memory_region_set_owner(region, piolist->owner); + memory_region_init_alias(alias, piolist->name, region, start + off_low, off_high - off_low); + memory_region_set_owner(alias, piolist->owner); + memory_region_add_subregion(piolist->address_space, start + off_low, alias); piolist->regions[piolist->nr] = region; -- 1.7.1