ia64/xen-unstable

changeset 17523:4e6577dec729

ioemu: Save PCI device INTx line states.

Otherwise, ioemu can be out of sync with the hypervisor after
restoring guest state, if INTx lines were asserted when the state was
saved. This prevents ioemu from setting the line to zero in Xen
(because it thinks the line is already zero). This can allow th eguest
to enter an endless IRQ loop and hang.

Signed-off-by: Kazuhiro Suzuki <kaz@jp.fujitsu.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 24 10:14:43 2008 +0100 (2008-04-24)
parents ae2b5cf5a686
children 97da69831384
files tools/ioemu/hw/pci.c
line diff
     1.1 --- a/tools/ioemu/hw/pci.c	Thu Apr 24 10:01:27 2008 +0100
     1.2 +++ b/tools/ioemu/hw/pci.c	Thu Apr 24 10:14:43 2008 +0100
     1.3 @@ -79,18 +79,30 @@ int pci_bus_num(PCIBus *s)
     1.4  
     1.5  void pci_device_save(PCIDevice *s, QEMUFile *f)
     1.6  {
     1.7 -    qemu_put_be32(f, 1); /* PCI device version */
     1.8 +    uint8_t irq_state = 0;
     1.9 +    int i;
    1.10 +    qemu_put_be32(f, 2); /* PCI device version */
    1.11      qemu_put_buffer(f, s->config, 256);
    1.12 +    for (i = 0; i < 4; i++)
    1.13 +        irq_state |= !!s->irq_state[i] << i;
    1.14 +    qemu_put_buffer(f, &irq_state, 1);
    1.15  }
    1.16  
    1.17  int pci_device_load(PCIDevice *s, QEMUFile *f)
    1.18  {
    1.19      uint32_t version_id;
    1.20      version_id = qemu_get_be32(f);
    1.21 -    if (version_id != 1)
    1.22 +    if (version_id != 1 && version_id != 2)
    1.23          return -EINVAL;
    1.24      qemu_get_buffer(f, s->config, 256);
    1.25      pci_update_mappings(s);
    1.26 +    if (version_id == 2) {
    1.27 +        uint8_t irq_state;
    1.28 +        int i;
    1.29 +        qemu_get_buffer(f, &irq_state, 1);
    1.30 +        for (i = 0; i < 4; i++)
    1.31 +            pci_set_irq(s, i, !!(irq_state >> i));
    1.32 +    }
    1.33      return 0;
    1.34  }
    1.35