Patchwork [v3,07/16] chardev: ensure qemu_chr_parse_compat reports missing driver error

login
register
mail settings
Submitter Daniel P. Berrange
Date Feb. 11, 2019, 6:24 p.m.
Message ID <20190211182442.8542-8-berrange@redhat.com>
Download mbox | patch
Permalink /patch/723221/
State New
Headers show

Comments

Daniel P. Berrange - Feb. 11, 2019, 6:24 p.m.
If no valid char driver was identified the qemu_chr_parse_compat method
was silent, leaving callers no clue what failed.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 chardev/char.c    | 2 ++
 tests/test-char.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

Patch

diff --git a/chardev/char.c b/chardev/char.c
index ccba36bafb..b99f3692f7 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -490,6 +490,8 @@  QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename,
         return opts;
     }
 
+    error_report("'%s' is not a valid char driver", filename);
+
 fail:
     qemu_opts_del(opts);
     return NULL;
diff --git a/tests/test-char.c b/tests/test-char.c
index 19c3efad72..89c43e4ada 100644
--- a/tests/test-char.c
+++ b/tests/test-char.c
@@ -856,9 +856,10 @@  static void char_null_test(void)
 static void char_invalid_test(void)
 {
     Chardev *chr;
-
+    g_setenv("QTEST_SILENT_ERRORS", "1", 1);
     chr = qemu_chr_new("label-invalid", "invalid");
     g_assert_null(chr);
+    g_unsetenv("QTEST_SILENT_ERRORS");
 }
 
 static int chardev_change(void *opaque)