diff options
Diffstat (limited to 'recipes-extended/images')
-rw-r--r-- | recipes-extended/images/README-xen.md | 173 | ||||
-rw-r--r-- | recipes-extended/images/README.md | 311 | ||||
-rw-r--r-- | recipes-extended/images/cloud-image-controller.bb | 2 | ||||
-rw-r--r-- | recipes-extended/images/container-app-base.bb | 17 | ||||
-rw-r--r-- | recipes-extended/images/container-base.bb | 14 | ||||
-rw-r--r-- | recipes-extended/images/container-devtools-base.bb | 51 | ||||
-rw-r--r-- | recipes-extended/images/container-image-host.bb | 129 | ||||
-rw-r--r-- | recipes-extended/images/container-systemd-base.bb | 17 | ||||
-rw-r--r-- | recipes-extended/images/container-systemd-base.inc | 72 | ||||
-rw-r--r-- | recipes-extended/images/xen-guest-image-minimal.bb | 28 | ||||
-rw-r--r-- | recipes-extended/images/xen-image-minimal.bb | 182 | ||||
-rw-r--r-- | recipes-extended/images/xtf-image.bb | 2 |
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 @@ | |||
1 | This README contains information on the xen reference images | ||
2 | and testing / usability information | ||
3 | |||
4 | Images | ||
5 | ------ | ||
6 | |||
7 | xen-image-minimal: | ||
8 | |||
9 | This is the reference xen host image. It currently requires systemd | ||
10 | and xen as DISTRO_FEATURES. | ||
11 | |||
12 | All required dependencies are included for typical execution (and | ||
13 | debug) of guests. | ||
14 | |||
15 | xen-guest-image-minimal: | ||
16 | |||
17 | This is the reference guest / domU image. Note that it boots the | ||
18 | same kernel as the xen host image (unless multiconfig is used | ||
19 | to differentiate). | ||
20 | |||
21 | It creates tarballs, ext4 and qcow images for testing purposes. | ||
22 | |||
23 | bundling | ||
24 | -------- | ||
25 | |||
26 | Guests 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 | |||
32 | The guests can be built via OE, or be 3rd party guests. They just | ||
33 | must be in the deploy directory so they can be copied into the rootfs | ||
34 | of the xen host image | ||
35 | |||
36 | Type 1) XEN_BUNDLED_GUESTS | ||
37 | |||
38 | If XEN_BUNDLED_GUESTS is used, it is simply a colon separated list of | ||
39 | rootfs:kernels. Normal variable rules apply, so it can be set in a | ||
40 | local.conf, or in a bbappend to the image recipe. | ||
41 | |||
42 | An example would be: | ||
43 | |||
44 | XEN_BUNDLED_GUESTS = "xen-guest-image-minimal-qemuarm64.rootfs.ext4:Image" | ||
45 | |||
46 | These point at symlinks created in the image deploy directory, or they | ||
47 | can be specific images/kernels without the symlink. | ||
48 | |||
49 | Type 2) A Xen guest configuration file | ||
50 | |||
51 | If xen guest configuration files are found in the deploy directories | ||
52 | the kernel and disk information contained within them will be processed | ||
53 | and modified for the xen host. The kernel and guest image will be | ||
54 | copied to the appropriate location, and the config made to match. | ||
55 | |||
56 | These files following the naming convention: xen-guest-bundle*.cfg | ||
57 | |||
58 | Guests of type #1 generate a configuration file that is picked up as | ||
59 | type #2. | ||
60 | |||
61 | An 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 | |||
71 | It should also be noted that when a xen-guest-image-minimal is built | ||
72 | with the XEN_GUEST_AUTO_BUNDLE varaible set to True, a configuration | ||
73 | file for type #2 will be generated and the guest bundled automatically | ||
74 | when the host image is built. | ||
75 | |||
76 | kernel and rootfs are copied to the target in /var/lib/xen/images/ | ||
77 | |||
78 | configuration files are copied to: /etc/xen | ||
79 | |||
80 | Guests can be launched after boot with: xl create -c /etc/xen/<config file> | ||
81 | |||
82 | Build and boot | ||
83 | -------------- | ||
84 | |||
85 | Using a reference qmeuarm64 MACHINE, the following are the commands | ||
86 | to build and boot a guest. | ||
87 | |||
88 | local.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 | |||
97 | Poky (Yocto Project Reference Distro) 5.1 qemuarm64 hvc0 | ||
98 | |||
99 | qemuarm64 login: root | ||
100 | |||
101 | WARNING: Poky is a reference Yocto Project distribution that should be used for | ||
102 | testing and development purposes only. It is recommended that you create your | ||
103 | own distribution for production use. | ||
104 | |||
105 | root@qemuarm64:~# uname -a | ||
106 | Linux qemuarm64 6.10.11-yocto-standard #1 SMP PREEMPT Fri Sep 20 22:32:26 UTC 2024 aarch64 GNU/Linux | ||
107 | root@qemuarm64:~# ls /etc/xen/ | ||
108 | auto | ||
109 | cpupool | ||
110 | scripts | ||
111 | xen-guest-bundle-xen-guest-image-minimal-qemuarm64--20241112174803.cfg | ||
112 | xl.conf | ||
113 | root@qemuarm64:~# ls /var/lib/xen/images/ | ||
114 | Image--6.10.11+git0+4bf82718cf_6c956b2ea6-r0-qemuarm64-20241018190311.bin | ||
115 | xen-guest-image-minimal-qemuarm64.rootfs-20241111222814.ext4 | ||
116 | |||
117 | root@qemuarm64:~# ip a s | ||
118 | 1: 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 | ||
124 | 2: 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 | ||
126 | 3: sit0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000 | ||
127 | link/sit 0.0.0.0 brd 0.0.0.0 | ||
128 | 4: 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 | |||
139 | qemuarm64 login: root | ||
140 | |||
141 | WARNING: Poky is a reference Yocto Project distribution that should be used for | ||
142 | testing and development purposes only. It is recommended that you create your | ||
143 | own distribution for production use. | ||
144 | |||
145 | root@qemuarm64:~# uname -a | ||
146 | Linux qemuarm64 6.10.11-yocto-standard #1 SMP PREEMPT Fri Sep 20 22:32:26 UTC 2024 aarch64 GNU/Linux | ||
147 | |||
148 | root@qemuarm64:~# wget example.com | ||
149 | Connecting to example.com (93.184.215.14:80) | ||
150 | wget: can't open 'index.html': File exists | ||
151 | root@qemuarm64:~# rm index.html | ||
152 | root@qemuarm64:~# wget example.com | ||
153 | Connecting to example.com (93.184.215.14:80) | ||
154 | saving to 'index.html' | ||
155 | index.html 100% |********************************| 1256 0:00:00 ETA | ||
156 | 'index.html' saved | ||
157 | |||
158 | From the host: | ||
159 | |||
160 | Connection to 127.0.0.1 closed. | ||
161 | build4 [/home/bruc.../qemuarm64]> ssh -p 2222 root@127.0.0.1 | ||
162 | Last login: Tue Nov 12 20:42:57 2024 from 10.0.2.2 | ||
163 | |||
164 | WARNING: Poky is a reference Yocto Project distribution that should be used for | ||
165 | testing and development purposes only. It is recommended that you create your | ||
166 | own distribution for production use. | ||
167 | |||
168 | root@qemuarm64:~# xl list | ||
169 | Name ID Mem VCPUs State Time(s) | ||
170 | Domain-0 0 192 4 r----- 696.2 | ||
171 | xen-guest 1 512 1 -b---- 153.0 | ||
172 | root@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 @@ | |||
1 | This README describes the contents of the reference images in | ||
2 | this directory, as well as some testing and usability tips. | ||
3 | |||
4 | container-image-host | ||
5 | -------------------- | ||
6 | |||
7 | As described in the recipe, this is a flexible image definition that | ||
8 | is suitable for building a container host image for a target. | ||
9 | |||
10 | The configuration options for the image are best found in the recipe | ||
11 | itself, so the information will not be duplicated here. The type of | ||
12 | container host that will be created is controlled by the CONTAINER_PROFILE | ||
13 | variable: | ||
14 | |||
15 | i.e. in your local.conf: CONTAINER_PROFILE="docker" | ||
16 | |||
17 | The valid settings for this variable can be found in the image recipe. | ||
18 | |||
19 | The recipe checks for mandatory distro features, recommends others | ||
20 | and provides a list of optional distro features for some workloads. | ||
21 | |||
22 | This image also builds using virt-unique-hostname, which ensures that | ||
23 | there is some randomization as hostname is often used to identify | ||
24 | hosts when clustered (i.e. k3s). | ||
25 | |||
26 | To have enough disk space for container images, it is configured | ||
27 | with extra space. Depending on your use case, you can add (or remove) | ||
28 | space as appropriate. | ||
29 | |||
30 | Also note that more memory than the default is often required. | ||
31 | |||
32 | An 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 | |||
36 | ssh is enabled in this image by default, so the image can be accessed | ||
37 | via: | ||
38 | |||
39 | % ssh -p 2222 root@127.0.0.1 | ||
40 | |||
41 | After a container image has been built, it can be copied fro the | ||
42 | deploy 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 | |||
47 | Examples of pulling images to the container host for the various | ||
48 | runtimes 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 | |||
68 | container-base: | ||
69 | --------------- | ||
70 | |||
71 | Provides a minimal container image (but not absolutely smallest) that is | ||
72 | inherited / included by the other container images. | ||
73 | |||
74 | By default container base does not execute anything (it doesn't define | ||
75 | and OCI_IMAGE_ENTRYPOINT), but does provide a shell that can be used | ||
76 | to 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 | |||
119 | container-devtools-base: | ||
120 | ------------------------- | ||
121 | |||
122 | includes container-base, and adds image features to make development | ||
123 | tools/headers available. | ||
124 | |||
125 | Anything added to CORE_DEV_IMAGE_EXTRA_INSTALL will be installed into | ||
126 | the image in it's development variant. | ||
127 | |||
128 | The container shell is changed to bash from busybox. | ||
129 | |||
130 | package-management is added to this image type, but by default there | ||
131 | is 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 | |||
144 | By default this container has (for rpm) package management configured | ||
145 | to point to a feed being run against the local build on the host machine | ||
146 | |||
147 | To create a package feed: | ||
148 | |||
149 | % bitbake package-index | ||
150 | |||
151 | To 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 | |||
157 | To run a local http server for the package feed: | ||
158 | |||
159 | % cd build/tmp/deploy | ||
160 | % sudo python3 -m http.server 80 | ||
161 | |||
162 | Run the dev container: | ||
163 | |||
164 | % docker run -it zeddii/container-devtools bash | ||
165 | % dnf makecache | ||
166 | % dnf --nogpgcheck install vim-tiny | ||
167 | |||
168 | container-app-base: | ||
169 | -------------------- | ||
170 | |||
171 | Includes container-base. | ||
172 | |||
173 | Provides an application container that installs a package (or packages) to | ||
174 | the 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 | |||
179 | The 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 | |||
190 | container-systemd-base: | ||
191 | ------------------------ | ||
192 | |||
193 | Extends container-base to create a systemd enabled container that is | ||
194 | an appropriate starting point if a systemd applciation is being run | ||
195 | or a mulit-user style environment is required. | ||
196 | |||
197 | The application specified in SYSTEMD_CONTAINER_APP will be installed | ||
198 | and be available to be executed. | ||
199 | |||
200 | The rootfs of this container type is post processed to enable and | ||
201 | disable services as specified by the containeer definition. This allows | ||
202 | service that are not appropriate in a containerized environemnt to | ||
203 | be disabled (i.e. getty login) | ||
204 | |||
205 | The list of services can be found in the recipes themselves. | ||
206 | |||
207 | This container enables ssh by default, so that it can be executed | ||
208 | in the background and then accessed as a full environment. | ||
209 | |||
210 | Note: this is currently a priviledged container if run under docker. | ||
211 | |||
212 | There are multiple ways to add/remove permissions from the container, | ||
213 | and 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 | |||
219 | or | ||
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 | |||
241 | Then 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 | |||
253 | Get 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 | |||
263 | ssh 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 | |||
309 | Enjoy! | ||
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 | |||
29 | IMAGE_FSTYPES = "wic.vmdk tar.gz" | 29 | IMAGE_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 @@ | |||
1 | SUMMARY = "Basic Application container image" | ||
2 | LICENSE = "MIT" | ||
3 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
4 | |||
5 | include 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 | ||
10 | CONTAINER_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 | ||
14 | CONTAINER_APP ?= "" | ||
15 | |||
16 | OCI_IMAGE_ENTRYPOINT = "${CONTAINER_APP_CMD}" | ||
17 | IMAGE_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" | |||
7 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | 7 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" |
8 | 8 | ||
9 | IMAGE_FSTYPES = "container oci" | 9 | IMAGE_FSTYPES = "container oci" |
10 | |||
10 | inherit image | 11 | inherit image |
11 | inherit image-oci | 12 | inherit 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 | ||
27 | OCI_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 | |||
36 | IMAGE_CONTAINER_NO_DUMMY = "1" | 41 | IMAGE_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. | ||
39 | ROOTFS_POSTPROCESS_COMMAND += "rootfs_fixup_var_volatile ; " | 48 | ROOTFS_POSTPROCESS_COMMAND += "rootfs_fixup_var_volatile ; " |
49 | |||
50 | # This :remove is required, because it comes along and deletes our /var/volatile/ | ||
51 | # fixups! | ||
52 | ROOTFS_POSTPROCESS_COMMAND:remove = "empty_var_volatile" | ||
53 | |||
40 | rootfs_fixup_var_volatile () { | 54 | rootfs_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 @@ | |||
1 | SUMMARY = "Basic container image with development tools" | ||
2 | LICENSE = "MIT" | ||
3 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
4 | |||
5 | CONTAINER_SHELL = "bash" | ||
6 | |||
7 | CORE_DEV_IMAGE_EXTRA_INSTALL ?= "" | ||
8 | |||
9 | include container-base.bb | ||
10 | inherit core-image | ||
11 | |||
12 | CORE_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 | ||
15 | CORE_DEV_IMAGE_CORE_UTILS ?= "${VIRTUAL-RUNTIME_base-utils}" | ||
16 | |||
17 | IMAGE_INSTALL += " \ | ||
18 | ${CORE_DEV_IMAGE_EXTRA_INSTALL} \ | ||
19 | ${CORE_DEV_IMAGE_CORE_UTILS} \ | ||
20 | ${CORE_DEV_IMAGE_EDITOR} \ | ||
21 | " | ||
22 | |||
23 | OCI_IMAGE_ENTRYPOINT = "" | ||
24 | |||
25 | # development headers, tools and package management to update | ||
26 | # the container. | ||
27 | IMAGE_FEATURES += "dev-pkgs" | ||
28 | IMAGE_FEATURES += "tools-sdk" | ||
29 | IMAGE_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 | # | ||
38 | DEVTOOLS_BASE_PKG_FEED_URL ?= "http://10.0.2.2/rpm" | ||
39 | |||
40 | |||
41 | # TODO: support more than rpm | ||
42 | ROOTFS_POSTPROCESS_COMMAND += "rootfs_pkg_feed_config ; " | ||
43 | rootfs_pkg_feed_config () { | ||
44 | if [ "${IMAGE_PKGTYPE}" = "rpm" ]; then | ||
45 | install -m 755 -d ${IMAGE_ROOTFS}/${sysconfdir}/yum.repos.d | ||
46 | cat <<EOF >>${IMAGE_ROOTFS}/${sysconfdir}/yum.repos.d/oe-packages.repo | ||
47 | [oe-packages] | ||
48 | baseurl="${DEVTOOLS_BASE_PKG_FEED_URL}" | ||
49 | EOF | ||
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 @@ | |||
1 | DESCRIPTION = "A configurable container host image" | ||
2 | LICENSE = "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 | |||
58 | inherit features_check | ||
59 | |||
60 | # minimum features tested to have a working container host | ||
61 | # image. These will be enforced by the features_check inherit | ||
62 | REQUIRED_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. | ||
70 | RECOMMENDED_DISTRO_FEATURES ?= " pam \ | ||
71 | usrmerge \ | ||
72 | " | ||
73 | # features that are enabled for specific wworkloads. These | ||
74 | # are not enforced, except for specific configurations. | ||
75 | OPTIONAL_DISTRO_FEATURES ?= " vmsep \ | ||
76 | k3s \ | ||
77 | k8s \ | ||
78 | " | ||
79 | |||
80 | REQUIRED_DISTRO_FEATURES:append = " ${@bb.utils.contains('VIRTUAL-RUNTIME_container_orchestration','k3s-node','k3s','',d)}" | ||
81 | REQUIRED_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 | ||
85 | IMAGE_FEATURES[validitems] += "virt-unique-hostname" | ||
86 | IMAGE_FEATURES[validitems] += "container-tools" | ||
87 | |||
88 | IMAGE_FEATURES += "ssh-server-openssh" | ||
89 | IMAGE_FEATURES += "package-management" | ||
90 | IMAGE_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 | |||
94 | IMAGE_LINGUAS = " " | ||
95 | |||
96 | # additional packages to install | ||
97 | CONTAINER_IMAGE_HOST_EXTRA_INSTALL ?= "" | ||
98 | |||
99 | # values can be: "all", "split" or "" | ||
100 | CONTAINER_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. | ||
106 | IMAGE_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 | ||
123 | inherit core-image | ||
124 | |||
125 | IMAGE_ROOTFS_SIZE = "8192" | ||
126 | |||
127 | # we always need extra space to install container images | ||
128 | # 2GB | ||
129 | IMAGE_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 @@ | |||
1 | SUMMARY = "Systemd system container for ${SYSTEMD_CONTAINER_APP}" | ||
2 | DESCRIPTION = "A small systemd system container which will run \ | ||
3 | ${SYSTEMD_CONTAINER_APP}." | ||
4 | |||
5 | SYSTEMD_CONTAINER_APP ?= "" | ||
6 | |||
7 | # Use local.conf to specify the application(s) to install | ||
8 | IMAGE_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 | ||
12 | SERVICES_TO_DISABLE:append = " ${SYSTEMD_CONTAINER_DISABLE_SERVICES}" | ||
13 | |||
14 | # Use local.conf to enable systemd services | ||
15 | SERVICES_TO_ENABLE += "${SYSTEMD_CONTAINER_ENABLE_SERVICES}" | ||
16 | |||
17 | require 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 @@ | |||
1 | SUMMARY ?= "Sample systemd system container" | ||
2 | DESCRIPTION ?= "A small systemd system container which will run \ | ||
3 | the application defined in IMAGE_INSTALL." | ||
4 | |||
5 | LICENSE ?= "MIT" | ||
6 | LIC_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 | |||
21 | require container-base.bb | ||
22 | |||
23 | OCI_IMAGE_ENTRYPOINT = "/sbin/init" | ||
24 | |||
25 | IMAGE_INSTALL:append = " systemd" | ||
26 | IMAGE_INSTALL:append = " packagegroup-core-base-utils" | ||
27 | IMAGE_INSTALL:append = " packagegroup-core-ssh-openssh" | ||
28 | IMAGE_INSTALL:append = " busybox" | ||
29 | |||
30 | IMAGE_FEATURES ?= "" | ||
31 | |||
32 | NO_RECOMMENDATIONS = "1" | ||
33 | |||
34 | SERVICES_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 | |||
48 | SERVICES_TO_ENABLE ?= "" | ||
49 | |||
50 | disable_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 | |||
61 | enable_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 | |||
72 | ROOTFS_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 @@ | |||
1 | DESCRIPTION = "A Xen guest image." | 1 | DESCRIPTION = "A Xen guest image." |
2 | 2 | ||
3 | inherit core-image features_check | 3 | inherit core-image features_check deploy |
4 | inherit kernel-artifact-names | ||
4 | 5 | ||
5 | IMAGE_INSTALL += " \ | 6 | IMAGE_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 |
25 | APPEND += "console=hvc0" | 26 | APPEND += "console=hvc0" |
27 | |||
28 | IMAGE_FSTYPES = "tar.bz2 ext4 ext4.qcow2" | ||
29 | |||
30 | XEN_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. | ||
36 | do_deploy() { | ||
37 | if [ -n "${XEN_GUEST_AUTO_BUNDLE}" ]; then | ||
38 | outname="xen-guest-bundle-${IMAGE_BASENAME}${IMAGE_MACHINE_SUFFIX}-${IMAGE_VERSION_SUFFIX}.cfg" | ||
39 | cat <<EOF >>${DEPLOYDIR}/$outname | ||
40 | name = "xen-guest" | ||
41 | memory = 512 | ||
42 | vcpus = 1 | ||
43 | disk = ['file:${IMAGE_LINK_NAME}.ext4,xvda,rw'] | ||
44 | vif = ['bridge=xenbr0'] | ||
45 | kernel = "${KERNEL_IMAGETYPE}" | ||
46 | extra = "root=/dev/xvda ro ip=dhcp" | ||
47 | EOF | ||
48 | fi | ||
49 | } | ||
50 | |||
51 | addtask 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 @@ | |||
1 | DESCRIPTION = "A minimal xen image" | 1 | DESCRIPTION = "A minimal xen image" |
2 | 2 | ||
3 | inherit features_check | ||
4 | |||
5 | REQUIRED_DISTRO_FEATURES ?= "xen systemd" | ||
6 | |||
3 | INITRD_IMAGE = "core-image-minimal-initramfs" | 7 | INITRD_IMAGE = "core-image-minimal-initramfs" |
4 | 8 | ||
5 | XEN_KERNEL_MODULES ?= "kernel-module-xen-blkback kernel-module-xen-gntalloc \ | 9 | XEN_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 = "" | |||
44 | QB_QEMU_CLASSES:qemuall = "qemuboot-xen-defaults qemuboot-xen-dtb qemuboot-testimage-network" | 50 | QB_QEMU_CLASSES:qemuall = "qemuboot-xen-defaults qemuboot-xen-dtb qemuboot-testimage-network" |
45 | inherit ${QB_QEMU_CLASSES} | 51 | inherit ${QB_QEMU_CLASSES} |
46 | 52 | ||
47 | do_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 | |||
53 | addtask 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 |
56 | syslinux_iso_populate:append() { | 54 | syslinux_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 | ||
90 | get_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 | |||
99 | generate_guest_config() { | ||
100 | name=$1 | ||
101 | kernel=$2 | ||
102 | disk=$3 | ||
103 | outname=$name.cfg | ||
104 | |||
105 | cat <<EOF >${DEPLOY_DIR_IMAGE}/$outname | ||
106 | name = "$name" | ||
107 | memory = 512 | ||
108 | vcpus = 1 | ||
109 | disk = ['file:$disk,xvda,rw'] | ||
110 | vif = ['bridge=xenbr0'] | ||
111 | kernel = "$kernel" | ||
112 | extra = "root=/dev/xvda ro ip=dhcp" | ||
113 | EOF | ||
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 | # | ||
172 | bundle_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 | } | ||
249 | ROOTFS_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 |
92 | WKS_FILE:x86-64 = "directdisk-xen.wks" | 252 | WKS_FILE:x86-64 = "directdisk-xen.wks" |
93 | WKS_FILE_DEPENDS_DEFAULT:x86-64 = "syslinux-native" | 253 | WKS_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: |
104 | IMAGE_FSTYPES:qemux86-64 += "wic" | 264 | IMAGE_FSTYPES:qemux86-64 += "wic" |
265 | do_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 | |||
272 | IMAGE_ROOTFS_SIZE = "8192" | ||
273 | # we always need extra space to install VMs, so add 2GB | ||
274 | IMAGE_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 | ||
28 | IMAGE_NAME="xtf" | 28 | IMAGE_NAME = "xtf" |
29 | 29 | ||
30 | IMAGE_INSTALL:append = " xtf" | 30 | IMAGE_INSTALL:append = " xtf" |
31 | 31 | ||