[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/7] chardev/char.c: Use qemu_co_sleep_ns if in coroutine
From: |
Zhang Chen |
Subject: |
[PATCH 3/7] chardev/char.c: Use qemu_co_sleep_ns if in coroutine |
Date: |
Wed, 20 May 2020 04:02:03 +0800 |
From: Lukas Straub <address@hidden>
This will be needed in the next patch.
Signed-off-by: Lukas Straub <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Reviewed-by: Zhang Chen <address@hidden>
Signed-off-by: Zhang Chen <address@hidden>
---
chardev/char.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/chardev/char.c b/chardev/char.c
index 0196e2887b..4c58ea1836 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -38,6 +38,7 @@
#include "qemu/module.h"
#include "qemu/option.h"
#include "qemu/id.h"
+#include "qemu/coroutine.h"
#include "chardev/char-mux.h"
@@ -119,7 +120,11 @@ static int qemu_chr_write_buffer(Chardev *s,
retry:
res = cc->chr_write(s, buf + *offset, len - *offset);
if (res < 0 && errno == EAGAIN && write_all) {
- g_usleep(100);
+ if (qemu_in_coroutine()) {
+ qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 100000);
+ } else {
+ g_usleep(100);
+ }
goto retry;
}
--
2.17.1
- [PATCH 0/7] Latest COLO tree queued patches, Zhang Chen, 2020/05/19
- [PATCH 3/7] chardev/char.c: Use qemu_co_sleep_ns if in coroutine,
Zhang Chen <=
- [PATCH 2/7] net/colo-compare.c: Create event_bh with the right AioContext, Zhang Chen, 2020/05/19
- [PATCH 1/7] colo-compare: Fix memory leak in packet_enqueue(), Zhang Chen, 2020/05/19
- [PATCH 4/7] net/colo-compare.c: Fix deadlock in compare_chr_send, Zhang Chen, 2020/05/19
- [PATCH 5/7] net/colo-compare.c: Only hexdump packets if tracing is enabled, Zhang Chen, 2020/05/19
- [PATCH 6/7] net/colo-compare.c, softmmu/vl.c: Check that colo-compare is active, Zhang Chen, 2020/05/19
- [PATCH 7/7] net/colo-compare.c: Correct ordering in complete and finalize, Zhang Chen, 2020/05/19
- Re: [PATCH 0/7] Latest COLO tree queued patches, Jason Wang, 2020/05/19
- Re: [PATCH 0/7] Latest COLO tree queued patches, no-reply, 2020/05/20