Skip to content

Commit

Permalink
ramfb-standalone: add migration support
Browse files Browse the repository at this point in the history
Add a "ramfb-dev" section whenever "x-migrate" is turned on. Turn it off
by default on machines <= 8.1 for compatibility reasons.

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 303c33e commit a1e88d2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions hw/core/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

GlobalProperty hw_compat_8_1[] = {
{ TYPE_PCI_BRIDGE, "x-pci-express-writeable-slt-bug", "true" },
{ "ramfb", "x-migrate", "off" },
};
const size_t hw_compat_8_1_len = G_N_ELEMENTS(hw_compat_8_1);

Expand Down
27 changes: 27 additions & 0 deletions hw/display/ramfb-standalone.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "qemu/osdep.h"
#include "migration/vmstate.h"
#include "qapi/error.h"
#include "qemu/module.h"
#include "hw/loader.h"
Expand All @@ -15,6 +16,7 @@ struct RAMFBStandaloneState {
SysBusDevice parent_obj;
QemuConsole *con;
RAMFBState *state;
bool migrate;
};

static void display_update_wrapper(void *dev)
Expand All @@ -40,14 +42,39 @@ static void ramfb_realizefn(DeviceState *dev, Error **errp)
ramfb->state = ramfb_setup(errp);
}

static bool migrate_needed(void *opaque)
{
RAMFBStandaloneState *ramfb = RAMFB(opaque);

return ramfb->migrate;
}

static const VMStateDescription ramfb_dev_vmstate = {
.name = "ramfb-dev",
.version_id = 1,
.minimum_version_id = 1,
.needed = migrate_needed,
.fields = (VMStateField[]) {
VMSTATE_STRUCT_POINTER(state, RAMFBStandaloneState, ramfb_vmstate, RAMFBState),
VMSTATE_END_OF_LIST()
}
};

static Property ramfb_properties[] = {
DEFINE_PROP_BOOL("x-migrate", RAMFBStandaloneState, migrate, true),
DEFINE_PROP_END_OF_LIST(),
};

static void ramfb_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);

set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
dc->vmsd = &ramfb_dev_vmstate;
dc->realize = ramfb_realizefn;
dc->desc = "ram framebuffer standalone device";
dc->user_creatable = true;
device_class_set_props(dc, ramfb_properties);
}

static const TypeInfo ramfb_info = {
Expand Down

0 comments on commit a1e88d2

Please sign in to comment.