From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, andrey.gruzdev@virtuozzo.com,
berrange@redhat.com, gaojinhao@huawei.com, armbru@redhat.com,
mst@redhat.com, philmd@redhat.com, wainersm@redhat.com
Subject: [PULL 18/27] migration: stop returning errno from load_snapshot()
Date: Thu, 4 Feb 2021 16:39:50 +0000 [thread overview]
Message-ID: <20210204163959.377618-19-dgilbert@redhat.com> (raw)
In-Reply-To: <20210204163959.377618-1-dgilbert@redhat.com>
From: Daniel P. Berrangé <berrange@redhat.com>
None of the callers care about the errno value since there is a full
Error object populated. This gives consistency with save_snapshot()
which already just returns a boolean value.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
[PMD: Return false/true instead of -1/0, document function]
Acked-by: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210204124834.774401-4-berrange@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
include/migration/snapshot.h | 10 +++++++++-
migration/savevm.c | 19 +++++++++----------
monitor/hmp-cmds.c | 2 +-
replay/replay-snapshot.c | 2 +-
softmmu/vl.c | 2 +-
5 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/include/migration/snapshot.h b/include/migration/snapshot.h
index 0eaf1ba0b1..d7d210820c 100644
--- a/include/migration/snapshot.h
+++ b/include/migration/snapshot.h
@@ -23,6 +23,14 @@
* On failure, store an error through @errp and return %false.
*/
bool save_snapshot(const char *name, Error **errp);
-int load_snapshot(const char *name, Error **errp);
+
+/**
+ * load_snapshot: Load an internal snapshot.
+ * @name: name of internal snapshot
+ * @errp: pointer to error object
+ * On success, return %true.
+ * On failure, store an error through @errp and return %false.
+ */
+bool load_snapshot(const char *name, Error **errp);
#endif
diff --git a/migration/savevm.c b/migration/savevm.c
index 63f1e63e51..b85eefd682 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2965,7 +2965,7 @@ void qmp_xen_load_devices_state(const char *filename, Error **errp)
migration_incoming_state_destroy();
}
-int load_snapshot(const char *name, Error **errp)
+bool load_snapshot(const char *name, Error **errp)
{
BlockDriverState *bs_vm_state;
QEMUSnapshotInfo sn;
@@ -2975,16 +2975,16 @@ int load_snapshot(const char *name, Error **errp)
MigrationIncomingState *mis = migration_incoming_get_current();
if (!bdrv_all_can_snapshot(errp)) {
- return -ENOTSUP;
+ return false;
}
ret = bdrv_all_find_snapshot(name, errp);
if (ret < 0) {
- return ret;
+ return false;
}
bs_vm_state = bdrv_all_find_vmstate_bs(errp);
if (!bs_vm_state) {
- return -ENOTSUP;
+ return false;
}
aio_context = bdrv_get_aio_context(bs_vm_state);
@@ -2993,11 +2993,11 @@ int load_snapshot(const char *name, Error **errp)
ret = bdrv_snapshot_find(bs_vm_state, &sn, name);
aio_context_release(aio_context);
if (ret < 0) {
- return ret;
+ return false;
} else if (sn.vm_state_size == 0) {
error_setg(errp, "This is a disk-only snapshot. Revert to it "
" offline using qemu-img");
- return -EINVAL;
+ return false;
}
/*
@@ -3018,7 +3018,6 @@ int load_snapshot(const char *name, Error **errp)
f = qemu_fopen_bdrv(bs_vm_state, 0);
if (!f) {
error_setg(errp, "Could not open VM state file");
- ret = -EINVAL;
goto err_drain;
}
@@ -3038,14 +3037,14 @@ int load_snapshot(const char *name, Error **errp)
if (ret < 0) {
error_setg(errp, "Error %d while loading VM state", ret);
- return ret;
+ return false;
}
- return 0;
+ return true;
err_drain:
bdrv_drain_all_end();
- return ret;
+ return false;
}
void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 2b954763e4..6ff050ac3d 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1139,7 +1139,7 @@ void hmp_loadvm(Monitor *mon, const QDict *qdict)
vm_stop(RUN_STATE_RESTORE_VM);
- if (load_snapshot(name, &err) == 0 && saved_vm_running) {
+ if (!load_snapshot(name, &err) && saved_vm_running) {
vm_start();
}
hmp_handle_error(mon, err);
diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c
index 4f2560d156..b289365937 100644
--- a/replay/replay-snapshot.c
+++ b/replay/replay-snapshot.c
@@ -83,7 +83,7 @@ void replay_vmstate_init(void)
exit(1);
}
} else if (replay_mode == REPLAY_MODE_PLAY) {
- if (load_snapshot(replay_snapshot, &err) != 0) {
+ if (!load_snapshot(replay_snapshot, &err)) {
error_report_err(err);
error_report("Could not load snapshot for icount replay");
exit(1);
diff --git a/softmmu/vl.c b/softmmu/vl.c
index bd55468669..8f655086b7 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2529,7 +2529,7 @@ void qmp_x_exit_preconfig(Error **errp)
if (loadvm) {
Error *local_err = NULL;
- if (load_snapshot(loadvm, &local_err) < 0) {
+ if (!load_snapshot(loadvm, &local_err)) {
error_report_err(local_err);
autostart = 0;
exit(1);
--
2.29.2
next prev parent reply other threads:[~2021-02-04 17:30 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-04 16:39 [PULL 00/27] migration queue Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 01/27] spapr_pci: Fix memory leak of vmstate_spapr_pci Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 02/27] savevm: Fix memory leak of vmstate_configuration Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 03/27] vmstate: Fix memory leak in vmstate_handle_alloc() Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 04/27] migration/qemu-file: Fix maybe uninitialized on qemu_get_buffer_in_place() Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 05/27] migration: introduce 'background-snapshot' migration capability Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 06/27] migration: introduce UFFD-WP low-level interface helpers Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 07/27] migration: support UFFD write fault processing in ram_save_iterate() Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 08/27] migration: implementation of background snapshot thread Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 09/27] migration: introduce 'userfaultfd-wrlat.py' script Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 10/27] migration: Fix migrate-set-parameters argument validation Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 11/27] migration: Clean up signed vs. unsigned XBZRLE cache-size Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 12/27] migration: Fix cache_init()'s "Failed to allocate" error messages Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 13/27] migration: Fix a few absurdly defective " Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 14/27] migration: Add blocker information Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 15/27] migration: Display the migration blockers Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 16/27] block: push error reporting into bdrv_all_*_snapshot functions Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 17/27] migration: Make save_snapshot() return bool, not 0/-1 Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` Dr. David Alan Gilbert (git) [this message]
2021-02-04 16:39 ` [PULL 19/27] block: add ability to specify list of blockdevs during snapshot Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 20/27] block: allow specifying name of block device for vmstate storage Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 21/27] block: rename and alter bdrv_all_find_snapshot semantics Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 22/27] migration: control whether snapshots are ovewritten Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 23/27] migration: wire up support for snapshot device selection Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 24/27] migration: introduce a delete_snapshot wrapper Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 25/27] iotests: add support for capturing and matching QMP events Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 26/27] iotests: fix loading of common.config from tests/ subdir Dr. David Alan Gilbert (git)
2021-02-04 16:39 ` [PULL 27/27] migration: introduce snapshot-{save, load, delete} QMP commands Dr. David Alan Gilbert (git)
2021-02-04 19:48 ` [PULL 00/27] migration queue Peter Maydell
2021-02-04 19:51 ` Dr. David Alan Gilbert
2021-02-08 10:42 ` Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210204163959.377618-19-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=andrey.gruzdev@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=gaojinhao@huawei.com \
--cc=mst@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wainersm@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).