[Sheepdog] [PATCH 5/5] sheepdog: support specifying snapshot name in creating snapshot
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Sat Jan 9 15:03:35 CET 2010
usage:
$ qemu-img snapshot -f sheepdog -c [tag name] [vdi name]
Currently, the tag name must be a hex number. If you specify a non
number, an auto-generated number will be used.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
block/sheepdog.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 72c1ee4..701c0d8 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1946,8 +1946,15 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
struct bdrv_sd_state *s = bs->opaque;
int ret;
struct timeval tv;
-
- gettimeofday(&tv, NULL);
+ uint64_t tag = 0;
+
+ tag = strtoull(sn_info->name, NULL, 16);
+ if (tag == 0) {
+ eprintf("currently, only a hex number is supported as a tag name\n");
+ eprintf("use a generated number\n");
+ gettimeofday(&tv, NULL);
+ tag = tv.tv_sec;
+ }
dprintf("%s %s %s %d %d\n", sn_info->name, sn_info->id_str,
s->name, sn_info->vm_state_size, s->is_current);
@@ -1963,7 +1970,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
dprintf("%s %s\n", sn_info->name, sn_info->id_str);
ret = do_sd_create(s->name, s->inode.vdi_size >> 9,
- s->inode.oid, NULL, tv.tv_sec, 0);
+ s->inode.oid, NULL, tag, 0);
return ret;
}
--
1.5.6.5
More information about the sheepdog
mailing list