thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
a83cc2
From e23a2be8c57666e091d9192e113a30ea06cd83ef Mon Sep 17 00:00:00 2001
a83cc2
From: Sergio Lopez Pascual <slp@redhat.com>
a83cc2
Date: Thu, 17 Jun 2021 09:13:20 -0400
a83cc2
Subject: [PATCH 05/12] block-backend: add drained_poll
a83cc2
MIME-Version: 1.0
a83cc2
Content-Type: text/plain; charset=UTF-8
a83cc2
Content-Transfer-Encoding: 8bit
a83cc2
a83cc2
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
RH-MergeRequest: 16: Synchronize with RHEL-AV 8.5 release 21 to RHEL 9
a83cc2
RH-Commit: [3/8] 4ad1f536b00a762a1b094d76383b74826228892a (mrezanin/centos-src-qemu-kvm)
a83cc2
RH-Bugzilla: 1957194
a83cc2
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
a83cc2
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
a83cc2
a83cc2
Allow block backends to poll their devices/users to check if they have
a83cc2
been quiesced when entering a drained section.
a83cc2
a83cc2
This will be used in the next patch to wait for the NBD server to be
a83cc2
completely quiesced.
a83cc2
a83cc2
Suggested-by: Kevin Wolf <kwolf@redhat.com>
a83cc2
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
a83cc2
Reviewed-by: Eric Blake <eblake@redhat.com>
a83cc2
Signed-off-by: Sergio Lopez <slp@redhat.com>
a83cc2
Message-Id: <20210602060552.17433-2-slp@redhat.com>
a83cc2
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
a83cc2
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
a83cc2
(cherry picked from commit 095cc4d0f62513d75e9bc1da37f08d9e97f267c4)
a83cc2
Signed-off-by: Sergio Lopez <slp@redhat.com>
a83cc2
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
a83cc2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
---
a83cc2
 block/block-backend.c          | 7 ++++++-
a83cc2
 include/sysemu/block-backend.h | 4 ++++
a83cc2
 2 files changed, 10 insertions(+), 1 deletion(-)
a83cc2
a83cc2
diff --git a/block/block-backend.c b/block/block-backend.c
a83cc2
index 413af51f3b..05d8e5fb5d 100644
a83cc2
--- a/block/block-backend.c
a83cc2
+++ b/block/block-backend.c
a83cc2
@@ -2378,8 +2378,13 @@ static void blk_root_drained_begin(BdrvChild *child)
a83cc2
 static bool blk_root_drained_poll(BdrvChild *child)
a83cc2
 {
a83cc2
     BlockBackend *blk = child->opaque;
a83cc2
+    bool busy = false;
a83cc2
     assert(blk->quiesce_counter);
a83cc2
-    return !!blk->in_flight;
a83cc2
+
a83cc2
+    if (blk->dev_ops && blk->dev_ops->drained_poll) {
a83cc2
+        busy = blk->dev_ops->drained_poll(blk->dev_opaque);
a83cc2
+    }
a83cc2
+    return busy || !!blk->in_flight;
a83cc2
 }
a83cc2
 
a83cc2
 static void blk_root_drained_end(BdrvChild *child, int *drained_end_counter)
a83cc2
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
a83cc2
index 880e903293..5423e3d9c6 100644
a83cc2
--- a/include/sysemu/block-backend.h
a83cc2
+++ b/include/sysemu/block-backend.h
a83cc2
@@ -66,6 +66,10 @@ typedef struct BlockDevOps {
a83cc2
      * Runs when the backend's last drain request ends.
a83cc2
      */
a83cc2
     void (*drained_end)(void *opaque);
a83cc2
+    /*
a83cc2
+     * Is the device still busy?
a83cc2
+     */
a83cc2
+    bool (*drained_poll)(void *opaque);
a83cc2
 } BlockDevOps;
a83cc2
 
a83cc2
 /* This struct is embedded in (the private) BlockBackend struct and contains
a83cc2
-- 
a83cc2
2.27.0
a83cc2