qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 00/11] main-loop: switch to g_poll(3) on POSIX hosts


From: Stefan Hajnoczi
Subject: [Qemu-devel] [PATCH 00/11] main-loop: switch to g_poll(3) on POSIX hosts
Date: Thu, 31 Jan 2013 11:53:53 +0100

Amos Kong <address@hidden> reported that file descriptors numbered higher
than 1024 could crash QEMU.  This is due to the fixed size of the fd_set type
used for select(2) event polling.

This series converts the main-loop.c and aio-posix.c select(2) calls to
g_poll(3).  This eliminates the fd_set type and allows QEMU to scale to high
numbers of file descriptors.

The g_poll(3) interface is a portable version of the poll(2) system call.  The
difference to select(2) is that fine-grained events (G_IO_IN, G_IO_OUT,
G_IO_HUP, G_IO_ERR, G_IO_PRI) can be monitored instead of just
read/write/exception.  Also, there is no limit to the file descriptor numbers
that may be used, allowing applications to scale to many file descriptors.  See
the documentation for details:

  http://developer.gnome.org/glib/2.28/glib-The-Main-Event-Loop.html#g-poll

The QEMU main loop works as follows today:

1. Call out to slirp, iohandlers, and glib sources to fill rfds/wfds/xfds with
   the file descriptors to select(2).
2. Perform the select(2) call.
3. Call out to slirp, iohandlers, and glib sources to handle events polled in
   rfds/wfds/xfds.

The plan of attack is as follows:

1. Add a Poller type for growable GPollFD arrays.  The is the new type that
   will be used instead of fd_set.

2. Replace select(2) with g_poll(3).  Use glue that converts between
   rfds/wfds/xfds and Poller so that the unconverted QEMU components still
   work.

3. Convert slirp, iohandlers, and glib source fill/poll functions to use Poller
   directly instead of rfds/wfds/xfds.

4. Drop the glue since all components now natively use Poller.

5. Convert aio-posix.c to g_poll(3) by reusing Poller.

I have tested that the series builds and is bisectable on Linux and Windows
hosts.  But I have not done extensive testing on other host platforms or with
long-term guests to check for performance regressions.

Stefan Hajnoczi (11):
  main-loop: fix select_ret uninitialized variable warning
  poller: add Poller for growable GPollFD arrays
  poller: add poller_fill() and poller_poll()
  main-loop: switch to g_poll() on POSIX hosts
  main-loop: switch POSIX glib integration to Poller
  slirp: switch to Poller
  iohandler: switch to Poller
  main-loop: drop rfds/wfds/xfds for good
  aio: extract aio_dispatch() from aio_poll()
  aio: convert aio_poll() to g_poll(3)
  aio: support G_IO_HUP and G_IO_ERR

 aio-posix.c              | 125 ++++++++++++++++++++---------------------------
 async.c                  |   2 +
 include/block/aio.h      |   4 ++
 include/qemu/main-loop.h |   5 +-
 include/qemu/poller.h    |  68 ++++++++++++++++++++++++++
 iohandler.c              |  33 +++++++++----
 main-loop.c              | 110 +++++++++++++++++------------------------
 slirp/libslirp.h         |   8 +--
 slirp/main.h             |   1 -
 slirp/slirp.c            | 113 +++++++++++++++++++++---------------------
 slirp/socket.c           |   9 ----
 slirp/socket.h           |   2 +
 stubs/slirp.c            |   6 +--
 util/Makefile.objs       |   1 +
 util/poller.c            | 100 +++++++++++++++++++++++++++++++++++++
 15 files changed, 365 insertions(+), 222 deletions(-)
 create mode 100644 include/qemu/poller.h
 create mode 100644 util/poller.c

-- 
1.8.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]