fuj...@rose:~/git/qemu-kvm$ qemu-img snapshot -c test3 sheepdog:linux fuj...@rose:~/git/qemu-kvm$ qemu-img snapshot -l sheepdog:linux Snapshot list: ID TAG VM SIZE DATE VMCLOCK 1 test1 0 2010-01-19 00:09:39 00:00:00.000 2 test2 0 2010-01-19 00:10:34 00:00:00.000 3 test3 0 2010-01-19 00:10:43 00:00:00.000
Signed-off-by: FUJITA Tomonori <[email protected]> --- collie/collie.h | 2 +- collie/group.c | 2 +- collie/store.c | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/collie/collie.h b/collie/collie.h index 05ee029..f25857a 100644 --- a/collie/collie.h +++ b/collie/collie.h @@ -76,7 +76,7 @@ int create_listen_port(int port, void *data); int init_store(char *dir); -int add_vdi(struct cluster_info *ci, char *name, int len, uint64_t size, +int add_vdi(struct cluster_info *ci, char *buf, int len, uint64_t size, uint64_t *added_oid, uint64_t base_oid, uint32_t tag, int copies, uint16_t flags); diff --git a/collie/group.c b/collie/group.c index b58f60e..716f52c 100644 --- a/collie/group.c +++ b/collie/group.c @@ -364,7 +364,7 @@ static void vdi_op(struct cluster_info *ci, struct vdi_op_message *msg) switch (hdr->opcode) { case SD_OP_NEW_VDI: - ret = add_vdi(ci, data, strlen(data), hdr->vdi_size, &oid, + ret = add_vdi(ci, data, hdr->data_length, hdr->vdi_size, &oid, hdr->base_oid, hdr->tag, hdr->copies, hdr->flags); break; case SD_OP_LOCK_VDI: diff --git a/collie/store.c b/collie/store.c index 337ac7e..9cef425 100644 --- a/collie/store.c +++ b/collie/store.c @@ -631,9 +631,13 @@ static int so_read_vdis(struct request *req) *p = '\0'; sde->oid = strtoull(vdent[i]->d_name, NULL, 16); - if (p) + if (p) { sde->id = strtoull(p + 1, NULL, 16); - else { + + p = strchr(p + 1, '-'); + if (p) + strcpy(sde->tag, p + 1); + } else { sde->id = 0; sde->flags = FLAG_CURRENT; } @@ -708,6 +712,7 @@ static int so_lookup_vdi(struct request *req) *p = '\0'; oid = strtoull(dent->d_name, NULL, 16); rsp->oid = oid; + dprintf("%lx, %x\n", oid, hdr->tag); ret = SD_RES_SUCCESS; @@ -786,8 +791,8 @@ void so_queue_request(struct work *work, int idx) goto out; } - strncpy(path + strlen(path), "/", 1); - strncpy(path + strlen(path), (char *)req->data, hdr->data_length); + snprintf(path + strlen(path), sizeof(path) - strlen(path), + "/%s", (char *)req->data); if (hdr->flags & SD_FLAG_CMD_SNAPSHOT) { DIR *dir; @@ -865,7 +870,11 @@ void so_queue_request(struct work *work, int idx) close(fd); if (hdr->flags & SD_FLAG_CMD_SNAPSHOT) { - snprintf(path, sizeof(path), "%s-%04x", oldname, id); + if (hdr->data_length == SD_MAX_VDI_LEN * 2) + snprintf(path, sizeof(path), "%s-%04x-%s", oldname, + id, (char *)req->data + SD_MAX_VDI_LEN); + else + snprintf(path, sizeof(path), "%s-%04x", oldname, id); ret = rename(oldname, path); if (ret) { eprintf("%s, %s, %m\n", oldname, path); -- 1.5.6.5 -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
