[sheepdog] [PATCH v2 1/5] sheep: return error if the requested snapshot is the current vdi

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Mon Mar 11 08:07:07 CET 2013


It is confusing that we can specify the current vdi with snapid.  This
patch makes sheep return SD_RES_INVALID_PARMS in the such case.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/vdi.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/sheep/vdi.c b/sheep/vdi.c
index 8d32217..cf1d3ba 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -341,8 +341,17 @@ static int find_first_vdi(unsigned long start, unsigned long end,
 			if (tag && tag[0] &&
 			    strncmp(inode->tag, tag, sizeof(inode->tag)) != 0)
 				continue;
-			if (snapid && snapid != inode->snap_id)
-				continue;
+			if (snapid) {
+				if (snapid != inode->snap_id)
+					continue;
+
+				if (inode->snap_ctime == 0) {
+					sd_dprintf("vdi %" PRIx32 " is not a "
+						   "snapshot\n", inode->vdi_id);
+					ret = SD_RES_INVALID_PARMS;
+					goto out_free_inode;
+				}
+			}
 
 			*vid = inode->vdi_id;
 			*inode_nr_copies = inode->nr_copies;
-- 
1.8.1.3.566.gaa39828




More information about the sheepdog mailing list