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

[Xen-changelog] [xen-unstable] ioemu/qemu vga: save and restore vram buffer



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1197453180 0
# Node ID 0884e0a5ecc33afac8d60ea09652cf436d1a33ce
# Parent  4054cd60895b667eb349221effb678bb5244042e
ioemu/qemu vga: save and restore vram buffer

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.

I have reinterpreted the `is_vbe' byte, which is related to
CONFIG_BOCHS_VBE, as a general flags word.  This enables my code to
allow old images to be restored (albeit with loss of VGA memory), by
using another bit in that word to indicate whether the VGA memory dump
is present.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/ioemu/hw/vga.c     |   32 ++++++++++++++++++++++----------
 tools/ioemu/hw/vga_int.h |    3 +++
 2 files changed, 25 insertions(+), 10 deletions(-)

diff -r 4054cd60895b -r 0884e0a5ecc3 tools/ioemu/hw/vga.c
--- a/tools/ioemu/hw/vga.c      Mon Dec 10 13:49:22 2007 +0000
+++ b/tools/ioemu/hw/vga.c      Wed Dec 12 09:53:00 2007 +0000
@@ -1742,6 +1742,8 @@ static void vga_save(QEMUFile *f, void *
 static void vga_save(QEMUFile *f, void *opaque)
 {
     VGAState *s = opaque;
+    unsigned save_format_flags;
+    uint32_t vram_size;
 #ifdef CONFIG_BOCHS_VBE
     int i;
 #endif
@@ -1772,8 +1774,9 @@ static void vga_save(QEMUFile *f, void *
     qemu_put_buffer(f, s->palette, 768);
 
     qemu_put_be32s(f, &s->bank_offset);
+    save_format_flags = VGA_SAVE_FORMAT_FLAG_VRAM_DATA;
 #ifdef CONFIG_BOCHS_VBE
-    qemu_put_byte(f, 1);
+    qemu_put_byte(f, save_format_flags | VGA_SAVE_FORMAT_FLAG_BOCHS_VBE);
     qemu_put_be16s(f, &s->vbe_index);
     for(i = 0; i < VBE_DISPI_INDEX_NB; i++)
         qemu_put_be16s(f, &s->vbe_regs[i]);
@@ -1781,17 +1784,19 @@ static void vga_save(QEMUFile *f, void *
     qemu_put_be32s(f, &s->vbe_line_offset);
     qemu_put_be32s(f, &s->vbe_bank_mask);
 #else
-    qemu_put_byte(f, 0);
-#endif
+    qemu_put_byte(f, save_format_flags);
+#endif
+    vram_size = s->vram_size;
+    qemu_put_be32s(f, &vram_size); 
+    qemu_put_buffer(f, s->vram_ptr, s->vram_size); 
 }
 
 static int vga_load(QEMUFile *f, void *opaque, int version_id)
 {
     VGAState *s = opaque;
-    int is_vbe, ret;
-#ifdef CONFIG_BOCHS_VBE
-    int i;
-#endif
+    int ret;
+    unsigned int save_format_flags;
+    uint32_t vram_size;
 
     if (version_id > 2)
         return -EINVAL;
@@ -1825,9 +1830,9 @@ static int vga_load(QEMUFile *f, void *o
     qemu_get_buffer(f, s->palette, 768);
 
     qemu_get_be32s(f, &s->bank_offset);
-    is_vbe = qemu_get_byte(f);
+    save_format_flags = qemu_get_byte(f);
 #ifdef CONFIG_BOCHS_VBE
-    if (!is_vbe)
+    if (!(save_format_flags & VGA_SAVE_FORMAT_FLAG_BOCHS_VBE))
         return -EINVAL;
     qemu_get_be16s(f, &s->vbe_index);
     for(i = 0; i < VBE_DISPI_INDEX_NB; i++)
@@ -1836,9 +1841,16 @@ static int vga_load(QEMUFile *f, void *o
     qemu_get_be32s(f, &s->vbe_line_offset);
     qemu_get_be32s(f, &s->vbe_bank_mask);
 #else
-    if (is_vbe)
+    if (save_format_flags & VGA_SAVE_FORMAT_FLAG_BOCHS_VBE)
         return -EINVAL;
 #endif
+    if (save_format_flags & VGA_SAVE_FORMAT_FLAG_VRAM_DATA) {
+       /* people who restore old images may be lucky ... */
+       qemu_get_be32s(f, &vram_size);
+       if (vram_size != s->vram_size)
+           return -EINVAL;
+       qemu_get_buffer(f, s->vram_ptr, s->vram_size); 
+    }
 
     /* force refresh */
     s->graphic_mode = -1;
diff -r 4054cd60895b -r 0884e0a5ecc3 tools/ioemu/hw/vga_int.h
--- a/tools/ioemu/hw/vga_int.h  Mon Dec 10 13:49:22 2007 +0000
+++ b/tools/ioemu/hw/vga_int.h  Wed Dec 12 09:53:00 2007 +0000
@@ -157,6 +157,9 @@ static inline int c6_to_8(int v)
     return (v << 2) | (b << 1) | b;
 }
 
+#define VGA_SAVE_FORMAT_FLAG_BOCHS_VBE  0x01
+#define VGA_SAVE_FORMAT_FLAG_VRAM_DATA  0x02
+
 void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base, 
                      unsigned long vga_ram_offset, int vga_ram_size);
 uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.