Backport upstream patches.

1. fix the null pointer of get_tty_driver.
2. criu files Dont cache fd ids for device files.
3. pre dump call vmsplice with SPLICE_F_GIFT.

Signed-off-by: euleroswander <314264452@qq.com>
This commit is contained in:
euleroswander 2022-11-22 16:16:02 +08:00
parent fc7d18d6cb
commit 0898adc167
4 changed files with 115 additions and 2 deletions

View File

@ -0,0 +1,35 @@
From 485a83c110bef1b2700acec0bd63bad4518aa62f Mon Sep 17 00:00:00 2001
From: "fu.lin" <fulin10@huawei.com>
Date: Fri, 17 Sep 2021 17:16:48 +0800
Subject: [PATCH] tty: fix the null pointer of get_tty_driver
v2: split error checking from index variable initialization
v3: use PRIx64 for printing dev_t
Signed-off-by: fu.lin <fulin10@huawei.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: He Wenliang <hewenliang4@huawei.com>
---
criu/tty.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/criu/tty.c b/criu/tty.c
index 1598ad956..1462193c5 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1977,6 +1977,12 @@ static int dump_one_tty(int lfd, u32 id, const struct fd_parms *p)
pr_info("Dumping tty %d with id %#x\n", lfd, id);
driver = get_tty_driver(p->stat.st_rdev, p->stat.st_dev);
+ if (driver == NULL) {
+ pr_err("Unable to find a tty driver (rdev %#" PRIx64 " dev %#" PRIx64 ")\n", p->stat.st_rdev,
+ p->stat.st_dev);
+ return -1;
+ }
+
if (driver->fd_get_index)
index = driver->fd_get_index(lfd, p);
else
--
2.33.0

View File

@ -0,0 +1,42 @@
From 74d1233b596c52ae8dc5da4730e6e3e48152023e Mon Sep 17 00:00:00 2001
From: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Date: Tue, 27 Apr 2021 19:08:57 -0400
Subject: [PATCH] criu/files: Don't cache fd ids for device files
Restore operation fails when we perform CR operation of multiple
independent proceses that have device files because criu caches
the ids for the device files with same mnt_ids, inode pair. This
change ensures that even in case of a cached id found for a device, a
unique subid is generated and returned which is used for dumping.
Suggested-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: He Wenliang <hewenliang4@huawei.com>
---
criu/file-ids.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/criu/file-ids.c b/criu/file-ids.c
index 1b9d68888..772bd92cf 100644
--- a/criu/file-ids.c
+++ b/criu/file-ids.c
@@ -77,8 +77,14 @@ int fd_id_generate_special(struct fd_parms *p, u32 *id)
fi = fd_id_cache_lookup(p);
if (fi) {
- *id = fi->id;
- return 0;
+ if (p->stat.st_mode & (S_IFCHR | S_IFBLK)) {
+ /* Don't cache the id for mapped devices */
+ *id = fd_tree.subid++;
+ return 1;
+ } else {
+ *id = fi->id;
+ return 0;
+ }
}
}
--
2.33.0

View File

@ -0,0 +1,28 @@
From efeedf3912df4a9a13d5ac719700ca06a9dad327 Mon Sep 17 00:00:00 2001
From: Andrei Vagin <avagin@gmail.com>
Date: Wed, 27 Apr 2022 07:02:58 +0300
Subject: [PATCH] pre-dump: call vmsplice with SPLICE_F_GIFT
In this case, vmplice attaches pages without coping them.
Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
criu/page-xfer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 3d29fbf78..2a9f6e2cc 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -822,7 +822,7 @@ int page_xfer_predump_pages(int pid, struct page_xfer *xfer, struct page_pipe *p
bufvec.iov_base = userbuf;
bufvec.iov_len = bytes_read;
- ret = vmsplice(ppb->p[1], &bufvec, 1, SPLICE_F_NONBLOCK);
+ ret = vmsplice(ppb->p[1], &bufvec, 1, SPLICE_F_NONBLOCK | SPLICE_F_GIFT);
if (ret == -1 || ret != bytes_read) {
pr_err("vmsplice: Failed to splice user buffer to pipe %ld\n", ret);
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: criu
Version: 3.16.1
Release: 6
Release: 7
Provides: crtools = %{version}-%{release}
Obsoletes: crtools <= 1.0-2
Summary: A tool of Checkpoint/Restore in User-space
@ -34,7 +34,10 @@ Patch16: 0015-cr-dump-handle-rseq-flags-field.patch
Patch17: 0016-zdtm-add-rseq02-transition-test-with-NO_RESTART-CS-f.patch
Patch1000: 1000-backport-page-pipe-fix-limiting-a-pipe-size.patch
Patch1001: 1001-backport-tty-fix-the-null-pointer-of-get_tty_driver.patch
Patch1002: 1002-backport-criu-files-Don-t-cache-fd-ids-for-device-files.patch
Patch1003: 1003-backport-pre-dump-call-vmsplice-with-SPLICE_F_GIFT.patch
%description
Checkpoint/Restore in Userspace(CRIU),is a software tool for the linux operating system.
Using this tool,it is possible to freeze a running application (or part of it) and
@ -116,6 +119,11 @@ chmod 0755 %{buildroot}/run/%{name}/
%doc %{_mandir}/man1/{compel.1*,crit.1*,criu-ns.1*}
%changelog
* Tue Nov 22 2022 Hewenliang <hewenliang4@huawei.com> - 3.16.1-7
- fix the null pointer of get_tty_driver.
- criu files Dont cache fd ids for device files.
- pre dump call vmsplice with SPLICE_F_GIFT.
* Tue Nov 22 2022 Hewenliang <hewenliang4@huawei.com> - 3.16.1-6
- page-pipe:fix-limiting a pipe size.