From: Paolo Bonzini <pbonzini@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 05/10] Introduce QemuEvent abstraction
Date: Thu, 05 Apr 2012 13:23:28 +0200 [thread overview]
Message-ID: <4F7D80B0.5070008@redhat.com> (raw)
In-Reply-To: <14c3f383cbeedf4bf67a920a8fb6f6ced85d5be2.1333623555.git.jan.kiszka@siemens.com>
Il 05/04/2012 12:59, Jan Kiszka ha scritto:
> Provide generic services for binary events. Blocking wait would be
> feasible but is not included yet as there are no users.
>
> diff --git a/qemu-event-posix.c b/qemu-event-posix.c
> new file mode 100644
> index 0000000..6138168
> --- /dev/null
> +++ b/qemu-event-posix.c
> @@ -0,0 +1,110 @@
> +/*
> + * Posix implementations of event signaling service
> + *
> + * Copyright Red Hat, Inc. 2012
> + * Copyright Siemens AG 2012
> + *
> + * Author:
> + * Paolo Bonzini <pbonzini@redhat.com>
> + * Jan Kiszka <jan.kiszka@siemens.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +#include "qemu-thread.h"
> +#include "qemu-common.h"
> +#include "main-loop.h"
> +
> +#ifdef CONFIG_EVENTFD
> +#include <sys/eventfd.h>
> +#endif
> +
> +void qemu_event_init(QemuEvent *event, bool signaled)
> +{
> + int fds[2];
> + int ret;
> +
> +#ifdef CONFIG_EVENTFD
> + ret = eventfd(signaled, EFD_NONBLOCK | EFD_CLOEXEC);
> + if (ret >= 0) {
> + event->rfd = ret;
> + event->wfd = dup(ret);
> + if (event->wfd < 0) {
> + qemu_error_exit(errno, __func__);
> + }
> + qemu_set_cloexec(event->wfd);
> + return;
> + }
> + if (errno != ENOSYS) {
> + qemu_error_exit(errno, __func__);
> + }
> + /* fall back to pipe-based support */
> +#endif
> +
> + ret = qemu_pipe(fds);
> + if (ret < 0) {
> + qemu_error_exit(errno, __func__);
> + }
> + event->rfd = fds[0];
> + event->wfd = fds[1];
> + if (signaled) {
> + qemu_event_signal(event);
> + }
> +}
> +
> +void qemu_event_destroy(QemuEvent *event)
> +{
> + close(event->rfd);
> + close(event->wfd);
> +}
> +
> +int qemu_event_get_signal_fd(QemuEvent *event)
> +{
> + return event->wfd;
> +}
How would you use it? Since qemu_event_signal ignores EAGAIN, polling
for writeability of the fd is useless.
This is really little more than search-and-replace from what gets out of
event-notifier.c after my patches, and the commit message does not
explain the differences in the two APIs. Having separate commits as I
had would make the steps obvious. Is it really worthwhile to do this
and introduce the need for patches 9+10 (plus IIRC conflicts in qemu-kvm)?
(In fact, qemu_event_get_poll_fd is a layering violation too. In a
perfect world, aio.c would simply get a list of EventNotifiers and no
other types of fd).
Paolo
next prev parent reply other threads:[~2012-04-05 11:23 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-05 10:59 [Qemu-devel] [PATCH v3 00/10] Use more central threading and synchronization services Jan Kiszka
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX Jan Kiszka
2012-04-05 11:19 ` Peter Maydell
2012-04-05 11:56 ` Jan Kiszka
2012-04-05 12:15 ` Peter Maydell
2012-04-05 12:30 ` malc
2012-04-05 12:37 ` Paolo Bonzini
2012-04-05 12:53 ` malc
2012-04-05 12:56 ` Paolo Bonzini
2012-04-05 12:59 ` Jan Kiszka
2012-04-05 13:00 ` malc
2012-04-05 13:03 ` Jan Kiszka
2012-04-05 13:20 ` malc
2012-04-05 13:24 ` Jan Kiszka
2012-04-05 13:37 ` malc
2012-04-05 12:59 ` malc
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 02/10] Switch POSIX compat AIO to QEMU abstractions Jan Kiszka
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 03/10] Switch compatfd to QEMU thread Jan Kiszka
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 04/10] qemu-thread: Factor out qemu_error_exit Jan Kiszka
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 05/10] Introduce QemuEvent abstraction Jan Kiszka
2012-04-05 11:23 ` Paolo Bonzini [this message]
2012-04-05 12:20 ` Jan Kiszka
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 06/10] Use QemuEvent in main loop Jan Kiszka
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 07/10] Drop unused qemu_eventfd Jan Kiszka
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 08/10] Use QemuEvent for POSIX AIO Jan Kiszka
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 09/10] virtio: Switch to QemuEvent Jan Kiszka
2012-04-05 10:59 ` [Qemu-devel] [PATCH v3 10/10] Remove EventNotifier Jan Kiszka
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=4F7D80B0.5070008@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=jan.kiszka@siemens.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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.