ui: Convert vnc_display_init(), init_keyboard_layout() to Error

Signed-off-by: Fei Li <fli@suse.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20181017082702.5581-27-armbru@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Fei Li 2018-10-17 10:26:50 +02:00 committed by Markus Armbruster
parent f7b9e299a4
commit ab4f931e9f
6 changed files with 24 additions and 18 deletions

View file

@ -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,7 +4080,11 @@ 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_report_err(local_err);
exit(1);
}
vnc_display_open(id, &local_err);
if (local_err != NULL) {
error_reportf_err(local_err, "Failed to start VNC server: ");