All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V2 2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create()
Date: Mon, 20 May 2013 10:17:50 +0800	[thread overview]
Message-ID: <519987CE.5010907@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130517092701.GC15001@stefanha-thinkpad.redhat.com>

于 2013-5-17 17:27, Stefan Hajnoczi 写道:
> On Fri, May 17, 2013 at 03:56:45PM +0800, Wenchao Xia wrote:
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>   block/qcow2-snapshot.c |   17 ++++++++++++++---
>>   1 files changed, 14 insertions(+), 3 deletions(-)
>>
>> diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
>> index 45da32d..033f705 100644
>> --- a/block/qcow2-snapshot.c
>> +++ b/block/qcow2-snapshot.c
>> @@ -367,7 +367,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
>>       ret = bdrv_pwrite(bs->file, sn->l1_table_offset, l1_table,
>>                         s->l1_size * sizeof(uint64_t));
>>       if (ret < 0) {
>> -        goto fail;
>> +        goto dealloc_cluster;
>>       }
>>
>>       g_free(l1_table);
>> @@ -380,7 +380,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
>>        */
>>       ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1);
>>       if (ret < 0) {
>> -        goto fail;
>> +        goto dealloc_cluster;
>>       }
>>
>>       /* Append the new snapshot to the snapshot list */
>> @@ -397,7 +397,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
>>       if (ret < 0) {
>>           g_free(s->snapshots);
>>           s->snapshots = old_snapshot_list;
>> -        goto fail;
>> +        goto restore_refcount;
>>       }
>>
>>       g_free(old_snapshot_list);
>> @@ -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);
>
> sn->l1_size is in uint64_t units, not in bytes.
>
> Do you have test cases to exercise these code paths?  Use blkdebug to
> inject errors at the right point so that the error code path is taken.
>
   OK, I'll try it.

-- 
Best Regards

Wenchao Xia

      reply	other threads:[~2013-05-20  2:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-17  7:56 [Qemu-devel] [PATCH V2 0/2] qcow2: try cancel the modification on fail in snapshot creation Wenchao Xia
2013-05-17  7:56 ` [Qemu-devel] [PATCH V2 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() Wenchao Xia
2013-05-17  9:19   ` Stefan Hajnoczi
2013-05-17  7:56 ` [Qemu-devel] [PATCH V2 2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create() Wenchao Xia
2013-05-17  9:27   ` Stefan Hajnoczi
2013-05-20  2:17     ` Wenchao Xia [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=519987CE.5010907@linux.vnet.ibm.com \
    --to=xiawenc@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.