qemu-block
[Top][All Lists]
Advanced

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

[PATCH 10/14] qcow2: qcow2_inactivate(): don't call qcow2_mark_clean() w


From: Vladimir Sementsov-Ogievskiy
Subject: [PATCH 10/14] qcow2: qcow2_inactivate(): don't call qcow2_mark_clean() when RO
Date: Mon, 7 Feb 2022 17:37:24 +0100

qcow2_inactivate() prints errors on different failures, let's not
exclude qcow2_mark_clean() call.

Still, if image is read-only, no reason to report failed write and no
reason even to try write. Write failure is possible when we open dirty
image for check in read-only mode. Let's not do it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/qcow2.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 04994df240..ccfcd0db05 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2699,8 +2699,12 @@ static int qcow2_inactivate(BlockDriverState *bs)
         local_err = NULL;
     }
 
-    if (result == 0) {
-        qcow2_mark_clean(bs);
+    if (result == 0 && bdrv_is_writable(bs)) {
+        ret = qcow2_mark_clean(bs);
+        if (ret < 0) {
+            error_report("Failed to mark qcow2 node '%s' clean",
+                         bdrv_get_device_or_node_name(bs));
+        }
     }
 
     return result;
-- 
2.31.1




reply via email to

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