]> xenbits.xensource.com Git - xenclient/ioemu.git/commitdiff
pv-on-hvm-ioemu/CA-5941
authorJean Guyader <jean.guyader@eu.citrix.com>
Mon, 13 Oct 2008 13:02:55 +0000 (14:02 +0100)
committerJean Guyader <jean.guyader@eu.citrix.com>
Mon, 13 Oct 2008 13:02:55 +0000 (14:02 +0100)
hw/pci.c
qemu-xen.h

index 4a76bde356d9e56cd49ac692e51145493248978b..1b554cc266abbd88de0ddb5bdac7d2a952fb4c2d 100644 (file)
--- 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);
+                   }
+               }
            }
        }
     }
index 3a4869b343c39564ae5d182f3ac097102060aa6a..764f9015bf5b1bc21ed94da00edb60f453f8d4fb 100644 (file)
@@ -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)