summaryrefslogtreecommitdiffstats
path: root/iohandler.c
Commit message (Collapse)AuthorAgeFilesLines
* iohandler: Use aio APIFam Zheng2015-09-071-96/+15
| | | | | | | | | | | | | iohandler.c shares the same interface with aio, but with duplicated code. It's better to rebase iohandler, also because that aio is a more friendly interface to multi-threads. Create a global AioContext instance and let its GSource handle the iohandler events. Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <1441596538-4412-1-git-send-email-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* iohandler: Change return type of qemu_set_fd_handler to "void"Fam Zheng2015-06-121-5/+4
| | | | | | Signed-off-by: Fam Zheng <famz@redhat.com> Message-id: 1433400324-7358-14-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* main-loop: Drop qemu_set_fd_handler2Fam Zheng2015-06-121-21/+5
| | | | | | | | | All users are converted to qemu_set_fd_handler now, drop qemu_set_fd_handler2 and IOHandlerRecord.fd_read_poll. Signed-off-by: Fam Zheng <famz@redhat.com> Message-id: 1433400324-7358-9-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* iohandler.c: Properly initialize sigaction structPeter Maydell2014-05-241-0/+1
| | | | | | | | | | | The code in qemu_init_child_watch() wasn't clearing the 'struct sigaction' before passing it to sigaction(); this meant that we would block a random set of signals while executing the SIGCHLD handler. Initialize properly by using memset() on the struct, as we do in similar cases elsewhere. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* iohandler: switch to GPollFDStefan Hajnoczi2013-02-211-10/+30
| | | | | | | | | | Convert iohandler_select_fill() and iohandler_select_poll() to use GPollFD instead of rfds/wfds/xfds. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-id: 1361356113-11049-7-git-send-email-stefanha@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-2/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* block: move include files to include/block/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* janitor: do not include qemu-char everywherePaolo Bonzini2012-12-191-1/+0
| | | | | | | Touching char/char.h basically causes the whole of QEMU to be rebuilt. Avoid this, it is usually unnecessary. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* aio: introduce AioContext, move bottom halves therePaolo Bonzini2012-10-301-0/+1
| | | | | | | | | | | | Start introducing AioContext, which will let us remove globals from aio.c/async.c, and introduce multiple I/O threads. The bottom half functions now take an additional AioContext argument. A bottom half is created with a specific AioContext that remains the same throughout the lifetime. qemu_bh_new is just a wrapper that uses a global context. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: BUGFIX, don't call FD_ISSET with negative fdDavid Gibson2012-09-171-0/+2
| | | | | | | | | | | | | | | | tcp_chr_connect(), unlike for example udp_chr_update_read_handler() does not check if the fd it is using is valid (>= 0) before passing it to qemu_set_fd_handler2(). If using e.g. a TCP serial port, which is not initially connected, this can result in -1 being passed to FD_ISSET, which has undefined behaviour. On x86 it seems to harmlessly return 0, but on PowerPC, it causes a fortify buffer overflow error to be thrown. This patch fixes this by putting an extra test in tcp_chr_connect(), and also adds an assert qemu_set_fd_handler2() to catch other such errors on all platforms, rather than just some. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* eventfd: making it thread safeAlexey Kardashevskiy2012-08-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | QEMU uses IO handlers to run select() in the main loop. The handlers list is managed by qemu_set_fd_handler() helper which works fine when called from the main thread as it is called when select() is not waiting. However IO handlers list can be changed in the thread other than the main one doing os_host_main_loop_wait(), for example, as a result of a hypercall which changes PCI config space (VFIO on POWER is the case) and enables/disabled MSI/MSIX which closes/creates eventfd handles. As the main loop should be waiting on the newly created eventfds, it has to be restarted. The patch adds the qemu_notify_event() call to interrupt select() to make main_loop() restart select() with the updated IO handlers list. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* iohandler: Use bool for boolean struct member and remove holesStefan Weil2012-05-011-2/+2
| | | | | | | | Using bool reduces the size of the structure and improves readability. Two holes in the structure were removed. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* Revert to a hand-made select loopPaolo Bonzini2011-10-211-53/+1
| | | | | | | This reverts commit c82dc29a9112f34e0a51cad9a412cf6d9d05dfb2 and 4d88a2ac8643265108ef1fb47ceee5d7b28e19f2. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* main-loop: create main-loop.hPaolo Bonzini2011-10-211-0/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* iohandlers: fix issue with qemu_set_fd_handler()Anthony Liguori2011-09-081-5/+2
| | | | | | | | | As spotted by Aneesh, some users pass a NULL opaque so we need to be more aggressive in checking whether a user means to unregister. Also fix a double free caused by tag not being reset to zero after delete. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* main: switch qemu_set_fd_handler to g_io_add_watchAnthony Liguori2011-09-011-1/+56
| | | | | | | | | | | | | | | | | This patch changes qemu_set_fd_handler to be implemented in terms of g_io_add_watch(). The semantics are a bit different so some glue is required. qemu_set_fd_handler2 is much harder to convert because of its use of polling. The glib main loop has the major of advantage of having a proven thread safe architecture. By using the glib main loop instead of our own, it will allow us to eventually introduce multiple I/O threads. I'm pretty sure that this will work on Win32, but I would appreciate some help testing. I think the semantics of g_io_channel_unix_new() are really just tied to the notion of a "unix fd" and not necessarily unix itself. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-201-4/+4
| | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* add a service to reap zombies, use it in SLIRPPaolo Bonzini2011-03-291-0/+64
| | | | | | | | | | | | | SLIRP -smb support wants to fork a process and forget about reaping it. To please it, add a generic service to register a process id and let QEMU reap it. In the future it could be enhanced to pass a status, but this would be unused. With this in place, the SIGCHLD signal handler would not stomp on pclose anymore. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* extract I/O handler lists to iohandler.cPaolo Bonzini2011-03-291-0/+129
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
OpenPOWER on IntegriCloud