]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
block: Add bdrv_co_get_self_request()
authorMax Reitz <mreitz@redhat.com>
Fri, 1 Nov 2019 15:25:09 +0000 (16:25 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 12 Nov 2019 17:59:58 +0000 (11:59 -0600)
Cc: qemu-stable@nongnu.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20191101152510.11719-3-mreitz@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
(cherry picked from commit c28107e9e55b11cd35cf3dc2505e3e69d10dcf13)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block/io.c
include/block/block_int.h

index d4ceaaa2ce3eec70f5c17aa661ac794933cd95fb..65b5102714d4d60ff6a5e594ef1b30ae82e06b1e 100644 (file)
@@ -721,6 +721,24 @@ static bool is_request_serialising_and_aligned(BdrvTrackedRequest *req)
            (req->bytes == req->overlap_bytes);
 }
 
+/**
+ * Return the tracked request on @bs for the current coroutine, or
+ * NULL if there is none.
+ */
+BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs)
+{
+    BdrvTrackedRequest *req;
+    Coroutine *self = qemu_coroutine_self();
+
+    QLIST_FOREACH(req, &bs->tracked_requests, list) {
+        if (req->co == self) {
+            return req;
+        }
+    }
+
+    return NULL;
+}
+
 /**
  * Round a region to cluster boundaries
  */
index 4465b022424c23aea82942547cc3b02bb460b865..05ee6b4866f84a9ab9ba0dcda5da8028e03a45fb 100644 (file)
@@ -964,6 +964,7 @@ void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent);
 
 bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self);
 void bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align);
+BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs);
 
 int get_tmp_filename(char *filename, int size);
 BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,