From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Chrysostomos Nanakos <cnanakos@grnet.gr>
Cc: kwolf@redhat.com, pingfank@linux.vnet.ibm.com, famz@redhat.com,
kroosec@gmail.com, jan.kiszka@siemens.com, mjt@tls.msk.ru,
qemu-devel@nongnu.org, stefanha@redhat.com, sw@weilnetz.de,
pbonzini@redhat.com, afaerber@suse.de, aliguori@amazon.com
Subject: Re: [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure
Date: Tue, 16 Sep 2014 15:53:16 +0200 [thread overview]
Message-ID: <20140916135316.GA19869@irqsave.net> (raw)
In-Reply-To: <1410858395-24589-2-git-send-email-cnanakos@grnet.gr>
> 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
>
>
next prev parent reply other threads:[~2014-09-16 13:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 9:06 [Qemu-devel] [PATCH v2] async: aio_context_new(): Handle event_notifier_init failure Chrysostomos Nanakos
2014-09-16 9:06 ` Chrysostomos Nanakos
2014-09-16 13:53 ` Benoît Canet [this message]
2014-09-16 13:57 ` Paolo Bonzini
2014-09-16 15:43 ` Chrysostomos Nanakos
2014-09-16 15:45 ` Paolo Bonzini
2014-09-16 15:50 ` Chrysostomos Nanakos
2014-09-16 17:58 ` Chrysostomos Nanakos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140916135316.GA19869@irqsave.net \
--to=benoit.canet@irqsave.net \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=cnanakos@grnet.gr \
--cc=famz@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kroosec@gmail.com \
--cc=kwolf@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=pbonzini@redhat.com \
--cc=pingfank@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.