ia64/xen-unstable

changeset 16602:20898120c8f9

ioemu/qemu vga: save and restore vram buffer (take 2)

The existing stdvga driver from xen-unstable tools/ioemu/hw/vga* does
not save the emulated VGA memory contents. The symptoms include video
malfunction after restore, including black screen (which can often be
fixed by asking the guest to redraw) but also missing font setup etc.
The attached patch fixes this by saving the entire VGA memory buffer,
just like the Xen ioemu Cirrus emulator does.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 12 12:02:01 2007 +0000 (2007-12-12)
parents 51c9755a52d5
children 4553bc1087d9
files tools/ioemu/hw/vga.c
line diff
     1.1 --- a/tools/ioemu/hw/vga.c	Wed Dec 12 12:00:46 2007 +0000
     1.2 +++ b/tools/ioemu/hw/vga.c	Wed Dec 12 12:02:01 2007 +0000
     1.3 @@ -1742,6 +1742,7 @@ static CPUWriteMemoryFunc *vga_mem_write
     1.4  static void vga_save(QEMUFile *f, void *opaque)
     1.5  {
     1.6      VGAState *s = opaque;
     1.7 +    uint32_t vram_size;
     1.8  #ifdef CONFIG_BOCHS_VBE
     1.9      int i;
    1.10  #endif
    1.11 @@ -1783,17 +1784,21 @@ static void vga_save(QEMUFile *f, void *
    1.12  #else
    1.13      qemu_put_byte(f, 0);
    1.14  #endif
    1.15 +    vram_size = s->vram_size;
    1.16 +    qemu_put_be32s(f, &vram_size); 
    1.17 +    qemu_put_buffer(f, s->vram_ptr, s->vram_size); 
    1.18  }
    1.19  
    1.20  static int vga_load(QEMUFile *f, void *opaque, int version_id)
    1.21  {
    1.22      VGAState *s = opaque;
    1.23      int is_vbe, ret;
    1.24 +    uint32_t vram_size;
    1.25  #ifdef CONFIG_BOCHS_VBE
    1.26      int i;
    1.27  #endif
    1.28  
    1.29 -    if (version_id > 2)
    1.30 +    if (version_id > 3)
    1.31          return -EINVAL;
    1.32  
    1.33      if (s->pci_dev && version_id >= 2) {
    1.34 @@ -1839,6 +1844,13 @@ static int vga_load(QEMUFile *f, void *o
    1.35      if (is_vbe)
    1.36          return -EINVAL;
    1.37  #endif
    1.38 +    if (version_id >= 3) {
    1.39 +	/* people who restore old images may be lucky ... */
    1.40 +	qemu_get_be32s(f, &vram_size);
    1.41 +	if (vram_size != s->vram_size)
    1.42 +	    return -EINVAL;
    1.43 +	qemu_get_buffer(f, s->vram_ptr, s->vram_size); 
    1.44 +    }
    1.45  
    1.46      /* force refresh */
    1.47      s->graphic_mode = -1;
    1.48 @@ -2052,7 +2064,7 @@ static void vga_init(VGAState *s)
    1.49  {
    1.50      int vga_io_memory;
    1.51  
    1.52 -    register_savevm("vga", 0, 2, vga_save, vga_load, s);
    1.53 +    register_savevm("vga", 0, 3, vga_save, vga_load, s);
    1.54  
    1.55      register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s);
    1.56