[Sheepdog] [PATCH 1/5] use SD_FLAG_CMD_SNAPSHOT to specify the creation of snapshots
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Tue Jan 26 05:32:06 CET 2010
Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
block/sheepdog.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index b67919c..b6e5299 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -49,6 +49,8 @@
#define SD_FLAG_CMD_WRITE 0x01
#define SD_FLAG_CMD_COW 0x02
+#define SD_FLAG_CMD_SNAPSHOT (1U << 8)
+
#define SD_RES_SUCCESS 0x00 /* Success */
#define SD_RES_UNKNOWN 0x01 /* Unknown error */
#define SD_RES_NO_OBJ 0x02 /* No object found */
@@ -1236,7 +1238,8 @@ out:
#define CHUNK_SIZE (1ULL << 22)
static int do_sd_create(char *filename, int64_t total_sectors,
- uint64_t base_oid, uint64_t *oid, uint64_t tag)
+ uint64_t base_oid, uint64_t *oid, uint64_t tag,
+ int snapshot)
{
struct sd_vdi_req hdr;
struct sd_vdi_rsp *rsp = (struct sd_vdi_rsp *)&hdr;
@@ -1255,6 +1258,8 @@ static int do_sd_create(char *filename, int64_t total_sectors,
wlen = strlen(filename) + 1;
hdr.flags = SD_FLAG_CMD_WRITE;
+ if (snapshot)
+ hdr.flags |= SD_FLAG_CMD_SNAPSHOT;
hdr.data_length = wlen;
hdr.vdi_size = total_sectors * 512;
hdr.tag = tag;
@@ -1327,7 +1332,7 @@ static int sd_create(const char *filename, QEMUOptionParameter *options)
return -1;
}
- return do_sd_create((char *)filename, total_sectors, oid, NULL, 0);
+ return do_sd_create((char *)filename, total_sectors, oid, NULL, 0, 0);
}
static void sd_close(BlockDriverState *bs)
@@ -1468,7 +1473,7 @@ static int sd_create_branch(struct bdrv_sd_state *s)
gettimeofday(&tv, NULL);
ret = do_sd_create(s->name, s->inode.vdi_size >> 9,
- s->inode.oid, &oid, tv.tv_sec);
+ s->inode.oid, &oid, tv.tv_sec, 0);
if (ret)
goto out;
@@ -1726,7 +1731,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);
+ s->inode.oid, NULL, tv.tv_sec, 1);
return ret;
}
--
1.5.6.5
More information about the sheepdog
mailing list