summaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 5f82ebb774..7fa87a8b6e 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -39,6 +39,7 @@
#include "io/channel-file.h"
#include "io/channel-tls.h"
#include "sysemu/replay.h"
+#include "qemu/help_option.h"
#include <zlib.h>
@@ -440,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);
}
@@ -556,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);
@@ -594,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);
}
}
}
@@ -625,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;
}
@@ -3879,16 +3886,26 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
const char *id = qemu_opts_id(opts);
char *bid = NULL;
- if (id == NULL) {
- error_setg(errp, "chardev: no id specified");
- goto err;
- }
-
if (qemu_opt_get(opts, "backend") == NULL) {
error_setg(errp, "chardev: \"%s\" missing backend",
qemu_opts_id(opts));
goto err;
}
+
+ if (is_help_option(qemu_opt_get(opts, "backend"))) {
+ fprintf(stderr, "Available chardev backend types:\n");
+ for (i = backends; i; i = i->next) {
+ cd = i->data;
+ fprintf(stderr, "%s\n", cd->name);
+ }
+ exit(!is_help_option(qemu_opt_get(opts, "backend")));
+ }
+
+ if (id == NULL) {
+ error_setg(errp, "chardev: no id specified");
+ goto err;
+ }
+
for (i = backends; i; i = i->next) {
cd = i->data;