[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 4/5] ramfb-standalone: add migration support
From: |
marcandre . lureau |
Subject: |
[PATCH v3 4/5] ramfb-standalone: add migration support |
Date: |
Tue, 3 Oct 2023 12:56:43 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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>
---
hw/core/machine.c | 4 +++-
hw/display/ramfb-standalone.c | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index df40f10dfa..47a07d1d9b 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -30,7 +30,9 @@
#include "hw/virtio/virtio-pci.h"
#include "hw/virtio/virtio-net.h"
-GlobalProperty hw_compat_8_1[] = {};
+GlobalProperty hw_compat_8_1[] = {
+ { "ramfb", "x-migrate", "off" },
+};
const size_t hw_compat_8_1_len = G_N_ELEMENTS(hw_compat_8_1);
GlobalProperty hw_compat_8_0[] = {
diff --git a/hw/display/ramfb-standalone.c b/hw/display/ramfb-standalone.c
index 8c0094397f..a96e7ebcd9 100644
--- a/hw/display/ramfb-standalone.c
+++ b/hw/display/ramfb-standalone.c
@@ -1,4 +1,5 @@
#include "qemu/osdep.h"
+#include "migration/vmstate.h"
#include "qapi/error.h"
#include "qemu/module.h"
#include "hw/loader.h"
@@ -15,6 +16,7 @@ struct RAMFBStandaloneState {
SysBusDevice parent_obj;
QemuConsole *con;
RAMFBState *state;
+ bool migrate;
};
static void display_update_wrapper(void *dev)
@@ -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 = {
--
2.41.0
- [PATCH v3 0/5] WIP: ramfb: migration support, marcandre . lureau, 2023/10/03
- [PATCH v3 1/5] hw/core: remove needless includes, marcandre . lureau, 2023/10/03
- [PATCH v3 2/5] hw/pc: remove needless includes, marcandre . lureau, 2023/10/03
- [PATCH v3 4/5] ramfb-standalone: add migration support,
marcandre . lureau <=
- [PATCH v3 3/5] ramfb: add migration support, marcandre . lureau, 2023/10/03
- [PATCH v3 5/5] hw/vfio: add ramfb migration support, marcandre . lureau, 2023/10/03
- Re: [PATCH v3 5/5] hw/vfio: add ramfb migration support, Laszlo Ersek, 2023/10/03