qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots()
@ 2013-05-15  8:43 Wenchao Xia
  2013-05-15  8:43 ` [Qemu-devel] [PATCH 2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create() Wenchao Xia
  2013-05-16  9:32 ` [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() Stefan Hajnoczi
  0 siblings, 2 replies; 5+ messages in thread
From: Wenchao Xia @ 2013-05-15  8:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, pbonzini, aliguori, Wenchao Xia, stefanha

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 block/qcow2-snapshot.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 992a5c8..a6065a9 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -268,6 +268,8 @@ static int qcow2_write_snapshots(BlockDriverState *bs)
     return 0;
 
 fail:
+    /* free the new snapshot table */
+    qcow2_free_clusters(bs, snapshots_offset, snapshots_size);
     return ret;
 }
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create()
  2013-05-15  8:43 [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() Wenchao Xia
@ 2013-05-15  8:43 ` Wenchao Xia
  2013-05-16  9:34   ` Stefan Hajnoczi
  2013-05-16  9:32 ` [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() Stefan Hajnoczi
  1 sibling, 1 reply; 5+ messages in thread
From: Wenchao Xia @ 2013-05-15  8:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, pbonzini, aliguori, Wenchao Xia, stefanha

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);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots()
  2013-05-15  8:43 [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() Wenchao Xia
  2013-05-15  8:43 ` [Qemu-devel] [PATCH 2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create() Wenchao Xia
@ 2013-05-16  9:32 ` Stefan Hajnoczi
  2013-05-17  4:58   ` Wenchao Xia
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2013-05-16  9:32 UTC (permalink / raw)
  To: Wenchao Xia; +Cc: kwolf, pbonzini, aliguori, qemu-devel

On Wed, May 15, 2013 at 04:43:38PM +0800, Wenchao Xia wrote:
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  block/qcow2-snapshot.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
> index 992a5c8..a6065a9 100644
> --- a/block/qcow2-snapshot.c
> +++ b/block/qcow2-snapshot.c
> @@ -268,6 +268,8 @@ static int qcow2_write_snapshots(BlockDriverState *bs)
>      return 0;
>  
>  fail:
> +    /* free the new snapshot table */
> +    qcow2_free_clusters(bs, snapshots_offset, snapshots_size);
>      return ret;
>  }

snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size);
offset = snapshots_offset;
if (offset < 0) {
    return offset;
}
ret = bdrv_flush(bs);
if (ret < 0) {
    return ret;
}

For completeness the bdrv_flush() return ret should be change to a goto
fail so that we cover all failure cases.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create()
  2013-05-15  8:43 ` [Qemu-devel] [PATCH 2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create() Wenchao Xia
@ 2013-05-16  9:34   ` Stefan Hajnoczi
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2013-05-16  9:34 UTC (permalink / raw)
  To: Wenchao Xia; +Cc: kwolf, pbonzini, aliguori, qemu-devel

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots()
  2013-05-16  9:32 ` [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() Stefan Hajnoczi
@ 2013-05-17  4:58   ` Wenchao Xia
  0 siblings, 0 replies; 5+ messages in thread
From: Wenchao Xia @ 2013-05-17  4:58 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: kwolf, pbonzini, aliguori, qemu-devel

于 2013-5-16 17:32, Stefan Hajnoczi 写道:
> On Wed, May 15, 2013 at 04:43:38PM +0800, Wenchao Xia wrote:
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>   block/qcow2-snapshot.c |    2 ++
>>   1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
>> index 992a5c8..a6065a9 100644
>> --- a/block/qcow2-snapshot.c
>> +++ b/block/qcow2-snapshot.c
>> @@ -268,6 +268,8 @@ static int qcow2_write_snapshots(BlockDriverState *bs)
>>       return 0;
>>
>>   fail:
>> +    /* free the new snapshot table */
>> +    qcow2_free_clusters(bs, snapshots_offset, snapshots_size);
>>       return ret;
>>   }
>
> snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size);
> offset = snapshots_offset;
> if (offset < 0) {
>      return offset;
> }
> ret = bdrv_flush(bs);
> if (ret < 0) {
>      return ret;
> }
>
> For completeness the bdrv_flush() return ret should be change to a goto
> fail so that we cover all failure cases.
>
   Ok, will add those.

-- 
Best Regards

Wenchao Xia

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-17  4:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-15  8:43 [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() Wenchao Xia
2013-05-15  8:43 ` [Qemu-devel] [PATCH 2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create() Wenchao Xia
2013-05-16  9:34   ` Stefan Hajnoczi
2013-05-16  9:32 ` [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() Stefan Hajnoczi
2013-05-17  4:58   ` Wenchao Xia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).