Skip to content

Commit

Permalink
pass real fd when restore and dump ext file
Browse files Browse the repository at this point in the history
Signed-off-by: haozi007 <[email protected]>
  • Loading branch information
duguhaotian committed Oct 24, 2024
1 parent dfb56ee commit 23b64b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions criu/files-ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static int dump_one_ext_file(int lfd, u32 id, const struct fd_parms *p)
FileEntry fe = FILE_ENTRY__INIT;
ExtFileEntry xfe = EXT_FILE_ENTRY__INIT;

ret = run_plugins(DUMP_EXT_FILE, lfd, id);
ret = run_plugins(DUMP_EXT_FILE, lfd, p->fd, id);
if (ret < 0)
return ret;

Expand Down Expand Up @@ -44,11 +44,13 @@ struct ext_file_info {
static int open_fd(struct file_desc *d, int *new_fd)
{
struct ext_file_info *xfi;
struct fdinfo_list_entry *fle_m;
int fd;

xfi = container_of(d, struct ext_file_info, d);
fle_m = file_master(d);

fd = run_plugins(RESTORE_EXT_FILE, xfi->xfe->id);
fd = run_plugins(RESTORE_EXT_FILE, xfi->xfe->id, fle_m->fe->fd);
if (fd < 0) {
pr_err("Unable to restore %#x\n", xfi->xfe->id);
return -1;
Expand Down
8 changes: 4 additions & 4 deletions criu/include/criu-plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ enum {

DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_UNIX_SK, int fd, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_UNIX_SK, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_FILE, int fd, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_EXT_FILE, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_FILE, int fd, int real_fd, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_EXT_FILE, int id, int target_fd);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_MOUNT, char *mountpoint, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_EXT_MOUNT, int id, char *mountpoint, char *old_root, int *is_file);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_LINK, int index, int type, char *kind);
Expand Down Expand Up @@ -143,8 +143,8 @@ typedef int(cr_plugin_init_t)(void);
typedef void(cr_plugin_fini_t)(void);
typedef int(cr_plugin_dump_unix_sk_t)(int fd, int id);
typedef int(cr_plugin_restore_unix_sk_t)(int id);
typedef int(cr_plugin_dump_file_t)(int fd, int id);
typedef int(cr_plugin_restore_file_t)(int id);
typedef int(cr_plugin_dump_file_t)(int fd, int real_fd, int id);
typedef int(cr_plugin_restore_file_t)(int id, int target_fd);
typedef int(cr_plugin_dump_ext_mount_t)(char *mountpoint, int id);
typedef int(cr_plugin_restore_ext_mount_t)(int id, char *mountpoint, char *old_root, int *is_file);
typedef int(cr_plugin_dump_ext_link_t)(int index, int type, char *kind);
Expand Down
4 changes: 2 additions & 2 deletions plugins/amdgpu/amdgpu_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ bool kernel_supports_criu(int fd)
return ret;
}

int amdgpu_plugin_dump_file(int fd, int id)
int amdgpu_plugin_dump_file(int fd, int real_fd, int id)
{
struct kfd_ioctl_criu_args args = { 0 };
char img_path[PATH_MAX];
Expand Down Expand Up @@ -1551,7 +1551,7 @@ static int restore_bo_data(int id, struct kfd_criu_bo_bucket *bo_buckets, CriuKf
return ret;
}

int amdgpu_plugin_restore_file(int id)
int amdgpu_plugin_restore_file(int id, int target_fd)
{
int ret = 0, fd;
char img_path[PATH_MAX];
Expand Down

0 comments on commit 23b64b9

Please sign in to comment.