summaryrefslogtreecommitdiffstats
path: root/recipes-extended/images
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-extended/images')
-rw-r--r--recipes-extended/images/README-xen.md173
-rw-r--r--recipes-extended/images/README.md311
-rw-r--r--recipes-extended/images/cloud-image-controller.bb2
-rw-r--r--recipes-extended/images/container-app-base.bb17
-rw-r--r--recipes-extended/images/container-base.bb14
-rw-r--r--recipes-extended/images/container-devtools-base.bb51
-rw-r--r--recipes-extended/images/container-image-host.bb129
-rw-r--r--recipes-extended/images/container-systemd-base.bb17
-rw-r--r--recipes-extended/images/container-systemd-base.inc72
-rw-r--r--recipes-extended/images/xen-guest-image-minimal.bb28
-rw-r--r--recipes-extended/images/xen-image-minimal.bb182
-rw-r--r--recipes-extended/images/xtf-image.bb2
12 files changed, 987 insertions, 11 deletions
diff --git a/recipes-extended/images/README-xen.md b/recipes-extended/images/README-xen.md
new file mode 100644
index 00000000..82d72364
--- /dev/null
+++ b/recipes-extended/images/README-xen.md
@@ -0,0 +1,173 @@
1This README contains information on the xen reference images
2and testing / usability information
3
4Images
5------
6
7xen-image-minimal:
8
9This is the reference xen host image. It currently requires systemd
10and xen as DISTRO_FEATURES.
11
12All required dependencies are included for typical execution (and
13debug) of guests.
14
15xen-guest-image-minimal:
16
17This is the reference guest / domU image. Note that it boots the
18same kernel as the xen host image (unless multiconfig is used
19to differentiate).
20
21It creates tarballs, ext4 and qcow images for testing purposes.
22
23bundling
24--------
25
26Guests can be bundled automatically through the following mechanisms:
27
28 - via the variable XEN_BUNDLED_GUESTS
29 - via a xen configuration file in the deploy directory of the format
30 xen-guest-bundle-*.cfg
31
32The guests can be built via OE, or be 3rd party guests. They just
33must be in the deploy directory so they can be copied into the rootfs
34of the xen host image
35
36Type 1) XEN_BUNDLED_GUESTS
37
38If XEN_BUNDLED_GUESTS is used, it is simply a colon separated list of
39rootfs:kernels. Normal variable rules apply, so it can be set in a
40local.conf, or in a bbappend to the image recipe.
41
42An example would be:
43
44 XEN_BUNDLED_GUESTS = "xen-guest-image-minimal-qemuarm64.rootfs.ext4:Image"
45
46These point at symlinks created in the image deploy directory, or they
47can be specific images/kernels without the symlink.
48
49Type 2) A Xen guest configuration file
50
51If xen guest configuration files are found in the deploy directories
52the kernel and disk information contained within them will be processed
53and modified for the xen host. The kernel and guest image will be
54copied to the appropriate location, and the config made to match.
55
56These files following the naming convention: xen-guest-bundle*.cfg
57
58Guests of type #1 generate a configuration file that is picked up as
59type #2.
60
61An example config file follows:
62
63 name = "xen-guest"
64 memory = 512
65 vcpus = 1
66 disk = ['file:xen-guest-image-minimal-qemuarm64.rootfs.ext4,xvda,rw']
67 vif = ['bridge=xenbr0']
68 kernel = "Image"
69 extra = "root=/dev/xvda ro console=hvc0 ip=dhcp"
70
71It should also be noted that when a xen-guest-image-minimal is built
72with the XEN_GUEST_AUTO_BUNDLE varaible set to True, a configuration
73file for type #2 will be generated and the guest bundled automatically
74when the host image is built.
75
76kernel and rootfs are copied to the target in /var/lib/xen/images/
77
78configuration files are copied to: /etc/xen
79
80Guests can be launched after boot with: xl create -c /etc/xen/<config file>
81
82Build and boot
83--------------
84
85Using a reference qmeuarm64 MACHINE, the following are the commands
86to build and boot a guest.
87
88local.conf contains:
89
90 XEN_BUNDLED_GUESTS = "xen-guest-image-minimal-qemuarm64.rootfs.ext4:Image"
91
92 % bitbake xen-guest-image-minimal
93 % bitbake xen-image-minimal
94
95 % runqemu qemuarm64 nographic slirp qemuparams="-m 4096" tmp/deploy/images/qemuarm64/xen-image-minimal-qemuarm64.rootfs.ext4
96
97Poky (Yocto Project Reference Distro) 5.1 qemuarm64 hvc0
98
99qemuarm64 login: root
100
101WARNING: Poky is a reference Yocto Project distribution that should be used for
102testing and development purposes only. It is recommended that you create your
103own distribution for production use.
104
105 root@qemuarm64:~# uname -a
106Linux qemuarm64 6.10.11-yocto-standard #1 SMP PREEMPT Fri Sep 20 22:32:26 UTC 2024 aarch64 GNU/Linux
107root@qemuarm64:~# ls /etc/xen/
108auto
109cpupool
110scripts
111xen-guest-bundle-xen-guest-image-minimal-qemuarm64--20241112174803.cfg
112xl.conf
113root@qemuarm64:~# ls /var/lib/xen/images/
114Image--6.10.11+git0+4bf82718cf_6c956b2ea6-r0-qemuarm64-20241018190311.bin
115xen-guest-image-minimal-qemuarm64.rootfs-20241111222814.ext4
116
117 root@qemuarm64:~# ip a s
1181: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
119 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
120 inet 127.0.0.1/8 scope host lo
121 valid_lft forever preferred_lft forever
122 inet6 ::1/128 scope host noprefixroute
123 valid_lft forever preferred_lft forever
1242: enp0s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master xenbr0 qlen 1000
125 link/ether 52:54:00:12:35:02 brd ff:ff:ff:ff:ff:ff
1263: sit0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
127 link/sit 0.0.0.0 brd 0.0.0.0
1284: xenbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue qlen 1000
129 link/ether ee:e4:a8:24:24:e7 brd ff:ff:ff:ff:ff:ff
130 inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic xenbr0
131 valid_lft 86354sec preferred_lft 86354sec
132 inet6 fec0::ece4:a8ff:fe24:24e7/64 scope site dynamic noprefixroute flags 100
133 valid_lft 86356sec preferred_lft 14356sec
134 inet6 fe80::ece4:a8ff:fe24:24e7/64 scope link
135 valid_lft forever preferred_lft forever
136
137 root@qemuarm64:~# xl create -c /etc/xen/xen-guest-bundle-xen-guest-image-minimal-qemuarm64--20241112174803.cfg
138
139qemuarm64 login: root
140
141WARNING: Poky is a reference Yocto Project distribution that should be used for
142testing and development purposes only. It is recommended that you create your
143own distribution for production use.
144
145root@qemuarm64:~# uname -a
146Linux qemuarm64 6.10.11-yocto-standard #1 SMP PREEMPT Fri Sep 20 22:32:26 UTC 2024 aarch64 GNU/Linux
147
148root@qemuarm64:~# wget example.com
149Connecting to example.com (93.184.215.14:80)
150wget: can't open 'index.html': File exists
151root@qemuarm64:~# rm index.html
152root@qemuarm64:~# wget example.com
153Connecting to example.com (93.184.215.14:80)
154saving to 'index.html'
155index.html 100% |********************************| 1256 0:00:00 ETA
156'index.html' saved
157
158From the host:
159
160Connection to 127.0.0.1 closed.
161build4 [/home/bruc.../qemuarm64]> ssh -p 2222 root@127.0.0.1
162Last login: Tue Nov 12 20:42:57 2024 from 10.0.2.2
163
164WARNING: Poky is a reference Yocto Project distribution that should be used for
165testing and development purposes only. It is recommended that you create your
166own distribution for production use.
167
168root@qemuarm64:~# xl list
169Name ID Mem VCPUs State Time(s)
170Domain-0 0 192 4 r----- 696.2
171xen-guest 1 512 1 -b---- 153.0
172root@qemuarm64:~# xl destroy xen-guest
173
diff --git a/recipes-extended/images/README.md b/recipes-extended/images/README.md
new file mode 100644
index 00000000..1a25f724
--- /dev/null
+++ b/recipes-extended/images/README.md
@@ -0,0 +1,311 @@
1This README describes the contents of the reference images in
2this directory, as well as some testing and usability tips.
3
4container-image-host
5--------------------
6
7As described in the recipe, this is a flexible image definition that
8is suitable for building a container host image for a target.
9
10The configuration options for the image are best found in the recipe
11itself, so the information will not be duplicated here. The type of
12container host that will be created is controlled by the CONTAINER_PROFILE
13variable:
14
15i.e. in your local.conf: CONTAINER_PROFILE="docker"
16
17The valid settings for this variable can be found in the image recipe.
18
19The recipe checks for mandatory distro features, recommends others
20and provides a list of optional distro features for some workloads.
21
22This image also builds using virt-unique-hostname, which ensures that
23there is some randomization as hostname is often used to identify
24hosts when clustered (i.e. k3s).
25
26To have enough disk space for container images, it is configured
27with extra space. Depending on your use case, you can add (or remove)
28space as appropriate.
29
30Also note that more memory than the default is often required.
31
32An example execution of the image is:
33
34 % runqemu qemuarm64 nographic slirp qemuparams="-m 2048" tmp/deploy/images/qemuarm64/container-image-host-qemuarm64.rootfs.ext4
35
36ssh is enabled in this image by default, so the image can be accessed
37via:
38
39 % ssh -p 2222 root@127.0.0.1
40
41After a container image has been built, it can be copied fro the
42deploy directory to the registry of your choice, for example:
43
44 % cd build/tmp/deploy/images/qemuarm64
45 % skopeo copy --dest-creds <username>:<creds> oci:c3-systemd-container-latest-oci:latest docker://zeddii/c3-systemd-container
46
47Examples of pulling images to the container host for the various
48runtimes follow:
49
50 % podman pull --creds <username>:<password> zeddii/container-devtools
51 % podman run -it docker.io/zeddii/container-devtools bash
52
53 % root@qemuarm64-54:~# docker login
54 # Login Succeeded
55 % root@qemuarm64-54:~# docker pull zeddii/container-devtools
56
57 % root@qemuarm64-54:~# docker run -it --entrypoint /bin/sh zeddii/container-base
58 # [ 804.133881] docker0: port 1(veth2801d6a) entered blocking state
59 # [ 804.134425] docker0: port 1(veth2801d6a) entered disabled state
60 # [ 804.135018] veth2801d6a: entered allmulticast mode
61 # [ 804.136101] veth2801d6a: entered promiscuous mode
62 # [ 806.227282] eth0: renamed from veth384b37d
63 # [ 806.235331] docker0: port 1(veth2801d6a) entered blocking state
64 # [ 806.236010] docker0: port 1(veth2801d6a) entered forwarding state
65 # / # ls
66 # bin boot dev etc home lib media mnt proc run sbin sys tmp usr var
67
68container-base:
69---------------
70
71Provides a minimal container image (but not absolutely smallest) that is
72inherited / included by the other container images.
73
74By default container base does not execute anything (it doesn't define
75and OCI_IMAGE_ENTRYPOINT), but does provide a shell that can be used
76to inspect the image.
77
78 % root@qemuarm64-54:~# docker run -it zeddii/container-base sh
79 [51393.764879] docker0: port 1(veth06cb397) entered blocking state
80 [51393.765340] docker0: port 1(veth06cb397) entered disabled state
81 [51393.765854] veth06cb397: entered allmulticast mode
82 [51393.766753] veth06cb397: entered promiscuous mode
83 [51396.060958] eth0: renamed from veth7e5a654
84 [51396.074281] docker0: port 1(veth06cb397) entered blocking state
85 [51396.074786] docker0: port 1(veth06cb397) entered forwarding state
86 / # ls
87 bin boot dev etc home lib media mnt proc run sbin sys tmp usr var
88 / # df -kh .
89 Filesystem Size Used Available Use% Mounted on
90 overlay 37.8G 1.9G 33.8G 5% /
91 / # du -sh .
92 2.6M .
93 / #
94
95 % root@qemuarm64-54:~# ctr images pull --user <user>:<password> docker.io/zeddii/container-base:latest
96 docker.io/zeddii/container base:latest saved
97 └──manifest (45395e734a93) complete |++++++++++++++++++++++++++++++++++++++|
98 ├──layer (1fd5069cdbad) waiting |--------------------------------------|
99 └──config (24b67db5b19e) waiting |--------------------------------------|
100 application/vnd.oci.image.manifest.v1+json sha256:45395e734a931468f5329d20d20babf13fbabbcd993e27b0e5c4198d09130966
101 Pulling from OCI Registry (docker.io/zeddii/container-base:latest) elapsed: 3.7 s total: 463.0 (123.0 B/s)
102
103 % root@qemuarm64-54:~# ctr run --rm -t docker.io/zeddii/container-base:latest zedd_shell sh
104 / # date
105 Tue Oct 29 00:09:19 UTC 2024
106 / #
107
108 % root@qemuarm64-54:~# nerdctl pull docker.io/zeddii/container-base:latest
109 docker.io/zeddii/container-base:latest: resolved |++++++++++++++++++++++++++++++++++++++|
110 docker.io/zeddii/container-base:latest: resolved |++++++++++++++++++++++++++++++++++++++|
111 manifest-sha256:45395e734a931468f5329d20d20babf13fbabbcd993e27b0e5c4198d09130966: exists |++++++++++++++++++++++++++++++++++++++|
112 config-sha256:24b67db5b19e0bb90291f1d5619362c7eaade7a8c65da9a32c2016394a5b57bf: exists |++++++++++++++++++++++++++++++++++++++|
113 elapsed: 1.2 s total: 0.0 B (0.0 B/s)
114
115 # FIXME: At the time of creating this README, bridge networking and CNI is not working.
116 % root@qemuarm64-54:~# nerdctl run -it --net=host docker.io/zeddii/container-base:latest sh
117 / #
118
119container-devtools-base:
120-------------------------
121
122includes container-base, and adds image features to make development
123tools/headers available.
124
125Anything added to CORE_DEV_IMAGE_EXTRA_INSTALL will be installed into
126the image in it's development variant.
127
128The container shell is changed to bash from busybox.
129
130package-management is added to this image type, but by default there
131is no package feed configured (since it must be pointed at a build)
132
133 % root@qemuarm64-54:~# docker run -it zeddii/container-devtools bash
134 bash-5.2# du -sh .
135 399M .
136 bash-5.2# rpm -qa | wc -l
137 308
138 bash-5.2# gcc --version
139 gcc (GCC) 14.2.0
140 Copyright (C) 2024 Free Software Foundation, Inc.
141 This is free software; see the source for copying conditions. There is NO
142 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
143
144By default this container has (for rpm) package management configured
145to point to a feed being run against the local build on the host machine
146
147To create a package feed:
148
149 % bitbake package-index
150
151To add a package to the package-index (example: vim-tiny)
152
153 % bitbake vim-tiny
154 % bitbake vim-tiny --runall package_write_rpm
155 % bitbake package-index
156
157To run a local http server for the package feed:
158
159 % cd build/tmp/deploy
160 % sudo python3 -m http.server 80
161
162Run the dev container:
163
164 % docker run -it zeddii/container-devtools bash
165 % dnf makecache
166 % dnf --nogpgcheck install vim-tiny
167
168container-app-base:
169--------------------
170
171Includes container-base.
172
173Provides an application container that installs a package (or packages) to
174the container and make the specified command the OCI_IMAGE_ENTRYPOINT.
175
176 CONTAINER_APP_CMD : the binary to run via the OCI_IMAGE_ENTRYPOINT
177 CONATINER_APP: packages to install to the container
178
179The default entry point is the "date" command.
180
181 % root@qemuarm64-54:~# docker run zeddii/container-app-base
182 Mon Oct 28 18:41:23 UTC 2024
183
184 % root@qemuarm64-54:~# docker run --entrypoint "du" zeddii/container-app-base -sh
185 2.6M .
186
187 % podman run docker.io/zeddii/container-app-base
188 Mon Oct 28 18:41:23 UTC 2024
189
190container-systemd-base:
191------------------------
192
193Extends container-base to create a systemd enabled container that is
194an appropriate starting point if a systemd applciation is being run
195or a mulit-user style environment is required.
196
197The application specified in SYSTEMD_CONTAINER_APP will be installed
198and be available to be executed.
199
200The rootfs of this container type is post processed to enable and
201disable services as specified by the containeer definition. This allows
202service that are not appropriate in a containerized environemnt to
203be disabled (i.e. getty login)
204
205The list of services can be found in the recipes themselves.
206
207This container enables ssh by default, so that it can be executed
208in the background and then accessed as a full environment.
209
210Note: this is currently a priviledged container if run under docker.
211
212There are multiple ways to add/remove permissions from the container,
213and most are configurable during launch:
214
215 % root@qemuarm64-54:~# docker run -d --rm --name systemd_test --privileged --cap-add SYS_ADMIN \
216 --security-opt seccomp=unconfined --cgroup-parent=docker.slice --cgroupns private \
217 --tmpfs /tmp --tmpfs /run --tmpfs /run/lock zeddii/systemd-container-base
218
219or
220
221 % docker run -d --rm --name systemd_test --privileged --cgroup-parent=docker.slice \
222 --cgroupns private zeddii/c3-systemd-container
223
224 % root@qemuarm64-54:~# docker ps
225 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
226 4b07cc907e26 zeddii/c3-systemd-container "/sbin/init" 5 minutes ago Up 5 minutes systemd_test
227
228 % podman run -d --name systemd_test --privileged --cgroupns=host --tmpfs /tmp --tmpfs /run --tmpfs /run/lock \
229 -v /sys/fs/cgroup:/sys/fs/cgroup:ro zeddii/systemd-container-base
230
231 % ctr container create --privileged --runtime="io.containerd.runc.v2" \
232 --mount type=bind,src=/sys/fs/cgroup,dst=/sys/fs/cgroup,options=rbind:rw \
233 docker.io/zeddii/systemd-container-base:latest my_systemd_container /sbin/init
234
235 % ctr task start --detach my_systemd_container
236
237 % ctr task ls
238 TASK PID STATUS
239 my_systemd_container 690 RUNNING
240
241Then add a user to the container so you can login:
242
243 % root@qemuarm64-54:~# docker exec systemd_test useradd testuser
244 % root@qemuarm64-54:~# docker exec systemd_test sh -c "echo 'testuser:password' | chpasswd"
245
246 % podman exec systemd_test useradd testuser
247 % podman exec systemd_test sh -c "echo 'testuser:password' | chpasswd"
248
249 % ctr task exec --exec-id test_exec my_systemd_container useradd testuser
250 % ctr task exec --exec-id test_exec my_systemd_container sh -c "echo 'testuser:password' | chpasswd"
251 % ctr task exec -t --exec-id test_exec my_systemd_container bash
252
253Get the IP address:
254
255 % root@qemuarm64-54:~# docker inspect systemd_test | grep \"IPAddress\":
256 "IPAddress": "172.17.0.2",
257 "IPAddress": "172.17.0.2",
258
259 % root@qemuarm64-54:~# podman inspect 2f9e00c53c13 | grep IPAdd
260 "IPAddress": "10.88.0.5",
261 "IPAddress": "10.88.0.5",
262
263ssh into the container:
264
265 % root@qemuarm64-54:~# ssh testuser@172.17.0.2
266 % testuser@172.17.0.2's password:
267
268 WARNING: Poky is a reference Yocto Project distribution that should be used for
269 testing and development purposes only. It is recommended that you create your
270 own distribution for production use.
271
272 4b07cc907e26:~$ systemctl | grep running
273 init.scope loaded active running System and Service Manager
274 session-c1.scope loaded active running Session c1 of User testuser
275 dbus.service loaded active running D-Bus System Message Bus
276 dhcpcd.service loaded active running A minimalistic network configuration daemon with DHCPv4, rdisc and DHCPv6 support
277 getty@tty1.service loaded active running Getty on tty1
278 sshd@2-172.17.0.2:22-172.17.0.1:39264.service loaded active running OpenSSH Per-Connection Daemon (172.17.0.1:39264)
279 systemd-journald.service loaded active running Journal Service
280 systemd-logind.service loaded active running User Login Management
281 systemd-networkd.service loaded active running Network Configuration
282 systemd-nsresourced.service loaded active running Namespace Resource Manager
283 systemd-resolved.service loaded active running Network Name Resolution
284 systemd-userdbd.service loaded active running User Database Manager
285 user@1000.service loaded active running User Manager for UID 1000
286 xinetd.service loaded active running Xinetd A Powerful Replacement For Inetd
287 dbus.socket loaded active running D-Bus System Message Bus Socket
288 systemd-journald-dev-log.socket loaded active running Journal Socket (/dev/log)
289 systemd-journald.socket loaded active running Journal Sockets
290 systemd-networkd.socket loaded active running Network Service Netlink Socket
291 systemd-nsresourced.socket loaded active running Namespace Resource Manager Socket
292 systemd-userdbd.socket loaded active running User Database Manager Socket
293
294
295 % root@qemuarm64-54:~# ssh testuser@10.88.0.5
296 The authenticity of host '10.88.0.5 (10.88.0.5)' can't be established.
297 ECDSA key fingerprint is SHA256:ydCJGSVNLdWiAcC5PUkDsiFZZ6sDTeQ9Nt13a6HQCc4.
298 This key is not known by any other names.
299 Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
300 Warning: Permanently added '10.88.0.5' (ECDSA) to the list of known hosts.
301 testuser@10.88.0.5's password:
302
303 WARNING: Poky is a reference Yocto Project distribution that should be used for
304 testing and development purposes only. It is recommended that you create your
305 own distribution for production use.
306
307 2f9e00c53c13:~$
308
309Enjoy!
310
311
diff --git a/recipes-extended/images/cloud-image-controller.bb b/recipes-extended/images/cloud-image-controller.bb
index c816545f..b192db90 100644
--- a/recipes-extended/images/cloud-image-controller.bb
+++ b/recipes-extended/images/cloud-image-controller.bb
@@ -29,4 +29,4 @@ inherit core-image
29IMAGE_FSTYPES = "wic.vmdk tar.gz" 29IMAGE_FSTYPES = "wic.vmdk tar.gz"
30 30
31# Ensure extra space for guest images 31# Ensure extra space for guest images
32#IMAGE_ROOTFS_EXTRA_SPACE = "41943040" 32#IMAGE_ROOTFS_EXTRA_SPACE = "2000000"
diff --git a/recipes-extended/images/container-app-base.bb b/recipes-extended/images/container-app-base.bb
new file mode 100644
index 00000000..34381ed2
--- /dev/null
+++ b/recipes-extended/images/container-app-base.bb
@@ -0,0 +1,17 @@
1SUMMARY = "Basic Application container image"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4
5include container-base.bb
6
7# CONTAINER_APP_CMD is the executable to run as the entrypoint of the
8# container. What we have below is a placholder. if you run this
9# container, you'll get the date echo'd
10CONTAINER_APP_CMD ?= "date"
11
12# The container app is the package(s) to install into the container.
13# They must provide the command specified in CONTAINER_APP_CMD
14CONTAINER_APP ?= ""
15
16OCI_IMAGE_ENTRYPOINT = "${CONTAINER_APP_CMD}"
17IMAGE_INSTALL:append = " ${CONTAINER_APP}"
diff --git a/recipes-extended/images/container-base.bb b/recipes-extended/images/container-base.bb
index c9dd32d1..64655e0b 100644
--- a/recipes-extended/images/container-base.bb
+++ b/recipes-extended/images/container-base.bb
@@ -7,6 +7,7 @@ LICENSE = "MIT"
7LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 7LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
8 8
9IMAGE_FSTYPES = "container oci" 9IMAGE_FSTYPES = "container oci"
10
10inherit image 11inherit image
11inherit image-oci 12inherit image-oci
12 13
@@ -21,6 +22,10 @@ IMAGE_INSTALL = " \
21 ${CONTAINER_SHELL} \ 22 ${CONTAINER_SHELL} \
22" 23"
23 24
25# Keep the entrypoint empty so that this image can be easily be
26# inherted and re-used for interactive or non interactive images
27OCI_IMAGE_ENTRYPOINT ?= ""
28
24# If the following is configured in local.conf (or the distro): 29# If the following is configured in local.conf (or the distro):
25# PACKAGE_EXTRA_ARCHS:append = " container-dummy-provides" 30# PACKAGE_EXTRA_ARCHS:append = " container-dummy-provides"
26# 31#
@@ -36,7 +41,16 @@ CONTAINER_SHELL ?= "${@bb.utils.contains('PACKAGE_EXTRA_ARCHS', 'container-dummy
36IMAGE_CONTAINER_NO_DUMMY = "1" 41IMAGE_CONTAINER_NO_DUMMY = "1"
37 42
38# Workaround /var/volatile for now 43# Workaround /var/volatile for now
44# This is required because the lack of post-install scripts means volatile
45# directories (/var/volatile/*, etc.) are not created, so we do that ourselves
46# in a minimal way below. We could bootstrap and run some of the more standard
47# scripts that do it at boot, but we avoid that until needed.
39ROOTFS_POSTPROCESS_COMMAND += "rootfs_fixup_var_volatile ; " 48ROOTFS_POSTPROCESS_COMMAND += "rootfs_fixup_var_volatile ; "
49
50# This :remove is required, because it comes along and deletes our /var/volatile/
51# fixups!
52ROOTFS_POSTPROCESS_COMMAND:remove = "empty_var_volatile"
53
40rootfs_fixup_var_volatile () { 54rootfs_fixup_var_volatile () {
41 install -m 1777 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/tmp 55 install -m 1777 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/tmp
42 install -m 755 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/log 56 install -m 755 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/log
diff --git a/recipes-extended/images/container-devtools-base.bb b/recipes-extended/images/container-devtools-base.bb
new file mode 100644
index 00000000..63d40ab7
--- /dev/null
+++ b/recipes-extended/images/container-devtools-base.bb
@@ -0,0 +1,51 @@
1SUMMARY = "Basic container image with development tools"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4
5CONTAINER_SHELL = "bash"
6
7CORE_DEV_IMAGE_EXTRA_INSTALL ?= ""
8
9include container-base.bb
10inherit core-image
11
12CORE_DEV_IMAGE_EDITOR ?= "vim-tiny"
13# base-utils is required for post-install scriptlets in most packages,
14# coreutils or busybox can do the job
15CORE_DEV_IMAGE_CORE_UTILS ?= "${VIRTUAL-RUNTIME_base-utils}"
16
17IMAGE_INSTALL += " \
18 ${CORE_DEV_IMAGE_EXTRA_INSTALL} \
19 ${CORE_DEV_IMAGE_CORE_UTILS} \
20 ${CORE_DEV_IMAGE_EDITOR} \
21 "
22
23OCI_IMAGE_ENTRYPOINT = ""
24
25# development headers, tools and package management to update
26# the container.
27IMAGE_FEATURES += "dev-pkgs"
28IMAGE_FEATURES += "tools-sdk"
29IMAGE_FEATURES += "package-management"
30
31# This default configuration of 10.0.2.2 is configured
32# to contact a web server running against a bitbaked
33# package-index
34#
35# % cd build/tmp/deploy
36# % sudo python3 -m http.server 80
37#
38DEVTOOLS_BASE_PKG_FEED_URL ?= "http://10.0.2.2/rpm"
39
40
41# TODO: support more than rpm
42ROOTFS_POSTPROCESS_COMMAND += "rootfs_pkg_feed_config ; "
43rootfs_pkg_feed_config () {
44 if [ "${IMAGE_PKGTYPE}" = "rpm" ]; then
45 install -m 755 -d ${IMAGE_ROOTFS}/${sysconfdir}/yum.repos.d
46cat <<EOF >>${IMAGE_ROOTFS}/${sysconfdir}/yum.repos.d/oe-packages.repo
47[oe-packages]
48baseurl="${DEVTOOLS_BASE_PKG_FEED_URL}"
49EOF
50 fi
51}
diff --git a/recipes-extended/images/container-image-host.bb b/recipes-extended/images/container-image-host.bb
new file mode 100644
index 00000000..d63ef51e
--- /dev/null
+++ b/recipes-extended/images/container-image-host.bb
@@ -0,0 +1,129 @@
1DESCRIPTION = "A configurable container host image"
2LICENSE = "MIT"
3
4# This image is a reference implementation to create a target platform
5# capable of running containers. This includes kernel configuration,
6# container runtimes, tools and other support applications.
7#
8# The wpackages to install are largely described in the packagegroups
9# that are part of this layer. packagegroups are preferred as they can
10# easily be used to create similar images of different composition.
11# The recipes for the packages have their list of build and runtime
12# dependencies, as such, those dependencies are not part of the image
13# install or listed explicitly in the packgroups.
14#
15# CNCF areas that have choices are described by VIRTUAL-RUNTIME
16# variables. These variables can be set individually (in a distro,
17# layer or local configuration file), or can be set by the setting of
18# a "CONTAINER_PROFILE". It is possible to select incompatible
19# packages if setting the VIRTUAL-RUNTIME variables individually.
20# container profiles have been created as valid / tested stacks of the
21# components in meta-virtualization.
22#
23# The contents of the image are selected by testing the VIRTUAL-RUNTIME
24# values and mapping them to packagegroups.
25#
26# The possible VIRTUAL-RUNTIME variables (and their values) are
27# currently:
28#
29## engines: docker/docker-moby, virtual-containerd, cri-o, podman, lxc
30## VIRTUAL-RUNTIME_container_engine ??= "podman"
31## runtime: runc, crun, runv, runx
32## VIRTUAL-RUNTIME_container_runtime ??= "virtual-runc"
33## networking: cni, netavark
34## VIRTUAL-RUNTIME_container_networking ??= "cni"
35## dns: cni, aardvark-dns
36## VIRTUAL-RUNTIME_container_dns ??= "cni"
37## orchestration: k8s, k3s
38## VIRTUAL-RUNTIME_container_orchestration ??= "k3s"
39## Kubernetes terminology "components"
40## VIRTUAL-RUNTIME_cri ??= "virtual-containerd"
41## VIRTUAL-RUNTIME_cni ??= "cni"
42#
43# To select a CONTAINER_PROFILE, set the variable in your local,
44# distro or layer configuration:
45#
46# CONTAINER_PROFILE="<your value>"
47#
48# The possible values for CONTAINER_PROFILE can be found in
49# conf/distro/include in the format of: meta-virt-container-<profile>.inc
50#
51## default (docker)
52## containerd
53## podman
54## docker
55## k3s-host
56## k3s-node
57
58inherit features_check
59
60# minimum features tested to have a working container host
61# image. These will be enforced by the features_check inherit
62REQUIRED_DISTRO_FEATURES ?= " virtualization \
63 systemd \
64 seccomp \
65 "
66
67# features that are typically enabled. Note, these are not
68# enforced, but maybe added to the required distro feature
69# definition in the future.
70RECOMMENDED_DISTRO_FEATURES ?= " pam \
71 usrmerge \
72 "
73# features that are enabled for specific wworkloads. These
74# are not enforced, except for specific configurations.
75OPTIONAL_DISTRO_FEATURES ?= " vmsep \
76 k3s \
77 k8s \
78 "
79
80REQUIRED_DISTRO_FEATURES:append = " ${@bb.utils.contains('VIRTUAL-RUNTIME_container_orchestration','k3s-node','k3s','',d)}"
81REQUIRED_DISTRO_FEATURES:append = " ${@bb.utils.contains('VIRTUAL-RUNTIME_container_orchestration','k3s-host','k3s','',d)}"
82
83# If the image is going to be placed into a cluster, we need some randomization
84# of the host name to make it unique
85IMAGE_FEATURES[validitems] += "virt-unique-hostname"
86IMAGE_FEATURES[validitems] += "container-tools"
87
88IMAGE_FEATURES += "ssh-server-openssh"
89IMAGE_FEATURES += "package-management"
90IMAGE_FEATURES += "virt-unique-hostname"
91# This may be automatically enabled in the future via a toold or debug flag
92# IMAGE_FEATURES += "container-tools"
93
94IMAGE_LINGUAS = " "
95
96# additional packages to install
97CONTAINER_IMAGE_HOST_EXTRA_INSTALL ?= ""
98
99# values can be: "all", "split" or ""
100CONTAINER_IMAGE_KERNEL_MODULES ?= "all"
101
102# These could be done via a mapping to allow a single selection line
103# per type of virtul runtime, but right now the format of the
104# virtual-runtime to packagegroup name is not mandated, so we keep
105# them separate to allow the mapping in the individual items.
106IMAGE_INSTALL = " \
107 packagegroup-core-boot \
108 packagegroup-oci \
109 container-host-config \
110 ${@bb.utils.contains('CONTAINER_IMAGE_KERNEL_MODULES','split','','kernel-modules',d)} \
111 ${@bb.utils.contains_any('VIRTUAL-RUNTIME_container_engine','docker docker-moby','packagegroup-docker','',d)} \
112 ${@bb.utils.contains_any('VIRTUAL-RUNTIME_container_engine','podman','packagegroup-podman','',d)} \
113 ${@bb.utils.contains_any('VIRTUAL-RUNTIME_container_engine','containerd','packagegroup-containerd','',d)} \
114 ${@bb.utils.contains('VIRTUAL-RUNTIME_container_networking','cni','packagegroup-cni','',d)} \
115 ${@bb.utils.contains('VIRTUAL-RUNTIME_container_networking','netavark','packagegroup-netavark','',d)} \
116 ${@bb.utils.contains('IMAGE_FEATURES','container-tools','packagegroup-container-tools','',d)} \
117 ${@bb.utils.contains('VIRTUAL-RUNTIME_container_orchestration','k3s-host','packagegroup-k3s-host','',d)} \
118 ${@bb.utils.contains('VIRTUAL-RUNTIME_container_orchestration','k3s-node','packagegroup-k3s-node','',d)} \
119 ${CONTAINER_IMAGE_HOST_EXTRA_INSTALL} \
120 "
121
122# inherit the basics of a booting image
123inherit core-image
124
125IMAGE_ROOTFS_SIZE = "8192"
126
127# we always need extra space to install container images
128# 2GB
129IMAGE_ROOTFS_EXTRA_SPACE = "2000000"
diff --git a/recipes-extended/images/container-systemd-base.bb b/recipes-extended/images/container-systemd-base.bb
new file mode 100644
index 00000000..96ef4667
--- /dev/null
+++ b/recipes-extended/images/container-systemd-base.bb
@@ -0,0 +1,17 @@
1SUMMARY = "Systemd system container for ${SYSTEMD_CONTAINER_APP}"
2DESCRIPTION = "A small systemd system container which will run \
3 ${SYSTEMD_CONTAINER_APP}."
4
5SYSTEMD_CONTAINER_APP ?= ""
6
7# Use local.conf to specify the application(s) to install
8IMAGE_INSTALL += "${SYSTEMD_CONTAINER_APP}"
9
10# Use local.conf to specify additional systemd services to disable. To overwrite
11# the default list use SERVICES_TO_DISABLE:pn-systemd-container in local.conf
12SERVICES_TO_DISABLE:append = " ${SYSTEMD_CONTAINER_DISABLE_SERVICES}"
13
14# Use local.conf to enable systemd services
15SERVICES_TO_ENABLE += "${SYSTEMD_CONTAINER_ENABLE_SERVICES}"
16
17require container-systemd-base.inc
diff --git a/recipes-extended/images/container-systemd-base.inc b/recipes-extended/images/container-systemd-base.inc
new file mode 100644
index 00000000..0b856e83
--- /dev/null
+++ b/recipes-extended/images/container-systemd-base.inc
@@ -0,0 +1,72 @@
1SUMMARY ?= "Sample systemd system container"
2DESCRIPTION ?= "A small systemd system container which will run \
3 the application defined in IMAGE_INSTALL."
4
5LICENSE ?= "MIT"
6LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
7
8# Some commands of interest:
9# % docker run -d --rm --name systemd_test --privileged \
10# --cap-add SYS_ADMIN --security-opt seccomp=unconfined --cgroup-parent=docker.slice \
11# --cgroupns private --tmpfs /tmp --tmpfs /run --tmpfs /run/lock zeddii/systemd-container-base
12#
13# % docker run -d --rm --name systemd_test --privileged \
14# --cgroup-parent=docker.slice --cgroupns private zeddii/c3-systemd-container
15#
16# % docker inspect systemd_test
17# % docker inspect systemd_test | grep \"IPAddress\":
18# % docker exec systemd_test bash -c "echo 'testuser:password' | chpasswd"
19# % ssh testuser@172.17.0.2
20
21require container-base.bb
22
23OCI_IMAGE_ENTRYPOINT = "/sbin/init"
24
25IMAGE_INSTALL:append = " systemd"
26IMAGE_INSTALL:append = " packagegroup-core-base-utils"
27IMAGE_INSTALL:append = " packagegroup-core-ssh-openssh"
28IMAGE_INSTALL:append = " busybox"
29
30IMAGE_FEATURES ?= ""
31
32NO_RECOMMENDATIONS = "1"
33
34SERVICES_TO_DISABLE ?= " \
35 systemd-udevd.service \
36 systemd-udevd-control.socket \
37 systemd-udevd-kernel.socket \
38 proc-sys-fs-binfmt_misc.automount \
39 sys-fs-fuse-connections.mount \
40 sys-kernel-debug.mount \
41 systemd-hwdb-update.service \
42 serial-getty@ttyS0.service \
43 dev-ttyS0.device \
44 console-getty.service \
45 serial-getty@.service \
46"
47
48SERVICES_TO_ENABLE ?= ""
49
50disable_systemd_services () {
51 SERVICES_TO_DISABLE="${SERVICES_TO_DISABLE}"
52 if [ -n "$SERVICES_TO_DISABLE" ]; then
53 echo "Disabling systemd services:"
54 for service in $SERVICES_TO_DISABLE; do
55 echo " $service"
56 systemctl --root="${IMAGE_ROOTFS}" mask $service > /dev/null >1
57 done
58 fi
59}
60
61enable_systemd_services () {
62 SERVICES_TO_ENABLE="${SERVICES_TO_ENABLE}"
63 if [ -n "$SERVICES_TO_ENABLE" ]; then
64 echo "Enabling additional systemd services:"
65 for service in $SERVICES_TO_ENABLE; do
66 echo " $service"
67 systemctl --root="${IMAGE_ROOTFS}" enable $service > /dev/null >1
68 done
69 fi
70}
71
72ROOTFS_POSTPROCESS_COMMAND += "disable_systemd_services; enable_systemd_services;"
diff --git a/recipes-extended/images/xen-guest-image-minimal.bb b/recipes-extended/images/xen-guest-image-minimal.bb
index fced7639..76f320e4 100644
--- a/recipes-extended/images/xen-guest-image-minimal.bb
+++ b/recipes-extended/images/xen-guest-image-minimal.bb
@@ -1,6 +1,7 @@
1DESCRIPTION = "A Xen guest image." 1DESCRIPTION = "A Xen guest image."
2 2
3inherit core-image features_check 3inherit core-image features_check deploy
4inherit kernel-artifact-names
4 5
5IMAGE_INSTALL += " \ 6IMAGE_INSTALL += " \
6 packagegroup-core-boot \ 7 packagegroup-core-boot \
@@ -23,3 +24,28 @@ LICENSE = "MIT"
23 24
24# Send console messages to xen console 25# Send console messages to xen console
25APPEND += "console=hvc0" 26APPEND += "console=hvc0"
27
28IMAGE_FSTYPES = "tar.bz2 ext4 ext4.qcow2"
29
30XEN_GUEST_AUTO_BUNDLE ?= ""
31
32# When a xen-guest-image-minimal is built with the
33# XEN_GUEST_AUTO_BUNDLE varaible set to True, a configuration file for
34# automatic guest bundling will be generated and the guest bundled
35# automatically when a xen host image is built.
36do_deploy() {
37 if [ -n "${XEN_GUEST_AUTO_BUNDLE}" ]; then
38 outname="xen-guest-bundle-${IMAGE_BASENAME}${IMAGE_MACHINE_SUFFIX}-${IMAGE_VERSION_SUFFIX}.cfg"
39cat <<EOF >>${DEPLOYDIR}/$outname
40name = "xen-guest"
41memory = 512
42vcpus = 1
43disk = ['file:${IMAGE_LINK_NAME}.ext4,xvda,rw']
44vif = ['bridge=xenbr0']
45kernel = "${KERNEL_IMAGETYPE}"
46extra = "root=/dev/xvda ro ip=dhcp"
47EOF
48 fi
49}
50
51addtask deploy after do_compile
diff --git a/recipes-extended/images/xen-image-minimal.bb b/recipes-extended/images/xen-image-minimal.bb
index fe79a485..6da797d7 100644
--- a/recipes-extended/images/xen-image-minimal.bb
+++ b/recipes-extended/images/xen-image-minimal.bb
@@ -1,9 +1,14 @@
1DESCRIPTION = "A minimal xen image" 1DESCRIPTION = "A minimal xen image"
2 2
3inherit features_check
4
5REQUIRED_DISTRO_FEATURES ?= "xen systemd"
6
3INITRD_IMAGE = "core-image-minimal-initramfs" 7INITRD_IMAGE = "core-image-minimal-initramfs"
4 8
5XEN_KERNEL_MODULES ?= "kernel-module-xen-blkback kernel-module-xen-gntalloc \ 9XEN_KERNEL_MODULES ?= "kernel-module-xen-blkback kernel-module-xen-gntalloc \
6 kernel-module-xen-gntdev kernel-module-xen-netback kernel-module-xen-wdt \ 10 kernel-module-xen-gntdev kernel-module-xen-netback kernel-module-xen-wdt \
11 kernel-module-xt-comment kernel-module-xt-masquerade \
7 ${@bb.utils.contains('MACHINE_FEATURES', 'pci', "${XEN_PCIBACK_MODULE}", '', d)} \ 12 ${@bb.utils.contains('MACHINE_FEATURES', 'pci', "${XEN_PCIBACK_MODULE}", '', d)} \
8 ${@bb.utils.contains('MACHINE_FEATURES', 'acpi', '${XEN_ACPI_PROCESSOR_MODULE}', '', d)} \ 13 ${@bb.utils.contains('MACHINE_FEATURES', 'acpi', '${XEN_ACPI_PROCESSOR_MODULE}', '', d)} \
9 " 14 "
@@ -16,6 +21,7 @@ IMAGE_INSTALL += " \
16 qemu \ 21 qemu \
17 kernel-image \ 22 kernel-image \
18 kernel-vmlinux \ 23 kernel-vmlinux \
24 rsync \
19 " 25 "
20 26
21# The hypervisor may not be within the dom0 filesystem image but at least 27# The hypervisor may not be within the dom0 filesystem image but at least
@@ -44,14 +50,6 @@ QB_QEMU_CLASSES = ""
44QB_QEMU_CLASSES:qemuall = "qemuboot-xen-defaults qemuboot-xen-dtb qemuboot-testimage-network" 50QB_QEMU_CLASSES:qemuall = "qemuboot-xen-defaults qemuboot-xen-dtb qemuboot-testimage-network"
45inherit ${QB_QEMU_CLASSES} 51inherit ${QB_QEMU_CLASSES}
46 52
47do_check_xen_state() {
48 if [ "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' yes', 'no', d)}" = "no" ]; then
49 die "DISTRO_FEATURES does not contain 'xen'"
50 fi
51}
52
53addtask check_xen_state before do_rootfs
54
55# note: this may be unused, see the wic plugin 53# note: this may be unused, see the wic plugin
56syslinux_iso_populate:append() { 54syslinux_iso_populate:append() {
57 install -m 0444 ${STAGING_DATADIR}/syslinux/libcom32.c32 ${ISODIR}${ISOLINUXDIR} 55 install -m 0444 ${STAGING_DATADIR}/syslinux/libcom32.c32 ${ISODIR}${ISOLINUXDIR}
@@ -88,6 +86,168 @@ build_syslinux_cfg () {
88 echo " APPEND /xen.gz ${SYSLINUX_XEN_ARGS} --- /vmlinuz ${SYSLINUX_KERNEL_ARGS} --- /initrd" >> ${SYSLINUX_CFG} 86 echo " APPEND /xen.gz ${SYSLINUX_XEN_ARGS} --- /vmlinuz ${SYSLINUX_KERNEL_ARGS} --- /initrd" >> ${SYSLINUX_CFG}
89} 87}
90 88
89# Function to parse the config file and get values for specific keys
90get_config_value() {
91 config_file="$1"
92 key="$2"
93 line=$(grep -w "$key" $config_file)
94 value=$(echo "$line" | cut -d '=' -f 2-)
95 # Remove quotes, leading/trailing whitespace, and content after the first comma
96 echo "${value#*=}" | sed "s/'//g; s/^\s*|\s*$//g; s/\[//g;s/\"//g;s/^ *//g;" | cut -d ',' -f 1
97}
98
99generate_guest_config() {
100 name=$1
101 kernel=$2
102 disk=$3
103 outname=$name.cfg
104
105 cat <<EOF >${DEPLOY_DIR_IMAGE}/$outname
106name = "$name"
107memory = 512
108vcpus = 1
109disk = ['file:$disk,xvda,rw']
110vif = ['bridge=xenbr0']
111kernel = "$kernel"
112extra = "root=/dev/xvda ro ip=dhcp"
113EOF
114}
115
116# Guests can be bundled automatically through the following mechanisms:
117#
118# - via the variable XEN_BUNDLED_GUESTS
119# - via a xen configuration file in the deploy directory of the format
120# xen-guest-bundle-*.cfg
121#
122# The guests can be built via OE, or be 3rd party guests. They just
123# must be in the deploy directory so they can be copied into the rootfs
124# of the xen host image
125#
126# Type 1) XEN_BUNDLED_GUESTS
127#
128# If XEN_BUNDLED_GUESTS is used, it is simply a colon separated list of
129# rootfs:kernels. Normal variable rules apply, so it can be set in a
130# local.conf, or in a bbappend to the image recipe.
131#
132# An example would be:
133#
134# XEN_BUNDLED_GUESTS = "xen-guest-image-minimal-qemuarm64.rootfs.ext4:Image"
135#
136# These point at symlinks created in the image deploy directory, or they
137# can be specific images/kernels without the symlink.
138#
139# Type 2) A Xen guest configuration file
140#
141# If xen guest configuration files are found in the deploy directories
142# the kernel and disk information contained within them will be processed
143# and modified for the xen host. The kernel and guest image will be
144# copied to the appropriate location, and the config made to match.
145#
146# These files following the naming convention: xen-guest-bundle*.cfg
147#
148# Guests of type #1 generate a configuration file that is picked up as
149# type #2.
150#
151# An example config file follows:
152#
153## name = "xen-guest"
154## memory = 512
155## vcpus = 1
156## disk = ['file:xen-guest-image-minimal-qemuarm64.rootfs.ext4,xvda,rw']
157## vif = ['bridge=xenbr0']
158## kernel = "Image"
159## extra = "root=/dev/xvda ro console=hvc0 ip=dhcp"
160#
161# It should also be noted that when a xen-guest-image-minimal is built
162# with the XEN_GUEST_AUTO_BUNDLE varaible set to True, a configuration
163# file for type #2 will be generated and the guest bundled automatically
164# when the host image is built.
165#
166# kernel and rootfs are copied to the target in /var/lib/xen/images/
167#
168# configuration files are copied to: /etc/xen
169#
170# Guests can be launched after boot with: xl create -c /etc/xen/<config file>
171#
172bundle_xen_guests() {
173 set +e
174
175 if [ -n "${XEN_BUNDLED_GUESTS}" ]; then
176 echo "Processing Xen bundled guests variable: ${XEN_BUNDLED_GUESTS}"
177 # these are a colon separated list of rootfs:kernel
178 count=1
179 for g in ${XEN_BUNDLED_GUESTS}; do
180 echo "Guest line: $g"
181 rootfs=$(echo "$g" | cut -d":" -f1)
182 kernel=$(echo "$g" | cut -d":" -f2)
183 name="xen-guest-bundle-$count"
184
185 if ! [ -e ${DEPLOY_DIR_IMAGE}/$rootfs ]; then
186 echo "rootfs '${DEPLOY_DIR_IMAGE}/$rootfs' not found, skipping ...."
187 continue
188 fi
189 if ! [ -e ${DEPLOY_DIR_IMAGE}/$kernel ]; then
190 echo "kernel '${DEPLOY_DIR_IMAGE}/$kernel' not found, skipping ...."
191 continue
192 fi
193
194 generate_guest_config $name $kernel $rootfs
195
196 count=$(expr $count + 1)
197 done
198 fi
199
200 echo ls ${DEPLOY_DIR_IMAGE}/xen-guest-bundle*.cfg
201 ls ${DEPLOY_DIR_IMAGE}/xen-guest-bundle*.cfg >/dev/null 2>/dev/null
202 if [ $? -eq 0 ]; then
203 for guest_cfg in $(ls ${DEPLOY_DIR_IMAGE}/xen-guest-bundle*.cfg); do
204 echo "Bundling guest: $guest_cfg"
205
206 CONFIG_FILE_BASE=$(basename $guest_cfg .cfg)
207 CONFIG_FILE="${DEPLOY_DIR_IMAGE}/$CONFIG_FILE_BASE.cfg"
208 DEST_DIR="${IMAGE_ROOTFS}/var/lib/xen/images"
209 MODIFIED_CONFIG_FILE="${DEPLOY_DIR_IMAGE}/$CONFIG_FILE_BASE-modified.cfg"
210
211 # Extract values from the configuration file
212 DISK_ORIG=$(get_config_value $CONFIG_FILE "disk" | sed 's/file://g')
213 DISK=$(readlink -f ${DEPLOY_DIR_IMAGE}/$DISK_ORIG)
214 DISK_NAME=$(basename $DISK)
215 KERNEL_ORIG=$(get_config_value $CONFIG_FILE "kernel")
216 KERNEL=$(readlink -f ${DEPLOY_DIR_IMAGE}/$KERNEL_ORIG)
217 KERNEL_NAME=$(basename $KERNEL)
218
219 if [ -z "$DISK" ]; then
220 echo "rootfs '$DISK' not found, skipping ...."
221 continue
222 fi
223 if [ -z "$KERNEL" ]; then
224 echo "kernel '$KERNEL' not found, skipping ...."
225 continue
226 fi
227
228 mkdir -p "$DEST_DIR"
229 # Copy the disk and kernel to the destination directory
230 echo "Copying disk and kernel files..."
231 echo cp "$DISK" "$DEST_DIR"
232 echo cp "$KERNEL" "$DEST_DIR"
233 cp "$DISK" "$DEST_DIR"
234 cp "$KERNEL" "$DEST_DIR"
235
236 # Create a modified config file with updated paths
237 sed -E \
238 -e "s#^(disk = \[)[^,]+#\1'file:/var/lib/xen/images/$DISK_NAME#" \
239 -e "s#^(kernel = )\"[^\"]+\"#\1\"/var/lib/xen/images/$KERNEL_NAME\"#" \
240 "$CONFIG_FILE" > "$MODIFIED_CONFIG_FILE"
241
242 mkdir -p ${IMAGE_ROOTFS}/etc/xen
243 cp $MODIFIED_CONFIG_FILE ${IMAGE_ROOTFS}/etc/xen/$CONFIG_FILE_BASE.cfg
244 rm -f $MODIFIED_CONFIG_FILE
245 done
246 fi
247 # exit 1
248}
249ROOTFS_POSTPROCESS_COMMAND += "bundle_xen_guests;"
250
91# Enable runqemu. eg: runqemu xen-image-minimal nographic slirp 251# Enable runqemu. eg: runqemu xen-image-minimal nographic slirp
92WKS_FILE:x86-64 = "directdisk-xen.wks" 252WKS_FILE:x86-64 = "directdisk-xen.wks"
93WKS_FILE_DEPENDS_DEFAULT:x86-64 = "syslinux-native" 253WKS_FILE_DEPENDS_DEFAULT:x86-64 = "syslinux-native"
@@ -102,7 +262,13 @@ QB_SERIAL_OPT = "-serial mon:stdio"
102# qemux86-64 machine does not include 'wic' in IMAGE_FSTYPES, which is needed 262# qemux86-64 machine does not include 'wic' in IMAGE_FSTYPES, which is needed
103# to boot this image, so add it here: 263# to boot this image, so add it here:
104IMAGE_FSTYPES:qemux86-64 += "wic" 264IMAGE_FSTYPES:qemux86-64 += "wic"
265do_image_wic[depends] += "xen:do_deploy"
105# Networking: the qemuboot.bbclass default virtio network device works ok 266# Networking: the qemuboot.bbclass default virtio network device works ok
106# and so does the emulated e1000 -- choose according to the network device 267# and so does the emulated e1000 -- choose according to the network device
107# drivers that are present in your dom0 Linux kernel. To switch to e1000: 268# drivers that are present in your dom0 Linux kernel. To switch to e1000:
108# QB_NETWORK_DEVICE = "-device e1000,netdev=net0,mac=@MAC@" 269# QB_NETWORK_DEVICE = "-device e1000,netdev=net0,mac=@MAC@"
270
271
272IMAGE_ROOTFS_SIZE = "8192"
273# we always need extra space to install VMs, so add 2GB
274IMAGE_ROOTFS_EXTRA_SPACE = "2000000"
diff --git a/recipes-extended/images/xtf-image.bb b/recipes-extended/images/xtf-image.bb
index f9ecea91..7b6eadfd 100644
--- a/recipes-extended/images/xtf-image.bb
+++ b/recipes-extended/images/xtf-image.bb
@@ -25,7 +25,7 @@ DESCRIPTION = "A minimal Xen Test Framework (XTF) image for testing the Xen hype
25# For testimage, see the qemu boot log: ${WORKDIR}/testimage/qemu_boot_log.* 25# For testimage, see the qemu boot log: ${WORKDIR}/testimage/qemu_boot_log.*
26# and the test log: ${WORKDIR}/temp/log.do_testimage 26# and the test log: ${WORKDIR}/temp/log.do_testimage
27 27
28IMAGE_NAME="xtf" 28IMAGE_NAME = "xtf"
29 29
30IMAGE_INSTALL:append = " xtf" 30IMAGE_INSTALL:append = " xtf"
31 31