[libvirt] [BUG] EPOLL_CLOEXEC undeclared

Philipp Hahn hahn at univention.de
Tue Jan 17 11:42:11 UTC 2012


Hello Eric,

thank you for taking a look at my problem.

On Monday 16 January 2012 16:36:00 Eric Blake wrote:
> On 01/16/2012 08:07 AM, Philipp Hahn wrote:
> > $ dpkg-query -W linux-libc-dev
> > linux-libc-dev  2.6.32-35~ucs1.48.201109051614
>
> glibc has supported epoll_create1() and EPOLL_CLOEXEC since glibc 2.9.

That's the problem on this (old) Debian Lenny system:
# dpkg-query -W libc6-dev
libc6-dev       2.7-18.32.201101241735

> #define EPOLL_CLOEXEC O_CLOEXEC

Adding that define doesn't solve the problem; the next errors are

lxc/lxc_controller.c: In function ‘lxcControllerMain’:
lxc/lxc_controller.c:1176: warning: implicit declaration of 
function ‘epoll_create1’
lxc/lxc_controller.c:1176: warning: nested extern declaration 
of ‘epoll_create1’ [-Wnested-externs]


# objdump -T /lib/libc-2.7.so | grep epoll_create
00000000000cfb60 g    DF .text  0000000000000025  GLIBC_2.3.2 epoll_create

From a different (newer) Debian Squeeze system:
# objdump -T /lib/libc-2.11.2.so  | grep epoll_create
000cc020 g    DF .text  00000034  GLIBC_2.3.2 epoll_create
000cc060 g    DF .text  00000034  GLIBC_2.9   epoll_create1

> Would you like to submit the patch for that?

For me this looks like lxc now only works with glibc >= 2.9, so an appropriate 
check in configure should be added?
Or a fall-back to epoll_create()?

diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 49727dd..bb36d91 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1173,7 +1173,11 @@ static int lxcControllerMain(int serverFd,
         consoles[i].hostFd = hostFds[i];
         consoles[i].contFd = contFds[i];
 
+#ifdef EPOLL_CLOEXEC
         if ((consoles[i].epollFd = epoll_create1(EPOLL_CLOEXEC)) < 0) {
+#else
+        if ((consoles[i].epollFd = epoll_create(0)) < 0 || 
virSetInherit(consoles[i].epollFd, false) < 0) {
+#endif
             virReportSystemError(errno, "%s",
                                  _("Unable to create epoll fd"));
             goto cleanup;

Yes, I know it's ugly and not 100% thread/signal/async save, but at least if 
compiles again with older libc versions.

Sincerely
Philipp
-- 
Philipp Hahn           Open Source Software Engineer      hahn at univention.de
Univention GmbH        Linux for Your Business        fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99
                                                   http://www.univention.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120117/d39430c3/attachment-0001.sig>


More information about the libvir-list mailing list