Some time after created snapshot, auto_backing_file only has filename,
this confused overridden check, update it to full path if it is not.

Signed-off-by: Joe Jin <joe....@oracle.com>
---
 block.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/block.c b/block.c
index c5b887cec1..8f9a027dee 100644
--- a/block.c
+++ b/block.c
@@ -6969,6 +6969,19 @@ void bdrv_refresh_filename(BlockDriverState *bs)
         return;
     }
 
+    /* auto_backing_file only has filename, update it to the full path */
+    if (bs->backing && bs->auto_backing_file[0] != '/') {
+        char *backing_filename = NULL;
+        Error *local_err = NULL;
+
+        backing_filename = bdrv_make_absolute_filename(bs,
+                                     bs->auto_backing_file, &local_err);
+        if (!local_err && backing_filename) {
+            pstrcpy(bs->auto_backing_file, sizeof(bs->auto_backing_file),
+                     backing_filename);
+            g_free(backing_filename);
+        }
+    }
     backing_overridden = bdrv_backing_overridden(bs);
 
     if (bs->open_flags & BDRV_O_NO_IO) {
-- 
2.21.1 (Apple Git-122.3)


Reply via email to