diff mbox

[v2,07/17] block: add error parameter to del_existing_snapshots()

Message ID 0e0b8429c8da2bc3b210d52e0e223bbf79cb5dcf.1355404685.git.phrdina@redhat.com
State New
Headers show

Commit Message

Pavel Hrdina Dec. 13, 2012, 3:40 p.m. UTC
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 savevm.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Luiz Capitulino Dec. 14, 2012, 4:42 p.m. UTC | #1
On Thu, 13 Dec 2012 16:40:41 +0100
Pavel Hrdina <phrdina@redhat.com> wrote:

> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  savevm.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/savevm.c b/savevm.c
> index 7ab7c7c..3ee7da5 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -2094,22 +2094,18 @@ static int bdrv_snapshot_find(BlockDriverState *bs,
>  /*
>   * 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;
> -    int ret;
>  
>      bs = NULL;
>      while ((bs = bdrv_next(bs))) {
>          if (bdrv_can_snapshot(bs) &&
>              bdrv_snapshot_find(bs, snapshot, name, NULL) >= 0)
>          {
> -            ret = bdrv_snapshot_delete(bs, name, NULL);
> -            if (ret < 0) {
> -                monitor_printf(mon,
> -                               "Error while deleting snapshot on '%s'\n",
> -                               bdrv_get_device_name(bs));
> +            if (bdrv_snapshot_delete(bs, name, errp) < 0) {
>                  return -1;
>              }
>          }
> @@ -2194,7 +2190,7 @@ 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, NULL) < 0) {

Where do you print the error message returned by
del_existing_snapshots()? Actually, you seem to be leaking the
error object...

>          goto the_end;
>      }
>
diff mbox

Patch

diff --git a/savevm.c b/savevm.c
index 7ab7c7c..3ee7da5 100644
--- a/savevm.c
+++ b/savevm.c
@@ -2094,22 +2094,18 @@  static int bdrv_snapshot_find(BlockDriverState *bs,
 /*
  * 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;
-    int ret;
 
     bs = NULL;
     while ((bs = bdrv_next(bs))) {
         if (bdrv_can_snapshot(bs) &&
             bdrv_snapshot_find(bs, snapshot, name, NULL) >= 0)
         {
-            ret = bdrv_snapshot_delete(bs, name, NULL);
-            if (ret < 0) {
-                monitor_printf(mon,
-                               "Error while deleting snapshot on '%s'\n",
-                               bdrv_get_device_name(bs));
+            if (bdrv_snapshot_delete(bs, name, errp) < 0) {
                 return -1;
             }
         }
@@ -2194,7 +2190,7 @@  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, NULL) < 0) {
         goto the_end;
     }