Patchwork [V3,7/7] block: Add backing file loop check in qed_change_backing_file()

login
register
mail settings
Submitter Xu Wang
Date July 15, 2013, 9:42 a.m.
Message ID <1373881356-3294-8-git-send-email-cngesaint@gmail.com>
Download mbox | patch
Permalink /patch/258977/
State New
Headers show

Comments

Xu Wang - July 15, 2013, 9:42 a.m.
Add backing file loop check before execute change backing file for
qed format.

Signed-off-by: Xu Wang <cngesaint@gmail.com>
---
 block/qed.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch

diff --git a/block/qed.c b/block/qed.c
index f767b05..79c2875 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1468,6 +1468,13 @@  static int bdrv_qed_change_backing_file(BlockDriverState *bs,
         return -ENOTSUP;
     }
 
+    /* Check if loop exists in backing files chain after changed */
+    if (bdrv_backing_file_loop_check(bs->filename,
+                                     bs->drv ? bs->drv->format_name : NULL,
+                                     backing_file, backing_fmt)) {
+        return -EIO;
+    }
+
     memcpy(&new_header, &s->header, sizeof(new_header));
 
     new_header.features &= ~(QED_F_BACKING_FILE |