[sheepdog] [PATCH v2 2/2] sheepdog: support 'qemu-img snapshot -a'
Liu Yuan
namei.unix at gmail.com
Fri Jun 7 16:15:51 CEST 2013
Just call sd_create_branch() to rollback the image is good enough
Cc: qemu-devel at nongnu.org
Cc: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf at redhat.com>
Cc: Stefan Hajnoczi <stefanha at redhat.com>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
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
More information about the sheepdog
mailing list