summaryrefslogtreecommitdiffstats
path: root/recipes-core/runx
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@xilinx.com>2019-12-17 17:25:31 -0800
committerBruce Ashfield <bruce.ashfield@gmail.com>2020-03-11 12:20:04 -0400
commit4ff05c1bc7313743b572b116b37c893b69c68971 (patch)
treeec51e913ecae1cf18d512ca8deaca261b371b7be /recipes-core/runx
parent7a8ee8e986ea180f3a4d94d4d83d01c786488d96 (diff)
downloadmeta-virtualization-4ff05c1bc7313743b572b116b37c893b69c68971.tar.gz
runx: introduce xen OCI container recipe
This is the initial version of the runX OCI wrapper to allow Xen based virtual machines to be launched and managed as containers via an OCI interface. In this first version, runx consists of the following components: - runX binary/wrapper (/usr/bin/) - state control wrappers (/usr/share/runX) - runx kernel - initrd Once built and installed these allow the launching of Xen virtual machines in an OCI compliant manner. Dependencies of this recipe include: - kernel: must be a specific version, currently 4.15. This is done as a nested build and not as a multiconfig (by design). - static target busybox: used for the initrd - initrd: constructed from the kernel + busybox The configuration of the system to build the dependencies in the right mode for use in runX is controlled via the DISTRO_FEATURE "vmsep". If this feature is missing, and runx is bitbaked, an error is thrown. Installing the "runx" package to a rootfs will install all the required support components (and dependencies). Signed-off-by: Bruce Ashfield <bruce.ashfield@xilinx.com>
Diffstat (limited to 'recipes-core/runx')
-rw-r--r--recipes-core/runx/runx/0001-make-initrd-cross-install-tweaks.patch42
-rw-r--r--recipes-core/runx/runx/0001-make-kernel-cross-compilation-tweaks.patch86
-rw-r--r--recipes-core/runx/runx_git.bb154
3 files changed, 282 insertions, 0 deletions
diff --git a/recipes-core/runx/runx/0001-make-initrd-cross-install-tweaks.patch b/recipes-core/runx/runx/0001-make-initrd-cross-install-tweaks.patch
new file mode 100644
index 00000000..c9fdc5d6
--- /dev/null
+++ b/recipes-core/runx/runx/0001-make-initrd-cross-install-tweaks.patch
@@ -0,0 +1,42 @@
1From d8bd5749e6fc6e0c86a8720044ec78167bab3569 Mon Sep 17 00:00:00 2001
2From: Bruce Ashfield <bruce.ashfield@xilinx.com>
3Date: Mon, 16 Dec 2019 22:03:14 -0800
4Subject: [PATCH] make-initrd: cross install tweaks
5
6Signed-off-by: Bruce Ashfield <bruce.ashfield@xilinx.com>
7---
8 kernel/make-initrd | 18 ++++++++++++++++--
9 1 file changed, 16 insertions(+), 2 deletions(-)
10
11diff --git a/kernel/make-initrd b/kernel/make-initrd
12index 4c299dc..9ef386f 100755
13--- a/kernel/make-initrd
14+++ b/kernel/make-initrd
15@@ -16,8 +16,22 @@ mkdir -p $tmpdir/sys
16 mkdir -p $tmpdir/lib
17 mkdir -p $tmpdir/var
18 mkdir -p $tmpdir/mnt
19-cp `which busybox` $tmpdir/bin
20-$tmpdir/bin/busybox --install $tmpdir/bin
21+
22+
23+if [ -z "$BUSYBOX" ]; then
24+ BUSYBOX=`which busybox`
25+fi
26+cp $BUSYBOX $tmpdir/bin
27+if [ -n "$CROSS_COMPILE" ]; then
28+ echo "cross compiling, busybox --install emulation"
29+ if [ -n "$QEMU_USER" ]; then
30+ $QEMU_USER $tmpdir/bin/busybox --install $tmpdir/bin
31+ else
32+ echo "QEMU_USER is not defined, no binary symlinks will be available"
33+ fi
34+else
35+ $tmpdir/bin/busybox --install $tmpdir/bin
36+fi
37
38 cp $init $tmpdir/init
39 chmod +x $tmpdir/init
40--
412.17.1
42
diff --git a/recipes-core/runx/runx/0001-make-kernel-cross-compilation-tweaks.patch b/recipes-core/runx/runx/0001-make-kernel-cross-compilation-tweaks.patch
new file mode 100644
index 00000000..7d66f421
--- /dev/null
+++ b/recipes-core/runx/runx/0001-make-kernel-cross-compilation-tweaks.patch
@@ -0,0 +1,86 @@
1From 7e3498ab7c375bd545de501920acffa77eb24120 Mon Sep 17 00:00:00 2001
2From: Bruce Ashfield <bruce.ashfield@xilinx.com>
3Date: Mon, 16 Dec 2019 20:42:04 -0800
4Subject: [PATCH] make-kernel: cross-compilation tweaks
5
6Signed-off-by: Bruce Ashfield <bruce.ashfield@xilinx.com>
7---
8 kernel/make-kernel | 41 +++++++++++++++++++++++++++++++++--------
9 1 file changed, 33 insertions(+), 8 deletions(-)
10
11diff --git a/kernel/make-kernel b/kernel/make-kernel
12index 33b7150..c684669 100755
13--- a/kernel/make-kernel
14+++ b/kernel/make-kernel
15@@ -13,6 +13,7 @@ fi
16
17 kernel_stuffdir=`readlink -f kernel`
18 kernel_outpath=$kernel_stuffdir/out
19+kernel_srcdir=$kernel_stuffdir/src
20 kernel_builddir=$kernel_stuffdir/build
21 kernel_out=$kernel_outpath/kernel
22
23@@ -22,28 +23,52 @@ kernel_tarball="$kernel_name".tar.xz
24 kernel_url=https://www.kernel.org/pub/linux/kernel/v4.x/"$kernel_tarball"
25 kernel_src_config="$kernel_stuffdir"/cutdown-config.$ARCH
26 kernel_patchesdir="$kernel_stuffdir"/patches
27-kernel_image="$kernel_builddir"/"$kernel_name"/arch/"$ARCH"/boot/"$image"
28+kernel_image="$kernel_builddir"/arch/"$ARCH"/boot/"$image"
29
30+echo "#########################"
31+echo "kernel build summary:"
32+echo " version: $kernel_version"
33+echo " url: $kernel_url"
34+echo " src dir: $kernel_srcdir"
35+echo " out dir: $kernel_builddir"
36+echo " artifacts: $kernel_out"
37+echo " image: $image"
38+echo " build vars: $build_vars"
39+echo "#########################"
40
41-rm -rf $kernel_outpath
42+if [ ! -e "$kernel_builddir/.config" ];
43+then
44+ rm -rf $kernel_buildir
45+fi
46 mkdir -p $kernel_outpath
47 mkdir -p $kernel_builddir
48+mkdir -p $kernel_srcdir
49
50 if [[ ! -f $kernel_builddir/$kernel_tarball ]]
51 then
52+ echo "fetching the kernel .."
53 wget -O $kernel_builddir/$kernel_tarball --tries=20 $kernel_url
54 fi
55-if [[ ! -d $kernel_builddir/$kernel_name ]]
56+
57+if [[ ! -d $kernel_srcdir/$kernel_name ]]
58 then
59- tar --extract --xz --touch --file="$kernel_builddir/$kernel_tarball" --directory="$kernel_builddir"
60- cd $kernel_builddir/$kernel_name
61+ echo "extracting the kernel ..."
62+ echo " tar --extract --xz --touch --file=\"$kernel_builddir/$kernel_tarball\" --directory=\"$kernel_srcdir\""
63+ tar --extract --xz --touch --file="$kernel_builddir/$kernel_tarball" --directory="$kernel_srcdir"
64+ cd $kernel_srcdir/$kernel_name
65 for i in $kernel_patchesdir/*
66 do
67 patch -p1 < $i
68 done
69- cp $kernel_src_config .config
70 fi
71-cd $kernel_builddir/$kernel_name
72-make -j4 $image
73+if [[ ! -f $kernel_builddir/.config ]]
74+then
75+ cp $kernel_src_config $kernel_builddir/.config
76+fi
77+cd $kernel_srcdir/$kernel_name
78+
79+echo "building the kernel ..."
80+eval make O=$kernel_builddir $build_vars oldconfig
81+eval make -j4 O=$kernel_builddir $build_vars $image
82
83 cp $kernel_image $kernel_out
84--
852.17.1
86
diff --git a/recipes-core/runx/runx_git.bb b/recipes-core/runx/runx_git.bb
new file mode 100644
index 00000000..36fede67
--- /dev/null
+++ b/recipes-core/runx/runx_git.bb
@@ -0,0 +1,154 @@
1HOMEPAGE = "https://github.com/lf-edge/runx"
2SUMMARY = "runx stuff"
3DESCRIPTION = "Xen Runtime for OCI"
4
5SRCREV_runx = "a6fe5ca3081f44e9085972d424c74707d4f0fc71"
6SRC_URI = "\
7 git://github.com/lf-edge/runx;nobranch=1;name=runx \
8 https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.15.tar.xz;destsuffix=git/kernel/build \
9 file://0001-make-kernel-cross-compilation-tweaks.patch \
10 file://0001-make-initrd-cross-install-tweaks.patch \
11 "
12SRC_URI[md5sum] = "0d701ac1e2a67d47ce7127432df2c32b"
13SRC_URI[sha256sum] = "5a26478906d5005f4f809402e981518d2b8844949199f60c4b6e1f986ca2a769"
14
15LICENSE = "Apache-2.0"
16LIC_FILES_CHKSUM = "file://LICENSE;md5=945fc9aa694796a6337395cc291ddd8c"
17
18S = "${WORKDIR}/git"
19PV = "0.1-git${SRCREV_runx}"
20
21inherit distro_features_check
22REQUIRED_DISTRO_FEATURES = "vmsep"
23
24
25# TODO: for if we need a go shim
26# GO_IMPORT = "import"
27# inherit go
28# inherit goarch
29inherit pkgconfig
30
31# for the kernel build
32inherit kernel-arch
33
34# we have a busybox bbappend that makes /bin available to the
35# sysroot, and hence gets us the target binary that we need
36DEPENDS = "busybox"
37
38# for the kernel build phase
39DEPENDS += "openssl-native coreutils-native util-linux-native xz-native bc-native"
40DEPENDS += "qemu-native"
41
42RDEPENDS_${PN} += " jq bash"
43RDEPENDS_${PN} += " xen-xl"
44
45do_compile() {
46 # we'll need this for the initrd later, so lets error if it isn't what
47 # we expect (statically linked)
48 file ${STAGING_DIR_HOST}/bin/busybox.nosuid
49
50 # prep steps to short circuit some of make-kernel's fetching and
51 # building.
52 mkdir -p ${S}/kernel/build
53 mkdir -p ${S}/kernel/src
54 cp ${DL_DIR}/linux-4.15.tar.xz ${S}/kernel/build/
55
56 # In the future, we might want to link the extracted kernel source (if
57 # we move patches to recipe space, but for now, we need make-kernel to
58 # extract a copy and possibly patch it.
59 # ln -sf ${WORKDIR}/linux-4.15 ${S}/kernel/src/
60
61 # build the kernel
62 echo "[INFO]: runx: building the kernel"
63
64 export KERNEL_CC="${KERNEL_CC}"
65 export KERNEL_LD="${KERNEL_LD}"
66 export ARCH="${ARCH}"
67 export HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"
68 export HOSTCPP="${BUILD_CPP}"
69 export CROSS_COMPILE="${CROSS_COMPILE}"
70 export build_vars="HOSTCC='$HOSTCC' STRIP='$STRIP' OBJCOPY='$OBJCOPY' ARCH=$ARCH CC='$KERNEL_CC' LD='$KERNEL_LD'"
71
72 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
73
74 # We want make-kernel, to have the following build lines:
75 # make O=$kernel_builddir HOSTCC="${HOSTCC}" ARCH=$ARCH oldconfig
76 # make -j4 O=$kernel_builddir HOSTCC="${HOSTCC}" STRIP="$STRIP" OBJCOPY="$OBJCOPY" ARCH=$ARCH CC="$KERNEL_CC" LD="$KERNEL_LD" $image
77 ${S}/kernel/make-kernel
78
79 # construct the initrd
80 echo "[INFO]: runx: constructing the initrd"
81
82 cp ${STAGING_DIR_HOST}/bin/busybox.nosuid ${WORKDIR}/busybox
83 export QEMU_USER=`which qemu-${HOST_ARCH}`
84 export BUSYBOX="${WORKDIR}/busybox"
85 export CROSS_COMPILE="t"
86 ${S}/kernel/make-initrd
87}
88
89do_build_go_shim() {
90
91 # placeholder for any go shim code we may need, i.e. console
92
93 # export GOARCH="${TARGET_GOARCH}"
94 # export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
95 # export GOPATH="${S}/src/import:${S}/src/import/vendor"
96
97 # # Pass the needed cflags/ldflags so that cgo
98 # # can find the needed headers files and libraries
99 # export CGO_ENABLED="1"
100 # export CFLAGS=""
101 # export LDFLAGS=""
102 # export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
103 # export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
104
105 # # link fixups for compilation
106 # rm -f ${S}/src/import/vendor/src
107 # ln -sf ./ ${S}/src/import/vendor/src
108
109 # mkdir -p ${S}/src/import/vendor/github.com/hyperhq/runv
110
111 # ln -sf src/import/cli
112 # ln -sf ../../../../api ${S}/src/import/vendor/github.com/hyperhq/runv/api
113 # ln -sf ../../../../cli ${S}/src/import/vendor/github.com/hyperhq/runv/cli
114 # ln -sf ../../../../lib ${S}/src/import/vendor/github.com/hyperhq/runv/lib
115 # ln -sf ../../../../driverloader ${S}/src/import/vendor/github.com/hyperhq/runv/driverloader
116 # ln -sf ../../../../factory ${S}/src/import/vendor/github.com/hyperhq/runv/factory
117 # ln -sf ../../../../hyperstart ${S}/src/import/vendor/github.com/hyperhq/runv/hyperstart
118 # ln -sf ../../../../hypervisor ${S}/src/import/vendor/github.com/hyperhq/runv/hypervisor
119 # ln -sf ../../../../template ${S}/src/import/vendor/github.com/hyperhq/runv/template
120
121 # export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
122 # export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
123
124 # # Pass the needed cflags/ldflags so that cgo
125 # # can find the needed headers files and libraries
126 # export CGO_ENABLED="1"
127 # export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
128 # export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
129
130 # oe_runmake build-shim
131
132 true
133}
134
135do_install() {
136 install -d ${D}${bindir}
137 install -m 755 ${S}/runX ${D}${bindir}
138
139 install -d ${D}${datadir}/runX
140 install -m 755 ${S}/kernel/out/kernel ${D}/${datadir}/runX
141 install -m 755 ${S}/kernel/out/initrd ${D}/${datadir}/runX
142 install -m 755 ${S}/files/start ${D}/${datadir}/runX
143 install -m 755 ${S}/files/state ${D}/${datadir}/runX
144 install -m 755 ${S}/files/delete ${D}/${datadir}/runX
145
146
147}
148
149deltask compile_ptest_base
150
151FILES_${PN} += "${bindir}/* ${datadir}/runX/*"
152
153INHIBIT_PACKAGE_STRIP = "1"
154INSANE_SKIP_${PN} += "ldflags already-stripped"