1 Star 0 Fork 35

bzg_repo/criu

forked from src-openEuler/criu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0026-improve-char-dev-fd-check-and-repair-method.patch 2.06 KB
一键复制 编辑 原始数据 按行查看 历史
river 提交于 2022-04-13 15:05 . criu: backport kinds of features/bugfix
From 539add7149df575d6d8cdce60ad6fb2c2300e27d Mon Sep 17 00:00:00 2001
From: Jingxian He <hejingxian@huawei.com>
Date: Sun, 24 Oct 2021 15:20:27 +0800
Subject: [PATCH 26/72] improve char dev fd check and repair method
Some special char dev cannot work in child processes, we make dump fail
when the special char dev fd is in child processes.
In the char dev repair process, user may need recover fd. We should
make thre repair process running after the char dev fd is reopened as dumped fd.
Conflict:NA
Reference:https://gitee.com/src-openeuler/criu/pulls/21
Signed-off-by: Jingxian He <hejingxian@huawei.com>
---
criu/files-chr.c | 11 +----------
criu/files.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/criu/files-chr.c b/criu/files-chr.c
index 2eb023e..315e9c6 100644
--- a/criu/files-chr.c
+++ b/criu/files-chr.c
@@ -31,17 +31,8 @@ static int chrfile_open(struct file_desc *d, int *new_fd)
return -1;
}
- if (ci->cfe->repair) {
- ret = ioctl(fd, IOCTL_CMD_REPAIR , ci->cfe->index);
- pr_info("repair ioctl return: %d, index: %d\n", ret, ci->cfe->index);
- if (ret)
- goto err;
- }
-
*new_fd = fd;
- return ret;
-err:
- close(fd);
+
return ret;
}
diff --git a/criu/files.c b/criu/files.c
index e1681a1..7b688f5 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1231,6 +1231,7 @@ static int open_fd(struct fdinfo_list_entry *fle)
struct file_desc *d = fle->desc;
struct fdinfo_list_entry *flem;
int new_fd = -1, ret;
+ struct chrfile_info *ci;
flem = file_master(d);
if (fle != flem) {
@@ -1258,6 +1259,17 @@ static int open_fd(struct fdinfo_list_entry *fle)
if (ret != -1 && new_fd >= 0) {
if (setup_and_serve_out(fle, new_fd) < 0)
return -1;
+ if (d->ops->type == FD_TYPES__CHR) {
+ ci = container_of(d, struct chrfile_info, d);
+ if (ci->cfe->repair) {
+ ret = ioctl(fle->fe->fd, IOCTL_CMD_REPAIR , ci->cfe->index);
+ pr_info("repair ioctl return: %d, index: %d\n", ret, ci->cfe->index);
+ if (ret) {
+ close(fle->fe->fd);
+ return -1;
+ }
+ }
+ }
}
out:
if (ret == 0)
--
2.34.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/baizg1107/criu.git
git@gitee.com:baizg1107/criu.git
baizg1107
criu
criu
master

搜索帮助