aboutsummaryrefslogtreecommitdiff
path: root/qemu-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'qemu-io.c')
-rw-r--r--qemu-io.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/qemu-io.c b/qemu-io.c
index bf902302e9..57f07501df 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -411,6 +411,19 @@ static void prep_fetchline(void *opaque)
*fetchable= 1;
}
+static int do_qemuio_command(const char *cmd)
+{
+ int ret;
+ AioContext *ctx =
+ qemuio_blk ? blk_get_aio_context(qemuio_blk) : qemu_get_aio_context();
+
+ aio_context_acquire(ctx);
+ ret = qemuio_command(qemuio_blk, cmd);
+ aio_context_release(ctx);
+
+ return ret;
+}
+
static int command_loop(void)
{
int i, fetchable = 0, prompted = 0;
@@ -418,7 +431,7 @@ static int command_loop(void)
char *input;
for (i = 0; !quit_qemu_io && i < ncmdline; i++) {
- ret = qemuio_command(qemuio_blk, cmdline[i]);
+ ret = do_qemuio_command(cmdline[i]);
if (ret < 0) {
last_error = ret;
}
@@ -446,7 +459,7 @@ static int command_loop(void)
if (input == NULL) {
break;
}
- ret = qemuio_command(qemuio_blk, input);
+ ret = do_qemuio_command(input);
g_free(input);
if (ret < 0) {