diff mbox series

[PULL,05/29] block: Introduce 'bdrv_reopen_commit_post' step

Message ID 20200306171458.1848-6-kwolf@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,01/29] qcow2: Fix alloc_cluster_abort() for pre-existing clusters | expand

Commit Message

Kevin Wolf March 6, 2020, 5:14 p.m. UTC
From: Peter Krempa <pkrempa@redhat.com>

Add another step in the reopen process where driver can execute code
after permission changes are comitted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Message-Id: <adc02cf591c3cb34e98e33518eb1c540a0f27db1.1582893284.git.pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/block/block_int.h | 1 +
 block.c                   | 9 +++++++++
 2 files changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/include/block/block_int.h b/include/block/block_int.h
index 6f9fd5e20e..f422c0bff0 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -122,6 +122,7 @@  struct BlockDriver {
     int (*bdrv_reopen_prepare)(BDRVReopenState *reopen_state,
                                BlockReopenQueue *queue, Error **errp);
     void (*bdrv_reopen_commit)(BDRVReopenState *reopen_state);
+    void (*bdrv_reopen_commit_post)(BDRVReopenState *reopen_state);
     void (*bdrv_reopen_abort)(BDRVReopenState *reopen_state);
     void (*bdrv_join_options)(QDict *options, QDict *old_options);
 
diff --git a/block.c b/block.c
index 876bd45182..aaa387504e 100644
--- a/block.c
+++ b/block.c
@@ -3695,6 +3695,15 @@  cleanup_perm:
             }
         }
     }
+
+    if (ret == 0) {
+        QTAILQ_FOREACH_REVERSE(bs_entry, bs_queue, entry) {
+            BlockDriverState *bs = bs_entry->state.bs;
+
+            if (bs->drv->bdrv_reopen_commit_post)
+                bs->drv->bdrv_reopen_commit_post(&bs_entry->state);
+        }
+    }
 cleanup:
     QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) {
         if (ret) {