int import_thread_struct(struct epm_action *action, ghost_t *ghost, struct task_struct *tsk) { int r; r = ghost_read(ghost, &tsk->thread, sizeof (tsk->thread)); if (r) goto out; /* * Make get_wchan return do_exit for zombies * We only set a marker to let copy_thread() do the right thing. */ if (tsk->exit_state) tsk->thread.sp = ~0UL; else tsk->thread.sp = 0; if (tsk->thread.xstate) { r = -ENOMEM; tsk->thread.xstate = kmem_cache_alloc(task_xstate_cachep, GFP_KERNEL); if (!tsk->thread.xstate) goto out; r = ghost_read(ghost, tsk->thread.xstate, xstate_size); if (r) free_thread_xstate(tsk); } out: return r; }
int cr_link_to_file(struct epm_action *action, ghost_t *ghost, struct task_struct *task, struct file **returned_file) { int r; long key; enum shared_obj_type type; struct cr_file_link *file_link; BUG_ON(action->type != EPM_CHECKPOINT); /* files are linked while loading files_struct or mm_struct */ BUG_ON(action->restart.shared != CR_LOAD_NOW); r = ghost_read(ghost, &type, sizeof(enum shared_obj_type)); if (r) goto error; if (type != LOCAL_FILE && type != DVFS_FILE) goto err_bad_data; r = ghost_read(ghost, &key, sizeof(long)); if (r) goto error; /* look in the table to find the new allocated data * imported in import_shared_objects */ file_link = get_imported_shared_object(action->restart.app, type, key); if (file_link->desc_type == CR_FILE_NONE) { *returned_file = NULL; r = 0; } else r = __cr_link_to_file(action, ghost, task, file_link, returned_file); error: if (r) ckpt_err(NULL, r, "Fail to relink process %d of application %ld" " to file %d:%lu", task_pid_knr(task), action->restart.app->app_id, type, key); return r; err_bad_data: r = -E_CR_BADDATA; goto error; }
int import_pid(struct epm_action *action, ghost_t *ghost, struct pid_link *link, enum pid_type type) { struct pid *pid; int nr; int retval; retval = ghost_read(ghost, &nr, sizeof(nr)); if (retval) return retval; if (action->type == EPM_CHECKPOINT) { if ((action->restart.flags & APP_REPLACE_PGRP) && type == PIDTYPE_PGID) nr = action->restart.app->restart.substitution_pgrp; else if ((action->restart.flags & APP_REPLACE_SID) && type == PIDTYPE_SID) nr = action->restart.app->restart.substitution_sid; } pid = krg_get_pid(nr); if (!pid) return -ENOMEM; INIT_HLIST_NODE(&link->node); link->pid = pid; return 0; }
int ghost_read_file_krg_desc(ghost_t *ghost, void **desc, int *desc_size) { int r; r = ghost_read(ghost, desc_size, sizeof (int)); if (r) goto error; *desc = kmalloc(*desc_size, GFP_KERNEL); if (!(*desc)) { r = -ENOMEM; goto error; } r = ghost_read(ghost, *desc, *desc_size); if (r) { kfree(*desc); *desc = NULL; } error: return r; }
int import_kddm_info_struct (struct epm_action *action, ghost_t *ghost, struct task_struct *tsk) { struct kddm_info_struct *kddm_info; int r; if (tsk->exit_state) { tsk->kddm_info = NULL; return 0; } switch (action->type) { case EPM_REMOTE_CLONE: r = initialize_kddm_info_struct (tsk); break; case EPM_RESTART: case EPM_MIGRATE: r = -ENOMEM; kddm_info = kmem_cache_alloc(kddm_info_cachep, GFP_KERNEL); if (!kddm_info) break; r = ghost_read (ghost, kddm_info, sizeof(struct kddm_info_struct)); if (r) { kmem_cache_free(kddm_info_cachep, kddm_info); break; } kddm_info->wait_obj = NULL; tsk->kddm_info = kddm_info; break; default: BUG(); r = -EINVAL; } return r; }
int import_thread_info(struct epm_action *action, ghost_t *ghost, struct task_struct *task) { struct thread_info *p; int r; p = alloc_thread_info(task); if (!p) { r = -ENOMEM; goto exit; } r = ghost_read(ghost, p, sizeof(struct thread_info)); /* Required by [__]free_thread_info() */ p->task = task; if (r) goto exit_free_thread_info; p->exec_domain = import_exec_domain(action, ghost); p->preempt_count = 0; p->addr_limit = USER_DS; r = import_restart_block(action, ghost, &p->restart_block); if (r) goto exit_free_thread_info; task->stack = p; exit: return r; exit_free_thread_info: __free_thread_info(p); goto exit; }