aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2023-10-20 11:07:19 +0200
committerJuan Quintela <quintela@redhat.com>2023-11-01 16:13:58 +0100
commit71daf640d91d49a784ead059c9021070a2107008 (patch)
tree768ab05d2c456e6510c698876667624303894a2a
parent832685707fbe52b2525974a100a240338998e544 (diff)
downloadqemu-71daf640d91d49a784ead059c9021070a2107008.zip
qemu-71daf640d91d49a784ead059c9021070a2107008.tar.gz
qemu-71daf640d91d49a784ead059c9021070a2107008.tar.bz2
migration: Create vmstate_register_any()
We have lots of cases where we are using an instance_id==0 when we should be using VMSTATE_INSTANCE_ID_ANY (-1). Basically everything that can have more than one needs to have a proper instance_id or -1 and the system will take one for it. vmstate_register_any(): We register with -1. Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Message-ID: <20231020090731.28701-2-quintela@redhat.com>
-rw-r--r--include/migration/vmstate.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 1af1818..1ea97cc 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -1230,6 +1230,23 @@ static inline int vmstate_register(VMStateIf *obj, int instance_id,
opaque, -1, 0, NULL);
}
+/**
+ * vmstate_register_any() - legacy function to register state
+ * serialisation description and let the function choose the id
+ *
+ * New code shouldn't be using this function as QOM-ified devices have
+ * dc->vmsd to store the serialisation description.
+ *
+ * Returns: 0 on success, -1 on failure
+ */
+static inline int vmstate_register_any(VMStateIf *obj,
+ const VMStateDescription *vmsd,
+ void *opaque)
+{
+ return vmstate_register_with_alias_id(obj, VMSTATE_INSTANCE_ID_ANY, vmsd,
+ opaque, -1, 0, NULL);
+}
+
void vmstate_unregister(VMStateIf *obj, const VMStateDescription *vmsd,
void *opaque);