@@ -4,6 +4,7 @@ common-obj-y += bus.o reset.o
common-obj-y += resettable.o
common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o
common-obj-$(CONFIG_SOFTMMU) += fw-path-provider.o
+common-obj-$(CONFIG_SOFTMMU) += qdev-vmstate.o
# irq.o needed for qdev GPIO handling:
common-obj-y += irq.o
common-obj-y += hotplug.o
new file mode 100644
@@ -0,0 +1,34 @@
+/*
+ * Device vmstate
+ *
+ * Copyright (c) 2019 GreenSocs
+ *
+ * Authors:
+ * Damien Hedde
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/qdev.h"
+#include "migration/vmstate.h"
+
+static bool device_vmstate_reset_needed(void *opaque)
+{
+ DeviceState *dev = (DeviceState *) opaque;
+ return dev->resetting;
+}
+
+const struct VMStateDescription device_vmstate_reset = {
+ .name = "device_reset",
+ .version_id = 0,
+ .minimum_version_id = 0,
+ .needed = device_vmstate_reset_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT32(resetting, DeviceState),
+ VMSTATE_BOOL(cold_reset_input.state, DeviceState),
+ VMSTATE_BOOL(warm_reset_input.state, DeviceState),
+ VMSTATE_END_OF_LIST()
+ }
+};
@@ -546,4 +546,10 @@ static inline bool qbus_is_hotpluggable(BusState *bus)
void device_listener_register(DeviceListener *listener);
void device_listener_unregister(DeviceListener *listener);
+/**
+ * device_vmstate_reset:
+ * vmstate entry for reset related state
+ */
+extern const struct VMStateDescription device_vmstate_reset;
+
#endif
The `device_vmstate_reset` can be added by device specialization, as vmsd subsection, to migrate the reset related device state part. It contains the resetting counter and the reset inputs current status. Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> --- hw/core/Makefile.objs | 1 + hw/core/qdev-vmstate.c | 34 ++++++++++++++++++++++++++++++++++ include/hw/qdev-core.h | 6 ++++++ 3 files changed, 41 insertions(+) create mode 100644 hw/core/qdev-vmstate.c