diff mbox series

[4/5] block/prl-xml: add bdrv_check

Message ID 20201113125848.20498-5-vsementsov@virtuozzo.com
State New
Headers show
Series block: implement Parallels Disk format driver | expand

Commit Message

Vladimir Sementsov-Ogievskiy Nov. 13, 2020, 12:58 p.m. UTC
From: Klim Kireev <klim.kireev@virtuozzo.com>

Add bdrv_check, which just checks child image and all backings.

Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.com>
---
 block/prl-xml.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/block/prl-xml.c b/block/prl-xml.c
index 023651342c..736cd98469 100644
--- a/block/prl-xml.c
+++ b/block/prl-xml.c
@@ -520,6 +520,23 @@  static coroutine_fn int prl_co_flush_to_os(BlockDriverState *bs)
     return bdrv_co_flush(s->image->bs);
 }
 
+static coroutine_fn int prl_co_check_xml(BlockDriverState *bs, 
+                                        BdrvCheckResult *result,
+                                        BdrvCheckMode fix) {
+    BDRVPrlXmlState *s = bs->opaque;
+    BdrvChild *cur = s->image;
+    int ret = 0;
+
+    while (cur != NULL && ret >= 0) {
+        if (cur->bs->drv->bdrv_co_check != NULL) {
+            ret = bdrv_check(cur->bs, result, fix);
+        }
+        cur = cur->bs->backing;
+    }
+
+    return ret;
+}
+
 static BlockDriver bdrv_prl_xml = {
     .format_name                = "prl-xml",
     .instance_size              = sizeof(BDRVPrlXmlState),
@@ -529,6 +546,7 @@  static BlockDriver bdrv_prl_xml = {
     .bdrv_co_writev             = prl_co_writev,
     .bdrv_close                 = prl_close_xml,
     .bdrv_co_flush_to_os        = prl_co_flush_to_os,
+    .bdrv_co_check              = prl_co_check_xml,
     .create_opts                = &prl_xml_create_opts,
     .bdrv_child_perm            = bdrv_filter_default_perms,
     .is_filter                  = true