diff mbox

[20/22] savevm: Convert do_savevm() to QObject

Message ID 1271797792-24571-21-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino April 20, 2010, 9:09 p.m. UTC
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qemu-monitor.hx |    3 ++-
 savevm.c        |    7 +++++--
 sysemu.h        |    2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 71cb1a2..9a699d4 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -242,7 +242,8 @@  ETEXI
         .args_type  = "name:s?",
         .params     = "[tag|id]",
         .help       = "save a VM snapshot. If no tag or id are provided, a new snapshot is created",
-        .mhandler.cmd = do_savevm,
+        .user_print = monitor_user_noop,
+        .mhandler.cmd_new = do_savevm,
     },
 
 STEXI
diff --git a/savevm.c b/savevm.c
index 8a9e9d1..39a935d 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1664,7 +1664,7 @@  static int del_existing_snapshots(const char *name)
     return 0;
 }
 
-void do_savevm(Monitor *mon, const QDict *qdict)
+int do_savevm(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     DriveInfo *dinfo;
     BlockDriverState *bs, *bs1;
@@ -1683,7 +1683,7 @@  void do_savevm(Monitor *mon, const QDict *qdict)
     bs = get_bs_snapshots();
     if (!bs) {
         qerror_report(QERR_SNAPSHOT_NO_DEVICE);
-        return;
+        return -1;
     }
 
     /* ??? Should this occur after vm_stop?  */
@@ -1717,6 +1717,7 @@  void do_savevm(Monitor *mon, const QDict *qdict)
 
     /* Delete old snapshots of the same name */
     if (name && del_existing_snapshots(name) < 0) {
+        ret = -1;
         goto the_end;
     }
 
@@ -1739,6 +1740,7 @@  void do_savevm(Monitor *mon, const QDict *qdict)
             sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
             ret = bdrv_snapshot_create(bs1, sn);
             if (ret < 0) {
+                /* FIXME: will report multiple failures in QMP */
                 qerror_report(QERR_SNAPSHOT_CREATE_FAILED,
                               bdrv_get_device_name(bs1), get_errno_string(ret));
             }
@@ -1748,6 +1750,7 @@  void do_savevm(Monitor *mon, const QDict *qdict)
  the_end:
     if (saved_vm_running)
         vm_start();
+    return (ret < 0 ? -1 : 0);
 }
 
 int load_vmstate(const char *name)
diff --git a/sysemu.h b/sysemu.h
index ee14b8c..8d8bb64 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -53,7 +53,7 @@  int qemu_exit_requested(void);
 extern qemu_irq qemu_system_powerdown;
 void qemu_system_reset(void);
 
-void do_savevm(Monitor *mon, const QDict *qdict);
+int do_savevm(Monitor *mon, const QDict *qdict, QObject **ret_data);
 int load_vmstate(const char *name);
 int do_delvm(Monitor *mon, const QDict *qdict, QObject **ret_data);
 void do_info_snapshots(Monitor *mon);