block: Repair the throttling code.

The throttling code was segfaulting since commit
02ffb50448 because some qemu_co_queue_next caller
does not run in a coroutine.
qemu_co_queue_do_restart assume that the caller is a coroutinne.
As suggested by Stefan fix this by entering the coroutine directly.
Also make sure like suggested that qemu_co_queue_next() and
qemu_co_queue_restart_all() can be called only in coroutines.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Benoît Canet 2013-07-26 22:39:22 +02:00 committed by Stefan Hajnoczi
parent 42ec24e285
commit b681a1c73e
3 changed files with 28 additions and 8 deletions

View file

@ -130,12 +130,17 @@ void coroutine_fn qemu_co_queue_wait_insert_head(CoQueue *queue);
*
* Returns true if a coroutine was restarted, false if the queue is empty.
*/
bool qemu_co_queue_next(CoQueue *queue);
bool coroutine_fn qemu_co_queue_next(CoQueue *queue);
/**
* Restarts all coroutines in the CoQueue and leaves the queue empty.
*/
void qemu_co_queue_restart_all(CoQueue *queue);
void coroutine_fn qemu_co_queue_restart_all(CoQueue *queue);
/**
* Enter the next coroutine in the queue
*/
bool qemu_co_enter_next(CoQueue *queue);
/**
* Checks if the CoQueue is empty.