@samitouri / QOSamiQemu / commits / 949f0e231a

migration/cpr: move to new migration APIs

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-15-vsementsov@yandex-team.ru Signed-off-by: Fabiano Rosas <farosas@suse.de>

Vladimir Sementsov-Ogievskiy committed Mar 5, 2026 at 00:22 UTC 949f0e231a087d3cea92bb1e12b984d514de29f9
2 files changed +10 -14
include/migration/cpr.h
+1 -1
@@ -43,7 +43,7 @@ void cpr_set_incoming_mode(MigMode mode);
43 bool cpr_is_incoming(void);
44
45 bool cpr_state_save(MigrationChannel *channel, Error **errp);
46 -int cpr_state_load(MigrationChannel *channel, Error **errp);
46 +bool cpr_state_load(MigrationChannel *channel, Error **errp);
47 void cpr_state_close(void);
48 struct QIOChannel *cpr_state_ioc(void);
49
migration/cpr.c
+9 -13
@@ -178,7 +178,6 @@ bool cpr_is_incoming(void)
178
179 bool cpr_state_save(MigrationChannel *channel, Error **errp)
180 {
181 - int ret;
181 QEMUFile *f;
182 MigMode mode = migrate_mode();
183
@@ -199,8 +198,7 @@ bool cpr_state_save(MigrationChannel *channel, Error **errp)
198 qemu_put_be32(f, QEMU_CPR_FILE_MAGIC);
199 qemu_put_be32(f, QEMU_CPR_FILE_VERSION);
200
202 - ret = vmstate_save_state(f, &vmstate_cpr_state, &cpr_state, 0, errp);
203 - if (ret) {
201 + if (!vmstate_save_vmsd(f, &vmstate_cpr_state, &cpr_state, 0, errp)) {
202 qemu_fclose(f);
203 return false;
204 }
@@ -223,9 +221,8 @@ bool cpr_state_save(MigrationChannel *channel, Error **errp)
221 return true;
222 }
223
226 -int cpr_state_load(MigrationChannel *channel, Error **errp)
224 +bool cpr_state_load(MigrationChannel *channel, Error **errp)
225 {
228 - int ret;
226 uint32_t v;
227 QEMUFile *f;
228 MigMode mode = 0;
@@ -241,10 +238,10 @@ int cpr_state_load(MigrationChannel *channel, Error **errp)
238 cpr_set_incoming_mode(mode);
239 f = cpr_transfer_input(channel, errp);
240 } else {
244 - return 0;
241 + return true;
242 }
243 if (!f) {
247 - return -1;
244 + return false;
245 }
246
247 trace_cpr_state_load(MigMode_str(mode));
@@ -254,19 +251,18 @@ int cpr_state_load(MigrationChannel *channel, Error **errp)
251 if (v != QEMU_CPR_FILE_MAGIC) {
252 error_setg(errp, "Not a migration stream (bad magic %x)", v);
253 qemu_fclose(f);
257 - return -EINVAL;
254 + return false;
255 }
256 v = qemu_get_be32(f);
257 if (v != QEMU_CPR_FILE_VERSION) {
258 error_setg(errp, "Unsupported migration stream version %d", v);
259 qemu_fclose(f);
263 - return -ENOTSUP;
260 + return false;
261 }
262
266 - ret = vmstate_load_state(f, &vmstate_cpr_state, &cpr_state, 1, errp);
267 - if (ret) {
263 + if (!vmstate_load_vmsd(f, &vmstate_cpr_state, &cpr_state, 1, errp)) {
264 qemu_fclose(f);
269 - return ret;
265 + return false;
266 }
267
268 if (migrate_mode() == MIG_MODE_CPR_EXEC) {
@@ -280,7 +276,7 @@ int cpr_state_load(MigrationChannel *channel, Error **errp)
276 */
277 cpr_state_file = f;
278
283 - return ret;
279 + return true;
280 }
281
282 void cpr_state_close(void)