gnu: Add criu

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Ricardo Wurmus
Owner
unassigned
Submitted by
Ricardo Wurmus
Severity
normal
R
R
Ricardo Wurmus wrote on 18 Oct 2017 21:09
(address . guix-patches@gnu.org)
87lgk846jt.fsf@elephly.net
This patch set adds libnet and criu. Criu supposedly allows one to dump
a process’s memory image to disk and recover it even after a reboot. It
uses the kernel’s snapshot facility (which is not enabled in our kernel
packages) to achieve this.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
R
R
Ricardo Wurmus wrote on 21 Oct 2017 02:55
[PATCH 2/2] gnu: Add criu.
(address . 28913@debbugs.gnu.org)(name . Ricardo Wurmus)(address . rekado@elephly.net)
20171021005556.28993-2-rekado@elephly.net
* gnu/packages/virtualization.scm (criu): New variable.
---
gnu/packages/virtualization.scm | 101 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 99 insertions(+), 2 deletions(-)

Toggle diff (142 lines)
diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 4e384e79a..9ff1b9814 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -2,7 +2,7 @@
;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -31,6 +31,8 @@
#:use-module (gnu packages cyrus-sasl)
#:use-module (gnu packages disk)
#:use-module (gnu packages dns)
+ #:use-module (gnu packages docbook)
+ #:use-module (gnu packages documentation)
#:use-module (gnu packages gl)
#:use-module (gnu packages glib)
#:use-module (gnu packages gnome)
@@ -39,9 +41,11 @@
#:use-module (gnu packages libusb)
#:use-module (gnu packages linux)
#:use-module (gnu packages ncurses)
+ #:use-module (gnu packages networking)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages polkit)
+ #:use-module (gnu packages protobuf)
#:use-module (gnu packages python)
#:use-module (gnu packages selinux)
#:use-module (gnu packages sdl)
@@ -54,7 +58,7 @@
#:use-module (guix build-system gnu)
#:use-module (guix build-system python)
#:use-module (guix download)
- #:use-module ((guix licenses) #:select (gpl2 gpl2+ lgpl2.1+))
+ #:use-module ((guix licenses) #:select (gpl2 gpl2+ lgpl2.1 lgpl2.1+))
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (srfi srfi-1))
@@ -558,3 +562,96 @@ virtual machines through libvirt. It primarily targets KVM VMs, but also
manages Xen and LXC (Linux containers). It presents a summary view of running
domains, their live performance and resource utilization statistics.")
(license gpl2+)))
+
+(define-public criu
+ (package
+ (name "criu")
+ (version "3.5")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "http://download.openvz.org/criu/criu-"
+ version ".tar.bz2"))
+ (sha256
+ (base32
+ "1w0ybla7ac0ql0jzh0vxdf2w9amqp88jcg0na3b33r3hq8acry6x"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:test-target "test"
+ #:tests? #f ; tests require mounting as root
+ #:make-flags
+ (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
+ (string-append "LIBDIR=" (assoc-ref %outputs "out")
+ "/lib"))
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'configure
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; The includes for libnl are located in a sub-directory.
+ (setenv "C_INCLUDE_PATH"
+ (string-append (assoc-ref inputs "libnl")
+ "/include/libnl3:"
+ (getenv "C_INCLUDE_PATH")))
+ ;; Prevent xmlto from failing the install phase.
+ (substitute* "Documentation/Makefile"
+ (("XMLTO.*:=.*")
+ (string-append "XMLTO:="
+ (assoc-ref inputs "xmlto")
+ "/bin/xmlto"
+ " --skip-validation "
+ " -x "
+ (assoc-ref inputs "docbook-xsl")
+ "/xml/xsl/docbook-xsl-"
+ ,(package-version docbook-xsl)
+ "/manpages/docbook.xsl")))
+ #t))
+ (add-before 'build 'fix-symlink
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; The file 'images/google/protobuf/descriptor.proto' points to
+ ;; /usr/include/..., which obviously does not exist.
+ (let* ((file "google/protobuf/descriptor.proto")
+ (target (string-append "images/" file))
+ (source (string-append (assoc-ref inputs "protobuf")
+ "/include/" file)))
+ (delete-file target)
+ (symlink source target)
+ #t)))
+ (add-after 'install 'wrap
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; Make sure 'crit' runs with the correct PYTHONPATH.
+ (let* ((out (assoc-ref outputs "out"))
+ (path (string-append out
+ "/lib/python"
+ (string-take (string-take-right
+ (assoc-ref inputs "python") 5) 3)
+ "/site-packages:"
+ (getenv "PYTHONPATH"))))
+ (wrap-program (string-append out "/bin/crit")
+ `("PYTHONPATH" ":" prefix (,path))))
+ #t)))))
+ (inputs
+ `(("protobuf" ,protobuf)
+ ("python" ,python-2)
+ ("python2-protobuf" ,python2-protobuf)
+ ("python2-ipaddr" ,python2-ipaddr)
+ ("iproute" ,iproute)
+ ("libaio" ,libaio)
+ ("libcap" ,libcap)
+ ("libnet" ,libnet)
+ ("libnl" ,libnl)))
+ (native-inputs
+ `(("pkg-config" ,pkg-config)
+ ("protobuf-c" ,protobuf-c)
+ ("asciidoc" ,asciidoc)
+ ("xmlto" ,xmlto)
+ ("docbook-xml" ,docbook-xml)
+ ("docbook-xsl" ,docbook-xsl)))
+ (home-page "https://criu.org")
+ (synopsis "Checkpoint and restore in userspace")
+ (description "Using this tool, you can freeze a running application (or
+part of it) and checkpoint it to a hard drive as a collection of files. You
+can then use the files to restore and run the application from the point it
+was frozen at. The distinctive feature of the CRIU project is that it is
+mainly implemented in user space.")
+ ;; The project is licensed under GPLv2; files in the lib/ directory are
+ ;; LGPLv2.1.
+ (license (list gpl2 lgpl2.1))))
--
2.14.1
R
R
Ricardo Wurmus wrote on 21 Oct 2017 02:55
[PATCH 1/2] gnu: Add libnet.
(address . 28913@debbugs.gnu.org)(name . Ricardo Wurmus)(address . rekado@elephly.net)
20171021005556.28993-1-rekado@elephly.net
* gnu/packages/networking.scm (libnet): New variable.
---
gnu/packages/networking.scm | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)

Toggle diff (62 lines)
diff --git a/gnu/packages/networking.scm b/gnu/packages/networking.scm
index 633b8ca43..115e58660 100644
--- a/gnu/packages/networking.scm
+++ b/gnu/packages/networking.scm
@@ -48,6 +48,7 @@
#:use-module (gnu packages adns)
#:use-module (gnu packages algebra)
#:use-module (gnu packages audio)
+ #:use-module (gnu packages autotools)
#:use-module (gnu packages bison)
#:use-module (gnu packages check)
#:use-module (gnu packages code)
@@ -55,6 +56,7 @@
#:use-module (gnu packages curl)
#:use-module (gnu packages databases)
#:use-module (gnu packages dejagnu)
+ #:use-module (gnu packages documentation)
#:use-module (gnu packages flex)
#:use-module (gnu packages gettext)
#:use-module (gnu packages glib)
@@ -1494,3 +1496,39 @@ interface and a programmable text output for scripting.")
;; Update the license field when upstream responds.
(license (list license:bsd-2
license:expat))))
+
+(define-public libnet
+ (package
+ (name "libnet")
+ (version "1.1.6")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "https://github.com/sam-github/libnet/"
+ "archive/libnet-" version ".tar.gz"))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0l4gbzzvr199fzczzricjz7b825i7dlk6sgl5p5alnkcagmq0xys"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _ (chdir "libnet") #t))
+ (add-after 'chdir 'bootstrap
+ (lambda _ (zero? (system* "autoreconf" "-vif"))))
+ (add-before 'build 'build-doc
+ (lambda* (#:key make-flags #:allow-other-keys)
+ (zero? (apply system* "make" "-C" "doc" "doc"
+ make-flags)))))))
+ (native-inputs
+ `(("autoconf" ,autoconf)
+ ("automake" ,automake)
+ ("libtool" ,libtool)
+ ("doxygen" ,doxygen)))
+ (home-page "https://sourceforge.net/projects/libnet-dev/")
+ (synopsis "Framework for low-level network packet construction")
+ (description
+ "Libnet provides a fairly portable framework for network packet
+construction and injection.")
+ (license license:bsd-2)))
--
2.14.1
L
L
Ludovic Courtès wrote on 23 Oct 2017 00:38
(name . Ricardo Wurmus)(address . rekado@elephly.net)(address . 28913@debbugs.gnu.org)
87mv4iyfji.fsf@gnu.org
Ricardo Wurmus <rekado@elephly.net> skribis:

Toggle quote (2 lines)
> * gnu/packages/networking.scm (libnet): New variable.

LGTM!

Toggle quote (6 lines)
> + (synopsis "Framework for low-level network packet construction")
> + (description
> + "Libnet provides a fairly portable framework for network packet
> +construction and injection.")

Bonus points if you can elaborate based on ‘README’ or whatever. :-)

Ludo’.
L
L
Ludovic Courtès wrote on 23 Oct 2017 00:39
Re: [bug#28913] [PATCH 2/2] gnu: Add criu.
(name . Ricardo Wurmus)(address . rekado@elephly.net)(address . 28913@debbugs.gnu.org)
87h8uqyfgv.fsf@gnu.org
Ricardo Wurmus <rekado@elephly.net> skribis:

Toggle quote (2 lines)
> * gnu/packages/virtualization.scm (criu): New variable.

[...]

Toggle quote (8 lines)
> + (replace 'configure
> + (lambda* (#:key inputs #:allow-other-keys)
> + ;; The includes for libnl are located in a sub-directory.
> + (setenv "C_INCLUDE_PATH"
> + (string-append (assoc-ref inputs "libnl")
> + "/include/libnl3:"
> + (getenv "C_INCLUDE_PATH")))

And there’s no libnet.pc or similar to provide the right -I flag?

Toggle quote (2 lines)
> + (synopsis "Checkpoint and restore in userspace")

“user space” (two words)?

Otherwise LGTM, thank you!

Ludo’.
R
R
Ricardo Wurmus wrote on 23 Oct 2017 08:07
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 28913@debbugs.gnu.org)
87po9etn19.fsf@elephly.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (16 lines)
> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>> * gnu/packages/virtualization.scm (criu): New variable.
>
> [...]
>
>> + (replace 'configure
>> + (lambda* (#:key inputs #:allow-other-keys)
>> + ;; The includes for libnl are located in a sub-directory.
>> + (setenv "C_INCLUDE_PATH"
>> + (string-append (assoc-ref inputs "libnl")
>> + "/include/libnl3:"
>> + (getenv "C_INCLUDE_PATH")))
>
> And there’s no libnet.pc or similar to provide the right -I flag?

There is a libnl-3.0.pc file with these contents:

Toggle snippet (12 lines)
prefix=/gnu/store/qyr5m7c21a4myx5421m90yxkxav2qij7-libnl-3.4.0
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: libnl
Description: Convenience library for netlink sockets
Version: 3.4.0
Libs: -L${libdir} -lnl-3
Cflags: -I${includedir}/libnl3

That’s not enough, though, to find header files included by other libnl
headers. Without the setenv snippet above compilation fails with this
error:

Toggle snippet (5 lines)
In file included from criu/libnetlink.c:5:0:
/gnu/store/qyr5m7c21a4myx5421m90yxkxav2qij7-libnl-3.4.0/include/libnl3/netlink/attr.h:15:29: fatal error: netlink/netlink.h: No such file or directory
compilation terminated.

Toggle quote (4 lines)
>> + (synopsis "Checkpoint and restore in userspace")
>
> “user space” (two words)?

Okay. Thanks for reviewing these patches!

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
R
R
Ricardo Wurmus wrote on 23 Oct 2017 08:10
(address . 28913-done@debbugs.gnu.org)
87o9oytmwe.fsf@elephly.net
Pushed to master with commit fe420383e.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
Closed
L
L
Ludovic Courtès wrote on 23 Oct 2017 18:25
(name . Ricardo Wurmus)(address . rekado@elephly.net)(address . 28913@debbugs.gnu.org)
87zi8hu8zn.fsf@gnu.org
Ricardo Wurmus <rekado@elephly.net> skribis:

Toggle quote (40 lines)
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Ricardo Wurmus <rekado@elephly.net> skribis:
>>
>>> * gnu/packages/virtualization.scm (criu): New variable.
>>
>> [...]
>>
>>> + (replace 'configure
>>> + (lambda* (#:key inputs #:allow-other-keys)
>>> + ;; The includes for libnl are located in a sub-directory.
>>> + (setenv "C_INCLUDE_PATH"
>>> + (string-append (assoc-ref inputs "libnl")
>>> + "/include/libnl3:"
>>> + (getenv "C_INCLUDE_PATH")))
>>
>> And there’s no libnet.pc or similar to provide the right -I flag?
>
> There is a libnl-3.0.pc file with these contents:
>
> prefix=/gnu/store/qyr5m7c21a4myx5421m90yxkxav2qij7-libnl-3.4.0
> exec_prefix=${prefix}
> libdir=${exec_prefix}/lib
> includedir=${prefix}/include
>
> Name: libnl
> Description: Convenience library for netlink sockets
> Version: 3.4.0
> Libs: -L${libdir} -lnl-3
> Cflags: -I${includedir}/libnl3
>
>
> That’s not enough, though, to find header files included by other libnl
> headers. Without the setenv snippet above compilation fails with this
> error:
>
> In file included from criu/libnetlink.c:5:0:
> /gnu/store/qyr5m7c21a4myx5421m90yxkxav2qij7-libnl-3.4.0/include/libnl3/netlink/attr.h:15:29: fatal error: netlink/netlink.h: No such file or directory
> compilation terminated.

Could it be that ‘Cflags’ from the .pc file is not honored?

Ludo’.
?