]> xenbits.xensource.com Git - libvirt.git/commitdiff
Remove use of qemudSetNonBlock/SetCloseExec in favour of shared impl
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 12 May 2009 15:43:07 +0000 (15:43 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 12 May 2009 15:43:07 +0000 (15:43 +0000)
ChangeLog
qemud/event.c
qemud/qemud.c
qemud/qemud.h

index 5be64adbf8e72a7f9f418d568b20332f13c73d49..077a9487a3450bbe4aff554cb7763395f0f9a4b8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue May 12 16:38:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
+
+       * qemud/qemud.c, qemud/qemud.h, qemud/event.c: Remove use
+       of qemudSetNonBock/SetCloseExec in favour of virSetNonBlock
+       and virSetCloseExec.
+
 Tue May 12 16:38:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
 
        Allow for quieter build with 'make -s'
index 0887008b4df2a19a6ea91517868ea523ffcff9bd..65f548e44e4107d87fd226db396413243b42802f 100644 (file)
@@ -30,7 +30,8 @@
 #include <errno.h>
 #include <unistd.h>
 
-#include "qemud.h"
+#include "threads.h"
+#include "logging.h"
 #include "event.h"
 #include "memory.h"
 #include "util.h"
@@ -597,10 +598,10 @@ int virEventInit(void)
         return -1;
 
     if (pipe(eventLoop.wakeupfd) < 0 ||
-        qemudSetNonBlock(eventLoop.wakeupfd[0]) < 0 ||
-        qemudSetNonBlock(eventLoop.wakeupfd[1]) < 0 ||
-        qemudSetCloseExec(eventLoop.wakeupfd[0]) < 0 ||
-        qemudSetCloseExec(eventLoop.wakeupfd[1]) < 0)
+        virSetNonBlock(eventLoop.wakeupfd[0]) < 0 ||
+        virSetNonBlock(eventLoop.wakeupfd[1]) < 0 ||
+        virSetCloseExec(eventLoop.wakeupfd[0]) < 0 ||
+        virSetCloseExec(eventLoop.wakeupfd[1]) < 0)
         return -1;
 
     if (virEventAddHandleImpl(eventLoop.wakeupfd[0],
index 829a4bc5f29ba54eac674324a284cf60bd6a198b..1847407911ce6cbccee08d29965f60c4100b91f7 100644 (file)
@@ -371,32 +371,6 @@ qemudDispatchSignalEvent(int watch ATTRIBUTE_UNUSED,
     virMutexUnlock(&server->lock);
 }
 
-int qemudSetCloseExec(int fd) {
-    int flags;
-    if ((flags = fcntl(fd, F_GETFD)) < 0)
-        goto error;
-    flags |= FD_CLOEXEC;
-    if ((fcntl(fd, F_SETFD, flags)) < 0)
-        goto error;
-    return 0;
- error:
-    VIR_ERROR0(_("Failed to set close-on-exec file descriptor flag"));
-    return -1;
-}
-
-
-int qemudSetNonBlock(int fd) {
-    int flags;
-    if ((flags = fcntl(fd, F_GETFL)) < 0)
-        goto error;
-    flags |= O_NONBLOCK;
-    if ((fcntl(fd, F_SETFL, flags)) < 0)
-        goto error;
-    return 0;
- error:
-    VIR_ERROR0(_("Failed to set non-blocking file descriptor flag"));
-    return -1;
-}
 
 static int qemudGoDaemon(void) {
     int pid = fork();
@@ -525,8 +499,8 @@ static int qemudListenUnix(struct qemud_server *server,
         goto cleanup;
     }
 
-    if (qemudSetCloseExec(sock->fd) < 0 ||
-        qemudSetNonBlock(sock->fd) < 0)
+    if (virSetCloseExec(sock->fd) < 0 ||
+        virSetNonBlock(sock->fd) < 0)
         goto cleanup;
 
     memset(&addr, 0, sizeof(addr));
@@ -687,8 +661,8 @@ remoteListenTCP (struct qemud_server *server,
         else
             sock->port = -1;
 
-        if (qemudSetCloseExec(sock->fd) < 0 ||
-            qemudSetNonBlock(sock->fd) < 0)
+        if (virSetCloseExec(sock->fd) < 0 ||
+            virSetNonBlock(sock->fd) < 0)
             goto cleanup;
 
         if (listen (sock->fd, 30) < 0) {
@@ -1273,8 +1247,8 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
     setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, (void *)&no_slow_start,
                 sizeof no_slow_start);
 
-    if (qemudSetCloseExec(fd) < 0 ||
-        qemudSetNonBlock(fd) < 0) {
+    if (virSetCloseExec(fd) < 0 ||
+        virSetNonBlock(fd) < 0) {
         close(fd);
         return -1;
     }
@@ -2872,10 +2846,10 @@ int main(int argc, char **argv) {
         goto error1;
 
     if (pipe(sigpipe) < 0 ||
-        qemudSetNonBlock(sigpipe[0]) < 0 ||
-        qemudSetNonBlock(sigpipe[1]) < 0 ||
-        qemudSetCloseExec(sigpipe[0]) < 0 ||
-        qemudSetCloseExec(sigpipe[1]) < 0) {
+        virSetNonBlock(sigpipe[0]) < 0 ||
+        virSetNonBlock(sigpipe[1]) < 0 ||
+        virSetCloseExec(sigpipe[0]) < 0 ||
+        virSetCloseExec(sigpipe[1]) < 0) {
         char ebuf[1024];
         VIR_ERROR(_("Failed to create pipe: %s"),
                   virStrerror(errno, ebuf, sizeof ebuf));
index 4ddbc41576579f4161b7c0f302b9850a09994969..e3bae462486c5fe685a6c9ffb04ab9f872a752fc 100644 (file)
@@ -198,9 +198,6 @@ void qemudLog(int priority, const char *fmt, ...)
     ATTRIBUTE_FORMAT(printf,2,3);
 
 
-int qemudSetCloseExec(int fd);
-int qemudSetNonBlock(int fd);
-
 int
 remoteDispatchClientRequest (struct qemud_server *server,
                              struct qemud_client *client,