From: Jean Guyader Date: Mon, 13 Oct 2008 13:02:55 +0000 (+0100) Subject: pv-on-hvm-ioemu/CA-5941 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=71c839b0eb6f23073e1bda2ae47e49a0a580ab97;p=xenclient%2Fioemu.git pv-on-hvm-ioemu/CA-5941 --- diff --git a/hw/pci.c b/hw/pci.c index 4a76bde3..1b554cc2 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -27,6 +27,9 @@ #include "net.h" #include "pass-through.h" +#include "exec-all.h" +#include "qemu-xen.h" + //#define DEBUG_PCI struct PCIBus { @@ -667,20 +670,38 @@ void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn) void pci_unplug_netifs(void) { PCIBus *bus; + PCIDevice *dev; + PCIIORegion *region; int x; + int i; /* We only support one PCI bus */ for (bus = first_bus; bus; bus = NULL) { for (x = 0; x < 256; x++) { - if (bus->devices[x] && - bus->devices[x]->config[0xa] == 0 && - bus->devices[x]->config[0xb] == 2) { + dev = bus->devices[x]; + if (dev && + dev->config[0xa] == 0 && + dev->config[0xb] == 2) { /* Found a netif. Remove it from the bus. Note that we don't free it here, since there could still be references to it floating around. There are only ever one or two structures leaked, and it's not worth finding them all. */ bus->devices[x] = NULL; + for (i = 0; i < PCI_NUM_REGIONS; i++) { + region = &dev->io_regions[i]; + if (region->addr == (uint32_t)-1 || + region->size == 0) + continue; + fprintf(logfile, "region type %d at [%x,%x).\n", + region->type, region->addr, + region->addr+region->size); + if (region->type == PCI_ADDRESS_SPACE_IO) { + isa_unassign_ioport(region->addr, region->size); + } else if (region->type == PCI_ADDRESS_SPACE_MEM) { + unregister_iomem(region->addr); + } + } } } } diff --git a/qemu-xen.h b/qemu-xen.h index 3a4869b3..764f9015 100644 --- a/qemu-xen.h +++ b/qemu-xen.h @@ -30,6 +30,7 @@ void ide_unplug_harddisks(void); void net_tap_shutdown_all(void); void pci_unplug_netifs(void); void destroy_hvm_domain(void); +void unregister_iomem(target_phys_addr_t start); #ifdef __ia64__ static inline void xc_domain_shutdown_hook(int xc_handle, uint32_t domid)