libxl_ctx *ctx = libxl__gc_owner(gc);
char **vments = NULL, **localents = NULL;
struct timeval start_time;
- int i, esave, flags;
+ int i, esave;
/* convenience aliases */
const uint32_t domid = dcs->guest_domid;
}
esave = errno;
-
- flags = fcntl(fd, F_GETFL);
- if (flags == -1) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to get flags on restore fd");
- } else {
- flags &= ~O_NONBLOCK;
- if (fcntl(fd, F_SETFL, flags) == -1)
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to put restore fd"
- " back to blocking mode");
- }
-
+ libxl_fd_set_nonblock(ctx, fd, 0);
errno = esave;
domcreate_rebuild_done(egc, dcs, ret);
}
int timeout)
{
int ret;
- int flags = 0;
int i = 0;
qmp->qmp_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (qmp->qmp_fd < 0) {
return -1;
}
- if ((flags = fcntl(qmp->qmp_fd, F_GETFL)) == -1) {
- flags = 0;
- }
- if (fcntl(qmp->qmp_fd, F_SETFL, flags | O_NONBLOCK) == -1) {
- return -1;
- }
+ ret = libxl_fd_set_nonblock(qmp->ctx, qmp->qmp_fd, 1);
+ if (ret) return -1;
ret = libxl_fd_set_cloexec(qmp->ctx, qmp->qmp_fd, 1);
if (ret) return -1;
int fd;
int ret;
- fd = open(dev, O_RDONLY | O_CLOEXEC);
+ fd = open(dev, O_RDONLY);
if (fd < 0) {
LOGE(ERROR, "failed to open \"%s\"", dev);
return ERROR_FAIL;
}
+ ret = libxl_fd_set_cloexec(CTX, fd, 1);
+ if (ret) {
+ close(fd);
+ return ERROR_FAIL;
+ }
ret = libxl_read_exactly(CTX, fd, buf, len, dev, NULL);