Patchwork [3/3] Prevent creating an image with the same filename as backing file

login
register
mail settings
Submitter Jes Sorensen
Date Dec. 13, 2010, 7:32 a.m.
Message ID <1292225579-27320-4-git-send-email-Jes.Sorensen@redhat.com>
Download mbox | patch
Permalink /patch/75301/
State New
Headers show

Comments

Jes Sorensen - Dec. 13, 2010, 7:32 a.m.
From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 block.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

Patch

diff --git a/block.c b/block.c
index 3ab062c..403a434 100644
--- a/block.c
+++ b/block.c
@@ -2752,6 +2752,13 @@  int bdrv_img_create(const char *filename, const char *fmt,
     BlockDriver *drv, *proto_drv;
     int ret = 0;
 
+    if (!strcmp(filename, base_filename)) {
+        error_report("Error: Trying to create a snapshot with the same "
+                     "filename as the backing file");
+        ret = -1;
+        goto out;
+    }
+
     /* Find driver and parse its options */
     drv = bdrv_find_format(fmt);
     if (!drv) {