aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2023-10-09 10:32:45 +0400
committerCédric Le Goater <clg@redhat.com>2023-10-18 10:10:49 +0200
commit303c33e606f629c7467b457a19c53698b114ee0f (patch)
tree169ee41df5388ce4b3f80bc54141af3d579cfe60 /hw
parentc0f527f4cc6659f55279f7d774dd804a1504a401 (diff)
ramfb: add migration support
Implementing RAMFB migration is quite straightforward. One caveat is to treat the whole RAMFBCfg as a blob, since that's what is exposed to the guest directly. This avoid having to fiddle with endianness issues if we were to migrate fields individually as integers. The devices using RAMFB will have to include ramfb_vmstate in their migration description. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/display/ramfb.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/hw/display/ramfb.c b/hw/display/ramfb.c
index c2b002d534..477ef7272a 100644
--- a/hw/display/ramfb.c
+++ b/hw/display/ramfb.c
@@ -28,6 +28,8 @@ struct QEMU_PACKED RAMFBCfg {
uint32_t stride;
};
+typedef struct RAMFBCfg RAMFBCfg;
+
struct RAMFBState {
DisplaySurface *ds;
uint32_t width, height;
@@ -116,6 +118,23 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s)
dpy_gfx_update_full(con);
}
+static int ramfb_post_load(void *opaque, int version_id)
+{
+ ramfb_fw_cfg_write(opaque, 0, 0);
+ return 0;
+}
+
+const VMStateDescription ramfb_vmstate = {
+ .name = "ramfb",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .post_load = ramfb_post_load,
+ .fields = (VMStateField[]) {
+ VMSTATE_BUFFER_UNSAFE(cfg, RAMFBState, 0, sizeof(RAMFBCfg)),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
RAMFBState *ramfb_setup(Error **errp)
{
FWCfgState *fw_cfg = fw_cfg_find();