Skip to content

Commit

Permalink
ramfb: add migration support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
elmarco authored and legoater committed Oct 18, 2023
1 parent c0f527f commit 303c33e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hw/display/ramfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct QEMU_PACKED RAMFBCfg {
uint32_t stride;
};

typedef struct RAMFBCfg RAMFBCfg;

struct RAMFBState {
DisplaySurface *ds;
uint32_t width, height;
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions include/hw/display/ramfb.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#ifndef RAMFB_H
#define RAMFB_H

#include "migration/vmstate.h"

/* ramfb.c */
typedef struct RAMFBState RAMFBState;
void ramfb_display_update(QemuConsole *con, RAMFBState *s);
RAMFBState *ramfb_setup(Error **errp);

extern const VMStateDescription ramfb_vmstate;

/* ramfb-standalone.c */
#define TYPE_RAMFB_DEVICE "ramfb"

Expand Down

0 comments on commit 303c33e

Please sign in to comment.