logfd is blocking, so we don't need to care about EAGAIN.
Let's simply use qemu_write_full().
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
Honestly, I'm not sure, may be EAGAIN handling is needed for some
non-linux OSes? That's why it's RFC..
The original commit 0d7708ba29cbcc34336
"qemu-char: add logfile facility to all chardev backends"
doen't mention, why should we handle EAGAIN.
chardev/char.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/chardev/char.c b/chardev/char.c
index 3e432195a5..64006a3119 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -82,29 +82,17 @@ void qemu_chr_be_event(Chardev *s, QEMUChrEvent event)
CHARDEV_GET_CLASS(s)->chr_be_event(s, event);
}
-/* Not reporting errors from writing to logfile, as logs are
- * defined to be "best effort" only */
static void qemu_chr_write_log(Chardev *s, const uint8_t *buf, size_t len)
{
- size_t done = 0;
- ssize_t ret;
-
if (s->logfd < 0) {
return;
}
- while (done < len) {
- retry:
- ret = write(s->logfd, buf + done, len - done);
- if (ret == -1 && errno == EAGAIN) {
- g_usleep(100);
- goto retry;
- }
-
- if (ret <= 0) {
- return;
- }
- done += ret;
+ if (qemu_write_full(s->logfd, buf, len) < len) {
+ /*
+ * qemu_write_full() is defined with G_GNUC_WARN_UNUSED_RESULT,
+ * but logging is best‑effort, we do ignore errors.
+ */
}
}
--
2.48.1