diff mbox

[19/19] qemu-char: Fix legacy chardev syntax error reporting

Message ID 1328623766-12287-20-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Feb. 7, 2012, 2:09 p.m. UTC
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(-)
diff mbox

Patch

diff --git a/qemu-char.c b/qemu-char.c
index fe0cfce..c74babb 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -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)) {
diff --git a/vl.c b/vl.c
index 1394a08..941fab0 100644
--- a/vl.c
+++ b/vl.c
@@ -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);