blkdebug events can be called from either non-coroutine or coroutine
contexts. However, some actions (specifically suspend actions and
errors reported with immediately=off) only make sense from within
a coroutine.
Currently, using those action would lead to an abort() in
qemu_coroutine_yield() ("Co-routine is yielding to no one").
Catch them and print an error instead.
Signed-off-by: Paolo Bonzini <[email protected]>
---
block/blkdebug.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index bbf2948703..bf0aedb17d 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -31,6 +31,7 @@
#include "block/qdict.h"
#include "qemu/module.h"
#include "qemu/option.h"
+#include "qemu/error-report.h"
#include "qapi/qapi-visit-block-core.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h"
@@ -623,8 +624,13 @@ static int rule_check(BlockDriverState *bs, uint64_t
offset, uint64_t bytes,
qemu_mutex_unlock(&s->lock);
if (!immediately) {
- aio_co_schedule(qemu_get_current_aio_context(), qemu_coroutine_self());
- qemu_coroutine_yield();
+ if (qemu_in_coroutine()) {
+ aio_co_schedule(qemu_get_current_aio_context(),
qemu_coroutine_self());
+ qemu_coroutine_yield();
+ } else {
+ error_report("Non-coroutine event %s needs immediately = off\n",
+ BlkdebugEvent_lookup.array[rule->event]);
+ }
}
return -error;
@@ -858,7 +864,12 @@ static void blkdebug_debug_event(BlockDriverState *bs,
BlkdebugEvent event)
}
while (actions_count[ACTION_SUSPEND] > 0) {
- qemu_coroutine_yield();
+ if (qemu_in_coroutine()) {
+ qemu_coroutine_yield();
+ } else {
+ error_report("Non-coroutine event %s cannot suspend\n",
+ BlkdebugEvent_lookup.array[event]);
+ }
actions_count[ACTION_SUSPEND]--;
}
}
--
2.37.3