[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notif
From: |
Benoît Canet |
Subject: |
Re: [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure |
Date: |
Tue, 16 Sep 2014 15:53:16 +0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
> static void iothread_complete(UserCreatable *obj, Error **errp)
> {
> + Error *local_error = NULL;
> IOThread *iothread = IOTHREAD(obj);
>
> iothread->stopping = false;
> - iothread->ctx = aio_context_new();
> + iothread->ctx = aio_context_new(&local_error);
> + if (!iothread->ctx) {
> + error_report("%s", error_get_pretty(local_error));
> + error_report("Failed to create AIO context");
I think reporting one line is sufficient.
You could do something in the vein of.
error_report("Failed to create AIO Context: \'%s\'",
error_get_pretty(local_error));
> + exit(1);
Also here I don't know if exiting in the middle of a class initialization
completion function is good taste.
You should ask to someone knowing QOM.
> signal(SIGPIPE, SIG_IGN);
> @@ -444,7 +446,13 @@ int main(int argc, char **argv)
> exit(1);
> }
>
> - qemu_init_main_loop();
> + ret = qemu_init_main_loop(&local_error);
> + if (ret < 0) {
> + error_report("%s", error_get_pretty(local_error));
> + error_report("qemu_init_main_loop failed");
> + error_free(local_error);
> + return ret;
We are in main here.
Should it be exit(something) like above ?
> if (local_err) {
> - errx(EXIT_FAILURE, "Failed to parse detect_zeroes mode: %s",
> + errx(EXIT_FAILURE, "Failed to parse detect_zeroes mode: %s",
> error_get_pretty(local_err));
> }
> if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
> !(flags & BDRV_O_UNMAP)) {
> errx(EXIT_FAILURE, "setting detect-zeroes to unmap is not
> allowed "
> - "without setting discard operation to
> unmap");
> + "without setting discard operation to
> unmap");
No cosmetic fixes on parts of the code unmodified by a patch please.
Your editor is probably removing these extra EOL spaces on your behalf. Fix it.
> }
> break;
> case 'b':
> @@ -674,7 +674,13 @@ int main(int argc, char **argv)
> snprintf(sockpath, 128, SOCKET_PATH, basename(device));
> }
>
> - qemu_init_main_loop();
> + ret = qemu_init_main_loop(&local_err);
> + if (ret < 0) {
> + error_report("%s", error_get_pretty(local_err));
> + error_report("qemu_init_main_loop failed");
> + error_free(local_err);
> + exit(EXIT_FAILURE);
> + }
> bdrv_init();
> atexit(bdrv_close_all);
>
> diff --git a/tests/test-aio.c b/tests/test-aio.c
> index c6a8713..4cb3783 100644
> --- a/tests/test-aio.c
> +++ b/tests/test-aio.c
> @@ -14,6 +14,7 @@
> #include "block/aio.h"
> #include "qemu/timer.h"
> #include "qemu/sockets.h"
> +#include "qemu/error-report.h"
>
> static AioContext *ctx;
>
> @@ -810,11 +811,18 @@ static void test_source_timer_schedule(void)
>
> int main(int argc, char **argv)
> {
> + Error *local_error;
> GSource *src;
>
> init_clocks();
>
> - ctx = aio_context_new();
> + ctx = aio_context_new(&local_error);
> + if (!ctx) {
> + error_report("%s", error_get_pretty(local_error));
> + error_report("Failed to create AIO context");
> + error_free(local_error);
> + exit(1);
> + }
> src = aio_get_g_source(ctx);
> g_source_attach(src, NULL);
> g_source_unref(src);
> diff --git a/tests/test-thread-pool.c b/tests/test-thread-pool.c
> index f40b7fc..ff6a8b0 100644
> --- a/tests/test-thread-pool.c
> +++ b/tests/test-thread-pool.c
> @@ -4,6 +4,7 @@
> #include "block/thread-pool.h"
> #include "block/block.h"
> #include "qemu/timer.h"
> +#include "qemu/error-report.h"
>
> static AioContext *ctx;
> static ThreadPool *pool;
> @@ -205,10 +206,17 @@ static void test_cancel(void)
> int main(int argc, char **argv)
> {
> int ret;
> + Error *local_error;
>
> init_clocks();
>
> - ctx = aio_context_new();
> + ctx = aio_context_new(&local_error);
> + if (!ctx) {
> + error_report("%s", error_get_pretty(local_error));
> + error_report("Failed to create AIO context");
> + error_free(local_error);
> + exit(1);
> + }
> pool = aio_get_thread_pool(ctx);
>
> g_test_init(&argc, &argv, NULL);
> diff --git a/tests/test-throttle.c b/tests/test-throttle.c
> index 000ae31..7be607a 100644
> --- a/tests/test-throttle.c
> +++ b/tests/test-throttle.c
> @@ -14,6 +14,7 @@
> #include <math.h>
> #include "block/aio.h"
> #include "qemu/throttle.h"
> +#include "qemu/error-report.h"
>
> static AioContext *ctx;
> static LeakyBucket bkt;
> @@ -492,10 +493,17 @@ static void test_accounting(void)
> int main(int argc, char **argv)
> {
> GSource *src;
> + Error *local_error;
>
> init_clocks();
>
> - ctx = aio_context_new();
> + ctx = aio_context_new(&local_error);
> + if (!ctx) {
> + error_report("%s", error_get_pretty(local_error));
> + error_report("Failed to create AIO context");
> + error_free(local_error);
> + exit(1);
> + }
> src = aio_get_g_source(ctx);
> g_source_attach(src, NULL);
> g_source_unref(src);
> diff --git a/vl.c b/vl.c
> index 5db0d08..1340f6f 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2968,6 +2968,7 @@ int main(int argc, char **argv, char **envp)
> ram_addr_t maxram_size = default_ram_size;
> uint64_t ram_slots = 0;
> FILE *vmstate_dump_file = NULL;
> + Error *main_loop_err = NULL;
>
> atexit(qemu_run_exit_notifiers);
> error_set_progname(argv[0]);
> @@ -3998,8 +3999,10 @@ int main(int argc, char **argv, char **envp)
>
> os_daemonize();
>
> - if (qemu_init_main_loop()) {
> - fprintf(stderr, "qemu_init_main_loop failed\n");
> + if (qemu_init_main_loop(&main_loop_err)) {
> + error_report("%s", error_get_pretty(main_loop_err));
> + error_report("qemu_init_main_loop failed");
> + error_free(main_loop_err);
> exit(1);
> }
>
> --
> 1.7.10.4
>
>
- [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure, Chrysostomos Nanakos, 2014/09/16
- [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure, Chrysostomos Nanakos, 2014/09/16
- Re: [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure,
Benoît Canet <=
- Re: [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure, Paolo Bonzini, 2014/09/16
- Re: [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure, Chrysostomos Nanakos, 2014/09/16
- Re: [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure, Paolo Bonzini, 2014/09/16
- Re: [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure, Chrysostomos Nanakos, 2014/09/16
- Re: [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure, Chrysostomos Nanakos, 2014/09/16