diff mbox series

[10/14] qcow2: qcow2_inactivate(): don't call qcow2_mark_clean() when RO

Message ID 20220207163728.30362-11-vsementsov@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series block: blockdev-del force=false | expand

Commit Message

Vladimir Sementsov-Ogievskiy Feb. 7, 2022, 4:37 p.m. UTC
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 mbox series

Patch

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;