qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate
@ 2009-10-14 17:34 Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 01/16] vga: create is_vbe_vmstate field Juan Quintela
                   ` (15 more replies)
  0 siblings, 16 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:34 UTC (permalink / raw)
  To: qemu-devel

This series:
- port vga and related devices to vmstate
- port vmware_vga to vmstate
- cleans quite a bit vmware_vga
  * removed !EMBED_STDVGA
  * reove useless casts
  * pass right value to graphic_console_init
- Add VMSTATE_UInT32_VARRAY

Later, Juan.

Juan Quintela (16):
  vga: create is_vbe_vmstate field
  vmstate: Add support for partial buffers transmission
  vga: port vga_common_save/load to vmstate
  vga: port vga-isa-mm to vmstate
  vga: port vga-isa to vmstate
  vga: port vmware std vga to vmstate
  vga: port vga-pci to vmstate
  vga: remove unused vga_common_save/load
  vmware_vga: Pass pci_vmsga_state_t arg no VGACommonState
  vmware_vga: Remove uselss casts from void *
  vmware_vga: qemu_malloc() returns void *
  vmware_vga: remove !EMBED_STDVGA code
  vmstate: Add VMSTATE_UINT32_VARRAY support
  vmware_vga: scratch is really an array of uint32_t
  vmware_vga: the support to change dinamically depth is not there
  vmware_vga: port to vmstate

 hw/hw.h         |   16 +++++
 hw/vga-isa-mm.c |    2 +-
 hw/vga-isa.c    |    2 +-
 hw/vga-pci.c    |   34 ++++--------
 hw/vga.c        |  132 ++++++++++++++++----------------------------
 hw/vga_int.h    |    7 ++-
 hw/vmware_vga.c |  167 +++++++++++++++++++-----------------------------------
 7 files changed, 141 insertions(+), 219 deletions(-)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 01/16] vga: create is_vbe_vmstate field
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
@ 2009-10-14 17:34 ` Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 02/16] vmstate: Add support for partial buffers transmission Juan Quintela
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:34 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vga.c     |   17 ++++++++++-------
 hw/vga_int.h |    1 +
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/hw/vga.c b/hw/vga.c
index 6cbd3d3..99edf25 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2159,23 +2159,21 @@ void vga_common_save(QEMUFile *f, void *opaque)
     qemu_put_buffer(f, s->palette, 768);

     qemu_put_be32(f, s->bank_offset);
+    qemu_put_byte(f, s->is_vbe_vmstate);
 #ifdef CONFIG_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]);
     qemu_put_be32s(f, &s->vbe_start_addr);
     qemu_put_be32s(f, &s->vbe_line_offset);
     qemu_put_be32s(f, &s->vbe_bank_mask);
-#else
-    qemu_put_byte(f, 0);
 #endif
 }

 int vga_common_load(QEMUFile *f, void *opaque, int version_id)
 {
     VGACommonState *s = opaque;
-    int is_vbe, i;
+    int i;

     if (version_id > 2)
         return -EINVAL;
@@ -2203,9 +2201,9 @@ int vga_common_load(QEMUFile *f, void *opaque, int version_id)
     qemu_get_buffer(f, s->palette, 768);

     s->bank_offset=qemu_get_be32(f);
-    is_vbe = qemu_get_byte(f);
+    s->is_vbe_vmstate = qemu_get_byte(f);
 #ifdef CONFIG_BOCHS_VBE
-    if (!is_vbe)
+    if (!s->is_vbe_vmstate)
         return -EINVAL;
     qemu_get_be16s(f, &s->vbe_index);
     for(i = 0; i < VBE_DISPI_INDEX_NB; i++)
@@ -2214,7 +2212,7 @@ int vga_common_load(QEMUFile *f, void *opaque, int version_id)
     qemu_get_be32s(f, &s->vbe_line_offset);
     qemu_get_be32s(f, &s->vbe_bank_mask);
 #else
-    if (is_vbe)
+    if (s->is_vbe_vmstate)
         return -EINVAL;
 #endif

@@ -2250,6 +2248,11 @@ void vga_common_init(VGACommonState *s, int vga_ram_size)
         expand4to8[i] = v;
     }

+#ifdef CONFIG_BOCHS_VBE
+    s->is_vbe_vmstate = 1;
+#else
+    s->is_vbe_vmstate = 0;
+#endif
     s->vram_offset = qemu_ram_alloc(vga_ram_size);
     s->vram_ptr = qemu_get_ram_ptr(s->vram_offset);
     s->vram_size = vga_ram_size;
diff --git a/hw/vga_int.h b/hw/vga_int.h
index c162c07..4d5232f 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -176,6 +176,7 @@ typedef struct VGACommonState {
     vga_retrace_fn retrace;
     vga_update_retrace_info_fn update_retrace_info;
     union vga_retrace retrace_info;
+    uint8_t is_vbe_vmstate;
 } VGACommonState;

 static inline int c6_to_8(int v)
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 02/16] vmstate: Add support for partial buffers transmission
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 01/16] vga: create is_vbe_vmstate field Juan Quintela
@ 2009-10-14 17:34 ` Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 03/16] vga: port vga_common_save/load to vmstate Juan Quintela
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:34 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/hw.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/hw/hw.h b/hw/hw.h
index 8c223f8..6f7b7d4 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -464,6 +464,16 @@ extern const VMStateInfo vmstate_info_buffer;
         + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \
 }

+#define VMSTATE_PARTIAL_BUFFER(_field, _state, _version, _size) {    \
+    .name       = (stringify(_field)),                               \
+    .version_id = (_version),                                        \
+    .size       = (_size),                                           \
+    .info       = &vmstate_info_buffer,                              \
+    .flags      = VMS_BUFFER,                                        \
+    .offset     = offsetof(_state, _field)                           \
+        + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \
+}
+
 #define VMSTATE_BUFFER_START_MIDDLE(_field, _state, start) {         \
     .name       = (stringify(_field)),                               \
     .size       = sizeof(typeof_field(_state,_field)) - start,       \
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 03/16] vga: port vga_common_save/load to vmstate
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 01/16] vga: create is_vbe_vmstate field Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 02/16] vmstate: Add support for partial buffers transmission Juan Quintela
@ 2009-10-14 17:34 ` Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 04/16] vga: port vga-isa-mm " Juan Quintela
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:34 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vga.c     |  131 ++++++++++++++++++++++-----------------------------------
 hw/vga_int.h |    4 ++
 2 files changed, 55 insertions(+), 80 deletions(-)

diff --git a/hw/vga.c b/hw/vga.c
index 99edf25..706cb98 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2131,94 +2131,65 @@ CPUWriteMemoryFunc * const vga_mem_write[3] = {
     vga_mem_writel,
 };

-void vga_common_save(QEMUFile *f, void *opaque)
+static int vga_common_post_load(void *opaque, int version_id)
 {
     VGACommonState *s = opaque;
-    int i;
-
-    qemu_put_be32s(f, &s->latch);
-    qemu_put_8s(f, &s->sr_index);
-    qemu_put_buffer(f, s->sr, 8);
-    qemu_put_8s(f, &s->gr_index);
-    qemu_put_buffer(f, s->gr, 16);
-    qemu_put_8s(f, &s->ar_index);
-    qemu_put_buffer(f, s->ar, 21);
-    qemu_put_be32(f, s->ar_flip_flop);
-    qemu_put_8s(f, &s->cr_index);
-    qemu_put_buffer(f, s->cr, 256);
-    qemu_put_8s(f, &s->msr);
-    qemu_put_8s(f, &s->fcr);
-    qemu_put_byte(f, s->st00);
-    qemu_put_8s(f, &s->st01);
-
-    qemu_put_8s(f, &s->dac_state);
-    qemu_put_8s(f, &s->dac_sub_index);
-    qemu_put_8s(f, &s->dac_read_index);
-    qemu_put_8s(f, &s->dac_write_index);
-    qemu_put_buffer(f, s->dac_cache, 3);
-    qemu_put_buffer(f, s->palette, 768);
-
-    qemu_put_be32(f, s->bank_offset);
-    qemu_put_byte(f, s->is_vbe_vmstate);
+
+    /* force refresh */
+    s->graphic_mode = -1;
+    return 0;
+}
+
+const VMStateDescription vmstate_vga_common = {
+    .name = "vga",
+    .version_id = 2,
+    .minimum_version_id = 2,
+    .minimum_version_id_old = 2,
+    .post_load = vga_common_post_load,
+    .fields      = (VMStateField []) {
+        VMSTATE_UINT32(latch, VGACommonState),
+        VMSTATE_UINT8(sr_index, VGACommonState),
+        VMSTATE_PARTIAL_BUFFER(sr, VGACommonState, 0, 8),
+        VMSTATE_UINT8(gr_index, VGACommonState),
+        VMSTATE_PARTIAL_BUFFER(gr, VGACommonState, 0, 16),
+        VMSTATE_UINT8(ar_index, VGACommonState),
+        VMSTATE_BUFFER(ar, VGACommonState),
+        VMSTATE_INT32(ar_flip_flop, VGACommonState),
+        VMSTATE_UINT8(cr_index, VGACommonState),
+        VMSTATE_BUFFER(cr, VGACommonState),
+        VMSTATE_UINT8(msr, VGACommonState),
+        VMSTATE_UINT8(fcr, VGACommonState),
+        VMSTATE_UINT8(st00, VGACommonState),
+        VMSTATE_UINT8(st01, VGACommonState),
+
+        VMSTATE_UINT8(dac_state, VGACommonState),
+        VMSTATE_UINT8(dac_sub_index, VGACommonState),
+        VMSTATE_UINT8(dac_read_index, VGACommonState),
+        VMSTATE_UINT8(dac_write_index, VGACommonState),
+        VMSTATE_BUFFER(dac_cache, VGACommonState),
+        VMSTATE_BUFFER(palette, VGACommonState),
+
+        VMSTATE_INT32(bank_offset, VGACommonState),
+        VMSTATE_UINT8_EQUAL(is_vbe_vmstate, VGACommonState),
 #ifdef CONFIG_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]);
-    qemu_put_be32s(f, &s->vbe_start_addr);
-    qemu_put_be32s(f, &s->vbe_line_offset);
-    qemu_put_be32s(f, &s->vbe_bank_mask);
+        VMSTATE_UINT16(vbe_index, VGACommonState),
+        VMSTATE_UINT16_ARRAY(vbe_regs, VGACommonState, VBE_DISPI_INDEX_NB),
+        VMSTATE_UINT32(vbe_start_addr, VGACommonState),
+        VMSTATE_UINT32(vbe_line_offset, VGACommonState),
+        VMSTATE_UINT32(vbe_bank_mask, VGACommonState),
 #endif
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+void vga_common_save(QEMUFile *f, void *opaque)
+{
+    vmstate_save_state(f, &vmstate_vga_common, opaque);
 }

 int vga_common_load(QEMUFile *f, void *opaque, int version_id)
 {
-    VGACommonState *s = opaque;
-    int i;
-
-    if (version_id > 2)
-        return -EINVAL;
-
-    qemu_get_be32s(f, &s->latch);
-    qemu_get_8s(f, &s->sr_index);
-    qemu_get_buffer(f, s->sr, 8);
-    qemu_get_8s(f, &s->gr_index);
-    qemu_get_buffer(f, s->gr, 16);
-    qemu_get_8s(f, &s->ar_index);
-    qemu_get_buffer(f, s->ar, 21);
-    s->ar_flip_flop=qemu_get_be32(f);
-    qemu_get_8s(f, &s->cr_index);
-    qemu_get_buffer(f, s->cr, 256);
-    qemu_get_8s(f, &s->msr);
-    qemu_get_8s(f, &s->fcr);
-    qemu_get_8s(f, &s->st00);
-    qemu_get_8s(f, &s->st01);
-
-    qemu_get_8s(f, &s->dac_state);
-    qemu_get_8s(f, &s->dac_sub_index);
-    qemu_get_8s(f, &s->dac_read_index);
-    qemu_get_8s(f, &s->dac_write_index);
-    qemu_get_buffer(f, s->dac_cache, 3);
-    qemu_get_buffer(f, s->palette, 768);
-
-    s->bank_offset=qemu_get_be32(f);
-    s->is_vbe_vmstate = qemu_get_byte(f);
-#ifdef CONFIG_BOCHS_VBE
-    if (!s->is_vbe_vmstate)
-        return -EINVAL;
-    qemu_get_be16s(f, &s->vbe_index);
-    for(i = 0; i < VBE_DISPI_INDEX_NB; i++)
-        qemu_get_be16s(f, &s->vbe_regs[i]);
-    qemu_get_be32s(f, &s->vbe_start_addr);
-    qemu_get_be32s(f, &s->vbe_line_offset);
-    qemu_get_be32s(f, &s->vbe_bank_mask);
-#else
-    if (s->is_vbe_vmstate)
-        return -EINVAL;
-#endif
-
-    /* force refresh */
-    s->graphic_mode = -1;
-    return 0;
+    return vmstate_load_state(f, &vmstate_vga_common, opaque, vmstate_vga_common.version_id);
 }

 void vga_common_init(VGACommonState *s, int vga_ram_size)
diff --git a/hw/vga_int.h b/hw/vga_int.h
index 4d5232f..46c326d 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -21,6 +21,9 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
+#include <hw/hw.h>
+
 #define MSR_COLOR_EMULATION 0x01
 #define MSR_PAGE_SELECT     0x20

@@ -193,6 +196,7 @@ void vga_common_reset(VGACommonState *s);

 void vga_dirty_log_start(VGACommonState *s);

+extern const VMStateDescription vmstate_vga_common;
 void vga_common_save(QEMUFile *f, void *opaque);
 int vga_common_load(QEMUFile *f, void *opaque, int version_id);
 uint32_t vga_ioport_read(void *opaque, uint32_t addr);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 04/16] vga: port vga-isa-mm to vmstate
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (2 preceding siblings ...)
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 03/16] vga: port vga_common_save/load to vmstate Juan Quintela
@ 2009-10-14 17:34 ` Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 05/16] vga: port vga-isa " Juan Quintela
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:34 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vga-isa-mm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/vga-isa-mm.c b/hw/vga-isa-mm.c
index f8fc940..2faefa5 100644
--- a/hw/vga-isa-mm.c
+++ b/hw/vga-isa-mm.c
@@ -100,7 +100,7 @@ static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base,
     s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, vga_mm_write_ctrl, s);
     vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s);

-    register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
+    vmstate_register(0, &vmstate_vga_common, s);

     cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
     s->vga.bank_offset = 0;
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 05/16] vga: port vga-isa to vmstate
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (3 preceding siblings ...)
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 04/16] vga: port vga-isa-mm " Juan Quintela
@ 2009-10-14 17:34 ` Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 06/16] vga: port vmware std vga " Juan Quintela
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:34 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vga-isa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/vga-isa.c b/hw/vga-isa.c
index 7fa31d3..801121a 100644
--- a/hw/vga-isa.c
+++ b/hw/vga-isa.c
@@ -36,7 +36,7 @@ int isa_vga_init(void)

     vga_common_init(s, VGA_RAM_SIZE);
     vga_init(s);
-    register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
+    vmstate_register(0, &vmstate_vga_common, s);

     s->ds = graphic_console_init(s->update, s->invalidate,
                                  s->screen_dump, s->text_update, s);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 06/16] vga: port vmware std vga to vmstate
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (4 preceding siblings ...)
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 05/16] vga: port vga-isa " Juan Quintela
@ 2009-10-14 17:34 ` Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 07/16] vga: port vga-pci " Juan Quintela
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:34 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vmware_vga.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index a273f35..101d8ae 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1131,7 +1131,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
 #ifdef EMBED_STDVGA
     vga_common_init(&s->vga, vga_ram_size);
     vga_init(&s->vga);
-    register_savevm("vga", 0, 2, vga_common_save, vga_common_load, &s->vga);
+    vmstate_register(0, &vmstate_vga_common, &s->vga);
 #else
     s->vram_size = vga_ram_size;
     s->vram_offset = qemu_ram_alloc(vga_ram_size);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 07/16] vga: port vga-pci to vmstate
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (5 preceding siblings ...)
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 06/16] vga: port vmware std vga " Juan Quintela
@ 2009-10-14 17:34 ` Juan Quintela
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 08/16] vga: remove unused vga_common_save/load Juan Quintela
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:34 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vga-pci.c |   34 +++++++++++-----------------------
 1 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index 5e75938..1edfdee 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -34,29 +34,17 @@ typedef struct PCIVGAState {
     VGACommonState vga;
 } PCIVGAState;

-static void pci_vga_save(QEMUFile *f, void *opaque)
-{
-    PCIVGAState *s = opaque;
-
-    pci_device_save(&s->dev, f);
-    vga_common_save(f, &s->vga);
-}
-
-static int pci_vga_load(QEMUFile *f, void *opaque, int version_id)
-{
-    PCIVGAState *s = opaque;
-    int ret;
-
-    if (version_id > 2)
-        return -EINVAL;
-
-    if (version_id >= 2) {
-        ret = pci_device_load(&s->dev, f);
-        if (ret < 0)
-            return ret;
+static const VMStateDescription vmstate_vga_pci = {
+    .name = "vga",
+    .version_id = 2,
+    .minimum_version_id = 2,
+    .minimum_version_id_old = 2,
+    .fields      = (VMStateField []) {
+        VMSTATE_PCI_DEVICE(dev, PCIVGAState),
+        VMSTATE_STRUCT(vga, PCIVGAState, 0, vmstate_vga_common, VGACommonState),
+        VMSTATE_END_OF_LIST()
     }
-    return vga_common_load(f, &s->vga, version_id);
-}
+};

 static void vga_map(PCIDevice *pci_dev, int region_num,
                     uint32_t addr, uint32_t size, int type)
@@ -93,7 +81,7 @@ static int pci_vga_initfn(PCIDevice *dev)
      // vga + console init
      vga_common_init(s, VGA_RAM_SIZE);
      vga_init(s);
-     register_savevm("vga", 0, 2, pci_vga_save, pci_vga_load, d);
+     vmstate_register(0, &vmstate_vga_pci, d);

      s->ds = graphic_console_init(s->update, s->invalidate,
                                   s->screen_dump, s->text_update, s);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 08/16] vga: remove unused vga_common_save/load
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (6 preceding siblings ...)
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 07/16] vga: port vga-pci " Juan Quintela
@ 2009-10-14 17:34 ` Juan Quintela
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 09/16] vmware_vga: Pass pci_vmsga_state_t arg no VGACommonState Juan Quintela
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:34 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vga.c     |   10 ----------
 hw/vga_int.h |    2 --
 2 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/hw/vga.c b/hw/vga.c
index 706cb98..f2ec772 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2182,16 +2182,6 @@ const VMStateDescription vmstate_vga_common = {
     }
 };

-void vga_common_save(QEMUFile *f, void *opaque)
-{
-    vmstate_save_state(f, &vmstate_vga_common, opaque);
-}
-
-int vga_common_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return vmstate_load_state(f, &vmstate_vga_common, opaque, vmstate_vga_common.version_id);
-}
-
 void vga_common_init(VGACommonState *s, int vga_ram_size)
 {
     int i, j, v, b;
diff --git a/hw/vga_int.h b/hw/vga_int.h
index 46c326d..e2b9989 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -197,8 +197,6 @@ void vga_common_reset(VGACommonState *s);
 void vga_dirty_log_start(VGACommonState *s);

 extern const VMStateDescription vmstate_vga_common;
-void vga_common_save(QEMUFile *f, void *opaque);
-int vga_common_load(QEMUFile *f, void *opaque, int version_id);
 uint32_t vga_ioport_read(void *opaque, uint32_t addr);
 void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val);
 uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 09/16] vmware_vga: Pass pci_vmsga_state_t arg no VGACommonState
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (7 preceding siblings ...)
  2009-10-14 17:34 ` [Qemu-devel] [PATCH 08/16] vga: remove unused vga_common_save/load Juan Quintela
@ 2009-10-14 17:35 ` Juan Quintela
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 10/16] vmware_vga: Remove uselss casts from void * Juan Quintela
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:35 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vmware_vga.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 101d8ae..15609dd 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1141,7 +1141,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
     s->vga.ds = graphic_console_init(vmsvga_update_display,
                                      vmsvga_invalidate_display,
                                      vmsvga_screen_dump,
-                                     vmsvga_text_update, &s->vga);
+                                     vmsvga_text_update, s);

 #ifdef CONFIG_BOCHS_VBE
     /* XXX: use optimized standard vga accesses */
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 10/16] vmware_vga: Remove uselss casts from void *
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (8 preceding siblings ...)
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 09/16] vmware_vga: Pass pci_vmsga_state_t arg no VGACommonState Juan Quintela
@ 2009-10-14 17:35 ` Juan Quintela
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 11/16] vmware_vga: qemu_malloc() returns " Juan Quintela
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:35 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vmware_vga.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 15609dd..5e31d66 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -630,20 +630,20 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)

 static uint32_t vmsvga_index_read(void *opaque, uint32_t address)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     return s->index;
 }

 static void vmsvga_index_write(void *opaque, uint32_t address, uint32_t index)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     s->index = index;
 }

 static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
 {
     uint32_t caps;
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     switch (s->index) {
     case SVGA_REG_ID:
         return s->svgaid;
@@ -761,7 +761,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)

 static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     switch (s->index) {
     case SVGA_REG_ID:
         if (value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0)
@@ -892,7 +892,7 @@ static inline void vmsvga_size(struct vmsvga_state_s *s)

 static void vmsvga_update_display(void *opaque)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     if (!s->enable) {
 #ifdef EMBED_STDVGA
         s->vga.update(&s->vga);
@@ -960,7 +960,7 @@ static void vmsvga_reset(struct vmsvga_state_s *s)

 static void vmsvga_invalidate_display(void *opaque)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     if (!s->enable) {
 #ifdef EMBED_STDVGA
         s->vga.invalidate(&s->vga);
@@ -975,7 +975,7 @@ static void vmsvga_invalidate_display(void *opaque)
    available */
 static void vmsvga_screen_dump(void *opaque, const char *filename)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     if (!s->enable) {
 #ifdef EMBED_STDVGA
         s->vga.screen_dump(&s->vga, filename);
@@ -993,7 +993,7 @@ static void vmsvga_screen_dump(void *opaque, const char *filename)

 static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;

     if (s->vga.text_update)
         s->vga.text_update(&s->vga, chardata);
@@ -1002,7 +1002,7 @@ static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
 #ifdef DIRECT_VRAM
 static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     if (addr < s->fb_size)
         return *(uint8_t *) (ds_get_data(s->ds) + addr);
     else
@@ -1011,7 +1011,7 @@ static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr)

 static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     if (addr < s->fb_size)
         return *(uint16_t *) (ds_get_data(s->ds) + addr);
     else
@@ -1020,7 +1020,7 @@ static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr)

 static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     if (addr < s->fb_size)
         return *(uint32_t *) (ds_get_data(s->ds) + addr);
     else
@@ -1030,7 +1030,7 @@ static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr)
 static void vmsvga_vram_writeb(void *opaque, target_phys_addr_t addr,
                 uint32_t value)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     if (addr < s->fb_size)
         *(uint8_t *) (ds_get_data(s->ds) + addr) = value;
     else
@@ -1040,7 +1040,7 @@ static void vmsvga_vram_writeb(void *opaque, target_phys_addr_t addr,
 static void vmsvga_vram_writew(void *opaque, target_phys_addr_t addr,
                 uint32_t value)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     if (addr < s->fb_size)
         *(uint16_t *) (ds_get_data(s->ds) + addr) = value;
     else
@@ -1050,7 +1050,7 @@ static void vmsvga_vram_writew(void *opaque, target_phys_addr_t addr,
 static void vmsvga_vram_writel(void *opaque, target_phys_addr_t addr,
                 uint32_t value)
 {
-    struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
+    struct vmsvga_state_s *s = opaque;
     if (addr < s->fb_size)
         *(uint32_t *) (ds_get_data(s->ds) + addr) = value;
     else
@@ -1152,14 +1152,14 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)

 static void pci_vmsvga_save(QEMUFile *f, void *opaque)
 {
-    struct pci_vmsvga_state_s *s = (struct pci_vmsvga_state_s *) opaque;
+    struct pci_vmsvga_state_s *s = opaque;
     pci_device_save(&s->card, f);
     vmsvga_save(&s->chip, f);
 }

 static int pci_vmsvga_load(QEMUFile *f, void *opaque, int version_id)
 {
-    struct pci_vmsvga_state_s *s = (struct pci_vmsvga_state_s *) opaque;
+    struct pci_vmsvga_state_s *s = opaque;
     int ret;

     ret = pci_device_load(&s->card, f);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 11/16] vmware_vga: qemu_malloc() returns void *
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (9 preceding siblings ...)
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 10/16] vmware_vga: Remove uselss casts from void * Juan Quintela
@ 2009-10-14 17:35 ` Juan Quintela
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code Juan Quintela
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:35 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vmware_vga.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 5e31d66..1fb04bf 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1124,7 +1124,7 @@ static int vmsvga_load(struct vmsvga_state_s *s, QEMUFile *f)
 static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
 {
     s->scratch_size = SVGA_SCRATCH_SIZE;
-    s->scratch = (uint32_t *) qemu_malloc(s->scratch_size * 4);
+    s->scratch = qemu_malloc(s->scratch_size * 4);

     vmsvga_reset(s);

-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (10 preceding siblings ...)
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 11/16] vmware_vga: qemu_malloc() returns " Juan Quintela
@ 2009-10-14 17:35 ` Juan Quintela
  2009-10-14 18:15   ` andrzej zaborowski
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 13/16] vmstate: Add VMSTATE_UINT32_VARRAY support Juan Quintela
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:35 UTC (permalink / raw)
  To: qemu-devel

It don't compile.  And the trivial fixes (change vga.foo field to foo field
don't work either.  No output

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vmware_vga.c |   25 -------------------------
 1 files changed, 0 insertions(+), 25 deletions(-)

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 1fb04bf..48f3a06 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -26,20 +26,15 @@
 #include "pci.h"

 #define VERBOSE
-#define EMBED_STDVGA
 #undef DIRECT_VRAM
 #define HW_RECT_ACCEL
 #define HW_FILL_ACCEL
 #define HW_MOUSE_ACCEL

-#ifdef EMBED_STDVGA
 # include "vga_int.h"
-#endif

 struct vmsvga_state_s {
-#ifdef EMBED_STDVGA
     VGACommonState vga;
-#endif

     int width;
     int height;
@@ -55,12 +50,6 @@ struct vmsvga_state_s {
         int on;
     } cursor;

-#ifndef EMBED_STDVGA
-    DisplayState *ds;
-    int vram_size;
-    ram_addr_t vram_offset;
-    uint8_t *vram_ptr;
-#endif
     target_phys_addr_t vram_base;

     int index;
@@ -774,9 +763,7 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
         s->width = -1;
         s->height = -1;
         s->invalidated = 1;
-#ifdef EMBED_STDVGA
         s->vga.invalidate(&s->vga);
-#endif
         if (s->enable)
             s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height;
         break;
@@ -894,9 +881,7 @@ static void vmsvga_update_display(void *opaque)
 {
     struct vmsvga_state_s *s = opaque;
     if (!s->enable) {
-#ifdef EMBED_STDVGA
         s->vga.update(&s->vga);
-#endif
         return;
     }

@@ -962,9 +947,7 @@ static void vmsvga_invalidate_display(void *opaque)
 {
     struct vmsvga_state_s *s = opaque;
     if (!s->enable) {
-#ifdef EMBED_STDVGA
         s->vga.invalidate(&s->vga);
-#endif
         return;
     }

@@ -977,9 +960,7 @@ static void vmsvga_screen_dump(void *opaque, const char *filename)
 {
     struct vmsvga_state_s *s = opaque;
     if (!s->enable) {
-#ifdef EMBED_STDVGA
         s->vga.screen_dump(&s->vga, filename);
-#endif
         return;
     }

@@ -1128,15 +1109,9 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)

     vmsvga_reset(s);

-#ifdef EMBED_STDVGA
     vga_common_init(&s->vga, vga_ram_size);
     vga_init(&s->vga);
     vmstate_register(0, &vmstate_vga_common, &s->vga);
-#else
-    s->vram_size = vga_ram_size;
-    s->vram_offset = qemu_ram_alloc(vga_ram_size);
-    s->vram_ptr = qemu_get_ram_ptr(s->vram_offset);
-#endif

     s->vga.ds = graphic_console_init(vmsvga_update_display,
                                      vmsvga_invalidate_display,
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 13/16] vmstate: Add VMSTATE_UINT32_VARRAY support
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (11 preceding siblings ...)
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code Juan Quintela
@ 2009-10-14 17:35 ` Juan Quintela
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 14/16] vmware_vga: scratch is really an array of uint32_t Juan Quintela
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:35 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/hw.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/hw.h b/hw/hw.h
index 6f7b7d4..8d2352c 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -617,6 +617,12 @@ extern const VMStateDescription vmstate_i2c_slave;
 #define VMSTATE_INT32_VARRAY(_f, _s, _f_n)                            \
     VMSTATE_INT32_VARRAY_V(_f, _s, _f_n, 0)

+#define VMSTATE_UINT32_VARRAY_V(_f, _s, _f_n, _v)                      \
+    VMSTATE_VARRAY(_f, _s, _f_n, _v, vmstate_info_uint32, uint32_t)
+
+#define VMSTATE_UINT32_VARRAY(_f, _s, _f_n)                            \
+    VMSTATE_UINT32_VARRAY_V(_f, _s, _f_n, 0)
+
 #define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
     VMSTATE_STATIC_BUFFER(_f, _s, _v)

-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 14/16] vmware_vga: scratch is really an array of uint32_t
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (12 preceding siblings ...)
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 13/16] vmstate: Add VMSTATE_UINT32_VARRAY support Juan Quintela
@ 2009-10-14 17:35 ` Juan Quintela
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 15/16] vmware_vga: the support to change dinamically depth is not there Juan Quintela
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 16/16] vmware_vga: port to vmstate Juan Quintela
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:35 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vmware_vga.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 48f3a06..cc0acf7 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1053,6 +1053,7 @@ static CPUWriteMemoryFunc * const vmsvga_vram_write[] = {

 static void vmsvga_save(struct vmsvga_state_s *s, QEMUFile *f)
 {
+    int i;
     qemu_put_be32(f, s->depth);
     qemu_put_be32(f, s->enable);
     qemu_put_be32(f, s->config);
@@ -1061,7 +1062,9 @@ static void vmsvga_save(struct vmsvga_state_s *s, QEMUFile *f)
     qemu_put_be32(f, s->cursor.y);
     qemu_put_be32(f, s->cursor.on);
     qemu_put_be32(f, s->index);
-    qemu_put_buffer(f, (uint8_t *) s->scratch, s->scratch_size * 4);
+    for (i = 0; i < s->scratch_size; i++) {
+        qemu_put_be32s(f, &s->scratch[i]);
+    }
     qemu_put_be32(f, s->new_width);
     qemu_put_be32(f, s->new_height);
     qemu_put_be32s(f, &s->guest);
@@ -1073,6 +1076,7 @@ static void vmsvga_save(struct vmsvga_state_s *s, QEMUFile *f)
 static int vmsvga_load(struct vmsvga_state_s *s, QEMUFile *f)
 {
     int depth;
+    int i;
     depth=qemu_get_be32(f);
     s->enable=qemu_get_be32(f);
     s->config=qemu_get_be32(f);
@@ -1081,7 +1085,9 @@ static int vmsvga_load(struct vmsvga_state_s *s, QEMUFile *f)
     s->cursor.y=qemu_get_be32(f);
     s->cursor.on=qemu_get_be32(f);
     s->index=qemu_get_be32(f);
-    qemu_get_buffer(f, (uint8_t *) s->scratch, s->scratch_size * 4);
+    for (i = 0; i < s->scratch_size; i++) {
+        qemu_get_be32s(f, &s->scratch[i]);
+    }
     s->new_width=qemu_get_be32(f);
     s->new_height=qemu_get_be32(f);
     qemu_get_be32s(f, &s->guest);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 15/16] vmware_vga: the support to change dinamically depth is not there
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (13 preceding siblings ...)
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 14/16] vmware_vga: scratch is really an array of uint32_t Juan Quintela
@ 2009-10-14 17:35 ` Juan Quintela
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 16/16] vmware_vga: port to vmstate Juan Quintela
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:35 UTC (permalink / raw)
  To: qemu-devel

For a start bypp is not changed after vmsvga_reset() and it depends on depth

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vmware_vga.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index cc0acf7..d0a19dd 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1095,7 +1095,7 @@ static int vmsvga_load(struct vmsvga_state_s *s, QEMUFile *f)
     s->syncing=qemu_get_be32(f);
     s->fb_size=qemu_get_be32(f);

-    if (s->enable && depth != s->depth) {
+    if (depth != s->depth) {
         printf("%s: need colour depth of %i bits to resume operation.\n",
                         __FUNCTION__, depth);
         return -EINVAL;
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 16/16] vmware_vga: port to vmstate
  2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
                   ` (14 preceding siblings ...)
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 15/16] vmware_vga: the support to change dinamically depth is not there Juan Quintela
@ 2009-10-14 17:35 ` Juan Quintela
  15 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 17:35 UTC (permalink / raw)
  To: qemu-devel


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/vmware_vga.c |  114 ++++++++++++++++++++----------------------------------
 1 files changed, 42 insertions(+), 72 deletions(-)

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index d0a19dd..de3d0a1 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1051,55 +1051,9 @@ static CPUWriteMemoryFunc * const vmsvga_vram_write[] = {
 };
 #endif

-static void vmsvga_save(struct vmsvga_state_s *s, QEMUFile *f)
+static int vmsvga_post_load(void *opaque, int version_id)
 {
-    int i;
-    qemu_put_be32(f, s->depth);
-    qemu_put_be32(f, s->enable);
-    qemu_put_be32(f, s->config);
-    qemu_put_be32(f, s->cursor.id);
-    qemu_put_be32(f, s->cursor.x);
-    qemu_put_be32(f, s->cursor.y);
-    qemu_put_be32(f, s->cursor.on);
-    qemu_put_be32(f, s->index);
-    for (i = 0; i < s->scratch_size; i++) {
-        qemu_put_be32s(f, &s->scratch[i]);
-    }
-    qemu_put_be32(f, s->new_width);
-    qemu_put_be32(f, s->new_height);
-    qemu_put_be32s(f, &s->guest);
-    qemu_put_be32s(f, &s->svgaid);
-    qemu_put_be32(f, s->syncing);
-    qemu_put_be32(f, s->fb_size);
-}
-
-static int vmsvga_load(struct vmsvga_state_s *s, QEMUFile *f)
-{
-    int depth;
-    int i;
-    depth=qemu_get_be32(f);
-    s->enable=qemu_get_be32(f);
-    s->config=qemu_get_be32(f);
-    s->cursor.id=qemu_get_be32(f);
-    s->cursor.x=qemu_get_be32(f);
-    s->cursor.y=qemu_get_be32(f);
-    s->cursor.on=qemu_get_be32(f);
-    s->index=qemu_get_be32(f);
-    for (i = 0; i < s->scratch_size; i++) {
-        qemu_get_be32s(f, &s->scratch[i]);
-    }
-    s->new_width=qemu_get_be32(f);
-    s->new_height=qemu_get_be32(f);
-    qemu_get_be32s(f, &s->guest);
-    qemu_get_be32s(f, &s->svgaid);
-    s->syncing=qemu_get_be32(f);
-    s->fb_size=qemu_get_be32(f);
-
-    if (depth != s->depth) {
-        printf("%s: need colour depth of %i bits to resume operation.\n",
-                        __FUNCTION__, depth);
-        return -EINVAL;
-    }
+    struct vmsvga_state_s *s = opaque;

     s->invalidated = 1;
     if (s->config)
@@ -1108,6 +1062,45 @@ static int vmsvga_load(struct vmsvga_state_s *s, QEMUFile *f)
     return 0;
 }

+const VMStateDescription vmstate_vmware_vga_internal = {
+    .name = "vmware_vga_internal",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .minimum_version_id_old = 0,
+    .post_load = vmsvga_post_load,
+    .fields      = (VMStateField []) {
+        VMSTATE_INT32_EQUAL(depth, struct vmsvga_state_s),
+        VMSTATE_INT32(enable, struct vmsvga_state_s),
+        VMSTATE_INT32(config, struct vmsvga_state_s),
+        VMSTATE_INT32(cursor.id, struct vmsvga_state_s),
+        VMSTATE_INT32(cursor.x, struct vmsvga_state_s),
+        VMSTATE_INT32(cursor.y, struct vmsvga_state_s),
+        VMSTATE_INT32(cursor.on, struct vmsvga_state_s),
+        VMSTATE_INT32(index, struct vmsvga_state_s),
+        VMSTATE_UINT32_VARRAY(scratch, struct vmsvga_state_s, scratch_size),
+        VMSTATE_INT32(new_width, struct vmsvga_state_s),
+        VMSTATE_INT32(new_height, struct vmsvga_state_s),
+        VMSTATE_UINT32(guest, struct vmsvga_state_s),
+        VMSTATE_UINT32(svgaid, struct vmsvga_state_s),
+        VMSTATE_INT32(syncing, struct vmsvga_state_s),
+        VMSTATE_INT32(fb_size, struct vmsvga_state_s),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+const VMStateDescription vmstate_vmware_vga = {
+    .name = "vmware_vga",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .minimum_version_id_old = 0,
+    .fields      = (VMStateField []) {
+        VMSTATE_PCI_DEVICE(card, struct pci_vmsvga_state_s),
+        VMSTATE_STRUCT(chip, struct pci_vmsvga_state_s, 0,
+                       vmstate_vmware_vga_internal, struct vmsvga_state_s),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
 {
     s->scratch_size = SVGA_SCRATCH_SIZE;
@@ -1131,29 +1124,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
 #endif
 }

-static void pci_vmsvga_save(QEMUFile *f, void *opaque)
-{
-    struct pci_vmsvga_state_s *s = opaque;
-    pci_device_save(&s->card, f);
-    vmsvga_save(&s->chip, f);
-}
-
-static int pci_vmsvga_load(QEMUFile *f, void *opaque, int version_id)
-{
-    struct pci_vmsvga_state_s *s = opaque;
-    int ret;
-
-    ret = pci_device_load(&s->card, f);
-    if (ret < 0)
-        return ret;
-
-    ret = vmsvga_load(&s->chip, f);
-    if (ret < 0)
-        return ret;
-
-    return 0;
-}
-
 static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num,
                 uint32_t addr, uint32_t size, int type)
 {
@@ -1217,7 +1187,7 @@ static int pci_vmsvga_initfn(PCIDevice *dev)

     vmsvga_init(&s->chip, VGA_RAM_SIZE);

-    register_savevm("vmware_vga", 0, 0, pci_vmsvga_save, pci_vmsvga_load, s);
+    vmstate_register(0, &vmstate_vmware_vga, s);
     return 0;
 }

-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code
  2009-10-14 17:35 ` [Qemu-devel] [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code Juan Quintela
@ 2009-10-14 18:15   ` andrzej zaborowski
  2009-10-14 19:28     ` [Qemu-devel] " Juan Quintela
  0 siblings, 1 reply; 22+ messages in thread
From: andrzej zaborowski @ 2009-10-14 18:15 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

2009/10/14 Juan Quintela <quintela@redhat.com>:
> It don't compile.  And the trivial fixes (change vga.foo field to foo field
> don't work either.  No output

Just a note that there's supposed to be no output because your guest
OS (and BIOS) expect the standard VGA functionality to be there.  The
define is only useful for debugging vmware_vga or OS driver.  It's ok
to drop it if you want.

Cheers

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code
  2009-10-14 18:15   ` andrzej zaborowski
@ 2009-10-14 19:28     ` Juan Quintela
  2009-10-14 19:42       ` andrzej zaborowski
  0 siblings, 1 reply; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 19:28 UTC (permalink / raw)
  To: andrzej zaborowski; +Cc: qemu-devel

andrzej zaborowski <balrogg@gmail.com> wrote:
> 2009/10/14 Juan Quintela <quintela@redhat.com>:
>> It don't compile.  And the trivial fixes (change vga.foo field to foo field
>> don't work either.  No output
>
> Just a note that there's supposed to be no output because your guest
> OS (and BIOS) expect the standard VGA functionality to be there.  The
> define is only useful for debugging vmware_vga or OS driver.  It's ok
> to drop it if you want.

I preffer to drop it because it has no chance of working (suspend/resume
code is not there for instance).

Once that we are there.  I did a fast try at enabling DIRECT_VRAM with
the same not working result.  Any idea if it would make things
better/fast/... whatever?

The reason that I ask is because the driver is smaller than cirrus_vga,
and it supports already lots of resolutions.

Later, Juan.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code
  2009-10-14 19:28     ` [Qemu-devel] " Juan Quintela
@ 2009-10-14 19:42       ` andrzej zaborowski
  2009-10-14 20:04         ` Juan Quintela
  0 siblings, 1 reply; 22+ messages in thread
From: andrzej zaborowski @ 2009-10-14 19:42 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

2009/10/14 Juan Quintela <quintela@redhat.com>:
> andrzej zaborowski <balrogg@gmail.com> wrote:
>> 2009/10/14 Juan Quintela <quintela@redhat.com>:
>>> It don't compile.  And the trivial fixes (change vga.foo field to foo field
>>> don't work either.  No output
>>
>> Just a note that there's supposed to be no output because your guest
>> OS (and BIOS) expect the standard VGA functionality to be there.  The
>> define is only useful for debugging vmware_vga or OS driver.  It's ok
>> to drop it if you want.
>
> I preffer to drop it because it has no chance of working (suspend/resume
> code is not there for instance).
>
> Once that we are there.  I did a fast try at enabling DIRECT_VRAM with
> the same not working result.  Any idea if it would make things
> better/fast/... whatever?

Currently it probably makes things slower.  I have not digged through
the newer SDL code deep enough, to tell if it's possible to create a
SDL surface directly from guest RAM provided it's contiguously mapped
on host -- this is what VMware does and it's one of the expected
benefits from using vmware_vga that isn't there, and I think using DGA
saves them another unneeded copy.  This would need reimplementing the
pieces guarded by #ifdef DIRECT_VRAM.

Cheers

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code
  2009-10-14 19:42       ` andrzej zaborowski
@ 2009-10-14 20:04         ` Juan Quintela
  2009-10-21  2:23           ` andrzej zaborowski
  0 siblings, 1 reply; 22+ messages in thread
From: Juan Quintela @ 2009-10-14 20:04 UTC (permalink / raw)
  To: andrzej zaborowski; +Cc: qemu-devel

andrzej zaborowski <balrogg@gmail.com> wrote:
> 2009/10/14 Juan Quintela <quintela@redhat.com>:
>> andrzej zaborowski <balrogg@gmail.com> wrote:
>>> 2009/10/14 Juan Quintela <quintela@redhat.com>:
>>>> It don't compile.  And the trivial fixes (change vga.foo field to foo field
>>>> don't work either.  No output
>>>
>>> Just a note that there's supposed to be no output because your guest
>>> OS (and BIOS) expect the standard VGA functionality to be there.  The
>>> define is only useful for debugging vmware_vga or OS driver.  It's ok
>>> to drop it if you want.
>>
>> I preffer to drop it because it has no chance of working (suspend/resume
>> code is not there for instance).
>>
>> Once that we are there.  I did a fast try at enabling DIRECT_VRAM with
>> the same not working result.  Any idea if it would make things
>> better/fast/... whatever?
>
> Currently it probably makes things slower.  I have not digged through
> the newer SDL code deep enough, to tell if it's possible to create a
> SDL surface directly from guest RAM provided it's contiguously mapped
> on host -- this is what VMware does and it's one of the expected
> benefits from using vmware_vga that isn't there, and I think using DGA
> saves them another unneeded copy.  This would need reimplementing the
> pieces guarded by #ifdef DIRECT_VRAM.

Without DIRECT_VRAM, my un-scientific test (run glxgears) show that
cirrus_vga is a bit faster (207 vs 190 fps), neither the test of the
results something to write home about.

I have another problem with the driver: depth.

I have to change s->depth to 32 in vmsvga_reset() to make it work
correctly on my setup (default qemu.git tree, i.e. nothing fancy),
running with sdl.  Any clue here?

Anthony thinks that the problem happens at the memcpy() in
vmsvga_update_rect(), but I haven't had the time to look at how to fix
it.  Any idea here?

Later, Juan.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code
  2009-10-14 20:04         ` Juan Quintela
@ 2009-10-21  2:23           ` andrzej zaborowski
  0 siblings, 0 replies; 22+ messages in thread
From: andrzej zaborowski @ 2009-10-21  2:23 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

Hi,
sorry for replying late,

2009/10/14 Juan Quintela <quintela@redhat.com>:
> I have another problem with the driver: depth.
>
> I have to change s->depth to 32 in vmsvga_reset() to make it work
> correctly on my setup (default qemu.git tree, i.e. nothing fancy),
> running with sdl.  Any clue here?
>
> Anthony thinks that the problem happens at the memcpy() in
> vmsvga_update_rect(), but I haven't had the time to look at how to fix
> it.  Any idea here?

There's a thread about this issue at
http://lists.gnu.org/archive/html/qemu-devel/2009-08/msg00835.html

Cheers

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-10-21  2:24 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-14 17:34 [Qemu-devel] [PATCH 00/16] Port rest of vga devices to vmstate Juan Quintela
2009-10-14 17:34 ` [Qemu-devel] [PATCH 01/16] vga: create is_vbe_vmstate field Juan Quintela
2009-10-14 17:34 ` [Qemu-devel] [PATCH 02/16] vmstate: Add support for partial buffers transmission Juan Quintela
2009-10-14 17:34 ` [Qemu-devel] [PATCH 03/16] vga: port vga_common_save/load to vmstate Juan Quintela
2009-10-14 17:34 ` [Qemu-devel] [PATCH 04/16] vga: port vga-isa-mm " Juan Quintela
2009-10-14 17:34 ` [Qemu-devel] [PATCH 05/16] vga: port vga-isa " Juan Quintela
2009-10-14 17:34 ` [Qemu-devel] [PATCH 06/16] vga: port vmware std vga " Juan Quintela
2009-10-14 17:34 ` [Qemu-devel] [PATCH 07/16] vga: port vga-pci " Juan Quintela
2009-10-14 17:34 ` [Qemu-devel] [PATCH 08/16] vga: remove unused vga_common_save/load Juan Quintela
2009-10-14 17:35 ` [Qemu-devel] [PATCH 09/16] vmware_vga: Pass pci_vmsga_state_t arg no VGACommonState Juan Quintela
2009-10-14 17:35 ` [Qemu-devel] [PATCH 10/16] vmware_vga: Remove uselss casts from void * Juan Quintela
2009-10-14 17:35 ` [Qemu-devel] [PATCH 11/16] vmware_vga: qemu_malloc() returns " Juan Quintela
2009-10-14 17:35 ` [Qemu-devel] [PATCH 12/16] vmware_vga: remove !EMBED_STDVGA code Juan Quintela
2009-10-14 18:15   ` andrzej zaborowski
2009-10-14 19:28     ` [Qemu-devel] " Juan Quintela
2009-10-14 19:42       ` andrzej zaborowski
2009-10-14 20:04         ` Juan Quintela
2009-10-21  2:23           ` andrzej zaborowski
2009-10-14 17:35 ` [Qemu-devel] [PATCH 13/16] vmstate: Add VMSTATE_UINT32_VARRAY support Juan Quintela
2009-10-14 17:35 ` [Qemu-devel] [PATCH 14/16] vmware_vga: scratch is really an array of uint32_t Juan Quintela
2009-10-14 17:35 ` [Qemu-devel] [PATCH 15/16] vmware_vga: the support to change dinamically depth is not there Juan Quintela
2009-10-14 17:35 ` [Qemu-devel] [PATCH 16/16] vmware_vga: port to vmstate Juan Quintela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).