Libvirt provides a portable, long term stable C API for managing the virtualization technologies provided by many operating systems. It includes support for QEMU, KVM, Xen, LXC, bhyve, Virtuozzo, VMware vCenter and ESX, VMware Desktop, Hyper-V, VirtualBox and the POWER Hypervisor.
Go to file
Laszlo Ersek d19149dda8 virCommandProcessIO(): make poll() usage more robust
POLLIN and POLLHUP are not mutually exclusive. Currently the following
seems possible: the child writes 3K to its stdout or stderr pipe, and
immediately closes it. We get POLLIN|POLLHUP (I'm not sure that's possible
on Linux, but SUSv4 seems to allow it). We read 1K and throw away the
rest.

When poll() returns and we're about to check the /revents/ member in a
given array element, let's map all the revents bits to two (independent)
ideas: "let's attempt to read()", and "let's attempt to write()". This
should cover all errors, EOFs, and normal conditions; the read()/write()
call should report any pending error.

Under this approach, both POLLHUP and POLLERR are mapped to "needs read()"
if we're otherwise prepared for POLLIN. POLLERR also maps to "needs
write()" if we're otherwise prepared for POLLOUT. The rest of the mappings
(POLLPRI etc.) would be easy, but probably useless for pipes.

Additionally, SUSv4 doesn't appear to forbid POLLIN|POLLERR (or
POLLOUT|POLLERR) set simultaneously. One could argue that the read() or
write() call would return without blocking in these cases (with an error),
so POLLIN / POLLOUT would be justified beside POLLERR.

The code now penalizes POLLIN|POLLERR differently from plain POLLERR. The
former (ie. read() returning -1) is terminal and we jump to cleanup, while
plain POLLERR masks only the affected file descriptor for the future.
Let's unify those.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2012-01-24 13:50:45 -07:00
.gnulib@dd6b2d751b build: fix bootstrap on fresh clone 2012-01-16 11:23:34 -07:00
daemon API: make declaration of _LAST enum values conditional 2012-01-20 16:05:51 -07:00
docs QEMU guest agent support 2012-01-24 12:19:51 +01:00
examples Permission change for systemtap examples. 2012-01-17 15:42:01 -07:00
gnulib build: update to latest gnulib 2012-01-12 15:47:54 -07:00
include Add new virDomainShutdownFlags API 2012-01-24 12:19:51 +01:00
m4 build: silence some compiler warnings from gnulib 2012-01-19 13:14:10 -07:00
po QEMU guest agent support 2012-01-24 12:19:51 +01:00
python API: make declaration of _LAST enum values conditional 2012-01-20 16:05:51 -07:00
src virCommandProcessIO(): make poll() usage more robust 2012-01-24 13:50:45 -07:00
tests hashtest: Initialize variable in virHashEqual test 2012-01-24 12:09:42 +01:00
tools Allow choice of shutdown method via virsh 2012-01-24 12:19:51 +01:00
.dir-locals.el maint: let emacs avoid tabs in rng files 2011-08-13 08:56:26 -06:00
.gitignore Define keepalive protocol 2011-11-24 11:44:08 +01:00
.gitmodules make .gnulib a submodule 2009-07-08 16:17:51 +02:00
.mailmap maint: use mailmap, not AUTHORS, for secondary addresses 2011-11-11 08:56:19 -07:00
AUTHORS virCommandProcessIO(): make poll() usage more robust 2012-01-24 13:50:45 -07:00
autobuild.sh Disable python explicitly in mingw32 autobuild 2011-12-19 13:44:18 +00:00
autogen.sh build: allow for local gnulib diffs 2011-11-09 09:03:33 -07:00
bootstrap build: fix bootstrap on fresh clone 2012-01-16 11:23:34 -07:00
bootstrap.conf build: update to latest gnulib 2012-01-12 15:47:54 -07:00
cfg.mk maint: enforce use of _LAST marker 2012-01-20 16:16:04 -07:00
ChangeLog-old generate ChangeLog from git logs into distribution tarball 2009-07-08 16:17:51 +02:00
configure.ac build: skip lxc with too-old glibc 2012-01-23 06:50:28 -07:00
COPYING.LIB remove all trailing blank lines 2009-07-16 15:06:42 +02:00
HACKING Document STREQ_NULLABLE and STRNEQ_NULLABLE 2011-10-06 16:50:38 +02:00
libvirt.pc.in * libvirt.pc.in: applied patch from Daniel Berrange to fix --cflags 2006-03-24 13:18:12 +00:00
libvirt.spec.in Remove dmidecode dependancy outside PC arches 2012-01-18 00:22:17 +08:00
Makefile.am maint: add missing copyright notices 2011-07-28 15:01:17 -06:00
Makefile.nonreentrant Ban use of all inet_* functions 2010-10-22 11:59:23 +01:00
mingw32-libvirt.spec.in spec: make it easier to autoreconf when building rpm 2011-12-08 09:49:50 -07:00
README Correct typos in the documentation (Atsushi SAKAI) 2008-01-24 10:15:13 +00:00
README-hacking maint: relax git minimum version 2010-02-24 14:29:27 -05:00
TODO Update todo list file to point at bugzilla/website 2010-10-13 16:45:26 +01:00

         LibVirt : simple API for virtualization

  Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). It is free software
available under the GNU Lesser General Public License. Virtualization of
the Linux Operating System means the ability to run multiple instances of
Operating Systems concurrently on a single hardware system where the basic
resources are driven by a Linux instance. The library aim at providing
long term stable C API initially for the Xen paravirtualization but
should be able to integrate other virtualization mechanisms if needed.

Daniel Veillard <veillard@redhat.com>