Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * QEMU aio implementation |
| 3 | * |
| 4 | * Copyright IBM Corp., 2008 |
| 5 | * Copyright Red Hat Inc., 2012 |
| 6 | * |
| 7 | * Authors: |
| 8 | * Anthony Liguori <aliguori@us.ibm.com> |
| 9 | * Paolo Bonzini <pbonzini@redhat.com> |
| 10 | * |
| 11 | * This work is licensed under the terms of the GNU GPL, version 2. See |
| 12 | * the COPYING file in the top-level directory. |
| 13 | * |
| 14 | * Contributions after 2012-01-13 are licensed under the terms of the |
| 15 | * GNU GPL, version 2 or (at your option) any later version. |
| 16 | */ |
| 17 | |
Peter Maydell | d38ea87 | 2016-01-29 17:50:05 +0000 | [diff] [blame] | 18 | #include "qemu/osdep.h" |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 19 | #include "qemu-common.h" |
Paolo Bonzini | 737e150 | 2012-12-17 18:19:44 +0100 | [diff] [blame] | 20 | #include "block/block.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 21 | #include "qemu/queue.h" |
| 22 | #include "qemu/sockets.h" |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 23 | |
| 24 | struct AioHandler { |
| 25 | EventNotifier *e; |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 26 | IOHandler *io_read; |
| 27 | IOHandler *io_write; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 28 | EventNotifierHandler *io_notify; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 29 | GPollFD pfd; |
| 30 | int deleted; |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 31 | void *opaque; |
Fam Zheng | dca21ef | 2015-10-23 11:08:05 +0800 | [diff] [blame] | 32 | bool is_external; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 33 | QLIST_ENTRY(AioHandler) node; |
| 34 | }; |
| 35 | |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 36 | void aio_set_fd_handler(AioContext *ctx, |
| 37 | int fd, |
Fam Zheng | dca21ef | 2015-10-23 11:08:05 +0800 | [diff] [blame] | 38 | bool is_external, |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 39 | IOHandler *io_read, |
| 40 | IOHandler *io_write, |
| 41 | void *opaque) |
| 42 | { |
| 43 | /* fd is a SOCKET in our case */ |
| 44 | AioHandler *node; |
| 45 | |
| 46 | QLIST_FOREACH(node, &ctx->aio_handlers, node) { |
| 47 | if (node->pfd.fd == fd && !node->deleted) { |
| 48 | break; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /* Are we deleting the fd handler? */ |
| 53 | if (!io_read && !io_write) { |
| 54 | if (node) { |
| 55 | /* If the lock is held, just mark the node as deleted */ |
| 56 | if (ctx->walking_handlers) { |
| 57 | node->deleted = 1; |
| 58 | node->pfd.revents = 0; |
| 59 | } else { |
| 60 | /* Otherwise, delete it for real. We can't just mark it as |
| 61 | * deleted because deleted nodes are only cleaned up after |
| 62 | * releasing the walking_handlers lock. |
| 63 | */ |
| 64 | QLIST_REMOVE(node, node); |
| 65 | g_free(node); |
| 66 | } |
| 67 | } |
| 68 | } else { |
| 69 | HANDLE event; |
| 70 | |
| 71 | if (node == NULL) { |
| 72 | /* Alloc and insert if it's not already there */ |
Markus Armbruster | 3ba235a | 2014-12-04 13:55:09 +0100 | [diff] [blame] | 73 | node = g_new0(AioHandler, 1); |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 74 | node->pfd.fd = fd; |
| 75 | QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node); |
| 76 | } |
| 77 | |
| 78 | node->pfd.events = 0; |
| 79 | if (node->io_read) { |
| 80 | node->pfd.events |= G_IO_IN; |
| 81 | } |
| 82 | if (node->io_write) { |
| 83 | node->pfd.events |= G_IO_OUT; |
| 84 | } |
| 85 | |
| 86 | node->e = &ctx->notifier; |
| 87 | |
| 88 | /* Update handler with latest information */ |
| 89 | node->opaque = opaque; |
| 90 | node->io_read = io_read; |
| 91 | node->io_write = io_write; |
Fam Zheng | dca21ef | 2015-10-23 11:08:05 +0800 | [diff] [blame] | 92 | node->is_external = is_external; |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 93 | |
| 94 | event = event_notifier_get_handle(&ctx->notifier); |
| 95 | WSAEventSelect(node->pfd.fd, event, |
| 96 | FD_READ | FD_ACCEPT | FD_CLOSE | |
| 97 | FD_CONNECT | FD_WRITE | FD_OOB); |
| 98 | } |
| 99 | |
| 100 | aio_notify(ctx); |
| 101 | } |
| 102 | |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 103 | void aio_set_event_notifier(AioContext *ctx, |
| 104 | EventNotifier *e, |
Fam Zheng | dca21ef | 2015-10-23 11:08:05 +0800 | [diff] [blame] | 105 | bool is_external, |
Stefan Hajnoczi | f2e5dca | 2013-04-11 17:26:25 +0200 | [diff] [blame] | 106 | EventNotifierHandler *io_notify) |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 107 | { |
| 108 | AioHandler *node; |
| 109 | |
| 110 | QLIST_FOREACH(node, &ctx->aio_handlers, node) { |
| 111 | if (node->e == e && !node->deleted) { |
| 112 | break; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /* Are we deleting the fd handler? */ |
| 117 | if (!io_notify) { |
| 118 | if (node) { |
Paolo Bonzini | e3713e0 | 2012-09-24 14:57:41 +0200 | [diff] [blame] | 119 | g_source_remove_poll(&ctx->source, &node->pfd); |
| 120 | |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 121 | /* If the lock is held, just mark the node as deleted */ |
| 122 | if (ctx->walking_handlers) { |
| 123 | node->deleted = 1; |
| 124 | node->pfd.revents = 0; |
| 125 | } else { |
| 126 | /* Otherwise, delete it for real. We can't just mark it as |
| 127 | * deleted because deleted nodes are only cleaned up after |
| 128 | * releasing the walking_handlers lock. |
| 129 | */ |
| 130 | QLIST_REMOVE(node, node); |
| 131 | g_free(node); |
| 132 | } |
| 133 | } |
| 134 | } else { |
| 135 | if (node == NULL) { |
| 136 | /* Alloc and insert if it's not already there */ |
Markus Armbruster | 3ba235a | 2014-12-04 13:55:09 +0100 | [diff] [blame] | 137 | node = g_new0(AioHandler, 1); |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 138 | node->e = e; |
| 139 | node->pfd.fd = (uintptr_t)event_notifier_get_handle(e); |
| 140 | node->pfd.events = G_IO_IN; |
Fam Zheng | dca21ef | 2015-10-23 11:08:05 +0800 | [diff] [blame] | 141 | node->is_external = is_external; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 142 | QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node); |
Paolo Bonzini | e3713e0 | 2012-09-24 14:57:41 +0200 | [diff] [blame] | 143 | |
| 144 | g_source_add_poll(&ctx->source, &node->pfd); |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 145 | } |
| 146 | /* Update handler with latest information */ |
| 147 | node->io_notify = io_notify; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 148 | } |
Paolo Bonzini | 7ed2b24 | 2012-09-25 10:22:39 +0200 | [diff] [blame] | 149 | |
| 150 | aio_notify(ctx); |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 151 | } |
| 152 | |
Paolo Bonzini | a3462c6 | 2014-07-09 11:53:08 +0200 | [diff] [blame] | 153 | bool aio_prepare(AioContext *ctx) |
| 154 | { |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 155 | static struct timeval tv0; |
| 156 | AioHandler *node; |
| 157 | bool have_select_revents = false; |
| 158 | fd_set rfds, wfds; |
| 159 | |
| 160 | /* fill fd sets */ |
| 161 | FD_ZERO(&rfds); |
| 162 | FD_ZERO(&wfds); |
| 163 | QLIST_FOREACH(node, &ctx->aio_handlers, node) { |
| 164 | if (node->io_read) { |
| 165 | FD_SET ((SOCKET)node->pfd.fd, &rfds); |
| 166 | } |
| 167 | if (node->io_write) { |
| 168 | FD_SET ((SOCKET)node->pfd.fd, &wfds); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | if (select(0, &rfds, &wfds, NULL, &tv0) > 0) { |
| 173 | QLIST_FOREACH(node, &ctx->aio_handlers, node) { |
| 174 | node->pfd.revents = 0; |
| 175 | if (FD_ISSET(node->pfd.fd, &rfds)) { |
| 176 | node->pfd.revents |= G_IO_IN; |
| 177 | have_select_revents = true; |
| 178 | } |
| 179 | |
| 180 | if (FD_ISSET(node->pfd.fd, &wfds)) { |
| 181 | node->pfd.revents |= G_IO_OUT; |
| 182 | have_select_revents = true; |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return have_select_revents; |
Paolo Bonzini | a3462c6 | 2014-07-09 11:53:08 +0200 | [diff] [blame] | 188 | } |
| 189 | |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 190 | bool aio_pending(AioContext *ctx) |
| 191 | { |
| 192 | AioHandler *node; |
| 193 | |
| 194 | QLIST_FOREACH(node, &ctx->aio_handlers, node) { |
| 195 | if (node->pfd.revents && node->io_notify) { |
| 196 | return true; |
| 197 | } |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 198 | |
| 199 | if ((node->pfd.revents & G_IO_IN) && node->io_read) { |
| 200 | return true; |
| 201 | } |
| 202 | if ((node->pfd.revents & G_IO_OUT) && node->io_write) { |
| 203 | return true; |
| 204 | } |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | return false; |
| 208 | } |
| 209 | |
Paolo Bonzini | a398dea | 2014-07-09 11:53:03 +0200 | [diff] [blame] | 210 | static bool aio_dispatch_handlers(AioContext *ctx, HANDLE event) |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 211 | { |
| 212 | AioHandler *node; |
Paolo Bonzini | a398dea | 2014-07-09 11:53:03 +0200 | [diff] [blame] | 213 | bool progress = false; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 214 | |
| 215 | /* |
Paolo Bonzini | 87f68d3 | 2014-07-07 15:18:02 +0200 | [diff] [blame] | 216 | * We have to walk very carefully in case aio_set_fd_handler is |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 217 | * called while we're walking. |
| 218 | */ |
| 219 | node = QLIST_FIRST(&ctx->aio_handlers); |
| 220 | while (node) { |
| 221 | AioHandler *tmp; |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 222 | int revents = node->pfd.revents; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 223 | |
| 224 | ctx->walking_handlers++; |
| 225 | |
Paolo Bonzini | a398dea | 2014-07-09 11:53:03 +0200 | [diff] [blame] | 226 | if (!node->deleted && |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 227 | (revents || event_notifier_get_handle(node->e) == event) && |
Paolo Bonzini | a398dea | 2014-07-09 11:53:03 +0200 | [diff] [blame] | 228 | node->io_notify) { |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 229 | node->pfd.revents = 0; |
| 230 | node->io_notify(node->e); |
Stefan Hajnoczi | 164a101 | 2013-04-11 16:56:50 +0200 | [diff] [blame] | 231 | |
| 232 | /* aio_notify() does not count as progress */ |
Stefan Hajnoczi | 8b2d42d | 2013-08-22 15:28:35 +0200 | [diff] [blame] | 233 | if (node->e != &ctx->notifier) { |
Stefan Hajnoczi | 164a101 | 2013-04-11 16:56:50 +0200 | [diff] [blame] | 234 | progress = true; |
| 235 | } |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 236 | } |
| 237 | |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 238 | if (!node->deleted && |
| 239 | (node->io_read || node->io_write)) { |
| 240 | node->pfd.revents = 0; |
| 241 | if ((revents & G_IO_IN) && node->io_read) { |
| 242 | node->io_read(node->opaque); |
| 243 | progress = true; |
| 244 | } |
| 245 | if ((revents & G_IO_OUT) && node->io_write) { |
| 246 | node->io_write(node->opaque); |
| 247 | progress = true; |
| 248 | } |
| 249 | |
| 250 | /* if the next select() will return an event, we have progressed */ |
| 251 | if (event == event_notifier_get_handle(&ctx->notifier)) { |
| 252 | WSANETWORKEVENTS ev; |
| 253 | WSAEnumNetworkEvents(node->pfd.fd, event, &ev); |
| 254 | if (ev.lNetworkEvents) { |
| 255 | progress = true; |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 260 | tmp = node; |
| 261 | node = QLIST_NEXT(node, node); |
| 262 | |
| 263 | ctx->walking_handlers--; |
| 264 | |
| 265 | if (!ctx->walking_handlers && tmp->deleted) { |
| 266 | QLIST_REMOVE(tmp, node); |
| 267 | g_free(tmp); |
| 268 | } |
| 269 | } |
| 270 | |
Paolo Bonzini | a398dea | 2014-07-09 11:53:03 +0200 | [diff] [blame] | 271 | return progress; |
| 272 | } |
| 273 | |
Paolo Bonzini | e4c7e2d | 2014-07-09 11:53:05 +0200 | [diff] [blame] | 274 | bool aio_dispatch(AioContext *ctx) |
Paolo Bonzini | a398dea | 2014-07-09 11:53:03 +0200 | [diff] [blame] | 275 | { |
| 276 | bool progress; |
| 277 | |
Paolo Bonzini | e4c7e2d | 2014-07-09 11:53:05 +0200 | [diff] [blame] | 278 | progress = aio_bh_poll(ctx); |
| 279 | progress |= aio_dispatch_handlers(ctx, INVALID_HANDLE_VALUE); |
Paolo Bonzini | d397ec99 | 2014-07-09 11:53:02 +0200 | [diff] [blame] | 280 | progress |= timerlistgroup_run_timers(&ctx->tlg); |
Paolo Bonzini | a398dea | 2014-07-09 11:53:03 +0200 | [diff] [blame] | 281 | return progress; |
| 282 | } |
| 283 | |
| 284 | bool aio_poll(AioContext *ctx, bool blocking) |
| 285 | { |
| 286 | AioHandler *node; |
| 287 | HANDLE events[MAXIMUM_WAIT_OBJECTS + 1]; |
Paolo Bonzini | eabc977 | 2015-07-21 16:07:51 +0200 | [diff] [blame] | 288 | bool progress, have_select_revents, first; |
Paolo Bonzini | a398dea | 2014-07-09 11:53:03 +0200 | [diff] [blame] | 289 | int count; |
| 290 | int timeout; |
| 291 | |
Paolo Bonzini | 4911017 | 2015-02-20 17:26:51 +0100 | [diff] [blame] | 292 | aio_context_acquire(ctx); |
Paolo Bonzini | a398dea | 2014-07-09 11:53:03 +0200 | [diff] [blame] | 293 | progress = false; |
| 294 | |
Paolo Bonzini | 0a9dd16 | 2014-07-09 11:53:07 +0200 | [diff] [blame] | 295 | /* aio_notify can avoid the expensive event_notifier_set if |
| 296 | * everything (file descriptors, bottom halves, timers) will |
| 297 | * be re-evaluated before the next blocking poll(). This is |
| 298 | * already true when aio_poll is called with blocking == false; |
Paolo Bonzini | eabc977 | 2015-07-21 16:07:51 +0200 | [diff] [blame] | 299 | * if blocking == true, it is only true after poll() returns, |
| 300 | * so disable the optimization now. |
Paolo Bonzini | 0a9dd16 | 2014-07-09 11:53:07 +0200 | [diff] [blame] | 301 | */ |
Paolo Bonzini | eabc977 | 2015-07-21 16:07:51 +0200 | [diff] [blame] | 302 | if (blocking) { |
| 303 | atomic_add(&ctx->notify_me, 2); |
| 304 | } |
Paolo Bonzini | 0a9dd16 | 2014-07-09 11:53:07 +0200 | [diff] [blame] | 305 | |
Paolo Bonzini | 6493c97 | 2015-07-21 16:07:50 +0200 | [diff] [blame] | 306 | have_select_revents = aio_prepare(ctx); |
| 307 | |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 308 | ctx->walking_handlers++; |
| 309 | |
| 310 | /* fill fd sets */ |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 311 | count = 0; |
| 312 | QLIST_FOREACH(node, &ctx->aio_handlers, node) { |
Fam Zheng | c1e1e5f | 2015-10-23 11:08:08 +0800 | [diff] [blame] | 313 | if (!node->deleted && node->io_notify |
| 314 | && aio_node_check(ctx, node->is_external)) { |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 315 | events[count++] = event_notifier_get_handle(node->e); |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | ctx->walking_handlers--; |
Paolo Bonzini | 3672fa5 | 2014-07-09 11:53:04 +0200 | [diff] [blame] | 320 | first = true; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 321 | |
Paolo Bonzini | 6493c97 | 2015-07-21 16:07:50 +0200 | [diff] [blame] | 322 | /* ctx->notifier is always registered. */ |
| 323 | assert(count > 0); |
| 324 | |
| 325 | /* Multiple iterations, all of them non-blocking except the first, |
| 326 | * may be necessary to process all pending events. After the first |
| 327 | * WaitForMultipleObjects call ctx->notify_me will be decremented. |
| 328 | */ |
| 329 | do { |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 330 | HANDLE event; |
Alex Bligh | 438e1f4 | 2013-08-21 16:02:53 +0100 | [diff] [blame] | 331 | int ret; |
| 332 | |
Paolo Bonzini | 6493c97 | 2015-07-21 16:07:50 +0200 | [diff] [blame] | 333 | timeout = blocking && !have_select_revents |
Paolo Bonzini | 845ca10 | 2014-07-09 11:53:01 +0200 | [diff] [blame] | 334 | ? qemu_timeout_ns_to_ms(aio_compute_timeout(ctx)) : 0; |
Paolo Bonzini | 4911017 | 2015-02-20 17:26:51 +0100 | [diff] [blame] | 335 | if (timeout) { |
| 336 | aio_context_release(ctx); |
| 337 | } |
Alex Bligh | 438e1f4 | 2013-08-21 16:02:53 +0100 | [diff] [blame] | 338 | ret = WaitForMultipleObjects(count, events, FALSE, timeout); |
Paolo Bonzini | eabc977 | 2015-07-21 16:07:51 +0200 | [diff] [blame] | 339 | if (blocking) { |
| 340 | assert(first); |
| 341 | atomic_sub(&ctx->notify_me, 2); |
| 342 | } |
Paolo Bonzini | 4911017 | 2015-02-20 17:26:51 +0100 | [diff] [blame] | 343 | if (timeout) { |
| 344 | aio_context_acquire(ctx); |
| 345 | } |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 346 | |
Paolo Bonzini | 21a03d1 | 2015-07-21 16:07:52 +0200 | [diff] [blame] | 347 | if (first) { |
Paolo Bonzini | 05e514b | 2015-07-21 16:07:53 +0200 | [diff] [blame] | 348 | aio_notify_accept(ctx); |
Paolo Bonzini | 21a03d1 | 2015-07-21 16:07:52 +0200 | [diff] [blame] | 349 | progress |= aio_bh_poll(ctx); |
| 350 | first = false; |
Paolo Bonzini | 3672fa5 | 2014-07-09 11:53:04 +0200 | [diff] [blame] | 351 | } |
Paolo Bonzini | 3672fa5 | 2014-07-09 11:53:04 +0200 | [diff] [blame] | 352 | |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 353 | /* if we have any signaled events, dispatch event */ |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 354 | event = NULL; |
| 355 | if ((DWORD) (ret - WAIT_OBJECT_0) < count) { |
| 356 | event = events[ret - WAIT_OBJECT_0]; |
Paolo Bonzini | a90d411 | 2014-09-15 14:52:58 +0200 | [diff] [blame] | 357 | events[ret - WAIT_OBJECT_0] = events[--count]; |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 358 | } else if (!have_select_revents) { |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 359 | break; |
| 360 | } |
| 361 | |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 362 | have_select_revents = false; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 363 | blocking = false; |
| 364 | |
Paolo Bonzini | b493317 | 2014-07-09 11:53:10 +0200 | [diff] [blame] | 365 | progress |= aio_dispatch_handlers(ctx, event); |
Paolo Bonzini | 6493c97 | 2015-07-21 16:07:50 +0200 | [diff] [blame] | 366 | } while (count > 0); |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 367 | |
Paolo Bonzini | e4c7e2d | 2014-07-09 11:53:05 +0200 | [diff] [blame] | 368 | progress |= timerlistgroup_run_timers(&ctx->tlg); |
Alex Bligh | 438e1f4 | 2013-08-21 16:02:53 +0100 | [diff] [blame] | 369 | |
Paolo Bonzini | 4911017 | 2015-02-20 17:26:51 +0100 | [diff] [blame] | 370 | aio_context_release(ctx); |
Stefan Hajnoczi | 164a101 | 2013-04-11 16:56:50 +0200 | [diff] [blame] | 371 | return progress; |
Paolo Bonzini | f42b220 | 2012-06-09 04:01:51 +0200 | [diff] [blame] | 372 | } |
Fam Zheng | 37fcee5 | 2015-10-30 12:06:28 +0800 | [diff] [blame] | 373 | |
| 374 | void aio_context_setup(AioContext *ctx, Error **errp) |
| 375 | { |
| 376 | } |