summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2024-11-12 20:44:09 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2024-11-15 19:50:00 +0000
commit249c79e20b74b1b814440cc2a7fcf068550f4234 (patch)
treefba6ba1ea09054d4d5f2ee6cf112f46d4d8b5ab6
parentd2238e728783be3f1f254e93554f9e0a51fd2556 (diff)
downloadmeta-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.md173
-rw-r--r--recipes-extended/xen/README.test84
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 @@
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/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
31ssh from the host (if using slirp): https://docs.yoctoproject.org/dev-manual/qemu.html
32
33ssh root@127.0.0.1 -p 2222
34
35-------------------
36
37Install a guest:
38
39https://wiki.alpinelinux.org/wiki/Create_Alpine_Linux_PV_DomU
40
41
42----------------
43
44Add this:
45autoballoon=0
46
47to:
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
58kernel = "/media/cdrom/boot/vmlinuz-virt"
59ramdisk = "/media/cdrom/boot/initramfs-virt"
60extra="modules=loop,squashfs console=hvc0"
61
62# Path to HDD and iso file
63disk = [
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
69vif = ['bridge=br0']
70
71# DomU settings
72memory = 512
73name = "wqalpine-a1"
74vcpus = 1
75maxvcpus = 1
76
77device_model_version="qemu-xen"
78device_model_override="/bin/true"
79
80---------------------------
81
82xl create -f /etc/xen/a1.cfg -c
83
84