diff options
author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2024-11-12 20:44:09 +0000 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2024-11-15 19:50:00 +0000 |
commit | 249c79e20b74b1b814440cc2a7fcf068550f4234 (patch) | |
tree | fba6ba1ea09054d4d5f2ee6cf112f46d4d8b5ab6 | |
parent | d2238e728783be3f1f254e93554f9e0a51fd2556 (diff) | |
download | meta-virtualization-249c79e20b74b1b814440cc2a7fcf068550f4234.tar.gz |
xen: add README for testing
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r-- | recipes-extended/images/README-xen.md | 173 | ||||
-rw-r--r-- | recipes-extended/xen/README.test | 84 |
2 files changed, 173 insertions, 84 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/xen/README.test b/recipes-extended/xen/README.test deleted file mode 100644 index 4d45aab8..00000000 --- a/recipes-extended/xen/README.test +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | 1 xl | ||
2 | 2 xl list | ||
3 | 3 xl console | ||
4 | 4 xl console -n 0 | ||
5 | 5 xl -n0 console | ||
6 | 6 xl -n 0 console | ||
7 | 7 xl console -n 0 | ||
8 | 8 xl console Domain-0 | ||
9 | 9 xm | ||
10 | 10 wget | ||
11 | 11 wget https://www.alpinelinux.org/downloads/ | ||
12 | 12 wget https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-standard-3.19.1-x86_64.iso | ||
13 | 13 rm alpine-standard-3.19.1-x86_64.iso | ||
14 | 14 wget https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso | ||
15 | 15 mount -t iso9660 -o loop /data/alpine-virt-3.19.1-x86_64.iso /media/cdrom | ||
16 | 16 ll | ||
17 | 17 ls | ||
18 | 18 mount -t iso9660 -o loop alpine-virt-3.19.1-x86_64.iso /media/cdrom^ | ||
19 | 19 ls /media/ | ||
20 | 20 mkdir /media/cdrom | ||
21 | 21 mount -t iso9660 -o loop alpine-virt-3.19.1-x86_64.iso /media/cdrom | ||
22 | 22 ls /media/cdrom/ | ||
23 | 23 df -kh . | ||
24 | 24 dd if=/dev/zero of=/data/a1.img bs=1M count=300 | ||
25 | 25 mkdir /data | ||
26 | 26 dd if=/dev/zero of=/data/a1.img bs=1M count=300 | ||
27 | |||
28 | |||
29 | ------------------- | ||
30 | |||
31 | ssh from the host (if using slirp): https://docs.yoctoproject.org/dev-manual/qemu.html | ||
32 | |||
33 | ssh root@127.0.0.1 -p 2222 | ||
34 | |||
35 | ------------------- | ||
36 | |||
37 | Install a guest: | ||
38 | |||
39 | https://wiki.alpinelinux.org/wiki/Create_Alpine_Linux_PV_DomU | ||
40 | |||
41 | |||
42 | ---------------- | ||
43 | |||
44 | Add this: | ||
45 | autoballoon=0 | ||
46 | |||
47 | to: | ||
48 | |||
49 | /etc/xen/xl.conf | ||
50 | |||
51 | ---------------- | ||
52 | |||
53 | # /etc/xen/a1.cfg | ||
54 | |||
55 | # Alpine Linux PV DomU | ||
56 | |||
57 | # Kernel paths for install | ||
58 | kernel = "/media/cdrom/boot/vmlinuz-virt" | ||
59 | ramdisk = "/media/cdrom/boot/initramfs-virt" | ||
60 | extra="modules=loop,squashfs console=hvc0" | ||
61 | |||
62 | # Path to HDD and iso file | ||
63 | disk = [ | ||
64 | 'format=raw, vdev=xvda, access=w, target=/data/a1.img', | ||
65 | 'format=raw, vdev=xvdc, access=r, devtype=cdrom, target=/home/root/alpine-virt-3.19.1-x86_64.iso' | ||
66 | ] | ||
67 | |||
68 | # Network configuration | ||
69 | vif = ['bridge=br0'] | ||
70 | |||
71 | # DomU settings | ||
72 | memory = 512 | ||
73 | name = "wqalpine-a1" | ||
74 | vcpus = 1 | ||
75 | maxvcpus = 1 | ||
76 | |||
77 | device_model_version="qemu-xen" | ||
78 | device_model_override="/bin/true" | ||
79 | |||
80 | --------------------------- | ||
81 | |||
82 | xl create -f /etc/xen/a1.cfg -c | ||
83 | |||
84 | |||