[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 2/2] sheepdog: support 'qemu-img snapshot -a'
From: |
Liu Yuan |
Subject: |
[Qemu-devel] [PATCH v2 2/2] sheepdog: support 'qemu-img snapshot -a' |
Date: |
Fri, 7 Jun 2013 22:15:51 +0800 |
Just call sd_create_branch() to rollback the image is good enough
Cc: address@hidden
Cc: MORITA Kazutaka <address@hidden>
Cc: Kevin Wolf <address@hidden>
Cc: Stefan Hajnoczi <address@hidden>
Signed-off-by: Liu Yuan <address@hidden>
---
block/sheepdog.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 94218ac..c128b37 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2071,14 +2071,21 @@ static int sd_snapshot_goto(BlockDriverState *bs, const
char *snapshot_id)
goto out;
}
+ s->is_snapshot = true;
+
if (!s->inode.vm_state_size) {
- error_report("Invalid snapshot");
- ret = -ENOENT;
- goto out;
+ /*
+ * qemu-img asks us to rollback, we can't rely on the write to create
+ * the branch, so do it right now. We can call sd_create_branch() right
+ * here only when vm_state_size == 0 because it changes vdi_id
+ * internally, otherwise we will read the wrong vmstate if any.
+ */
+ ret = sd_create_branch(s);
+ if (ret) {
+ goto out;
+ }
}
- s->is_snapshot = true;
-
g_free(old_s);
return 0;
--
1.7.9.5