qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] pci.c: restore bus-level pci interrupt state via pc


From: Ian Jackson
Subject: [Qemu-devel] [PATCH] pci.c: restore bus-level pci interrupt state via pci_set_irq
Date: Fri, 16 May 2008 17:09:32 +0100

(This patch depends on my previous one which makes providing a save
function to register_savevm optional.)

    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.

Signed-off-by: Ian Jackson <address@hidden>

diff --git a/hw/pci.c b/hw/pci.c
index bc55989..bd848a5 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;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]