return 0;
}
+int libxl_fd_set_cloexec(int fd)
+{
+ int flags = 0;
+
+ if ((flags = fcntl(fd, F_GETFD)) == -1) {
+ flags = 0;
+ }
+ if ((flags & FD_CLOEXEC)) {
+ return 0;
+ }
+ return fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+}
+
/*
* Local variables:
* mode: C
const char *libxl_run_dir_path(void);
const char *libxl_xenpaging_dir_path(void);
+/* misc */
+int libxl_fd_set_cloexec(int fd);
+
#endif /* LIBXL_H */
/*
return 0;
}
-int libxl__fd_set_cloexec(int fd)
-{
- int flags = 0;
-
- if ((flags = fcntl(fd, F_GETFD)) == -1) {
- flags = 0;
- }
- if ((flags & FD_CLOEXEC)) {
- return 0;
- }
- return fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
-}
-
libxl_device_model_version libxl__device_model_version_running(libxl__gc *gc,
uint32_t domid)
{
_hidden int libxl__file_reference_map(libxl_file_reference *f);
_hidden int libxl__file_reference_unmap(libxl_file_reference *f);
-_hidden int libxl__fd_set_cloexec(int fd);
_hidden int libxl__e820_alloc(libxl__gc *gc, uint32_t domid, libxl_domain_config *d_config);
if (fcntl(qmp->qmp_fd, F_SETFL, flags | O_NONBLOCK) == -1) {
return -1;
}
- libxl__fd_set_cloexec(qmp->qmp_fd);
+ libxl_fd_set_cloexec(qmp->qmp_fd);
memset(&qmp->addr, 0, sizeof (&qmp->addr));
qmp->addr.sun_family = AF_UNIX;
union { uint32_t u32; char b[4]; } u32buf;
uint32_t badflags;
- restore_fd = migrate_fd >= 0 ? migrate_fd :
- open(restore_file, O_RDONLY);
+ if (migrate_fd >= 0) {
+ restore_fd = migrate_fd;
+ } else {
+ restore_fd = open(restore_file, O_RDONLY);
+ libxl_fd_set_cloexec(restore_fd);
+ }
CHK_ERRNO( libxl_read_exactly(ctx, restore_fd, &hdr,
sizeof(hdr), restore_file, "header") );