diff mbox

[2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create()

Message ID 1368607419-15178-2-git-send-email-xiawenc@linux.vnet.ibm.com
State New
Headers show

Commit Message

Wayne Xia May 15, 2013, 8:43 a.m. UTC
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 block/qcow2-snapshot.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

Comments

Stefan Hajnoczi May 16, 2013, 9:34 a.m. UTC | #1
On Wed, May 15, 2013 at 04:43:39PM +0800, Wenchao Xia wrote:
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  block/qcow2-snapshot.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
> index a6065a9..ad030f9 100644
> --- a/block/qcow2-snapshot.c
> +++ b/block/qcow2-snapshot.c
> @@ -410,6 +410,17 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
>  #endif
>      return 0;
>  
> +restore_refcount:
> +    ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset,
> +                                         s->l1_size, -1);
> +    if (ret < 0) {
> +        /* Nothing can be done none now, need image check later */
> +        error_report("qcow2: Error in restoring refcount in snapshot");
> +    }
> +
> +dealloc_cluster:
> +    qcow2_free_clusters(bs, sn->l1_table_offset, sn->l1_size);
> +
>  fail:
>      g_free(sn->id_str);
>      g_free(sn->name);

This patch is missing goto restore_refcount and goto dealloc_cluster.
diff mbox

Patch

diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index a6065a9..ad030f9 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -410,6 +410,17 @@  int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
 #endif
     return 0;
 
+restore_refcount:
+    ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset,
+                                         s->l1_size, -1);
+    if (ret < 0) {
+        /* Nothing can be done none now, need image check later */
+        error_report("qcow2: Error in restoring refcount in snapshot");
+    }
+
+dealloc_cluster:
+    qcow2_free_clusters(bs, sn->l1_table_offset, sn->l1_size);
+
 fail:
     g_free(sn->id_str);
     g_free(sn->name);