qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 18/19] qemu-char: Chardev open error reporting, gene


From: Markus Armbruster
Subject: [Qemu-devel] [PATCH 18/19] qemu-char: Chardev open error reporting, generic part
Date: Tue, 7 Feb 2012 15:09:25 +0100

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 <address@hidden>
---
 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

[Prev in Thread] Current Thread [Next in Thread]