]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
remove duplicate *SetCloseExec and *SetNonBlock functions
authorJim Meyering <meyering@redhat.com>
Thu, 5 Feb 2009 16:27:17 +0000 (16:27 +0000)
committerJim Meyering <meyering@redhat.com>
Thu, 5 Feb 2009 16:27:17 +0000 (16:27 +0000)
* src/qemu_driver.c: Use virSetCloseExec and virSetNonBlock,
rather than qemuSet* functions.  Suggested by Daniel P. Berrange.
* src/util.c (virSetCloseExec): Publicize.
* src/util.h (virSetCloseExec): Declare
* src/libvirt_private.syms: Add virSetCloseExec.

ChangeLog
src/libvirt_private.syms
src/qemu_driver.c
src/util.c
src/util.h

index aca5e6bb5f20516529772652a9856cef8991c7ab..1674f5001134879327c615e0d185da9a0de1befc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu Feb 5 17:03:35 +0100 2009 Jim Meyering <meyering@redhat.com>
+
+       remove duplicate *SetCloseExec and *SetNonBlock functions
+       * src/qemu_driver.c: Use virSetCloseExec and virSetNonBlock,
+       rather than qemuSet* functions.  Suggested by Daniel P. Berrange.
+       * src/util.c (virSetCloseExec): Publicize.
+       * src/util.h (virSetCloseExec): Declare
+       * src/libvirt_private.syms: Add virSetCloseExec.
+
 Thu Feb 5 17:03:35 +0100 2009 Jim Meyering <meyering@redhat.com>
 
        qemu_driver.c: use virReportSystemError in place of some qemudLog uses
index 17aefbec8d8850da1c3dd2d6428fcc93bb77b372..4338da7e4b6990978bdd0db0685aa637687501c4 100644 (file)
@@ -292,6 +292,7 @@ virEnumToString;
 virEventAddHandle;
 virEventRemoveHandle;
 virExec;
+virSetCloseExec;
 virSetNonBlock;
 virFormatMacAddr;
 virGetHostname;
index 3a790c1fea96eb95d64de376e127b93d682c749b..8d8d711cba2302dba693096db0a16b1555ed3aa6 100644 (file)
@@ -91,37 +91,6 @@ static void qemuDriverUnlock(struct qemud_driver *driver)
     virMutexUnlock(&driver->lock);
 }
 
-static 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:
-    qemudLog(QEMUD_ERR,
-             "%s", _("Failed to set close-on-exec file descriptor flag\n"));
-    return -1;
-}
-
-
-static 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:
-    qemudLog(QEMUD_ERR,
-             "%s", _("Failed to set non-blocking file descriptor flag\n"));
-    return -1;
-}
-
-
-
 static void qemuDomainEventFlush(int timer, void *opaque);
 static void qemuDomainEventQueue(struct qemud_driver *driver,
                                  virDomainEventPtr event);
@@ -180,7 +149,7 @@ qemudLogFD(virConnectPtr conn, const char* logDir, const char* name)
                              logfile);
         return -1;
     }
-    if (qemudSetCloseExec(fd) < 0) {
+    if (virSetCloseExec(fd) < 0) {
         virReportSystemError(conn, errno, "%s",
                              _("Unable to set VM logfile close-on-exec flag"));
         close(fd);
@@ -212,7 +181,7 @@ qemudLogReadFD(virConnectPtr conn, const char* logDir, const char* name, off_t p
                              logfile);
         return -1;
     }
-    if (qemudSetCloseExec(fd) < 0) {
+    if (virSetCloseExec(fd) < 0) {
         virReportSystemError(conn, errno, "%s",
                              _("Unable to set VM logfile close-on-exec flag"));
         close(fd);
@@ -721,12 +690,12 @@ static int qemudOpenMonitor(virConnectPtr conn,
                          _("Unable to open monitor path %s"), monitor);
         return -1;
     }
-    if (qemudSetCloseExec(monfd) < 0) {
+    if (virSetCloseExec(monfd) < 0) {
         qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
                          "%s", _("Unable to set monitor close-on-exec flag"));
         goto error;
     }
-    if (qemudSetNonBlock(monfd) < 0) {
+    if (virSetNonBlock(monfd) < 0) {
         qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
                          "%s", _("Unable to put monitor into non-blocking mode"));
         goto error;
index 7c7fe3134c3cd9f0487b4e8ae8f2e2eded60d6e9..96c1b00aef298d1edef492d1d15c571f95a7b91c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * utils.c: common, generic utility functions
  *
- * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  * Copyright (C) 2006, 2007 Binary Karma
  * Copyright (C) 2006 Shuveb Hussain
@@ -185,7 +185,7 @@ int virSetNonBlock(int fd) {
 
 #ifndef WIN32
 
-static int virSetCloseExec(int fd) {
+int virSetCloseExec(int fd) {
     int flags;
     if ((flags = fcntl(fd, F_GETFD)) < 0)
         return -1;
index c5532648b977129a1e645edf8bef2aa8e539da7c..4667b92e2fd6ffbdc72d37aa2fea7d35b238f46c 100644 (file)
@@ -39,6 +39,7 @@ enum {
 };
 
 int virSetNonBlock(int fd);
+int virSetCloseExec(int fd);
 
 int virExec(virConnectPtr conn,
             const char *const*argv,