From 14a765e5d4dc8227fb7028af132cee43e6fdcec0 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 31 Mar 2010 13:24:25 -0300 Subject: [PATCH 10/66] savevm: Fix -loadvm to report errors to stderr, not the monitor RH-Author: Markus Armbruster Message-id: <1270041921-28969-11-git-send-email-armbru@redhat.com> Patchwork-id: 8236 O-Subject: [PATCH 10/66] savevm: Fix -loadvm to report errors to stderr, not the monitor Bugzilla: 579470 RH-Acked-by: Juan Quintela RH-Acked-by: Kevin Wolf RH-Acked-by: Luiz Capitulino A monitor may not even exist. Change load_vmstate() to use qemu_error() instead of monitor_printf(). Parameter mon is now unused, remove it. (cherry picked from commit 03cd4655cbbc304f355deffd3413f7e3cbbcbe5e) --- monitor.c | 2 +- savevm.c | 24 +++++++++++------------- sysemu.h | 2 +- vl.c | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) Signed-off-by: Eduardo Habkost --- monitor.c | 2 +- savevm.c | 24 +++++++++++------------- sysemu.h | 2 +- vl.c | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/monitor.c b/monitor.c index 4591848..ee63437 100644 --- a/monitor.c +++ b/monitor.c @@ -2580,7 +2580,7 @@ static void do_loadvm(Monitor *mon, const QDict *qdict) vm_stop(0); - if (load_vmstate(mon, name) >= 0 && saved_vm_running) + if (load_vmstate(name) >= 0 && saved_vm_running) vm_start(); } diff --git a/savevm.c b/savevm.c index 2fd3de6..098dbcf 100644 --- a/savevm.c +++ b/savevm.c @@ -1756,7 +1756,7 @@ void do_savevm(Monitor *mon, const QDict *qdict) vm_start(); } -int load_vmstate(Monitor *mon, const char *name) +int load_vmstate(const char *name) { DriveInfo *dinfo; BlockDriverState *bs, *bs1; @@ -1766,7 +1766,7 @@ int load_vmstate(Monitor *mon, const char *name) bs = get_bs_snapshots(); if (!bs) { - monitor_printf(mon, "No block device supports snapshots\n"); + qemu_error("No block device supports snapshots\n"); return -EINVAL; } @@ -1779,21 +1779,19 @@ int load_vmstate(Monitor *mon, const char *name) ret = bdrv_snapshot_goto(bs1, name); if (ret < 0) { if (bs != bs1) - monitor_printf(mon, "Warning: "); + qemu_error("Warning: "); switch(ret) { case -ENOTSUP: - monitor_printf(mon, - "Snapshots not supported on device '%s'\n", - bdrv_get_device_name(bs1)); + qemu_error("Snapshots not supported on device '%s'\n", + bdrv_get_device_name(bs1)); break; case -ENOENT: - monitor_printf(mon, "Could not find snapshot '%s' on " - "device '%s'\n", - name, bdrv_get_device_name(bs1)); + qemu_error("Could not find snapshot '%s' on device '%s'\n", + name, bdrv_get_device_name(bs1)); break; default: - monitor_printf(mon, "Error %d while activating snapshot on" - " '%s'\n", ret, bdrv_get_device_name(bs1)); + qemu_error("Error %d while activating snapshot on '%s'\n", + ret, bdrv_get_device_name(bs1)); break; } /* fatal on snapshot block device */ @@ -1811,13 +1809,13 @@ int load_vmstate(Monitor *mon, const char *name) /* restore the VM state */ f = qemu_fopen_bdrv(bs, 0); if (!f) { - monitor_printf(mon, "Could not open VM state file\n"); + qemu_error("Could not open VM state file\n"); return -EINVAL; } ret = qemu_loadvm_state(f); qemu_fclose(f); if (ret < 0) { - monitor_printf(mon, "Error %d while loading VM state\n", ret); + qemu_error("Error %d while loading VM state\n", ret); return ret; } return 0; diff --git a/sysemu.h b/sysemu.h index c27018f..08008f4 100644 --- a/sysemu.h +++ b/sysemu.h @@ -55,7 +55,7 @@ extern qemu_irq qemu_system_powerdown; void qemu_system_reset(void); void do_savevm(Monitor *mon, const QDict *qdict); -int load_vmstate(Monitor *mon, const char *name); +int load_vmstate(const char *name); void do_delvm(Monitor *mon, const QDict *qdict); void do_info_snapshots(Monitor *mon); diff --git a/vl.c b/vl.c index 670b61b..94db683 100644 --- a/vl.c +++ b/vl.c @@ -6330,7 +6330,7 @@ int main(int argc, char **argv, char **envp) qemu_system_reset(); if (loadvm) { - if (load_vmstate(cur_mon, loadvm) < 0) { + if (load_vmstate(loadvm) < 0) { autostart = 0; } } -- 1.7.0.3