hw/intc/loongarch_extioi: Add pre_save interface
authorBibo Mao <maobibo@loongson.cn>
Fri, 8 Nov 2024 07:42:05 +0000 (15:42 +0800)
committerBibo Mao <maobibo@loongson.cn>
Thu, 19 Dec 2024 07:23:30 +0000 (15:23 +0800)
Add vmstate pre_save interface, which can be used extioi kvm driver
in future.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
hw/intc/loongarch_extioi_common.c
include/hw/intc/loongarch_extioi_common.h

index 428d105f7888b645e2e0a0710eecc0bd2b764577..e50431f124a3a09ebe2de7e099edc60089aa3676 100644 (file)
@@ -20,6 +20,18 @@ static void loongarch_extioi_common_realize(DeviceState *dev, Error **errp)
     }
 }
 
+static int loongarch_extioi_common_pre_save(void *opaque)
+{
+    LoongArchExtIOICommonState *s = (LoongArchExtIOICommonState *)opaque;
+    LoongArchExtIOICommonClass *lecc = LOONGARCH_EXTIOI_COMMON_GET_CLASS(s);
+
+    if (lecc->pre_save) {
+        return lecc->pre_save(s);
+    }
+
+    return 0;
+}
+
 static int loongarch_extioi_common_post_load(void *opaque, int version_id)
 {
     LoongArchExtIOICommonState *s = (LoongArchExtIOICommonState *)opaque;
@@ -46,6 +58,7 @@ static const VMStateDescription vmstate_loongarch_extioi = {
     .name = "loongarch.extioi",
     .version_id = 3,
     .minimum_version_id = 3,
+    .pre_save  = loongarch_extioi_common_pre_save,
     .post_load = loongarch_extioi_common_post_load,
     .fields = (const VMStateField[]) {
         VMSTATE_UINT32_ARRAY(bounce, LoongArchExtIOICommonState,
index d45caa45f2a1eafbd85c2825e636b284d5672e53..f6bc778a855db14978199abf78a12f2dac394066 100644 (file)
@@ -92,6 +92,7 @@ struct LoongArchExtIOICommonClass {
     SysBusDeviceClass parent_class;
 
     DeviceRealize parent_realize;
+    int (*pre_save)(void *s);
     int (*post_load)(void *s, int version_id);
 };
 #endif /* LOONGARCH_EXTIOI_H */