2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-03 15:55:53 +00:00

plugins: the UPDATE_VMA_MAP callback returns fd with the full control

It means CRIU has to close it when it is not needed.

It looks more logically correct and matches the behaviour of
the RESTORE_EXT_FILE callback.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
Andrei Vagin
2023-09-28 21:38:45 -07:00
parent 66f39adf12
commit a68975c06d
2 changed files with 10 additions and 5 deletions

View File

@@ -2506,7 +2506,7 @@ static int open_filemap(int pid, struct vma_area *vma)
* using dup because dup returns a reference to the same struct file inside kernel, but we
* cannot open a new FD.
*/
ret = dup(plugin_fd);
ret = plugin_fd;
} else if (vma->e->status & VMA_AREA_MEMFD) {
if (!inherited_fd(vma->vmfd, &ret))
ret = memfd_open(vma->vmfd, &flags);

View File

@@ -1955,10 +1955,15 @@ int amdgpu_plugin_update_vmamap(const char *in_path, const uint64_t addr, const
if (addr == vma_md->vma_entry && old_offset == vma_md->old_pgoff) {
*new_offset = vma_md->new_pgoff;
if (is_renderD)
*updated_fd = vma_md->fd;
else
*updated_fd = -1;
if (is_renderD) {
int fd = dup(vma_md->fd);
if (fd == -1) {
pr_perror("unable to duplicate the render fd");
return -1;
}
*updated_fd = fd;
}
plugin_log_msg("old_pgoff=0x%lx new_pgoff=0x%lx fd=%d\n", vma_md->old_pgoff, vma_md->new_pgoff,
*updated_fd);