Updated to 3.11

Removed upstreamed patches
This commit is contained in:
Adrian Reber 2018-11-06 19:34:40 +01:00
parent 80826651a3
commit b4ddc847bf
Failed to extract signature
3 changed files with 10 additions and 334 deletions

View File

@ -1,241 +0,0 @@
From patchwork Mon Jul 9 06:28:26 2018
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [1/2] Fix building with 4.18
From: Adrian Reber <adrian@lisas.de>
X-Patchwork-Id: 8849
Message-Id: <1531117707-8173-2-git-send-email-adrian@lisas.de>
To: <criu@openvz.org>, Andrei Vagin <avagin@virtuozzo.com>
Cc: Adrian Reber <areber@redhat.com>
Date: Mon, 9 Jul 2018 06:28:26 +0000
From: Adrian Reber <areber@redhat.com>
Building CRIU against 4.18 fails with multiple re-definition errors.
This has been reported upstream
https://lore.kernel.org/lkml/20180704142116.GM17048@lisas.de/
but there has not been any answer yet. This tries to workaround those
compile errors by pulling the required aio defines directly into CRIU.
Signed-off-by: Adrian Reber <areber@redhat.com>
---
criu/cr-check.c | 2 +-
criu/include/aio.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++-
criu/pie/restorer.c | 1 -
test/zdtm/static/aio01.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 145 insertions(+), 5 deletions(-)
diff --git a/criu/cr-check.c b/criu/cr-check.c
index d3393c4..fc53afb 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -22,7 +22,6 @@
#include <sys/prctl.h>
#include <sched.h>
#include <sys/mount.h>
-#include <linux/aio_abi.h>
#include "../soccr/soccr.h"
@@ -51,6 +50,7 @@
#include "net.h"
#include "restorer.h"
#include "uffd.h"
+#include "aio.h"
static char *feature_name(int (*func)());
diff --git a/criu/include/aio.h b/criu/include/aio.h
index 9a58089..a749c47 100644
--- a/criu/include/aio.h
+++ b/criu/include/aio.h
@@ -1,7 +1,6 @@
#ifndef __CR_AIO_H__
#define __CR_AIO_H__
-#include <linux/aio_abi.h>
#include "images/mm.pb-c.h"
unsigned int aio_estimate_nr_reqs(unsigned int size);
int dump_aio_ring(MmEntry *mme, struct vma_area *vma);
@@ -12,6 +11,78 @@ unsigned long aio_rings_args_size(struct vm_area_list *);
struct task_restore_args;
int prepare_aios(struct pstree_item *t, struct task_restore_args *ta);
+/* copied from linux/fs.h */
+typedef int __bitwise __kernel_rwf_t;
+
+/* copied from linux/aio_abi.h */
+#ifndef COMPEL_SYSCALL_TYPES_H__
+/* The ifndef is needed to avoid a clang compiler error */
+typedef __kernel_ulong_t aio_context_t;
+#endif
+
+enum {
+ IOCB_CMD_PREAD = 0,
+ IOCB_CMD_PWRITE = 1,
+ IOCB_CMD_FSYNC = 2,
+ IOCB_CMD_FDSYNC = 3,
+ /* These two are experimental.
+ * IOCB_CMD_PREADX = 4,
+ * IOCB_CMD_POLL = 5,
+ */
+ IOCB_CMD_NOOP = 6,
+ IOCB_CMD_PREADV = 7,
+ IOCB_CMD_PWRITEV = 8,
+};
+/* read() from /dev/aio returns these structures. */
+struct io_event {
+ __u64 data; /* the data field from the iocb */
+ __u64 obj; /* what iocb this event came from */
+ __s64 res; /* result code for this event */
+ __s64 res2; /* secondary result */
+};
+
+/*
+ * we always use a 64bit off_t when communicating
+ * with userland. its up to libraries to do the
+ * proper padding and aio_error abstraction
+ */
+
+struct iocb {
+ /* these are internal to the kernel/libc. */
+ __u64 aio_data; /* data to be returned in event's data */
+
+#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
+ __u32 aio_key; /* the kernel sets aio_key to the req # */
+ __kernel_rwf_t aio_rw_flags; /* RWF_* flags */
+#elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
+ __kernel_rwf_t aio_rw_flags; /* RWF_* flags */
+ __u32 aio_key; /* the kernel sets aio_key to the req # */
+#else
+#error edit for your odd byteorder.
+#endif
+
+ /* common fields */
+ __u16 aio_lio_opcode; /* see IOCB_CMD_ above */
+ __s16 aio_reqprio;
+ __u32 aio_fildes;
+
+ __u64 aio_buf;
+ __u64 aio_nbytes;
+ __s64 aio_offset;
+
+ /* extra parameters */
+ __u64 aio_reserved2; /* TODO: use this for a (struct sigevent *) */
+
+ /* flags for the "struct iocb" */
+ __u32 aio_flags;
+
+ /*
+ * if the IOCB_FLAG_RESFD flag of "aio_flags" is set, this is an
+ * eventfd to signal AIO readiness to
+ */
+ __u32 aio_resfd;
+}; /* 64 bytes */
+
struct aio_ring {
unsigned id; /* kernel internal index number */
unsigned nr; /* number of io_events */
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 9b7f6dd..f100213 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -3,7 +3,6 @@
#include <linux/securebits.h>
#include <linux/capability.h>
-#include <linux/aio_abi.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/file.h>
diff --git a/test/zdtm/static/aio01.c b/test/zdtm/static/aio01.c
index f84fd35..4ad29a7 100644
--- a/test/zdtm/static/aio01.c
+++ b/test/zdtm/static/aio01.c
@@ -1,6 +1,5 @@
-#include <linux/aio_abi.h>
+#include <linux/types.h>
#include <sys/syscall.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdlib.h>
@@ -13,6 +12,77 @@
const char *test_doc = "Check head and tail restore correct";
const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>";
+/* copied from linux/fs.h */
+typedef int __bitwise __kernel_rwf_t;
+
+/* copied from linux/aio_abi.h */
+#ifndef COMPEL_SYSCALL_TYPES_H__
+typedef __kernel_ulong_t aio_context_t;
+#endif
+
+enum {
+ IOCB_CMD_PREAD = 0,
+ IOCB_CMD_PWRITE = 1,
+ IOCB_CMD_FSYNC = 2,
+ IOCB_CMD_FDSYNC = 3,
+ /* These two are experimental.
+ * IOCB_CMD_PREADX = 4,
+ * IOCB_CMD_POLL = 5,
+ */
+ IOCB_CMD_NOOP = 6,
+ IOCB_CMD_PREADV = 7,
+ IOCB_CMD_PWRITEV = 8,
+};
+/* read() from /dev/aio returns these structures. */
+struct io_event {
+ __u64 data; /* the data field from the iocb */
+ __u64 obj; /* what iocb this event came from */
+ __s64 res; /* result code for this event */
+ __s64 res2; /* secondary result */
+};
+
+/*
+ * we always use a 64bit off_t when communicating
+ * with userland. its up to libraries to do the
+ * proper padding and aio_error abstraction
+ */
+
+struct iocb {
+ /* these are internal to the kernel/libc. */
+ __u64 aio_data; /* data to be returned in event's data */
+
+#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
+ __u32 aio_key; /* the kernel sets aio_key to the req # */
+ __kernel_rwf_t aio_rw_flags; /* RWF_* flags */
+#elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
+ __kernel_rwf_t aio_rw_flags; /* RWF_* flags */
+ __u32 aio_key; /* the kernel sets aio_key to the req # */
+#else
+#error edit for your odd byteorder.
+#endif
+
+ /* common fields */
+ __u16 aio_lio_opcode; /* see IOCB_CMD_ above */
+ __s16 aio_reqprio;
+ __u32 aio_fildes;
+
+ __u64 aio_buf;
+ __u64 aio_nbytes;
+ __s64 aio_offset;
+
+ /* extra parameters */
+ __u64 aio_reserved2; /* TODO: use this for a (struct sigevent *) */
+
+ /* flags for the "struct iocb" */
+ __u32 aio_flags;
+
+ /*
+ * if the IOCB_FLAG_RESFD flag of "aio_flags" is set, this is an
+ * eventfd to signal AIO readiness to
+ */
+ __u32 aio_resfd;
+}; /* 64 bytes */
+
struct aio_ring {
unsigned id; /* kernel internal index number */
unsigned nr; /* number of io_events */

View File

@ -1,83 +0,0 @@
From 27034e7c64b00a1f2467afb5ebb1d5b9b1a06ce1 Mon Sep 17 00:00:00 2001
From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Date: Wed, 11 Jul 2018 13:43:33 +0300
Subject: [PATCH] mount: fix regression where open_mountpoint failed on
readonly fs
If we fail to create temporary directory for doing a clean mount we can
make mount clean reusing the code which enters new mountns to umount
overmounts. As when last process exits mntns all mounts are implicitly
cleaned from children, see in kernel source - sys_exit->do_exit
->exit_task_namespaces->switch_task_namespaces->free_nsproxy
->put_mnt_ns->umount_tree->drop_collected_mounts->umount_tree:
/* Hide the mounts from mnt_mounts */
list_for_each_entry(p, &tmp_list, mnt_list) {
list_del_init(&p->mnt_child);
}
Fixes commit b6cfb1ce2948 ("mount: make open_mountpoint handle overmouts
properly")
https://github.com/checkpoint-restore/criu/issues/520
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Acked-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
criu/mount.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/criu/mount.c b/criu/mount.c
index b56164e953..9cc8f6e940 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1325,10 +1325,18 @@ int ns_open_mountpoint(void *arg)
if (umount_overmounts(mi))
goto err;
- /* Save fd which we opened for parent due to CLONE_FILES flag */
- *fd = get_clean_fd(mi);
- if (*fd < 0)
+ /*
+ * Save fd which we opened for parent due to CLONE_FILES flag
+ *
+ * Mount can still have children in it, but we don't need to clean it
+ * explicitly as when last process exits mntns all mounts in it are
+ * cleaned from their children, and we are exactly the last process.
+ */
+ *fd = open(mi->mountpoint, O_DIRECTORY|O_RDONLY);
+ if (*fd < 0) {
+ pr_perror("Unable to open %s", mi->mountpoint);
goto err;
+ }
return 0;
err:
@@ -1367,18 +1375,22 @@ int open_mountpoint(struct mount_info *pm)
if (!mnt_is_overmounted(pm)) {
pr_info("\tmount has children %s\n", pm->mountpoint);
-
fd = get_clean_fd(pm);
- if (fd < 0)
- goto err;
- } else {
+ }
+
+ /*
+ * Mount is overmounted or probably we can't create a temporary
+ * direcotry for a cleaned mount
+ */
+ if (fd < 0) {
int pid, status;
struct clone_arg ca = {
.mi = pm,
.fd = &fd
};
- pr_info("\tmount is overmounted %s\n", pm->mountpoint);
+ pr_info("\tmount is overmounted or has children %s\n",
+ pm->mountpoint);
/*
* We are overmounted - not accessible in a regular way. We

View File

@ -1,7 +1,9 @@
%if 0%{?fedora} >= 27 || 0%{?rhel} > 7
%global py_prefix python3
%global py_binary %{py_prefix}
%else
%global py_prefix python
%global py_binary python2
%endif
# With annobin enabled, CRIU does not work anymore. It seems CRIU's
@ -9,8 +11,8 @@
%undefine _annotated_build
Name: criu
Version: 3.10
Release: 5%{?dist}
Version: 3.11
Release: 1%{?dist}
Provides: crtools = %{version}-%{release}
Obsoletes: crtools <= 1.0-2
Summary: Tool for Checkpoint/Restore in User-space
@ -18,10 +20,6 @@ Group: System Environment/Base
License: GPLv2
URL: http://criu.org/
Source0: http://download.openvz.org/criu/criu-%{version}.tar.bz2
# https://patchwork.criu.org/patch/8849/mbox/
Patch1: 1-2-Fix-building-with-4.18.patch
# Fixes errors with read-only runc
Patch2: https://github.com/checkpoint-restore/criu/commit/27034e7c64b00a1f2467afb5ebb1d5b9b1a06ce1.patch
%if 0%{?rhel} && 0%{?rhel} <= 7
BuildRequires: perl
@ -93,8 +91,6 @@ their content in human-readable form.
%prep
%setup -q
%patch1 -p1
%patch2 -p1
%if 0%{?rhel} && 0%{?rhel} <= 7
%patch100 -p1
@ -103,7 +99,7 @@ their content in human-readable form.
%build
# %{?_smp_mflags} does not work
# -fstack-protector breaks build
CFLAGS+=`echo %{optflags} | sed -e 's,-fstack-protector\S*,,g'` make V=1 WERROR=0 PREFIX=%{_prefix} RUNDIR=/run/criu PYTHON=%{py_prefix}
CFLAGS+=`echo %{optflags} | sed -e 's,-fstack-protector\S*,,g'` make V=1 WERROR=0 PREFIX=%{_prefix} RUNDIR=/run/criu PYTHON=%{py_binary}
%if 0%{?fedora} || 0%{?rhel} > 7
make docs V=1
%endif
@ -111,7 +107,7 @@ make docs V=1
%install
make install-criu DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} LIBDIR=%{_libdir}
make install-lib DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} LIBDIR=%{_libdir} PYTHON=%{py_prefix}
make install-lib DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} LIBDIR=%{_libdir} PYTHON=%{py_binary}
%if 0%{?fedora} || 0%{?rhel} > 7
# only install documentation on Fedora as it requires asciidoc,
# which is not available on RHEL7
@ -168,6 +164,10 @@ rm -rf $RPM_BUILD_ROOT%{_libexecdir}/%{name}
%changelog
* Tue Nov 06 2018 Adrian Reber <adrian@lisas.de> - 3.11-1
- Updated to 3.11
- Removed upstreamed patches
* Tue Oct 30 2018 Adrian Reber <adrian@lisas.de> - 3.10-5
- Added Recommends: tar
It is necessary when checkpointing containers with a tmpfs