From: Ian Jackson Date: Fri, 16 May 2008 16:04:57 +0000 (+0100) Subject: pci.c: restore bus-level pci interrupt state via pci_set_irq X-Git-Tag: xen-3.3.0-rc1~182^2^2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=291ec0bf48503bba33c707650c62ce628100752e;p=qemu-xen-4.1-testing.git pci.c: restore bus-level pci interrupt state via pci_set_irq This change abolishes pcibus_save. Instead we use an invariant - that device interrupts are supposed to be reflected in the bus interrupt state - to restore the bus interrupt state. This makes the code smaller and removes one way in which a savefile could be corrupted (eg, if it had been generated by a buggy emulator). It also means that systems which do some of their own PCI bus emulation and thus reflect PCI bus state elsewhere (eg CPU acclerators such as Xen) get notified of the PCI bus interrupt level, via pci_set_irq's call to bus->set_irq. --- diff --git a/hw/pci.c b/hw/pci.c index bc55989f8..bd848a59c 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -53,33 +53,16 @@ target_phys_addr_t pci_mem_base; static int pci_irq_index; static PCIBus *first_bus; -static void pcibus_save(QEMUFile *f, void *opaque) +static int pcibus_load(QEMUFile *f, void *opaque, int version_id) { - PCIBus *bus = (PCIBus *)opaque; - int i; - - qemu_put_be32(f, bus->nirq); - for (i = 0; i < bus->nirq; i++) - qemu_put_be32(f, bus->irq_count[i]); -} - -static int pcibus_load(QEMUFile *f, void *opaque, int version_id) -{ - PCIBus *bus = (PCIBus *)opaque; int i, nirq; if (version_id != 1) return -EINVAL; nirq = qemu_get_be32(f); - if (bus->nirq != nirq) { - fprintf(stderr, "pcibus_load: nirq mismatch: src=%d dst=%d\n", - nirq, bus->nirq); - return -EINVAL; - } - for (i = 0; i < nirq; i++) - bus->irq_count[i] = qemu_get_be32(f); + qemu_get_be32(f); return 0; } @@ -97,7 +80,7 @@ PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, bus->devfn_min = devfn_min; bus->nirq = nirq; first_bus = bus; - register_savevm("PCIBUS", nbus++, 1, pcibus_save, pcibus_load, bus); + register_savevm("PCIBUS", nbus++, 1, NULL, pcibus_load, bus); return bus; } @@ -140,7 +123,7 @@ int pci_device_load(PCIDevice *s, QEMUFile *f) if (version_id >= 2) for (i = 0; i < 4; i ++) - s->irq_state[i] = qemu_get_be32(f); + pci_set_irq(s, i, qemu_get_be32(f)); return 0; }