[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/6] chardev/char.c: Use qemu_co_sleep_ns if in coroutine
From: |
Lukas Straub |
Subject: |
[PATCH v2 2/6] chardev/char.c: Use qemu_co_sleep_ns if in coroutine |
Date: |
Sun, 26 Apr 2020 21:25:42 +0200 |
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>
---
chardev/char.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/chardev/char.c b/chardev/char.c
index e77564060d..5c8014199f 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.20.1
pgpqaAQbkJX_u.pgp
Description: OpenPGP digital signature
- [PATCH v2 0/6] colo-compare bugfixes, Lukas Straub, 2020/04/26
- [PATCH v2 2/6] chardev/char.c: Use qemu_co_sleep_ns if in coroutine,
Lukas Straub <=
- [PATCH v2 1/6] net/colo-compare.c: Create event_bh with the right AioContext, Lukas Straub, 2020/04/26
- [PATCH v2 4/6] net/colo-compare.c: Only hexdump packets if tracing is enabled, Lukas Straub, 2020/04/26
- [PATCH v2 5/6] net/colo-compare.c, softmmu/vl.c: Check that colo-compare is active, Lukas Straub, 2020/04/26
- [PATCH v2 3/6] net/colo-compare.c: Fix deadlock in compare_chr_send, Lukas Straub, 2020/04/26
- [PATCH v2 6/6] net/colo-compare.c: Correct ordering in complete and finalize, Lukas Straub, 2020/04/26
- Re: [PATCH v2 0/6] colo-compare bugfixes, no-reply, 2020/04/26