[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 40/58] char: convert qemu_chr_fe_write to qemu_chr_fe
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 40/58] char: convert qemu_chr_fe_write to qemu_chr_fe_write_all |
Date: |
Tue, 13 Sep 2016 19:16:11 +0200 |
From: "Daniel P. Berrange" <address@hidden>
The mux chardev was not checking the return value of any
qemu_chr_fe_write() call so would silently loose data
on EAGAIN.
Similarly the qemu_chr_fe_printf method would not check
errors and was not in a position to retry even if it
could check.
Signed-off-by: Daniel P. Berrange <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
qemu-char.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index cf6a27a..7fa87a8 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -441,7 +441,9 @@ void qemu_chr_fe_printf(CharDriverState *s, const char
*fmt, ...)
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
- qemu_chr_fe_write(s, (uint8_t *)buf, strlen(buf));
+ /* XXX this blocks entire thread. Rewrite to use
+ * qemu_chr_fe_write and background I/O callbacks */
+ qemu_chr_fe_write_all(s, (uint8_t *)buf, strlen(buf));
va_end(ap);
}
@@ -557,7 +559,9 @@ static int mux_chr_write(CharDriverState *chr, const
uint8_t *buf, int len)
(secs / 60) % 60,
secs % 60,
(int)(ti % 1000));
- qemu_chr_fe_write(d->drv, (uint8_t *)buf1, strlen(buf1));
+ /* XXX this blocks entire thread. Rewrite to use
+ * qemu_chr_fe_write and background I/O callbacks */
+ qemu_chr_fe_write_all(d->drv, (uint8_t *)buf1, strlen(buf1));
d->linestart = 0;
}
ret += qemu_chr_fe_write(d->drv, buf+i, 1);
@@ -595,13 +599,15 @@ static void mux_print_help(CharDriverState *chr)
"\n\rEscape-Char set to Ascii: 0x%02x\n\r\n\r",
term_escape_char);
}
- qemu_chr_fe_write(chr, (uint8_t *)cbuf, strlen(cbuf));
+ /* XXX this blocks entire thread. Rewrite to use
+ * qemu_chr_fe_write and background I/O callbacks */
+ qemu_chr_fe_write_all(chr, (uint8_t *)cbuf, strlen(cbuf));
for (i = 0; mux_help[i] != NULL; i++) {
for (j=0; mux_help[i][j] != '\0'; j++) {
if (mux_help[i][j] == '%')
- qemu_chr_fe_write(chr, (uint8_t *)ebuf, strlen(ebuf));
+ qemu_chr_fe_write_all(chr, (uint8_t *)ebuf, strlen(ebuf));
else
- qemu_chr_fe_write(chr, (uint8_t *)&mux_help[i][j], 1);
+ qemu_chr_fe_write_all(chr, (uint8_t *)&mux_help[i][j], 1);
}
}
}
@@ -626,7 +632,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver
*d, int ch)
case 'x':
{
const char *term = "QEMU: Terminated\n\r";
- qemu_chr_fe_write(chr, (uint8_t *)term, strlen(term));
+ qemu_chr_fe_write_all(chr, (uint8_t *)term, strlen(term));
exit(0);
break;
}
--
1.8.3.1
- [Qemu-devel] [PULL 28/58] vmxcap: Add TSC scaling bit, (continued)
- [Qemu-devel] [PULL 28/58] vmxcap: Add TSC scaling bit, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 30/58] chardev: Add 'help' option to print all available chardev backend types, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 29/58] doc/rcu: fix typo, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 31/58] MAINTAINERS: Fix wildcard for scsi headers, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 32/58] MAINTAINERS: Add some header files to the PC chipset section, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 35/58] default-configs: removed obsolete CONFIG_ISA_MMIO, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 33/58] scsi: pvscsi: limit loop to fetch SG list, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 34/58] default-configs: remove CONFIG_PAM, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 38/58] sclpconsolelm: remove bogus check for -EAGAIN, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 37/58] ipmi: check return of qemu_chr_fe_write() for errors, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 40/58] char: convert qemu_chr_fe_write to qemu_chr_fe_write_all,
Paolo Bonzini <=
- [Qemu-devel] [PULL 39/58] hw: replace most use of qemu_chr_fe_write with qemu_chr_fe_write_all, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 42/58] i8257: Make device "i8257" unavailable with -device, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 43/58] kvm-all: drop kvm_setup_guest_memory, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 41/58] Revert "megasas: remove useless check for cmd->frame", Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 36/58] default-configs: remove CONFIG_PIIX_PCI, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 45/58] atomics: Use __atomic_*_n() variant primitives, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 44/58] atomics: Remove redundant barrier()'s, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 46/58] checkpatch: Fix whitespace checks for documentation code blocks, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 47/58] optionrom: do not rely on compiler's bswap optimization, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 51/58] cutils: Remove SPLAT macro, Paolo Bonzini, 2016/09/13