diff options
author | Markus Armbruster <armbru@redhat.com> | 2018-10-17 10:26:46 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2018-10-19 14:51:34 +0200 |
commit | 2d5a3a8b02aeed25a46b311abf9088f62ec61d66 (patch) | |
tree | ce8a80d50e02105ccf8c3d7f4d201d44bcc28fe7 /vl.c | |
parent | 702832b8c0444fd3ea703ab494e9e955ce0433b1 (diff) | |
download | qemu-2d5a3a8b02aeed25a46b311abf9088f62ec61d66.zip qemu-2d5a3a8b02aeed25a46b311abf9088f62ec61d66.tar.gz qemu-2d5a3a8b02aeed25a46b311abf9088f62ec61d66.tar.bz2 |
vl: Clean up error reporting in mon_init_func()
Calling error_report() in a function that takes an Error ** argument
is suspicious. mon_init_func() does that, and then fails without
setting an error. Its caller main(), via qemu_opts_foreach(), is fine
with it, but clean it up anyway.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20181017082702.5581-23-armbru@redhat.com>
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -2270,8 +2270,8 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp) } else if (strcmp(mode, "control") == 0) { flags = MONITOR_USE_CONTROL; } else { - error_report("unknown monitor mode \"%s\"", mode); - exit(1); + error_setg(errp, "unknown monitor mode \"%s\"", mode); + return -1; } if (qemu_opt_get_bool(opts, "pretty", 0)) @@ -2285,8 +2285,8 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp) chardev = qemu_opt_get(opts, "chardev"); chr = qemu_chr_find(chardev); if (chr == NULL) { - error_report("chardev \"%s\" not found", chardev); - exit(1); + error_setg(errp, "chardev \"%s\" not found", chardev); + return -1; } monitor_init(chr, flags); @@ -4413,10 +4413,8 @@ int main(int argc, char **argv, char **envp) default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); - if (qemu_opts_foreach(qemu_find_opts("mon"), - mon_init_func, NULL, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("mon"), + mon_init_func, NULL, &error_fatal); if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) exit(1); |