[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/20] spice-char: improve error reporting
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 15/20] spice-char: improve error reporting |
Date: |
Thu, 5 Jan 2017 17:53:24 +0100 |
Set errp to report errors up to the right monitor.
Use error_append_hint() to give hints about parameters on !qmp monitors,
instead of a direct fprintf() call.
Signed-off-by: Marc-André Lureau <address@hidden>
---
spice-qemu-char.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 38b1f6c29b..5e5897b189 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -2,6 +2,7 @@
#include "trace.h"
#include "ui/qemu-spice.h"
#include "sysemu/char.h"
+#include "qemu/error-report.h"
#include <spice.h>
#include <spice/protocol.h>
@@ -239,23 +240,6 @@ static void spice_port_set_fe_open(struct Chardev *chr,
int fe_open)
#endif
}
-static void print_allowed_subtypes(void)
-{
- const char** psubtype;
- int i;
-
- fprintf(stderr, "allowed names: ");
- for(i=0, psubtype = spice_server_char_device_recognized_subtypes();
- *psubtype != NULL; ++psubtype, ++i) {
- if (i == 0) {
- fprintf(stderr, "%s", *psubtype);
- } else {
- fprintf(stderr, ", %s", *psubtype);
- }
- }
- fprintf(stderr, "\n");
-}
-
static void spice_chr_accept_input(struct Chardev *chr)
{
SpiceChardev *s = (SpiceChardev *)chr;
@@ -302,8 +286,14 @@ static Chardev *qemu_chr_open_spice_vmc(const CharDriver
*driver,
}
}
if (*psubtype == NULL) {
- fprintf(stderr, "spice-qemu-char: unsupported type: %s\n", type);
- print_allowed_subtypes();
+ char *subtypes = g_strjoinv(", ",
+ (gchar **)spice_server_char_device_recognized_subtypes());
+
+ error_setg(errp, "unsupported type name: %s", type);
+ error_append_hint(errp, "allowed spice char type names: %s\n",
+ subtypes);
+
+ g_free(subtypes);
return NULL;
}
@@ -326,7 +316,7 @@ static Chardev *qemu_chr_open_spice_port(const CharDriver
*driver,
SpiceChardev *s;
if (name == NULL) {
- fprintf(stderr, "spice-qemu-char: missing name parameter\n");
+ error_setg(errp, "missing name parameter");
return NULL;
}
--
2.11.0
- Re: [Qemu-devel] [PATCH 06/20] char: use a static array for backends, (continued)
- [Qemu-devel] [PATCH 08/20] char: fold single-user functions in caller, Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 09/20] char: introduce generic qemu_chr_get_kind(), Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 10/20] char: use a feature bit for replay, Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 12/20] bt: use qemu_chr_alloc(), Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 07/20] char: move callbacks in CharDriver, Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 14/20] char: rename TCPChardev and NetChardev, Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 11/20] char: allocate CharDriverState as a single object, Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 15/20] spice-char: improve error reporting,
Marc-André Lureau <=
- [Qemu-devel] [PATCH 16/20] char: use error_report(), Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 18/20] baum: use a common prefix for chr callbacks, Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 17/20] gtk: overwrite the console.c char driver, Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 19/20] vc: use a common prefix for chr callbacks, Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 13/20] char: rename CharDriverState Chardev, Marc-André Lureau, 2017/01/05
- [Qemu-devel] [PATCH 20/20] chardev: qom-ify, Marc-André Lureau, 2017/01/05