Skip to contentSkip to conversation

package/criu: new package

PATCH Superseded Marcus Folkesson 2 participants 2 messages Sep 10, 2023

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/criu: new package

Checkpoint/Restore In Userspace (CRIU), is a software tool for the Linux operating system to make it possible to freeze a running application and checkpoint it to persistent storage as a collection of files.

---

Notes:

    v2:
    
    - Addressed comments from Thomas.
    - Tested on ARM target and on x86_64 with qemu.
    
    test-pkg skips test though, and I'm not sure why.
    $ utils/test-pkg -d ~/mnt/encwork/git/br-test-pkg/ -p criu
                        bootlin-armv5-uclibc [1/6]: SKIPPED
                         bootlin-armv7-glibc [2/6]: SKIPPED
                       bootlin-armv7m-uclibc [3/6]: SKIPPED
                         bootlin-x86-64-musl [4/6]: SKIPPED
                          br-arm-full-static [5/6]: SKIPPED
                                sourcery-arm [6/6]: SKIPPED
 DEVELOPERS             |  1 +
 package/Config.in      |  1 +
 package/criu/Config.in | 44 +++++++++++++++++++++++++++++++++++
 package/criu/criu.hash |  3 +++
 package/criu/criu.mk   | 53 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 102 insertions(+)
 create mode 100644 package/criu/Config.in
 create mode 100644 package/criu/criu.hash
 create mode 100644 package/criu/criu.mk
DEVELOPERS +1 -0
index 3af43d2d27..cf7cb9718a 100644
@@ -2050,6 +2050,7 @@ F:	support/testing/tests/package/test_python_pytest.py
 F:	support/testing/tests/package/test_python_pytest_asyncio.py
 
 N:	Marcus Folkesson <[email protected]>
+F:	package/criu/
 F:	package/libcamera/
 F:	package/libcamera-apps/
 F:	package/libostree/
package/Config.in +1 -0
index b21a2f8c65..c6c809f59c 100644
@@ -2665,6 +2665,7 @@ menu "System tools"
 	source "package/coreutils/Config.in"
 	source "package/cpulimit/Config.in"
 	source "package/cpuload/Config.in"
+	source "package/criu/Config.in"
 	source "package/crun/Config.in"
 	source "package/daemon/Config.in"
 	source "package/dc3dd/Config.in"
package/criu/Config.in new file +44 -0

44 lines not on this page · raw message

package/criu/criu.hash new file +3 -0
new file mode 100644
index 0000000000..2c4a07252b
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256  6a9997981c9fe4730c848ce59346b3a22fad69b803607cb67a3f6ec0557fa474  criu-3.18.tar.gz
+sha256  568a1fa9d90e18a1a1a61ea58ec2eece16b56a5042cc72c1b4f8d4455ae6fcb7  COPYING
package/criu/criu.mk new file +53 -0

53 lines not on this page · raw message

Signature · 6 lines
2.41.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hi Marcus,

criu requires the Kernel to have the checkpoint/restore support. This support is disabled by default in the Kernel. It could be convenient to automatically enable it, when this package is selected. See below.

Quoted 156 lines · Marcus Folkesson

Checkpoint/Restore In Userspace (CRIU), is a software tool for the Linux operating system to make it possible to freeze a running application and checkpoint it to persistent storage as a collection of files.

---

Notes:

    v2:

    - Addressed comments from Thomas.
    - Tested on ARM target and on x86_64 with qemu.

    test-pkg skips test though, and I'm not sure why.
    $ utils/test-pkg -d ~/mnt/encwork/git/br-test-pkg/ -p criu
                        bootlin-armv5-uclibc [1/6]: SKIPPED
                         bootlin-armv7-glibc [2/6]: SKIPPED
                       bootlin-armv7m-uclibc [3/6]: SKIPPED
                         bootlin-x86-64-musl [4/6]: SKIPPED
                          br-arm-full-static [5/6]: SKIPPED
                                sourcery-arm [6/6]: SKIPPED
 DEVELOPERS             |  1 +
 package/Config.in      |  1 +
 package/criu/Config.in | 44 +++++++++++++++++++++++++++++++++++
 package/criu/criu.hash |  3 +++
 package/criu/criu.mk   | 53 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 102 insertions(+)
 create mode 100644 package/criu/Config.in
 create mode 100644 package/criu/criu.hash
 create mode 100644 package/criu/criu.mk
DEVELOPERS +0 -0
index 3af43d2d27..cf7cb9718a 100644
@@ -2050,6 +2050,7 @@ 

F: support/testing/tests/package/test_python_pytest.py
F: support/testing/tests/package/test_python_pytest_asyncio.py

N: Marcus Folkesson <[email protected]>

DEVELOPERS +1 -0
+F:	package/criu/
 F:	package/libcamera/
 F:	package/libcamera-apps/
 F:	package/libostree/
package/Config.in +1 -0
index b21a2f8c65..c6c809f59c 100644
@@ -2665,6 +2665,7 @@ menu "System tools"
 	source "package/coreutils/Config.in"
 	source "package/cpulimit/Config.in"
 	source "package/cpuload/Config.in"
+	source "package/criu/Config.in"
 	source "package/crun/Config.in"
 	source "package/daemon/Config.in"
 	source "package/dc3dd/Config.in"
package/criu/Config.in new file +44 -0
new file mode 100644
index 0000000000..932e65863e
@@ -0,0 +1,44 @@
+# criu only builds on certain architectures
+config BR2_PACKAGE_CRIU_ARCH_SUPPORTS
+	bool
+	default y if BR2_arm
+	default y if BR2_aarch64
+	default y if BR2_i386
+	default y if BR2_mips
+	default y if BR2_x86_64
+	default y if BR2_powerpc64
+	default y if BR2_s390x
+
+menuconfig BR2_PACKAGE_CRIU
+	bool "criu"
+	depends on BR2_PACKAGE_CRIU_ARCH_SUPPORTS
+	depends on BR2_PACKAGE_HOST_PYTHON3 # host-python3-ssl
+	depends on BR2_PACKAGE_HOST_PROTOBUF_ARCH_SUPPORTS # protobuf-c
+	depends on BR2_PACKAGE_PROTOBUF_ARCH_SUPPORTS
+	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS
+	depends on BR2_INSTALL_LIBSTDCPP # protobuf
+	depends on BR2_TOOLCHAIN_HAS_THREADS # protobuf, libnl
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 # protobuf
+	depends on !BR2_STATIC_LIBS # protobuf, libbsd
+	depends on BR2_USE_WCHAR # libbsd
+	depends on BR2_USE_MMU # libcap
+	select BR2_PACKAGE_HOST_PYTHON3_SSL
+	select BR2_PACKAGE_PROTOBUF
+	select BR2_PACKAGE_PROTOBUF_C
+	select BR2_PACKAGE_LIBAIO
+	select BR2_PACKAGE_LIBBSD
+	select BR2_PACKAGE_LIBCAP
+	select BR2_PACKAGE_LIBNET
+	select BR2_PACKAGE_LIBNL
+	select BR2_PACKAGE_PYTHON3
+	help
+	  Checkpoint/Restore In Userspace (CRIU), is a software
+	  tool for the Linux operating system to make it possible
+	  to freeze a running application and checkpoint it to
+	  persistent storage as a collection of files.
+
+	  https://criu.org/Main_Page
+
+comment "criu needs a toolchain w/ threads, dynamic library, wchar"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS \
+		|| !BR2_USE_WCHAR
package/criu/criu.hash new file +2 -0
new file mode 100644
index 0000000000..2c4a07252b
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256  

6a9997981c9fe4730c848ce59346b3a22fad69b803607cb67a3f6ec0557fa474 criu-3.18.tar.gz +sha256 568a1fa9d90e18a1a1a61ea58ec2eece16b56a5042cc72c1b4f8d4455ae6fcb7 COPYING

package/criu/criu.mk new file +9 -0
new file mode 100644
index 0000000000..095ff8e290
@@ -0,0 +1,53 @@
+################################################################################
+#
+# CRIU
+#
+################################################################################
+
+CRIU_VERSION = 3.18
+CRIU_SOURCE = criu-$(CRIU_VERSION).tar.gz
+CRIU_SITE = 

https://github.com/checkpoint-restore/criu/archive/refs/tags/v$(CRIU_VERSION)

package/criu/criu.mk new file +22 -0
+
+CRIU_LICENSE = GPL-2.0
+CRIU_LICENSE_FILES = COPYING
+CRIU_DEPENDENCIES =\
+	host-pkgconf \
+	host-protobuf-c \
+	host-python3 \
+	host-python-pip \
+	libaio \
+	libbsd \
+	libcap \
+	libnet \
+	libnl \
+	protobuf \
+	protobuf-c \
+	python3
+
+CRIU_MAKE_ENV =\
+	$(TARGET_MAKE_ENV) \
+	$(TARGET_CONFIGURE_OPTS) \
+	CROSS_COMPILE=$(TARGET_CROSS) \
+	WERROR=0

package/criu/criu.mk line 41

Quoted 10 lines
package/criu/criu.mk new file +10 -0
+
+#x86_64 is treated as x86 in criu
+#Also, powerpc64 is refered to as ppc64 in criu.
+ifeq ($(BR2_ARCH),"x86_64")
+CRIU_MAKE_ENV += ARCH=x86
+else ifeq ($(BR2_ARCH),"powerpc64")
+CRIU_MAKE_ENV += ARCH=ppc64
+else
+CRIU_MAKE_ENV += ARCH=$(BR2_ARCH)
+endif

You can add a Linux Kernel config fixup, for example:

# Criu needs Kernel Checkpoint/restore support which is not enabled # by default.
define CRIU_LINUX_CONFIG_FIXUPS
$(call KCONFIG_ENABLE_OPT,CONFIG_CHECKPOINT_RESTORE)
endef

Without this kernel option set, running criu checks fails:

criu check
...
Error (criu/cr-check.c:158): sys/kernel/ns_last_pid sysctl is
inaccessible: No such file or directory
Warn (criu/cr-check.c:1447): Does not look good.

With this option, criu check shows:

Looks good.

Quoted 11 lines
package/criu/criu.mk new file +4 -0
+
+define CRIU_BUILD_CMDS
+	rm -rf $(@D)/images/google/protobuf/descriptor.proto
+	ln -s  $(STAGING_DIR)/usr/include/google/protobuf/descriptor.proto 

$(@D)/images/google/protobuf/descriptor.proto

package/criu/criu.mk new file +5 -0
+	$(CRIU_MAKE_ENV) $(MAKE) USERCFLAGS="$(TARGET_CFLAGS)" -C $(@D)
+endef
+
+define CRIU_INSTALL_TARGET_CMDS
+	$(CRIU_MAKE_ENV) $(MAKE) DESTDIR=$(TARGET_DIR) PREFIX=/usr -C $(@D) 

install-criu install-lib install-compel

package/criu/criu.mk line 53

Quoted 3 lines
package/criu/criu.mk new file +3 -0
+endef
+
+$(eval $(generic-package))

Best regards,

Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot