WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] ioemu/qemu vga: save and restore vram buffer (revise

andrzej zaborowski writes ("Re: [Qemu-devel] [PATCH] ioemu/qemu vga: save and 
restore vram buffer"):
> On 10/12/2007, Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> wrote:
> > 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.
> 
> You can use the version_id parameter for that. Increase the value
> passed to register_savevm and load the vram only if version_id >= 2.

Oh!  That's much better.  Thanks.  Below are two patches:

The first one (stdvga-save-vram-update.patch) is against current
xen-unstable tip (which now includes my previous version) and should
be applied there.

The second (stdvga-save-vram-take2.patch) is a fresh diff against the
same qemu as before and should be regarded as replacing my previous
submission.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

Ian.

diff -r f2f7c92bf1c1 tools/ioemu/hw/vga.c
--- a/tools/ioemu/hw/vga.c      Wed Dec 12 11:08:21 2007 +0000
+++ b/tools/ioemu/hw/vga.c      Wed Dec 12 11:27:24 2007 +0000
@@ -1742,7 +1742,6 @@ 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;
@@ -1774,9 +1773,8 @@ 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, save_format_flags | VGA_SAVE_FORMAT_FLAG_BOCHS_VBE);
+    qemu_put_byte(f, 1);
     qemu_put_be16s(f, &s->vbe_index);
     for(i = 0; i < VBE_DISPI_INDEX_NB; i++)
         qemu_put_be16s(f, &s->vbe_regs[i]);
@@ -1784,7 +1782,7 @@ 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, save_format_flags);
+    qemu_put_byte(f, 0);
 #endif
     vram_size = s->vram_size;
     qemu_put_be32s(f, &vram_size); 
@@ -1794,11 +1792,13 @@ static int vga_load(QEMUFile *f, void *o
 static int vga_load(QEMUFile *f, void *opaque, int version_id)
 {
     VGAState *s = opaque;
-    int ret;
-    unsigned int save_format_flags;
+    int is_vbe, ret;
     uint32_t vram_size;
-
-    if (version_id > 2)
+#ifdef CONFIG_BOCHS_VBE
+    int i;
+#endif
+
+    if (version_id > 3)
         return -EINVAL;
 
     if (s->pci_dev && version_id >= 2) {
@@ -1830,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);
-    save_format_flags = qemu_get_byte(f);
+    is_vbe = qemu_get_byte(f);
 #ifdef CONFIG_BOCHS_VBE
-    if (!(save_format_flags & VGA_SAVE_FORMAT_FLAG_BOCHS_VBE))
+    if (!is_vbe)
         return -EINVAL;
     qemu_get_be16s(f, &s->vbe_index);
     for(i = 0; i < VBE_DISPI_INDEX_NB; i++)
@@ -1841,10 +1841,10 @@ 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 (save_format_flags & VGA_SAVE_FORMAT_FLAG_BOCHS_VBE)
+    if (is_vbe)
         return -EINVAL;
 #endif
-    if (save_format_flags & VGA_SAVE_FORMAT_FLAG_VRAM_DATA) {
+    if (version_id >= 3) {
        /* people who restore old images may be lucky ... */
        qemu_get_be32s(f, &vram_size);
        if (vram_size != s->vram_size)
@@ -2064,7 +2064,7 @@ static void vga_init(VGAState *s)
 {
     int vga_io_memory;
 
-    register_savevm("vga", 0, 2, vga_save, vga_load, s);
+    register_savevm("vga", 0, 3, vga_save, vga_load, s);
 
     register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s);
 
diff -r f2f7c92bf1c1 tools/ioemu/hw/vga_int.h
--- a/tools/ioemu/hw/vga_int.h  Wed Dec 12 11:08:21 2007 +0000
+++ b/tools/ioemu/hw/vga_int.h  Wed Dec 12 11:27:54 2007 +0000
@@ -157,9 +157,6 @@ 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);

h--99eSOG+WoR
Content-Type: text/plain
Content-Description: vga save vram (revised)
Content-Disposition: inline;
        filename="stdvga-save-vram-take2.patch"
Content-Transfer-Encoding: 7bit

diff -r 4054cd60895b 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 11:27:24 2007 +0000
@@ -1742,6 +1742,7 @@ static void vga_save(QEMUFile *f, void *
 static void vga_save(QEMUFile *f, void *opaque)
 {
     VGAState *s = opaque;
+    uint32_t vram_size;
 #ifdef CONFIG_BOCHS_VBE
     int i;
 #endif
@@ -1783,17 +1784,21 @@ static void vga_save(QEMUFile *f, void *
 #else
     qemu_put_byte(f, 0);
 #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;
+    uint32_t vram_size;
 #ifdef CONFIG_BOCHS_VBE
     int i;
 #endif
 
-    if (version_id > 2)
+    if (version_id > 3)
         return -EINVAL;
 
     if (s->pci_dev && version_id >= 2) {
@@ -1839,6 +1844,13 @@ static int vga_load(QEMUFile *f, void *o
     if (is_vbe)
         return -EINVAL;
 #endif
+    if (version_id >= 3) {
+       /* 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;
@@ -2052,7 +2064,7 @@ static void vga_init(VGAState *s)
 {
     int vga_io_memory;
 
-    register_savevm("vga", 0, 2, vga_save, vga_load, s);
+    register_savevm("vga", 0, 3, vga_save, vga_load, s);
 
     register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s);
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>