[RFC 01/22] migration: introduce vmstate_load_vmsd() and vmstate_save_vmsd()

Vladimir Sementsov-Ogievskiy posted 22 patches 2 weeks, 2 days ago
[RFC 01/22] migration: introduce vmstate_load_vmsd() and vmstate_save_vmsd()
Posted by Vladimir Sementsov-Ogievskiy 2 weeks, 2 days ago
Introduce new APIs, returning bool.
The analysis
https://lore.kernel.org/qemu-devel/aQDdRn8t0B8oE3gf@x1.local/
shows, that vmstate_load_state() return value actually only
used to check for success, specific errno values doesn't make
sense.

With this commit we introduce new functions with modern bool
interface, and in following commits we'll update the whole
code base to use them, and finally remove old vmstate_load_state()
and vmstate_save_state().

During this update, we'll see, that return values of both
functions is not significantly used, other then to check for
success.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 include/migration/vmstate.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index dbe330dd5f..0aac3b7a66 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -1228,6 +1228,20 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
                          void *opaque, JSONWriter *vmdesc,
                          int version_id, Error **errp);
 
+static inline bool vmstate_load_vmsd(
+    QEMUFile *f, const VMStateDescription *vmsd,
+    void *opaque, int version_id, Error **errp)
+{
+    return vmstate_load_state(f, vmsd, opaque, version_id, errp) >= 0;
+}
+
+static inline bool vmstate_save_vmsd(
+    QEMUFile *f, const VMStateDescription *vmsd,
+    void *opaque, JSONWriter *vmdesc, Error **errp)
+{
+    return vmstate_save_state(f, vmsd, opaque, vmdesc, errp) >= 0;
+}
+
 bool vmstate_section_needed(const VMStateDescription *vmsd, void *opaque);
 
 #define  VMSTATE_INSTANCE_ID_ANY  -1
-- 
2.48.1