From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, armbru@redhat.com
Cc: kraxel@redhat.com, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] save_vmstate: Convert to Error** from Monitor *
Date: Mon, 20 Mar 2017 17:38:39 +0000 [thread overview]
Message-ID: <20170320173840.3626-2-dgilbert@redhat.com> (raw)
In-Reply-To: <20170320173840.3626-1-dgilbert@redhat.com>
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
A bit more consistent and it removes one of the less necessary uses
of cur_mon.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
include/sysemu/sysemu.h | 2 +-
migration/savevm.c | 31 ++++++++++++++++++-------------
replay/replay-snapshot.c | 6 ++++--
3 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 576c7ce..26e1a7e 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -76,7 +76,7 @@ void qemu_add_machine_init_done_notifier(Notifier *notify);
void qemu_remove_machine_init_done_notifier(Notifier *notify);
void hmp_savevm(Monitor *mon, const QDict *qdict);
-int save_vmstate(Monitor *mon, const char *name);
+int save_vmstate(const char *name, Error **errp);
int load_vmstate(const char *name);
void hmp_delvm(Monitor *mon, const QDict *qdict);
void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
diff --git a/migration/savevm.c b/migration/savevm.c
index 3b19a4a..361a926 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2071,7 +2071,7 @@ int qemu_loadvm_state(QEMUFile *f)
return ret;
}
-int save_vmstate(Monitor *mon, const char *name)
+int save_vmstate(const char *name, Error **errp)
{
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
@@ -2085,8 +2085,8 @@ int save_vmstate(Monitor *mon, const char *name)
AioContext *aio_context;
if (!bdrv_all_can_snapshot(&bs)) {
- monitor_printf(mon, "Device '%s' is writable but does not "
- "support snapshots.\n", bdrv_get_device_name(bs));
+ error_setg(errp, "Device '%s' is writable but does not "
+ "support snapshots", bdrv_get_device_name(bs));
return ret;
}
@@ -2094,16 +2094,17 @@ int save_vmstate(Monitor *mon, const char *name)
if (name) {
ret = bdrv_all_delete_snapshot(name, &bs1, &local_err);
if (ret < 0) {
- error_reportf_err(local_err,
- "Error while deleting snapshot on device '%s': ",
- bdrv_get_device_name(bs1));
+ error_propagate(errp, local_err);
+ error_prepend(errp,
+ "Error while deleting snapshot on device '%s': ",
+ bdrv_get_device_name(bs1));
return ret;
}
}
bs = bdrv_all_find_vmstate_bs();
if (bs == NULL) {
- monitor_printf(mon, "No block device can accept snapshots\n");
+ error_setg(errp, "No block device can accept snapshots");
return ret;
}
aio_context = bdrv_get_aio_context(bs);
@@ -2112,7 +2113,7 @@ int save_vmstate(Monitor *mon, const char *name)
ret = global_state_store();
if (ret) {
- monitor_printf(mon, "Error saving global state\n");
+ error_setg(errp, "Error saving global state");
return ret;
}
vm_stop(RUN_STATE_SAVE_VM);
@@ -2144,21 +2145,21 @@ int save_vmstate(Monitor *mon, const char *name)
/* save the VM state */
f = qemu_fopen_bdrv(bs, 1);
if (!f) {
- monitor_printf(mon, "Could not open VM state file\n");
+ error_setg(errp, "Could not open VM state file");
goto the_end;
}
ret = qemu_savevm_state(f, &local_err);
vm_state_size = qemu_ftell(f);
qemu_fclose(f);
if (ret < 0) {
- error_report_err(local_err);
+ error_propagate(errp, local_err);
goto the_end;
}
ret = bdrv_all_create_snapshot(sn, bs, vm_state_size, &bs);
if (ret < 0) {
- monitor_printf(mon, "Error while creating snapshot on '%s'\n",
- bdrv_get_device_name(bs));
+ error_setg(errp, "Error while creating snapshot on '%s'",
+ bdrv_get_device_name(bs));
goto the_end;
}
@@ -2174,7 +2175,11 @@ int save_vmstate(Monitor *mon, const char *name)
void hmp_savevm(Monitor *mon, const QDict *qdict)
{
- save_vmstate(mon, qdict_get_try_str(qdict, "name"));
+ Error *local_err = NULL;
+ save_vmstate(qdict_get_try_str(qdict, "name"), &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
}
void qmp_xen_save_devices_state(const char *filename, Error **errp)
diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c
index 65e2d37..49b21f0 100644
--- a/replay/replay-snapshot.c
+++ b/replay/replay-snapshot.c
@@ -64,8 +64,10 @@ void replay_vmstate_init(void)
{
if (replay_snapshot) {
if (replay_mode == REPLAY_MODE_RECORD) {
- if (save_vmstate(cur_mon, replay_snapshot) != 0) {
- error_report("Could not create snapshot for icount record");
+ Error *local_err = NULL;
+ if (save_vmstate(replay_snapshot, &local_err) != 0) {
+ error_reportf_err(local_err,
+ "Could not create snapshot for icount record: ");
exit(1);
}
} else if (replay_mode == REPLAY_MODE_PLAY) {
--
2.9.3
next prev parent reply other threads:[~2017-03-20 17:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 17:38 [Qemu-devel] [PATCH 0/2 for 2.10] Remove some monitor_printf's Dr. David Alan Gilbert (git)
2017-03-20 17:38 ` Dr. David Alan Gilbert (git) [this message]
2017-03-20 18:05 ` [Qemu-devel] [PATCH 1/2] save_vmstate: Convert to Error** from Monitor * Juan Quintela
2017-03-20 17:38 ` [Qemu-devel] [PATCH 2/2] wavcapture: Convert to error_report Dr. David Alan Gilbert (git)
2017-03-21 6:38 ` Gerd Hoffmann
2017-06-13 11:26 ` Dr. David Alan Gilbert
2017-03-21 12:15 ` [Qemu-devel] [PATCH 0/2 for 2.10] Remove some monitor_printf's Markus Armbruster
2017-03-21 12:22 ` 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=20170320173840.3626-2-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.