From: Liu Yuan <namei.unix@gmail.com>
To: sheepdog@lists.wpkg.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org,
MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Subject: [Qemu-devel] [PATCH v2 2/2] sheepdog: support 'qemu-img snapshot -a'
Date: Fri, 7 Jun 2013 22:15:51 +0800 [thread overview]
Message-ID: <1370614552-4288-3-git-send-email-namei.unix@gmail.com> (raw)
In-Reply-To: <1370614552-4288-1-git-send-email-namei.unix@gmail.com>
Just call sd_create_branch() to rollback the image is good enough
Cc: qemu-devel@nongnu.org
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <namei.unix@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
prev parent reply other threads:[~2013-06-07 14:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 14:15 [Qemu-devel] [PATCH v2 0/2] fix 'qemu-img snapshot -a' operation for sheepdog Liu Yuan
2013-06-07 14:15 ` [Qemu-devel] [PATCH v2 1/2] sheepdog: fix snapshot tag initialization Liu Yuan
2013-06-07 14:15 ` Liu Yuan [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=1370614552-4288-3-git-send-email-namei.unix@gmail.com \
--to=namei.unix@gmail.com \
--cc=kwolf@redhat.com \
--cc=morita.kazutaka@lab.ntt.co.jp \
--cc=qemu-devel@nongnu.org \
--cc=sheepdog@lists.wpkg.org \
--cc=stefanha@redhat.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 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).