static int umlReadPidFile(struct uml_driver *driver,
virDomainObjPtr vm);
-static int umlSetCloseExec(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_ERROR(_("Failed to set close-on-exec file descriptor flag"));
- return -1;
-}
-
static int umlStartVMDaemon(virConnectPtr conn,
struct uml_driver *driver,
virDomainObjPtr vm);
}
VIR_FREE(logfile);
- if (umlSetCloseExec(logfd) < 0) {
- virReportSystemError(errno,
- "%s", _("Unable to set VM logfile close-on-exec flag"));
+ if (virSetCloseExec(logfd) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Unable to set VM logfile close-on-exec flag"));
VIR_FORCE_CLOSE(logfd);
return -1;
}
brInit(brControl **ctlp)
{
int fd;
- int flags;
if (!ctlp || *ctlp)
return EINVAL;
fd = socket(AF_INET, SOCK_STREAM, 0);
- if (fd < 0)
- return errno;
-
- if ((flags = fcntl(fd, F_GETFD)) < 0 ||
- fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
- int err = errno;
- VIR_FORCE_CLOSE(fd);
- return err;
- }
-
- if (VIR_ALLOC(*ctlp) < 0) {
+ if (fd < 0 ||
+ virSetCloseExec(fd) < 0 ||
+ VIR_ALLOC(*ctlp) < 0) {
VIR_FORCE_CLOSE(fd);
- return ENOMEM;
+ return errno;
}
(*ctlp)->fd = fd;
int up)
{
struct ifreq ifr;
- int flags;
+ int ifflags;
if (!ctl || !ifname)
return EINVAL;
if (ioctl(ctl->fd, SIOCGIFFLAGS, &ifr) < 0)
return errno;
- flags = up ? (ifr.ifr_flags | IFF_UP) : (ifr.ifr_flags & ~IFF_UP);
+ ifflags = up ? (ifr.ifr_flags | IFF_UP) : (ifr.ifr_flags & ~IFF_UP);
- if (ifr.ifr_flags != flags) {
- ifr.ifr_flags = flags;
+ if (ifr.ifr_flags != ifflags) {
+ ifr.ifr_flags = ifflags;
if (ioctl(ctl->fd, SIOCSIFFLAGS, &ifr) < 0)
return errno;