[RFC 04/22] ui/vdagent: move to new migration APIs

Vladimir Sementsov-Ogievskiy posted 22 patches 2 weeks, 2 days ago
[RFC 04/22] ui/vdagent: move to new migration APIs
Posted by Vladimir Sementsov-Ogievskiy 2 weeks, 2 days ago
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 ui/vdagent.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/ui/vdagent.c b/ui/vdagent.c
index ddb91e75c6..4388e90c0b 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -923,7 +923,7 @@ static void vdagent_chr_class_init(ObjectClass *oc, const void *data)
     cc->chr_accept_input = vdagent_chr_accept_input;
 }
 
-static int post_load(void *opaque, int version_id)
+static bool post_load(void *opaque, int version_id, Error **errp)
 {
     VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(opaque);
 
@@ -935,7 +935,7 @@ static int post_load(void *opaque, int version_id)
         vdagent_clipboard_peer_register(vd);
     }
 
-    return 0;
+    return true;
 }
 
 static const VMStateDescription vmstate_chunk = {
@@ -975,15 +975,16 @@ static const VMStateDescription vmstate_cbinfo_array = {
     }
 };
 
-static int put_cbinfo(QEMUFile *f, void *pv, size_t size,
-                      const VMStateField *field, JSONWriter *vmdesc)
+static bool save_cbinfo(QEMUFile *f, void *pv, size_t size,
+                        const VMStateField *field, JSONWriter *vmdesc,
+                        Error **errp)
 {
     VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(pv);
     struct CBInfoArray cbinfo = {};
     int i;
 
     if (!have_clipboard(vd)) {
-        return 0;
+        return true;
     }
 
     for (i = 0; i < QEMU_CLIPBOARD_SELECTION__COUNT; i++) {
@@ -992,29 +993,24 @@ static int put_cbinfo(QEMUFile *f, void *pv, size_t size,
         }
     }
 
-    return vmstate_save_state(f, &vmstate_cbinfo_array, &cbinfo, vmdesc,
-                              &error_fatal);
+    return vmstate_save_vmsd(f, &vmstate_cbinfo_array, &cbinfo, vmdesc, errp);
 }
 
-static int get_cbinfo(QEMUFile *f, void *pv, size_t size,
-                      const VMStateField *field)
+static bool load_cbinfo(QEMUFile *f, void *pv, size_t size,
+                        const VMStateField *field, Error **errp)
 {
     VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(pv);
     struct CBInfoArray cbinfo = {};
-    int i, ret;
-    Error *local_err = NULL;
+    int i;
 
     if (!have_clipboard(vd)) {
-        return 0;
+        return true;
     }
 
     vdagent_clipboard_peer_register(vd);
 
-    ret = vmstate_load_state(f, &vmstate_cbinfo_array, &cbinfo, 0,
-                             &local_err);
-    if (ret) {
-        error_report_err(local_err);
-        return ret;
+    if (!vmstate_load_vmsd(f, &vmstate_cbinfo_array, &cbinfo, 0, errp)) {
+        return false;
     }
 
     for (i = 0; i < cbinfo.n; i++) {
@@ -1025,20 +1021,20 @@ static int get_cbinfo(QEMUFile *f, void *pv, size_t size,
         qemu_clipboard_update(info);
     }
 
-    return 0;
+    return true;
 }
 
 static const VMStateInfo vmstate_cbinfos = {
     .name = "vdagent/cbinfos",
-    .get  = get_cbinfo,
-    .put  = put_cbinfo,
+    .load  = load_cbinfo,
+    .save  = save_cbinfo,
 };
 
 static const VMStateDescription vmstate_vdagent = {
     .name = "vdagent",
     .version_id = 0,
     .minimum_version_id = 0,
-    .post_load = post_load,
+    .post_load_errp = post_load,
     .fields = (const VMStateField[]) {
         VMSTATE_BOOL(connected, VDAgentChardev),
         VMSTATE_UINT32(caps, VDAgentChardev),
-- 
2.48.1