]> Git Repo - qemu.git/commitdiff
block: replace bdrv_states iteration with bdrv_next()
authorStefan Hajnoczi <[email protected]>
Tue, 28 Apr 2015 13:27:49 +0000 (14:27 +0100)
committerKevin Wolf <[email protected]>
Tue, 28 Apr 2015 13:36:17 +0000 (15:36 +0200)
The bdrv_states list is a static variable in block.c.

bdrv_drain_all() and bdrv_flush_all() use this variable to iterate over
all drives.

The next patch will move bdrv_drain_all() and bdrv_flush_all() out of
block.c so it's necessary to switch to the public bdrv_next() interface.

Reviewed-by: Alberto Garcia <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
block.c

diff --git a/block.c b/block.c
index ec235944568df3bf7c0426f83928eb45b7174987..1f0a4e2a7fb49356a1aef2b1012dc7e5819d2d90 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2051,9 +2051,9 @@ void bdrv_drain_all(void)
 {
     /* Always run first iteration so any pending completion BHs run */
     bool busy = true;
-    BlockDriverState *bs;
+    BlockDriverState *bs = NULL;
 
-    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+    while ((bs = bdrv_next(bs))) {
         AioContext *aio_context = bdrv_get_aio_context(bs);
 
         aio_context_acquire(aio_context);
@@ -2065,8 +2065,9 @@ void bdrv_drain_all(void)
 
     while (busy) {
         busy = false;
+        bs = NULL;
 
-        QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+        while ((bs = bdrv_next(bs))) {
             AioContext *aio_context = bdrv_get_aio_context(bs);
 
             aio_context_acquire(aio_context);
@@ -2075,7 +2076,8 @@ void bdrv_drain_all(void)
         }
     }
 
-    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+    bs = NULL;
+    while ((bs = bdrv_next(bs))) {
         AioContext *aio_context = bdrv_get_aio_context(bs);
 
         aio_context_acquire(aio_context);
@@ -4015,10 +4017,10 @@ int bdrv_get_flags(BlockDriverState *bs)
 
 int bdrv_flush_all(void)
 {
-    BlockDriverState *bs;
+    BlockDriverState *bs = NULL;
     int result = 0;
 
-    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+    while ((bs = bdrv_next(bs))) {
         AioContext *aio_context = bdrv_get_aio_context(bs);
         int ret;
 
This page took 0.03484 seconds and 4 git commands to generate.