[RFC 11/22] hw/pci/shpc.c: use new migration APIs

Vladimir Sementsov-Ogievskiy posted 22 patches 2 weeks, 2 days ago
[RFC 11/22] hw/pci/shpc.c: use new migration APIs
Posted by Vladimir Sementsov-Ogievskiy 2 weeks, 2 days ago
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 hw/pci/shpc.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index aac6f2d034..15f79d6bec 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -759,31 +759,35 @@ void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
     shpc_cap_update_dword(d);
 }
 
-static int shpc_save(QEMUFile *f, void *pv, size_t size,
-                     const VMStateField *field, JSONWriter *vmdesc)
+static bool shpc_save(QEMUFile *f, void *pv, size_t size,
+                      const VMStateField *field, JSONWriter *vmdesc,
+                      Error **errp)
 {
     PCIDevice *d = container_of(pv, PCIDevice, shpc);
     qemu_put_buffer(f, d->shpc->config, SHPC_SIZEOF(d));
 
-    return 0;
+    return true;
 }
 
-static int shpc_load(QEMUFile *f, void *pv, size_t size,
-                     const VMStateField *field)
+static bool shpc_load(QEMUFile *f, void *pv, size_t size,
+                      const VMStateField *field, Error **errp)
 {
     PCIDevice *d = container_of(pv, PCIDevice, shpc);
     int ret = qemu_get_buffer(f, d->shpc->config, SHPC_SIZEOF(d));
     if (ret != SHPC_SIZEOF(d)) {
-        return -EINVAL;
+        error_setg(errp,
+                   "Failed to load SHPC config: expected %d bytes, got %d",
+                   SHPC_SIZEOF(d), ret);
+        return false;
     }
     /* Make sure we don't lose notifications. An extra interrupt is harmless. */
     d->shpc->msi_requested = 0;
     shpc_interrupt_update(d);
-    return 0;
+    return true;
 }
 
 const VMStateInfo shpc_vmstate_info = {
     .name = "shpc",
-    .get  = shpc_load,
-    .put  = shpc_save,
+    .load = shpc_load,
+    .save = shpc_save,
 };
-- 
2.48.1