[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/33] qemu: add a cleanup callback function to Event
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 06/33] qemu: add a cleanup callback function to EventNotifier |
Date: |
Tue, 16 Jan 2018 06:46:56 +0200 |
From: Gal Hammer <address@hidden>
Adding a cleanup callback function to the EventNotifier struct
which allows users to execute event_notifier_cleanup in a
different context.
Signed-off-by: Gal Hammer <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/qemu/event_notifier.h | 1 +
util/event_notifier-posix.c | 5 ++++-
util/event_notifier-win32.c | 2 ++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/qemu/event_notifier.h b/include/qemu/event_notifier.h
index 599c99f..b30a454 100644
--- a/include/qemu/event_notifier.h
+++ b/include/qemu/event_notifier.h
@@ -26,6 +26,7 @@ struct EventNotifier {
int rfd;
int wfd;
#endif
+ void (*cleanup)(EventNotifier *);
};
typedef void EventNotifierHandler(EventNotifier *);
diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 73c4046..6525666 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -29,6 +29,7 @@ void event_notifier_init_fd(EventNotifier *e, int fd)
{
e->rfd = fd;
e->wfd = fd;
+ e->cleanup = NULL;
}
#endif
@@ -65,6 +66,7 @@ int event_notifier_init(EventNotifier *e, int active)
e->rfd = fds[0];
e->wfd = fds[1];
}
+ e->cleanup = NULL;
if (active) {
event_notifier_set(e);
}
@@ -80,10 +82,11 @@ void event_notifier_cleanup(EventNotifier *e)
{
if (e->rfd != e->wfd) {
close(e->rfd);
- e->rfd = -1;
}
close(e->wfd);
+ e->rfd = -1;
e->wfd = -1;
+ e->cleanup = NULL;
}
int event_notifier_get_fd(const EventNotifier *e)
diff --git a/util/event_notifier-win32.c b/util/event_notifier-win32.c
index 62c53b0..eff8670 100644
--- a/util/event_notifier-win32.c
+++ b/util/event_notifier-win32.c
@@ -19,6 +19,7 @@ int event_notifier_init(EventNotifier *e, int active)
{
e->event = CreateEvent(NULL, TRUE, FALSE, NULL);
assert(e->event);
+ e->cleanup = NULL;
return 0;
}
@@ -26,6 +27,7 @@ void event_notifier_cleanup(EventNotifier *e)
{
CloseHandle(e->event);
e->event = NULL;
+ e->cleanup = NULL;
}
HANDLE event_notifier_get_handle(EventNotifier *e)
--
MST
- [Qemu-devel] [PULL 00/33] pc, pci, virtio: features, fixes, cleanups, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 01/33] MAINTAINERS: Add myself as maintainer to X86 machines, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 02/33] vhost-user: add new vhost user messages to support virtio config space, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 03/33] vhost-user-blk: introduce a new vhost-user-blk host device, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 04/33] contrib/libvhost-user: enable virtio config space messages, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 07/33] virtio: postpone the execution of event_notifier_cleanup function, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 08/33] virtio: improve virtio devices initialization time, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 06/33] qemu: add a cleanup callback function to EventNotifier,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 05/33] contrib/vhost-user-blk: introduce a vhost-user-blk sample application, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 09/33] pci/shpc: Move function to generic header file, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 10/33] vhost-user: fix multiple queue specification, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 11/33] intel-iommu: Redefine macros to enable supporting 48 bit address width, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 14/33] ACPI/unit-test: Add a testcase for RAM allocation in numa node, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 12/33] intel-iommu: Extend address width to 48 bits, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 13/33] hw/pci-bridge: fix QEMU crash because of pcie-root-port, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 15/33] hw/acpi-build: Make next_base easy to follow, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 16/33] vhost-user-test: fix features mask, Michael S. Tsirkin, 2018/01/15
- [Qemu-devel] [PULL 17/33] vhost-user-test: extract read-guest-mem test from main loop, Michael S. Tsirkin, 2018/01/15