1. Convert to error_report().

2. All backends now report their errors, no need to follow up with an
unspecific "opening backend failed".  Drop the message.

Signed-off-by: Markus Armbruster <arm...@redhat.com>
---
 qemu-char.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index ecbb595..fe0cfce 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2808,33 +2808,30 @@ static const struct {
 CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
                                     void (*init)(struct CharDriverState *s))
 {
+    const char *backend = qemu_opt_get(opts, "backend");
     CharDriverState *chr;
     int i;
 
     if (qemu_opts_id(opts) == NULL) {
-        fprintf(stderr, "chardev: no id specified\n");
+        error_report("character device requires parameter id");
         return NULL;
     }
 
-    if (qemu_opt_get(opts, "backend") == NULL) {
-        fprintf(stderr, "chardev: \"%s\" missing backend\n",
-                qemu_opts_id(opts));
+    if (!backend) {
+        error_report("character device requires parameter backend");
         return NULL;
     }
     for (i = 0; i < ARRAY_SIZE(backend_table); i++) {
-        if (strcmp(backend_table[i].name, qemu_opt_get(opts, "backend")) == 0)
+        if (strcmp(backend_table[i].name, backend) == 0)
             break;
     }
     if (i == ARRAY_SIZE(backend_table)) {
-        fprintf(stderr, "chardev: backend \"%s\" not found\n",
-                qemu_opt_get(opts, "backend"));
+        error_report("character device backend '%s' not found", backend);
         return NULL;
     }
 
     chr = backend_table[i].open(opts);
     if (!chr) {
-        fprintf(stderr, "chardev: opening backend \"%s\" failed\n",
-                qemu_opt_get(opts, "backend"));
         return NULL;
     }
 
-- 
1.7.6.5


Reply via email to