diff options
Diffstat (limited to 'recipes-extended/libvirt/libvirt_10.0.0.bb')
-rw-r--r-- | recipes-extended/libvirt/libvirt_10.0.0.bb | 334 |
1 files changed, 334 insertions, 0 deletions
diff --git a/recipes-extended/libvirt/libvirt_10.0.0.bb b/recipes-extended/libvirt/libvirt_10.0.0.bb new file mode 100644 index 00000000..6b19b700 --- /dev/null +++ b/recipes-extended/libvirt/libvirt_10.0.0.bb | |||
@@ -0,0 +1,334 @@ | |||
1 | DESCRIPTION = "A toolkit to interact with the virtualization capabilities of recent versions of Linux." | ||
2 | HOMEPAGE = "http://libvirt.org" | ||
3 | LICENSE = "LGPL-2.1-or-later & GPL-2.0-or-later" | ||
4 | LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ | ||
5 | file://COPYING.LESSER;md5=4b54a1fd55a448865a0b32d41598759d" | ||
6 | SECTION = "console/tools" | ||
7 | |||
8 | DEPENDS = "bridge-utils gnutls libxml2 lvm2 avahi parted curl libpcap util-linux e2fsprogs pm-utils \ | ||
9 | iptables dnsmasq readline libtasn1 libxslt-native acl libdevmapper libtirpc \ | ||
10 | python3-docutils-native \ | ||
11 | ${@bb.utils.contains('PACKAGECONFIG', 'polkit', 'shadow-native', '', d)} \ | ||
12 | ${@bb.utils.contains('PACKAGECONFIG', 'gnutls', 'gnutls-native', '', d)}" | ||
13 | |||
14 | # libvirt-guests.sh needs gettext.sh | ||
15 | # | ||
16 | RDEPENDS:${PN} = "gettext-runtime" | ||
17 | |||
18 | RDEPENDS:libvirt-libvirtd += "bridge-utils iptables pm-utils dnsmasq netcat-openbsd ebtables" | ||
19 | RDEPENDS:libvirt-libvirtd:append:x86-64 = " dmidecode" | ||
20 | RDEPENDS:libvirt-libvirtd:append:x86 = " dmidecode" | ||
21 | RDEPENDS:libvirt-libvirtd:append:arm = " dmidecode" | ||
22 | RDEPENDS:libvirt-libvirtd:append:aarch64 = " dmidecode" | ||
23 | |||
24 | #connman blocks the 53 port and libvirtd can't start its DNS service | ||
25 | RCONFLICTS:${PN}_libvirtd = "connman" | ||
26 | |||
27 | SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.xz;name=libvirt \ | ||
28 | file://libvirtd.sh \ | ||
29 | file://libvirtd.conf \ | ||
30 | file://dnsmasq.conf \ | ||
31 | file://hook_support.py \ | ||
32 | file://gnutls-helper.py \ | ||
33 | file://0001-prevent-gendispatch.pl-generating-build-path-in-code.patch \ | ||
34 | file://0001-messon.build-remove-build-path-information-to-avoid-.patch \ | ||
35 | " | ||
36 | |||
37 | SRC_URI[libvirt.sha256sum] = "8ba2e72ec8bdd2418554a1474c42c35704c30174b7611eaf9a16544b71bcf00a" | ||
38 | |||
39 | inherit meson gettext update-rc.d pkgconfig systemd useradd perlnative | ||
40 | USERADD_PACKAGES = "${PN}" | ||
41 | GROUPADD_PARAM:${PN} = "-r qemu; -r kvm" | ||
42 | USERADD_PARAM:${PN} = "-r -g qemu -G kvm qemu" | ||
43 | |||
44 | |||
45 | EXTRA_OEMESON += "--cross-file ${WORKDIR}/meson-${PN}.cross" | ||
46 | do_write_config:append() { | ||
47 | cat >${WORKDIR}/meson-${PN}.cross <<EOF | ||
48 | [binaries] | ||
49 | iptables = '/usr/sbin/iptables' | ||
50 | ip6tables = '/usr/sbin/ip6tables' | ||
51 | dmidecode = '/usr/sbin/dmidecode' | ||
52 | ebtables = '/sbin/ebtables' | ||
53 | dnsmasq = '/usr/bin/dnsmasq' | ||
54 | EOF | ||
55 | } | ||
56 | |||
57 | ALLOW_EMPTY:${PN} = "1" | ||
58 | INSANE_SKIP:${PN} += "empty-dirs" | ||
59 | |||
60 | PACKAGES =+ "${PN}-libvirtd ${PN}-virsh" | ||
61 | |||
62 | ALLOW_EMPTY:${PN}-libvirtd = "1" | ||
63 | |||
64 | FILES:${PN}-libvirtd = " \ | ||
65 | ${sysconfdir}/init.d \ | ||
66 | ${sysconfdir}/sysctl.d \ | ||
67 | ${sysconfdir}/logrotate.d \ | ||
68 | ${sysconfdir}/libvirt/libvirtd.conf \ | ||
69 | /usr/lib/sysctl.d/60-libvirtd.conf \ | ||
70 | /usr/lib/sysctl.d/60-qemu-postcopy-migration.conf \ | ||
71 | ${sbindir}/libvirtd \ | ||
72 | ${systemd_system_unitdir} \ | ||
73 | ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '', '${libexecdir}/libvirt-guests.sh', d)} \ | ||
74 | ${@bb.utils.contains('PACKAGECONFIG', 'gnutls', '${sysconfdir}/pki/libvirt/* ${sysconfdir}/pki/CA/*', '', d)} \ | ||
75 | " | ||
76 | |||
77 | FILES:${PN}-virsh = " \ | ||
78 | ${bindir}/virsh \ | ||
79 | ${datadir}/bash-completion/completions/virsh \ | ||
80 | " | ||
81 | |||
82 | FILES:${PN} += "${libdir}/libvirt/connection-driver \ | ||
83 | ${datadir}/augeas \ | ||
84 | ${@bb.utils.contains('PACKAGECONFIG', 'polkit', '${datadir}/polkit-1', '', d)} \ | ||
85 | ${datadir}/bash-completion/completions/vsh \ | ||
86 | ${datadir}/bash-completion/completions/virt-admin \ | ||
87 | /usr/lib/firewalld/ \ | ||
88 | " | ||
89 | |||
90 | FILES:${PN}-dbg += "${libdir}/libvirt/connection-driver/.debug ${libdir}/libvirt/lock-driver/.debug" | ||
91 | FILES:${PN}-staticdev += "${libdir}/*.a ${libdir}/libvirt/connection-driver/*.a ${libdir}/libvirt/lock-driver/*.a" | ||
92 | |||
93 | CONFFILES:${PN} += "${sysconfdir}/libvirt/libvirt.conf \ | ||
94 | ${sysconfdir}/libvirt/lxc.conf \ | ||
95 | ${sysconfdir}/libvirt/qemu-lockd.conf \ | ||
96 | ${sysconfdir}/libvirt/qemu.conf \ | ||
97 | ${sysconfdir}/libvirt/virt-login-shell.conf \ | ||
98 | ${sysconfdir}/libvirt/virtlockd.conf" | ||
99 | |||
100 | CONFFILES:${PN}-libvirtd = "${sysconfdir}/logrotate.d/libvirt ${sysconfdir}/logrotate.d/libvirt.lxc \ | ||
101 | ${sysconfdir}/logrotate.d/libvirt.qemu ${sysconfdir}/logrotate.d/libvirt.uml \ | ||
102 | ${sysconfdir}/libvirt/libvirtd.conf \ | ||
103 | /usr/lib/sysctl.d/libvirtd.conf" | ||
104 | |||
105 | INITSCRIPT_PACKAGES = "${PN}-libvirtd" | ||
106 | INITSCRIPT_NAME:${PN}-libvirtd = "libvirtd" | ||
107 | INITSCRIPT_PARAMS:${PN}-libvirtd = "defaults 72" | ||
108 | |||
109 | SYSTEMD_PACKAGES = "${PN}-libvirtd" | ||
110 | SYSTEMD_SERVICE:${PN}-libvirtd = " \ | ||
111 | libvirtd.service \ | ||
112 | virtlockd.service \ | ||
113 | libvirt-guests.service \ | ||
114 | virtlockd.socket \ | ||
115 | " | ||
116 | |||
117 | # xen-minimal config | ||
118 | #PACKAGECONFIG ??= "xen libxl xen-inotify test remote libvirtd" | ||
119 | |||
120 | # full config | ||
121 | PACKAGECONFIG ??= "gnutls qemu yajl openvz vmware vbox esx lxc test remote \ | ||
122 | libvirtd netcf udev python fuse firewalld libpcap \ | ||
123 | ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux audit libcap-ng', '', d)} \ | ||
124 | ${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'libxl', '', d)} \ | ||
125 | ${@bb.utils.contains('DISTRO_FEATURES', 'polkit', 'polkit', '', d)} \ | ||
126 | " | ||
127 | |||
128 | # qemu is NOT compatible with mips64, powerpc and riscv32 | ||
129 | PACKAGECONFIG:remove:mipsarchn32 = "qemu" | ||
130 | PACKAGECONFIG:remove:mipsarchn64 = "qemu" | ||
131 | PACKAGECONFIG:remove:powerpc = "qemu" | ||
132 | PACKAGECONFIG:remove:riscv32 = "qemu" | ||
133 | |||
134 | # numactl is NOT compatible with arm | ||
135 | PACKAGECONFIG:remove:arm = "numactl" | ||
136 | PACKAGECONFIG:remove:armeb = "numactl" | ||
137 | |||
138 | # enable,disable,depends,rdepends | ||
139 | # | ||
140 | PACKAGECONFIG[gnutls] = ",,,gnutls-bin" | ||
141 | PACKAGECONFIG[qemu] = "-Ddriver_qemu=enabled -Dqemu_user=qemu -Dqemu_group=qemu,-Ddriver_qemu=disabled,qemu," | ||
142 | PACKAGECONFIG[yajl] = "-Dyajl=enabled,-Dyajl=disabled,yajl,yajl" | ||
143 | PACKAGECONFIG[libxl] = "-Ddriver_libxl=enabled,-Ddriver_libxl=disabled,xen," | ||
144 | PACKAGECONFIG[openvz] = "-Ddriver_openvz=enabled,-Ddriver_openvz=disabled,," | ||
145 | PACKAGECONFIG[vmware] = "-Ddriver_vmware=enabled,-Ddriver_vmware=disabled,," | ||
146 | PACKAGECONFIG[vbox] = "-Ddriver_vbox=enabled,-Ddriver_vbox=disabled,," | ||
147 | PACKAGECONFIG[esx] = "-Ddriver_esx=enabled,-Ddriver_esx=disabled,," | ||
148 | PACKAGECONFIG[hyperv] = "-Ddriver_hyperv=enabled,-Ddriver_hyperv=disabled,," | ||
149 | PACKAGECONFIG[polkit] = "-Dpolkit=enabled,-Dpolkit=disabled,polkit,polkit" | ||
150 | PACKAGECONFIG[lxc] = "-Ddriver_lxc=enabled,-Ddriver_lxc=disabled,lxc," | ||
151 | PACKAGECONFIG[test] = "-Ddriver_test=enabled,-Ddriver_test=disabled,," | ||
152 | PACKAGECONFIG[remote] = "-Ddriver_remote=enabled,-Ddriver_remote=disabled,," | ||
153 | PACKAGECONFIG[libvirtd] = "-Ddriver_libvirtd=enabled,-Ddriver_libvirtd=disabled,," | ||
154 | PACKAGECONFIG[netcf] = "-Dnetcf=enabled,-Dnetcf=disabled,netcf,netcf" | ||
155 | PACKAGECONFIG[dtrace] = "-Ddtrace=enabled,-Ddtrace=disabled,," | ||
156 | PACKAGECONFIG[udev] = "-Dudev=enabled -Dpciaccess=enabled,-Dudev=disabled,udev libpciaccess," | ||
157 | PACKAGECONFIG[selinux] = "-Dselinux=enabled,-Dselinux=disabled,libselinux," | ||
158 | PACKAGECONFIG[python] = ",,python3," | ||
159 | PACKAGECONFIG[sasl] = "-Dsasl=enabled,-Dsasl=disabled,cyrus-sasl,cyrus-sasl" | ||
160 | PACKAGECONFIG[numactl] = "-Dnumactl=enabled,-Dnumactl=disabled,numactl," | ||
161 | PACKAGECONFIG[fuse] = "-Dfuse=enabled,-Dfuse=disabled,fuse3," | ||
162 | PACKAGECONFIG[audit] = "-Daudit=enabled,-Daudit=disabled,audit," | ||
163 | PACKAGECONFIG[libcap-ng] = "-Dcapng=enabled,-Dcapng=disabled,libcap-ng," | ||
164 | PACKAGECONFIG[wireshark] = "-Dwireshark_dissector=enabled,-Dwireshark_dissector=disabled,wireshark libwsutil," | ||
165 | PACKAGECONFIG[apparmor_profiles] = "-Dapparmor_profiles=enabled, -Dapparmor_profiles=disabled," | ||
166 | PACKAGECONFIG[firewalld] = "-Dfirewalld=enabled, -Dfirewalld=disabled," | ||
167 | PACKAGECONFIG[libpcap] = "-Dlibpcap=enabled, -Dlibpcap=disabled,libpcap,libpcap" | ||
168 | PACKAGECONFIG[numad] = "-Dnumad=enabled, -Dnumad=disabled," | ||
169 | |||
170 | # Enable the Python tool support | ||
171 | require libvirt-python.inc | ||
172 | |||
173 | do_compile() { | ||
174 | cd ${B}/src | ||
175 | # There may be race condition, but without creating these directories | ||
176 | # in the source tree, generation of files fails. | ||
177 | for i in access admin logging esx locking rpc hyperv lxc \ | ||
178 | remote network storage interface nwfilter node_device \ | ||
179 | secret vbox qemu; do | ||
180 | mkdir -p $i; | ||
181 | done | ||
182 | |||
183 | cd ${B} | ||
184 | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${B}/src:" | ||
185 | ninja all | ||
186 | } | ||
187 | |||
188 | do_install:prepend() { | ||
189 | # so the install routines can find the libvirt.pc in the source dir | ||
190 | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${B}/src:" | ||
191 | } | ||
192 | |||
193 | do_install:append() { | ||
194 | install -d ${D}/etc/init.d | ||
195 | install -d ${D}/etc/libvirt | ||
196 | install -d ${D}/etc/dnsmasq.d | ||
197 | |||
198 | install -m 0755 ${WORKDIR}/libvirtd.sh ${D}/etc/init.d/libvirtd | ||
199 | install -m 0644 ${WORKDIR}/libvirtd.conf ${D}/etc/libvirt/libvirtd.conf | ||
200 | |||
201 | if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then | ||
202 | # This will wind up in the libvirtd package, but will NOT be invoked by default. | ||
203 | # | ||
204 | mv ${D}/${libexecdir}/libvirt-guests.sh ${D}/${sysconfdir}/init.d | ||
205 | fi | ||
206 | |||
207 | if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then | ||
208 | if [ "${systemd_system_unitdir}" != "${prefix}/lib/systemd/system" ] ; then | ||
209 | # ./src/meson.build: systemd_unit_dir = prefix / 'lib' / 'systemd' / 'system' | ||
210 | # ./tools/meson.build: install_dir: prefix / 'lib' / 'systemd' / 'system', | ||
211 | mkdir -p ${D}${systemd_system_unitdir} | ||
212 | mv ${D}${prefix}/lib/systemd/system/* ${D}${systemd_system_unitdir} | ||
213 | rmdir ${D}${prefix}/lib/systemd/system ${D}${prefix}/lib/systemd | ||
214 | fi | ||
215 | |||
216 | # We can't use 'notify' when we don't support 'sd_notify' dbus capabilities. | ||
217 | # Change default LIBVIRTD_ARGS to start libvirtd in the right mode. | ||
218 | sed -i -e 's/Type=notify/Type=forking/' \ | ||
219 | -e '/Type=forking/a PIDFile=/run/libvirtd.pid' \ | ||
220 | -e 's/\(Environment=LIBVIRTD_ARGS="--timeout 120"\)/#\1\nEnvironment=LIBVIRTD_ARGS="--listen --daemon"/' \ | ||
221 | ${D}/${systemd_system_unitdir}/libvirtd.service | ||
222 | fi | ||
223 | |||
224 | # The /run/libvirt directories created by the Makefile are | ||
225 | # wiped out in volatile, we need to create these at boot. | ||
226 | rm -rf ${D}/run | ||
227 | install -d ${D}${sysconfdir}/default/volatiles | ||
228 | echo "d root root 0755 /run/libvirt none" \ | ||
229 | > ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
230 | echo "d root root 0755 /run/libvirt/lockd none" \ | ||
231 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
232 | echo "d root root 0755 /run/libvirt/lxc none" \ | ||
233 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
234 | echo "d root root 0755 /run/libvirt/network none" \ | ||
235 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
236 | echo "d root root 0755 /run/libvirt/qemu none" \ | ||
237 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
238 | |||
239 | # Manually set permissions and ownership to match polkit recipe | ||
240 | if ${@bb.utils.contains('PACKAGECONFIG', 'polkit', 'true', 'false', d)}; then | ||
241 | install -d -m 0700 ${D}/${datadir}/polkit-1/rules.d | ||
242 | chown polkitd ${D}/${datadir}/polkit-1/rules.d | ||
243 | chgrp root ${D}/${datadir}/polkit-1/rules.d | ||
244 | else | ||
245 | rm -rf ${D}/${datadir}/polkit-1 | ||
246 | fi | ||
247 | |||
248 | # disable seccomp_sandbox | ||
249 | if [ -e ${D}${sysconfdir}/libvirt/qemu.conf ] ; then | ||
250 | sed -i '/^#seccomp_sandbox = 1/aseccomp_sandbox = 0' \ | ||
251 | ${D}${sysconfdir}/libvirt/qemu.conf | ||
252 | fi | ||
253 | |||
254 | # Add hook support for libvirt | ||
255 | mkdir -p ${D}/etc/libvirt/hooks | ||
256 | for hook in "daemon" "lxc" "network" "qemu" | ||
257 | do | ||
258 | install -m 0755 ${WORKDIR}/hook_support.py ${D}/etc/libvirt/hooks/${hook} | ||
259 | done | ||
260 | |||
261 | # Force the main dnsmasq instance to bind only to specified interfaces and | ||
262 | # to not bind to virbr0. Libvirt will run its own instance on this interface. | ||
263 | install -m 644 ${WORKDIR}/dnsmasq.conf ${D}/${sysconfdir}/dnsmasq.d/libvirt-daemon | ||
264 | |||
265 | # remove .la references to our working diretory | ||
266 | for i in `find ${D}${libdir} -type f -name *.la`; do | ||
267 | sed -i -e 's#-L${B}/src/.libs##g' $i | ||
268 | done | ||
269 | |||
270 | sed -i -e 's/^\(unix_sock_group\ =\ \).*/\1"kvm"/' ${D}/etc/libvirt/libvirtd.conf | ||
271 | sed -i -e 's/^\(unix_sock_rw_perms\ =\ \).*/\1"0776"/' ${D}/etc/libvirt/libvirtd.conf | ||
272 | |||
273 | case ${MACHINE_ARCH} in | ||
274 | *mips*) | ||
275 | break | ||
276 | ;; | ||
277 | *) | ||
278 | if ${@bb.utils.contains('PACKAGECONFIG', 'qemu', 'true', 'false', d)}; then | ||
279 | chown -R qemu:qemu ${D}/${localstatedir}/lib/libvirt/qemu | ||
280 | echo "d qemu qemu 0755 ${localstatedir}/cache/libvirt/qemu none" \ | ||
281 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
282 | break | ||
283 | fi | ||
284 | ;; | ||
285 | esac | ||
286 | |||
287 | if ${@bb.utils.contains('PACKAGECONFIG','gnutls','true','false',d)}; then | ||
288 | # Generate sample keys and certificates. | ||
289 | cd ${WORKDIR} | ||
290 | ${WORKDIR}/gnutls-helper.py -y | ||
291 | |||
292 | # Deploy all sample keys and certificates of CA, server and client | ||
293 | # to target so that libvirtd is able to boot successfully and local | ||
294 | # connection via 127.0.0.1 is available out of box. | ||
295 | install -d ${D}/etc/pki/CA | ||
296 | install -d ${D}/etc/pki/libvirt/private | ||
297 | install -m 0755 ${WORKDIR}/gnutls-helper.py ${D}/${bindir} | ||
298 | install -m 0644 ${WORKDIR}/cakey.pem ${D}/${sysconfdir}/pki/libvirt/private/cakey.pem | ||
299 | install -m 0644 ${WORKDIR}/cacert.pem ${D}/${sysconfdir}/pki/CA/cacert.pem | ||
300 | install -m 0644 ${WORKDIR}/serverkey.pem ${D}/${sysconfdir}/pki/libvirt/private/serverkey.pem | ||
301 | install -m 0644 ${WORKDIR}/servercert.pem ${D}/${sysconfdir}/pki/libvirt/servercert.pem | ||
302 | install -m 0644 ${WORKDIR}/clientkey.pem ${D}/${sysconfdir}/pki/libvirt/private/clientkey.pem | ||
303 | install -m 0644 ${WORKDIR}/clientcert.pem ${D}/${sysconfdir}/pki/libvirt/clientcert.pem | ||
304 | |||
305 | # Force the connection to be tls. | ||
306 | sed -i -e 's/^\(listen_tls\ =\ .*\)/#\1/' -e 's/^\(listen_tcp\ =\ .*\)/#\1/' ${D}/etc/libvirt/libvirtd.conf | ||
307 | fi | ||
308 | |||
309 | # virt-login-shell needs to run with setuid permission | ||
310 | chmod 4755 ${D}${bindir}/virt-login-shell | ||
311 | } | ||
312 | |||
313 | EXTRA_OEMESON += " \ | ||
314 | -Dinit_script=${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd','none', d)} \ | ||
315 | -Drunstatedir=/run \ | ||
316 | -Dtests=enabled \ | ||
317 | " | ||
318 | |||
319 | # gcc9 end up mis-compiling qemuxml2argvtest.o with Og which then | ||
320 | # crashes on target, so remove -Og and use -O2 as workaround | ||
321 | SELECTED_OPTIMIZATION:remove:virtclass-multilib-lib32:mipsarch = "-Og" | ||
322 | SELECTED_OPTIMIZATION:append:virtclass-multilib-lib32:mipsarch = " -O2" | ||
323 | |||
324 | pkg_postinst:${PN}() { | ||
325 | if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then | ||
326 | /etc/init.d/populate-volatile.sh update | ||
327 | fi | ||
328 | mkdir -m 711 -p $D/data/images | ||
329 | } | ||
330 | |||
331 | python () { | ||
332 | if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): | ||
333 | d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") | ||
334 | } | ||