@@ -2867,8 +2867,10 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*in
}
opts = qemu_chr_parse_compat(label, filename);
- if (!opts)
+ if (!opts) {
+ error_report("parse error");
return NULL;
+ }
chr = qemu_chr_new_from_opts(opts, init);
if (chr && qemu_opt_get_bool(opts, "mux", 0)) {
@@ -1907,8 +1907,6 @@ static int serial_parse(const char *devname)
snprintf(label, sizeof(label), "serial%d", index);
serial_hds[index] = qemu_chr_new(label, devname, NULL);
if (!serial_hds[index]) {
- fprintf(stderr, "qemu: could not open serial device '%s': %s\n",
- devname, strerror(errno));
return -1;
}
index++;
@@ -1929,8 +1927,6 @@ static int parallel_parse(const char *devname)
snprintf(label, sizeof(label), "parallel%d", index);
parallel_hds[index] = qemu_chr_new(label, devname, NULL);
if (!parallel_hds[index]) {
- fprintf(stderr, "qemu: could not open parallel device '%s': %s\n",
- devname, strerror(errno));
return -1;
}
index++;
@@ -1960,8 +1956,6 @@ static int virtcon_parse(const char *devname)
snprintf(label, sizeof(label), "virtcon%d", index);
virtcon_hds[index] = qemu_chr_new(label, devname, NULL);
if (!virtcon_hds[index]) {
- fprintf(stderr, "qemu: could not open virtio console '%s': %s\n",
- devname, strerror(errno));
return -1;
}
qemu_opt_set(dev_opts, "chardev", label);
Watch this: $ qemu-system-x86_64 -nodefaults -vnc :0 -debugcon crap $ echo $? 1 $ qemu-system-x86_64 -nodefaults -vnc :0 -serial crap qemu: could not open serial device 'crap': Success Two issues: 1. qemu_chr_new() fails silently on syntax errors. It does report other errors. 2. serial_parse() incorrectly asumes qemu_chr_new() sets errno on failure. Same for parallel_parse() and virtcon_parse(). Fix both of them. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- qemu-char.c | 4 +++- vl.c | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-)