+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
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);
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);
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);
_("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;
/*
* 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
#ifndef WIN32
-static int virSetCloseExec(int fd) {
+int virSetCloseExec(int fd) {
int flags;
if ((flags = fcntl(fd, F_GETFD)) < 0)
return -1;