qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V7 2/4] block: Add check infinite loop in bdrv_i


From: Fam Zheng
Subject: Re: [Qemu-devel] [PATCH V7 2/4] block: Add check infinite loop in bdrv_img_create()
Date: Wed, 13 Nov 2013 14:32:48 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 2013年11月13日 10:39, Xu Wang wrote:
Backing file loop should be checked before qemu-img create command
execution. If loop is found, qemu-img create should be stopped and
an error printed.

Signed-off-by: Xu Wang <address@hidden>
---
  block.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index 3c43179..c2ed6ef 100644
--- a/block.c
+++ b/block.c
@@ -4629,15 +4629,16 @@ void bdrv_img_create(const char *filename, const char 
*fmt,
      }

      backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE);
+    backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT);
      if (backing_file && backing_file->value.s) {
-        if (!strcmp(filename, backing_file->value.s)) {
-            error_setg(errp, "Error: Trying to create an image with the "
-                             "same filename as the backing file");
+        if (!bdrv_backing_chain_okay(backing_file->value.s,
+                                     backing_fmt->value.s, filename)) {
+            error_setg(errp, "bdrv_img_create: loop exists, "
+                             "image create failed");

Another failure path in file_chain_has_loop() is when bdrv_open fails, which is not a backing chain loop. What if the backing file doesn't exist? Would the error message still mention "look exits", which is very confusing?

Fam

              goto out;
          }
      }

-    backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT);
      if (backing_fmt && backing_fmt->value.s) {
          backing_drv = bdrv_find_format(backing_fmt->value.s);
          if (!backing_drv) {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]