[sheepdog] [PATCH 4/5] dog/vdi: check tag name is existed or not before creating snapshot
Ruoyu
liangry at ucweb.com
Thu Sep 4 15:44:11 CEST 2014
Otherwise, duplicated tag for two or more snapshots may lead to
unexpected problem.
Reported-by: Valerio Pachera <sirio81 at gmail.com>
Signed-off-by: Ruoyu <liangry at ucweb.com>
---
dog/vdi.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/dog/vdi.c b/dog/vdi.c
index be9cbe2..fa6130e 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -574,6 +574,23 @@ static int vdi_snapshot(int argc, char **argv)
return EXIT_USAGE;
}
+ ret = find_vdi_name(vdiname, vdi_cmd_data.snapshot_id,
+ vdi_cmd_data.snapshot_tag, &vid);
+ switch (ret) {
+ case SD_RES_NO_VDI:
+ sd_err("Failed to create snapshot for %s: %s",
+ vdiname, sd_strerror(ret));
+ return EXIT_FAILURE;
+ case SD_RES_NO_TAG:
+ break;
+ default:
+ sd_err("Failed to create snapshot for %s, maybe "
+ "snapshot id (%d) or tag (%s) is existed",
+ vdiname, vdi_cmd_data.snapshot_id,
+ vdi_cmd_data.snapshot_tag);
+ return EXIT_FAILURE;
+ }
+
ret = read_vdi_obj(vdiname, 0, "", &vid, inode, SD_INODE_HEADER_SIZE);
if (ret != EXIT_SUCCESS)
return ret;
--
1.8.3.2
More information about the sheepdog
mailing list