mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
use eventfd for iothread
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
bf76bafa5a
commit
f3dfda6114
3 changed files with 38 additions and 4 deletions
32
osdep.c
32
osdep.c
|
@ -37,6 +37,10 @@
|
|||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EVENTFD
|
||||
#include <sys/eventfd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#elif defined(CONFIG_BSD)
|
||||
|
@ -280,6 +284,34 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)
|
|||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/*
|
||||
* Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set.
|
||||
*/
|
||||
int qemu_eventfd(int fds[2])
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_EVENTFD
|
||||
ret = eventfd(0, 0);
|
||||
if (ret >= 0) {
|
||||
fds[0] = ret;
|
||||
qemu_set_cloexec(ret);
|
||||
if ((fds[1] = dup(ret)) == -1) {
|
||||
close(ret);
|
||||
return -1;
|
||||
}
|
||||
qemu_set_cloexec(fds[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (errno != ENOSYS) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return qemu_pipe(fds);
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a pipe with FD_CLOEXEC set on both file descriptors
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue