diff options
author | Peter Maydell | 2018-10-23 18:20:23 +0200 |
---|---|---|
committer | Peter Maydell | 2018-10-23 18:20:23 +0200 |
commit | 13399aad4fa87b2878c49d02a5d3bafa6c966ba3 (patch) | |
tree | 24a1320fa920963aebfea50c345cd682ea34089b /ui | |
parent | Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into sta... (diff) | |
parent | error: Drop bogus "use error_setg() instead" admonitions (diff) | |
download | qemu-13399aad4fa87b2878c49d02a5d3bafa6c966ba3.tar.gz qemu-13399aad4fa87b2878c49d02a5d3bafa6c966ba3.tar.xz qemu-13399aad4fa87b2878c49d02a5d3bafa6c966ba3.zip |
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2018-10-22' into staging
Error reporting patches for 2018-10-22
# gpg: Signature made Mon 22 Oct 2018 13:20:23 BST
# gpg: using RSA key 3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg: aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* remotes/armbru/tags/pull-error-2018-10-22: (40 commits)
error: Drop bogus "use error_setg() instead" admonitions
vpc: Fail open on bad header checksum
block: Clean up bdrv_img_create()'s error reporting
vl: Simplify call of parse_name()
vl: Fix exit status for -drive format=help
blockdev: Convert drive_new() to Error
vl: Assert drive_new() does not fail in default_drive()
fsdev: Clean up error reporting in qemu_fsdev_add()
spice: Clean up error reporting in add_channel()
tpm: Clean up error reporting in tpm_init_tpmdev()
numa: Clean up error reporting in parse_numa()
vnc: Clean up error reporting in vnc_init_func()
ui: Convert vnc_display_init(), init_keyboard_layout() to Error
ui/keymaps: Fix handling of erroneous include files
vl: Clean up error reporting in device_init_func()
vl: Clean up error reporting in parse_fw_cfg()
vl: Clean up error reporting in mon_init_func()
vl: Clean up error reporting in machine_set_property()
vl: Clean up error reporting in chardev_init_func()
qom: Clean up error reporting in user_creatable_add_opts_foreach()
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/curses.c | 6 | ||||
-rw-r--r-- | ui/keymaps.c | 40 | ||||
-rw-r--r-- | ui/keymaps.h | 2 | ||||
-rw-r--r-- | ui/sdl.c | 6 | ||||
-rw-r--r-- | ui/spice-core.c | 13 | ||||
-rw-r--r-- | ui/vnc.c | 19 |
6 files changed, 52 insertions, 34 deletions
diff --git a/ui/curses.c b/ui/curses.c index 59d819fd4d..f4e7a12f74 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -28,6 +28,7 @@ #include <termios.h> #endif +#include "qapi/error.h" #include "qemu-common.h" #include "ui/console.h" #include "ui/input.h" @@ -421,9 +422,8 @@ static void curses_keyboard_setup(void) keyboard_layout = "en-us"; #endif if(keyboard_layout) { - kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout); - if (!kbd_layout) - exit(1); + kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout, + &error_fatal); } } diff --git a/ui/keymaps.c b/ui/keymaps.c index 43fe604724..085889b555 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -27,6 +27,7 @@ #include "sysemu/sysemu.h" #include "trace.h" #include "qemu/error-report.h" +#include "qapi/error.h" struct keysym2code { uint32_t count; @@ -79,10 +80,11 @@ static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *k) trace_keymap_add(keysym, keycode, line); } -static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table, - const char *language, - kbd_layout_t *k) +static int parse_keyboard_layout(kbd_layout_t *k, + const name2keysym_t *table, + const char *language, Error **errp) { + int ret; FILE *f; char * filename; char line[1024]; @@ -94,13 +96,8 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table, f = filename ? fopen(filename, "r") : NULL; g_free(filename); if (!f) { - fprintf(stderr, "Could not read keymap file: '%s'\n", language); - return NULL; - } - - if (!k) { - k = g_new0(kbd_layout_t, 1); - k->hash = g_hash_table_new(NULL, NULL); + error_setg(errp, "could not read keymap file: '%s'", language); + return -1; } for(;;) { @@ -118,7 +115,10 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table, continue; } if (!strncmp(line, "include ", 8)) { - parse_keyboard_layout(table, line + 8, k); + if (parse_keyboard_layout(k, table, line + 8, errp) < 0) { + ret = -1; + goto out; + } } else { int offset = 0; while (line[offset] != 0 && @@ -164,15 +164,27 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table, } } } + + ret = 0; +out: fclose(f); - return k; + return ret; } kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, - const char *language) + const char *language, Error **errp) { - return parse_keyboard_layout(table, language, NULL); + kbd_layout_t *k; + + k = g_new0(kbd_layout_t, 1); + k->hash = g_hash_table_new(NULL, NULL); + if (parse_keyboard_layout(k, table, language, errp) < 0) { + g_hash_table_unref(k->hash); + g_free(k); + return NULL; + } + return k; } diff --git a/ui/keymaps.h b/ui/keymaps.h index 0693588225..98213a4191 100644 --- a/ui/keymaps.h +++ b/ui/keymaps.h @@ -53,7 +53,7 @@ typedef struct { typedef struct kbd_layout_t kbd_layout_t; kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, - const char *language); + const char *language, Error **errp); int keysym2scancode(kbd_layout_t *k, int keysym, bool shift, bool altgr, bool ctrl); int keycode_is_keypad(kbd_layout_t *k, int keycode); @@ -29,6 +29,7 @@ #include <SDL.h> #include <SDL_syswm.h> +#include "qapi/error.h" #include "qemu-common.h" #include "qemu/cutils.h" #include "ui/console.h" @@ -917,9 +918,8 @@ static void sdl1_display_init(DisplayState *ds, DisplayOptions *o) keyboard_layout = "en-us"; #endif if(keyboard_layout) { - kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout); - if (!kbd_layout) - exit(1); + kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout, + &error_fatal); } g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be removed\n" diff --git a/ui/spice-core.c b/ui/spice-core.c index a4fbbc3898..ebaae24643 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -597,9 +597,9 @@ static int add_channel(void *opaque, const char *name, const char *value, if (strcmp(name, "tls-channel") == 0) { int *tls_port = opaque; if (!*tls_port) { - error_report("spice: tried to setup tls-channel" - " without specifying a TLS port"); - exit(1); + error_setg(errp, "spice: tried to setup tls-channel" + " without specifying a TLS port"); + return -1; } security = SPICE_CHANNEL_SECURITY_SSL; } @@ -615,8 +615,9 @@ static int add_channel(void *opaque, const char *name, const char *value, rc = spice_server_set_channel_security(spice_server, value, security); } if (rc != 0) { - error_report("spice: failed to set channel security for %s", value); - exit(1); + error_setg(errp, "spice: failed to set channel security for %s", + value); + return -1; } return 0; } @@ -787,7 +788,7 @@ void qemu_spice_init(void) spice_server_set_playback_compression (spice_server, qemu_opt_get_bool(opts, "playback-compression", 1)); - qemu_opt_foreach(opts, add_channel, &tls_port, NULL); + qemu_opt_foreach(opts, add_channel, &tls_port, &error_fatal); spice_server_set_name(spice_server, qemu_name); spice_server_set_uuid(spice_server, (unsigned char *)&qemu_uuid); @@ -3205,7 +3205,7 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_cursor_define = vnc_dpy_cursor_define, }; -void vnc_display_init(const char *id) +void vnc_display_init(const char *id, Error **errp) { VncDisplay *vd; @@ -3222,13 +3222,14 @@ void vnc_display_init(const char *id) if (keyboard_layout) { trace_vnc_key_map_init(keyboard_layout); - vd->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout); + vd->kbd_layout = init_keyboard_layout(name2keysym, + keyboard_layout, errp); } else { - vd->kbd_layout = init_keyboard_layout(name2keysym, "en-us"); + vd->kbd_layout = init_keyboard_layout(name2keysym, "en-us", errp); } if (!vd->kbd_layout) { - exit(1); + return; } vd->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; @@ -4079,11 +4080,15 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp) char *id = (char *)qemu_opts_id(opts); assert(id); - vnc_display_init(id); + vnc_display_init(id, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return -1; + } vnc_display_open(id, &local_err); if (local_err != NULL) { - error_reportf_err(local_err, "Failed to start VNC server: "); - exit(1); + error_propagate(errp, local_err); + return -1; } return 0; } |