mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-28 12:57:57 +00:00
img: Remove O_OPT and COLLECT_OPTIONAL
Current code doesn't make any difference between OPT and no-OPT except for the message is printed or not in the open_image(). So this particular change changes nothing but the availability of this message. In the next patches I wil introduce "empty images" to deal with the ENOENT situation in a more graceful manner. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
8218e014d0
commit
e29c9daec2
@ -428,7 +428,7 @@ int cpu_validate_cpuinfo(void)
|
|||||||
struct cr_img *img;
|
struct cr_img *img;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
img = open_image(CR_FD_CPUINFO, O_RSTR | O_OPT);
|
img = open_image(CR_FD_CPUINFO, O_RSTR);
|
||||||
if (!img)
|
if (!img)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
2
cgroup.c
2
cgroup.c
@ -1291,7 +1291,7 @@ int prepare_cgroup(void)
|
|||||||
struct cr_img *img;
|
struct cr_img *img;
|
||||||
CgroupEntry *ce;
|
CgroupEntry *ce;
|
||||||
|
|
||||||
img = open_image(CR_FD_CGROUP, O_RSTR | O_OPT);
|
img = open_image(CR_FD_CGROUP, O_RSTR);
|
||||||
if (!img) {
|
if (!img) {
|
||||||
if (errno == ENOENT) /* backward compatibility */
|
if (errno == ENOENT) /* backward compatibility */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2419,7 +2419,7 @@ static int prepare_rlimits_from_fd(int pid)
|
|||||||
/*
|
/*
|
||||||
* Old image -- read from the file.
|
* Old image -- read from the file.
|
||||||
*/
|
*/
|
||||||
img = open_image(CR_FD_RLIMIT, O_RSTR | O_OPT, pid);
|
img = open_image(CR_FD_RLIMIT, O_RSTR, pid);
|
||||||
if (!img) {
|
if (!img) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
pr_info("Skip rlimits for %d\n", pid);
|
pr_info("Skip rlimits for %d\n", pid);
|
||||||
@ -2511,7 +2511,7 @@ static int open_signal_image(int type, pid_t pid, unsigned int *nr)
|
|||||||
int ret;
|
int ret;
|
||||||
struct cr_img *img;
|
struct cr_img *img;
|
||||||
|
|
||||||
img = open_image(type, O_RSTR | O_OPT, pid);
|
img = open_image(type, O_RSTR, pid);
|
||||||
if (!img) {
|
if (!img) {
|
||||||
if (errno == ENOENT) /* backward compatibility */
|
if (errno == ENOENT) /* backward compatibility */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -454,7 +454,7 @@ static int cr_show_pstree_item(struct pstree_item *item)
|
|||||||
cr_parse_fd(img_from_set(cr_imgset, i), imgset_template[i].magic);
|
cr_parse_fd(img_from_set(cr_imgset, i), imgset_template[i].magic);
|
||||||
}
|
}
|
||||||
|
|
||||||
img = open_image(CR_FD_RLIMIT, O_SHOW | O_OPT, item->pid.virt);
|
img = open_image(CR_FD_RLIMIT, O_SHOW, item->pid.virt);
|
||||||
if (img) {
|
if (img) {
|
||||||
pr_msg("* ");
|
pr_msg("* ");
|
||||||
pr_msg(imgset_template[CR_FD_RLIMIT].fmt, item->pid.virt);
|
pr_msg(imgset_template[CR_FD_RLIMIT].fmt, item->pid.virt);
|
||||||
|
@ -210,7 +210,6 @@ struct collect_image_info epoll_tfd_cinfo = {
|
|||||||
.pb_type = PB_EVENTPOLL_TFD,
|
.pb_type = PB_EVENTPOLL_TFD,
|
||||||
.priv_size = sizeof(struct eventpoll_tfd_file_info),
|
.priv_size = sizeof(struct eventpoll_tfd_file_info),
|
||||||
.collect = collect_one_epoll_tfd,
|
.collect = collect_one_epoll_tfd,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int collect_one_epoll(void *o, ProtobufCMessage *msg)
|
static int collect_one_epoll(void *o, ProtobufCMessage *msg)
|
||||||
|
@ -40,7 +40,6 @@ struct collect_image_info file_locks_cinfo = {
|
|||||||
.pb_type = PB_FILE_LOCK,
|
.pb_type = PB_FILE_LOCK,
|
||||||
.priv_size = sizeof(struct file_lock_rst),
|
.priv_size = sizeof(struct file_lock_rst),
|
||||||
.collect = collect_one_file_lock,
|
.collect = collect_one_file_lock,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct file_lock *alloc_file_lock(void)
|
struct file_lock *alloc_file_lock(void)
|
||||||
@ -342,7 +341,7 @@ static int restore_file_locks_legacy(int pid)
|
|||||||
struct cr_img *img;
|
struct cr_img *img;
|
||||||
FileLockEntry *fle;
|
FileLockEntry *fle;
|
||||||
|
|
||||||
img = open_image(CR_FD_FILE_LOCKS_PID, O_RSTR | O_OPT, pid);
|
img = open_image(CR_FD_FILE_LOCKS_PID, O_RSTR, pid);
|
||||||
if (!img) {
|
if (!img) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
|
4
files.c
4
files.c
@ -609,7 +609,7 @@ int prepare_fd_pid(struct pstree_item *item)
|
|||||||
INIT_LIST_HEAD(&rst_info->tty_slaves);
|
INIT_LIST_HEAD(&rst_info->tty_slaves);
|
||||||
|
|
||||||
if (!fdinfo_per_id) {
|
if (!fdinfo_per_id) {
|
||||||
img = open_image(CR_FD_FDINFO, O_RSTR | O_OPT, pid);
|
img = open_image(CR_FD_FDINFO, O_RSTR, pid);
|
||||||
if (!img) {
|
if (!img) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1116,7 +1116,7 @@ int prepare_fs_pid(struct pstree_item *item)
|
|||||||
struct cr_img *img;
|
struct cr_img *img;
|
||||||
FsEntry *fe;
|
FsEntry *fe;
|
||||||
|
|
||||||
img = open_image(CR_FD_FS, O_RSTR | O_OPT, pid);
|
img = open_image(CR_FD_FS, O_RSTR, pid);
|
||||||
if (!img) {
|
if (!img) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
goto ok;
|
goto ok;
|
||||||
|
@ -756,7 +756,6 @@ struct collect_image_info inotify_cinfo = {
|
|||||||
.pb_type = PB_INOTIFY_FILE,
|
.pb_type = PB_INOTIFY_FILE,
|
||||||
.priv_size = sizeof(struct fsnotify_file_info),
|
.priv_size = sizeof(struct fsnotify_file_info),
|
||||||
.collect = collect_one_inotify,
|
.collect = collect_one_inotify,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int collect_one_fanotify(void *o, ProtobufCMessage *msg)
|
static int collect_one_fanotify(void *o, ProtobufCMessage *msg)
|
||||||
@ -792,7 +791,6 @@ struct collect_image_info fanotify_cinfo = {
|
|||||||
.pb_type = PB_FANOTIFY_FILE,
|
.pb_type = PB_FANOTIFY_FILE,
|
||||||
.priv_size = sizeof(struct fsnotify_file_info),
|
.priv_size = sizeof(struct fsnotify_file_info),
|
||||||
.collect = collect_one_fanotify,
|
.collect = collect_one_fanotify,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int collect_one_inotify_mark(void *o, ProtobufCMessage *msg)
|
static int collect_one_inotify_mark(void *o, ProtobufCMessage *msg)
|
||||||
@ -811,7 +809,6 @@ struct collect_image_info inotify_mark_cinfo = {
|
|||||||
.pb_type = PB_INOTIFY_WD,
|
.pb_type = PB_INOTIFY_WD,
|
||||||
.priv_size = sizeof(struct fsnotify_mark_info),
|
.priv_size = sizeof(struct fsnotify_mark_info),
|
||||||
.collect = collect_one_inotify_mark,
|
.collect = collect_one_inotify_mark,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int collect_one_fanotify_mark(void *o, ProtobufCMessage *msg)
|
static int collect_one_fanotify_mark(void *o, ProtobufCMessage *msg)
|
||||||
@ -830,5 +827,4 @@ struct collect_image_info fanotify_mark_cinfo = {
|
|||||||
.pb_type = PB_FANOTIFY_MARK,
|
.pb_type = PB_FANOTIFY_MARK,
|
||||||
.priv_size = sizeof(struct fsnotify_mark_info),
|
.priv_size = sizeof(struct fsnotify_mark_info),
|
||||||
.collect = collect_one_fanotify_mark,
|
.collect = collect_one_fanotify_mark,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
10
image.c
10
image.c
@ -218,7 +218,7 @@ struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...)
|
|||||||
goto errn;
|
goto errn;
|
||||||
|
|
||||||
oflags |= imgset_template[type].oflags;
|
oflags |= imgset_template[type].oflags;
|
||||||
flags &= ~(O_OPT | O_NOBUF);
|
flags &= ~(O_NOBUF);
|
||||||
|
|
||||||
va_start(args, flags);
|
va_start(args, flags);
|
||||||
vsnprintf(path, PATH_MAX, imgset_template[type].fmt, args);
|
vsnprintf(path, PATH_MAX, imgset_template[type].fmt, args);
|
||||||
@ -226,11 +226,9 @@ struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...)
|
|||||||
|
|
||||||
ret = openat(dfd, path, flags, CR_FD_PERM);
|
ret = openat(dfd, path, flags, CR_FD_PERM);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if ((oflags & O_OPT) && errno == ENOENT) {
|
if (errno == ENOENT)
|
||||||
xfree(img);
|
pr_info("No %s image\n", path);
|
||||||
return NULL;
|
else
|
||||||
}
|
|
||||||
|
|
||||||
pr_perror("Unable to open %s", path);
|
pr_perror("Unable to open %s", path);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,6 @@
|
|||||||
extern bool fdinfo_per_id;
|
extern bool fdinfo_per_id;
|
||||||
extern bool ns_per_id;
|
extern bool ns_per_id;
|
||||||
|
|
||||||
#define O_OPT (O_PATH)
|
|
||||||
#define O_NOBUF (O_DIRECT)
|
#define O_NOBUF (O_DIRECT)
|
||||||
|
|
||||||
#define O_DUMP (O_WRONLY | O_CREAT | O_TRUNC)
|
#define O_DUMP (O_WRONLY | O_CREAT | O_TRUNC)
|
||||||
|
@ -50,7 +50,6 @@ struct collect_image_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define COLLECT_SHARED 0x1 /* use shared memory for obj-s */
|
#define COLLECT_SHARED 0x1 /* use shared memory for obj-s */
|
||||||
#define COLLECT_OPTIONAL 0x2 /* image file may be missing */
|
|
||||||
#define COLLECT_HAPPENED 0x4 /* image was opened and collected */
|
#define COLLECT_HAPPENED 0x4 /* image was opened and collected */
|
||||||
|
|
||||||
extern int collect_image(struct collect_image_info *);
|
extern int collect_image(struct collect_image_info *);
|
||||||
|
2
irmap.c
2
irmap.c
@ -399,7 +399,7 @@ static int open_irmap_cache(struct cr_img **img)
|
|||||||
|
|
||||||
pr_info("Searching irmap cache in work dir\n");
|
pr_info("Searching irmap cache in work dir\n");
|
||||||
in:
|
in:
|
||||||
*img = open_image_at(dir, CR_FD_IRMAP_CACHE, O_RSTR | O_OPT);
|
*img = open_image_at(dir, CR_FD_IRMAP_CACHE, O_RSTR);
|
||||||
if (dir != AT_FDCWD)
|
if (dir != AT_FDCWD)
|
||||||
close(dir);
|
close(dir);
|
||||||
|
|
||||||
|
2
mem.c
2
mem.c
@ -395,7 +395,7 @@ int prepare_mm_pid(struct pstree_item *i)
|
|||||||
struct cr_img *img;
|
struct cr_img *img;
|
||||||
struct rst_info *ri = rsti(i);
|
struct rst_info *ri = rsti(i);
|
||||||
|
|
||||||
img = open_image(CR_FD_MM, O_RSTR | O_OPT, pid);
|
img = open_image(CR_FD_MM, O_RSTR, pid);
|
||||||
if (!img) {
|
if (!img) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -408,7 +408,6 @@ struct collect_image_info nsfile_cinfo = {
|
|||||||
.pb_type = PB_NS_FILE,
|
.pb_type = PB_NS_FILE,
|
||||||
.priv_size = sizeof(struct ns_file_info),
|
.priv_size = sizeof(struct ns_file_info),
|
||||||
.collect = collect_one_nsfile,
|
.collect = collect_one_nsfile,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -633,7 +633,6 @@ err:
|
|||||||
|
|
||||||
int collect_image(struct collect_image_info *cinfo)
|
int collect_image(struct collect_image_info *cinfo)
|
||||||
{
|
{
|
||||||
bool optional = !!(cinfo->flags & COLLECT_OPTIONAL);
|
|
||||||
int ret;
|
int ret;
|
||||||
struct cr_img *img;
|
struct cr_img *img;
|
||||||
void *(*o_alloc)(size_t size) = malloc;
|
void *(*o_alloc)(size_t size) = malloc;
|
||||||
@ -642,9 +641,9 @@ int collect_image(struct collect_image_info *cinfo)
|
|||||||
pr_info("Collecting %d/%d (flags %x)\n",
|
pr_info("Collecting %d/%d (flags %x)\n",
|
||||||
cinfo->fd_type, cinfo->pb_type, cinfo->flags);
|
cinfo->fd_type, cinfo->pb_type, cinfo->flags);
|
||||||
|
|
||||||
img = open_image(cinfo->fd_type, O_RSTR | (optional ? O_OPT : 0));
|
img = open_image(cinfo->fd_type, O_RSTR);
|
||||||
if (!img) {
|
if (!img) {
|
||||||
if (optional && errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -120,5 +120,4 @@ struct collect_image_info signalfd_cinfo = {
|
|||||||
.pb_type = PB_SIGNALFD,
|
.pb_type = PB_SIGNALFD,
|
||||||
.priv_size = sizeof(struct signalfd_info),
|
.priv_size = sizeof(struct signalfd_info),
|
||||||
.collect = collect_one_sigfd,
|
.collect = collect_one_sigfd,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
@ -230,5 +230,4 @@ struct collect_image_info netlink_sk_cinfo = {
|
|||||||
.pb_type = PB_NETLINK_SK,
|
.pb_type = PB_NETLINK_SK,
|
||||||
.priv_size = sizeof(struct netlink_sock_info),
|
.priv_size = sizeof(struct netlink_sock_info),
|
||||||
.collect = collect_one_netlink_sk,
|
.collect = collect_one_netlink_sk,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
@ -500,5 +500,4 @@ struct collect_image_info packet_sk_cinfo = {
|
|||||||
.pb_type = PB_PACKET_SOCK,
|
.pb_type = PB_PACKET_SOCK,
|
||||||
.priv_size = sizeof(struct packet_sock_info),
|
.priv_size = sizeof(struct packet_sock_info),
|
||||||
.collect = collect_one_packet_sk,
|
.collect = collect_one_packet_sk,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
@ -194,5 +194,4 @@ struct collect_image_info timerfd_cinfo = {
|
|||||||
.pb_type = PB_TIMERFD,
|
.pb_type = PB_TIMERFD,
|
||||||
.priv_size = sizeof(struct timerfd_info),
|
.priv_size = sizeof(struct timerfd_info),
|
||||||
.collect = collect_one_timerfd,
|
.collect = collect_one_timerfd,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
2
tty.c
2
tty.c
@ -1274,7 +1274,6 @@ struct collect_image_info tty_info_cinfo = {
|
|||||||
.pb_type = PB_TTY_INFO,
|
.pb_type = PB_TTY_INFO,
|
||||||
.priv_size = sizeof(struct tty_info_entry),
|
.priv_size = sizeof(struct tty_info_entry),
|
||||||
.collect = collect_one_tty_info_entry,
|
.collect = collect_one_tty_info_entry,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int collect_one_tty(void *obj, ProtobufCMessage *msg)
|
static int collect_one_tty(void *obj, ProtobufCMessage *msg)
|
||||||
@ -1339,7 +1338,6 @@ struct collect_image_info tty_cinfo = {
|
|||||||
.pb_type = PB_TTY_FILE,
|
.pb_type = PB_TTY_FILE,
|
||||||
.priv_size = sizeof(struct tty_info),
|
.priv_size = sizeof(struct tty_info),
|
||||||
.collect = collect_one_tty,
|
.collect = collect_one_tty,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Make sure the ttys we're dumping do belong our process tree */
|
/* Make sure the ttys we're dumping do belong our process tree */
|
||||||
|
1
tun.c
1
tun.c
@ -400,7 +400,6 @@ struct collect_image_info tunfile_cinfo = {
|
|||||||
.pb_type = PB_TUNFILE,
|
.pb_type = PB_TUNFILE,
|
||||||
.priv_size = sizeof(struct tunfile_info),
|
.priv_size = sizeof(struct tunfile_info),
|
||||||
.collect = collect_one_tunfile,
|
.collect = collect_one_tunfile,
|
||||||
.flags = COLLECT_OPTIONAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds)
|
int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user