Commit 6bf22f8c authored by Pavel Emelyanov's avatar Pavel Emelyanov

crtools: Get rid of on-stack cr_options

We have global instance of them, that's enough.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent d01ffda2
......@@ -92,7 +92,7 @@ static int shmem_remap(void *old_addr, void *new_addr, unsigned long size)
return 0;
}
static int crtools_prepare_shared(struct cr_options *opts)
static int crtools_prepare_shared(void)
{
if (prepare_shared_fdinfo())
return -1;
......@@ -101,7 +101,7 @@ static int crtools_prepare_shared(struct cr_options *opts)
if (collect_inet_sockets())
return -1;
if (tty_prep_fds(opts))
if (tty_prep_fds())
return -1;
return 0;
......@@ -1188,7 +1188,7 @@ static int restore_switch_stage(int next_stage)
return 0;
}
static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
static int restore_root_task(struct pstree_item *init)
{
int ret;
struct sigaction act, old_act;
......@@ -1288,7 +1288,7 @@ out:
pr_info("Restore finished successfully. Resuming tasks.\n");
futex_set_and_wake(&task_entries->start, CR_STATE_COMPLETE);
if (!opts->restore_detach)
if (!opts.restore_detach)
wait(NULL);
return 0;
}
......@@ -1309,7 +1309,7 @@ static int prepare_task_entries()
return 0;
}
int cr_restore_tasks(struct cr_options *opts)
int cr_restore_tasks(void)
{
if (check_img_inventory() < 0)
return -1;
......@@ -1326,10 +1326,10 @@ int cr_restore_tasks(struct cr_options *opts)
if (prepare_pstree() < 0)
return -1;
if (crtools_prepare_shared(opts) < 0)
if (crtools_prepare_shared() < 0)
return -1;
return restore_root_task(root_item, opts);
return restore_root_task(root_item);
}
static long restorer_get_vma_hint(pid_t pid, struct list_head *tgt_vma_list,
......
......@@ -400,14 +400,14 @@ static void try_hint_magic(u32 magic)
pr_msg("This can be %s\n", magic_hints[i].hint);
}
static int cr_parse_file(struct cr_options *opts)
static int cr_parse_file(void)
{
u32 magic;
int fd = -1, ret = -1, i;
fd = open(opts->show_dump_file, O_RDONLY);
fd = open(opts.show_dump_file, O_RDONLY);
if (fd < 0) {
pr_perror("Can't open %s", opts->show_dump_file);
pr_perror("Can't open %s", opts.show_dump_file);
goto err;
}
......@@ -420,14 +420,14 @@ static int cr_parse_file(struct cr_options *opts)
if (i == CR_FD_MAX) {
pr_err("Unknown magic %#x in %s\n",
magic, opts->show_dump_file);
magic, opts.show_dump_file);
try_hint_magic(magic);
goto err;
}
if (!fdset_template[i].show) {
pr_err("No handler for %#x/%s\n",
magic, opts->show_dump_file);
magic, opts.show_dump_file);
goto err;
}
......@@ -438,7 +438,7 @@ err:
return ret;
}
static int cr_show_pstree_item(struct cr_options *opts, struct pstree_item *item)
static int cr_show_pstree_item(struct pstree_item *item)
{
int ret = -1, i;
struct cr_fdset *cr_fdset = NULL;
......@@ -507,7 +507,7 @@ out:
return ret;
}
static int cr_show_pid(struct cr_options *opts, int pid)
static int cr_show_pid(int pid)
{
int fd, ret;
struct pstree_item item;
......@@ -536,10 +536,10 @@ static int cr_show_pid(struct cr_options *opts, int pid)
close(fd);
return cr_show_pstree_item(opts, &item);
return cr_show_pstree_item(&item);
}
static int cr_show_all(struct cr_options *opts)
static int cr_show_all(void)
{
struct pstree_item *item = NULL, *tmp;
int ret = -1, fd, pid;
......@@ -558,12 +558,12 @@ static int cr_show_all(struct cr_options *opts)
close(fd);
pid = list_first_entry(&pstree_list, struct pstree_item, sibling)->pid.virt;
ret = try_show_namespaces(pid, opts);
ret = try_show_namespaces(pid);
if (ret)
goto out;
list_for_each_entry(item, &pstree_list, sibling)
if (cr_show_pstree_item(opts, item))
if (cr_show_pstree_item(item))
break;
out:
......@@ -575,13 +575,13 @@ out:
return ret;
}
int cr_show(struct cr_options *opts, int pid)
int cr_show(int pid)
{
if (opts->show_dump_file)
return cr_parse_file(opts);
if (opts.show_dump_file)
return cr_parse_file();
if (pid)
return cr_show_pid(opts, pid);
return cr_show_pid(pid);
return cr_show_all(opts);
return cr_show_all();
}
......@@ -329,11 +329,11 @@ int main(int argc, char *argv[])
if (!strcmp(argv[optind], "restore")) {
if (tree_id)
pr_warn("Using -t with criu restore is obsoleted\n");
return cr_restore_tasks(&opts);
return cr_restore_tasks();
}
if (!strcmp(argv[optind], "show"))
return cr_show(&opts, pid);
return cr_show(pid);
if (!strcmp(argv[optind], "check"))
return cr_check();
......
......@@ -223,12 +223,11 @@ static inline int fdset_fd(const struct cr_fdset *fdset, int type)
}
extern struct cr_fdset *glob_fdset;
extern struct cr_options opts;
int cr_dump_tasks(pid_t pid);
int cr_pre_dump_tasks(pid_t pid);
int cr_restore_tasks(struct cr_options *opts);
int cr_show(struct cr_options *opts, int pid);
int cr_restore_tasks(void);
int cr_show(int pid);
int convert_to_elf(char *elf_path, int fd_core);
int cr_check(void);
int cr_exec(int pid, char **opts);
......
......@@ -3,7 +3,6 @@
#include "crtools.h"
struct cr_options;
extern void show_ipc_var(int fd);
extern void show_ipc_shm(int fd);
extern void show_ipc_msg(int fd);
......
......@@ -12,7 +12,6 @@ extern struct fstype *find_fstype_by_name(char *fst);
struct cr_fdset;
extern int dump_mnt_ns(int pid, struct cr_fdset *);
struct cr_options;
extern void show_mountpoints(int fd);
int prepare_mnt_ns(int pid);
......
......@@ -5,8 +5,6 @@
#include "pstree.h"
#include "files.h"
struct cr_options;
struct ns_desc {
unsigned int cflag;
char *str;
......@@ -31,7 +29,7 @@ extern int collect_ns_files(void);
int dump_namespaces(struct pid *pid, unsigned int ns_flags);
int prepare_namespace(int pid, unsigned long clone_flags);
int try_show_namespaces(int pid, struct cr_options *o);
int try_show_namespaces(int pid);
int switch_ns(int pid, struct ns_desc *nd, int *rst);
int restore_ns(int rst, struct ns_desc *nd);
......
......@@ -3,7 +3,6 @@
#include "list.h"
struct cr_options;
void show_netdevices(int fd);
struct cr_fdset;
......
......@@ -3,7 +3,6 @@
struct cr_fdset;
struct fd_parms;
struct cr_options;
extern int is_signalfd_link(int lfd);
extern int dump_signalfd(struct fd_parms *p, int lfd, const int fdinfo);
extern void show_signalfd(int fd);
......
......@@ -67,7 +67,6 @@ int restore_one_tcp(int sk, struct inet_sk_info *si);
#define SK_EST_PARAM "tcp-established"
struct cr_options;
void show_tcp_stream(int fd);
int check_tcp(void);
......
......@@ -7,7 +7,6 @@
struct cr_fdset;
struct fd_parms;
struct cr_options;
struct vma_area;
int dump_one_packet_sk(struct fd_parms *p, int lfd, const int fdinfo);
......
......@@ -13,7 +13,6 @@
struct fdinfo_list_entry;
struct sk_opts_entry;
struct cr_options;
struct file_desc;
struct fd_parms;
struct cr_fdset;
......
......@@ -21,7 +21,7 @@ extern int tty_setup_slavery(void);
extern int tty_verify_active_pairs(void);
extern int tty_prep_fds(struct cr_options *opts);
extern int tty_prep_fds(void);
extern void tty_fini_fds(void);
#define OPT_SHELL_JOB "shell-job"
......
......@@ -4,7 +4,6 @@
#include "crtools.h"
int dump_uts_ns(int ns_pid, struct cr_fdset *fdset);
struct cr_options;
void show_utsns(int fd);
int prepare_utsns(int pid);
......
......@@ -470,7 +470,7 @@ int prepare_namespace(int pid, unsigned long clone_flags)
return 0;
}
int try_show_namespaces(int ns_pid, struct cr_options *o)
int try_show_namespaces(int ns_pid)
{
struct cr_fdset *fdset;
int i;
......
......@@ -1206,9 +1206,9 @@ int dump_tty(struct fd_parms *p, int lfd, const int fdinfo)
return do_dump_gen_file(p, lfd, &tty_ops, fdinfo);
}
int tty_prep_fds(struct cr_options *opts)
int tty_prep_fds(void)
{
if (!opts->shell_job)
if (!opts.shell_job)
return 0;
if (!isatty(STDIN_FILENO)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment