Patchwork [02/13] block: add error parameter to del_existing_snapshots()

login
register
mail settings
Submitter Pavel Hrdina
Date Jan. 9, 2013, 3:17 p.m.
Message ID <aada7ef4dc64180addb40531ba517c1dcdfe68c1.1357741229.git.phrdina@redhat.com>
Download mbox | patch
Permalink /patch/210753/
State New
Headers show

Comments

Pavel Hrdina - Jan. 9, 2013, 3:17 p.m.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 savevm.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Patch

diff --git a/savevm.c b/savevm.c
index b1acbf1..fae0cba 100644
--- a/savevm.c
+++ b/savevm.c
@@ -2061,7 +2061,7 @@  static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
 /*
  * Deletes snapshots of a given name in all opened images.
  */
-static int del_existing_snapshots(Monitor *mon, const char *name)
+static int del_existing_snapshots(const char *name, Error **errp)
 {
     BlockDriverState *bs;
     QEMUSnapshotInfo sn1, *snapshot = &sn1;
@@ -2074,9 +2074,8 @@  static int del_existing_snapshots(Monitor *mon, const char *name)
         {
             ret = bdrv_snapshot_delete(bs, name);
             if (ret < 0) {
-                monitor_printf(mon,
-                               "Error while deleting snapshot on '%s'\n",
-                               bdrv_get_device_name(bs));
+                error_setg(errp, "Error while deleting snapshot on '%s'",
+                           bdrv_get_device_name(bs));
                 return -1;
             }
         }
@@ -2101,6 +2100,7 @@  void do_savevm(Monitor *mon, const QDict *qdict)
     struct tm tm;
 #endif
     const char *name = qdict_get_try_str(qdict, "name");
+    Error *local_err = NULL;
 
     /* Verify if there is a device that doesn't support snapshots and is writable */
     bs = NULL;
@@ -2161,7 +2161,9 @@  void do_savevm(Monitor *mon, const QDict *qdict)
     }
 
     /* Delete old snapshots of the same name */
-    if (name && del_existing_snapshots(mon, name) < 0) {
+    if (name && del_existing_snapshots(name, &local_err) < 0) {
+        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
+        error_free(local_err);
         goto the_end;
     }