diff options
| -rwxr-xr-x | recipes-extended/libvirt/libvirt/hook_support.py | 55 | ||||
| -rw-r--r-- | recipes-extended/libvirt/libvirt_4.9.0.bb | 25 |
2 files changed, 79 insertions, 1 deletions
diff --git a/recipes-extended/libvirt/libvirt/hook_support.py b/recipes-extended/libvirt/libvirt/hook_support.py new file mode 100755 index 00000000..c3eb8b3a --- /dev/null +++ b/recipes-extended/libvirt/libvirt/hook_support.py | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | # | ||
| 3 | # Copyright (C) 2014 Wind River Systems, Inc. | ||
| 4 | # | ||
| 5 | # Description: Calls other scripts in order, so that there can be multiple | ||
| 6 | # scripts for a particular hook tied to libvirt. | ||
| 7 | # | ||
| 8 | # For example: If this script is called "qemu" and is in the | ||
| 9 | # "/etc/libvirt/hooks/" directory. This script will be called by libvirt | ||
| 10 | # when certain actions are performed on a qemu guest. This script then | ||
| 11 | # will in turn call any executable file in the same directory matching | ||
| 12 | # "qemu-" followed by at least one alpha-numeric character. The scripts | ||
| 13 | # are called in order (based on the python sorted function), and once any | ||
| 14 | # sub-script returns a non-zero exit code no futher scripts are called. | ||
| 15 | # This script passes any arguments it retrieves on the command line and a | ||
| 16 | # copy of stdin to the sub-scripts it calls. | ||
| 17 | |||
| 18 | import os | ||
| 19 | import re | ||
| 20 | import subprocess | ||
| 21 | import sys | ||
| 22 | |||
| 23 | def main(): | ||
| 24 | return_value = 0 | ||
| 25 | hook_name = os.path.basename( __file__ ) | ||
| 26 | try: | ||
| 27 | hook_dir = os.path.dirname( __file__ ) | ||
| 28 | hook_args = sys.argv | ||
| 29 | del hook_args[ 0 ] # Remove executable from argument list | ||
| 30 | |||
| 31 | # Save stdin, so we can pass it to each sub-script. | ||
| 32 | if sys.stdin.isatty(): | ||
| 33 | stdin_save = [ "" ] | ||
| 34 | else: | ||
| 35 | stdin_save = sys.stdin.readlines() | ||
| 36 | # Match the name name of the hook + a dash + atleast | ||
| 37 | # one alpha-numeric character. | ||
| 38 | matcher = re.compile( "%s-\w+" % hook_name ) | ||
| 39 | for file_name in sorted( os.listdir( hook_dir ) ): | ||
| 40 | file_path = os.path.join( hook_dir, file_name ) | ||
| 41 | if matcher.match( file_name ) \ | ||
| 42 | and os.access( file_path, os.X_OK ) \ | ||
| 43 | and os.path.isfile( file_path ) \ | ||
| 44 | and return_value == 0: | ||
| 45 | cmd = [ file_path ] + hook_args | ||
| 46 | p = subprocess.Popen( cmd, stdin=subprocess.PIPE ) | ||
| 47 | p.communicate( input = ''.join( stdin_save ) )[0] | ||
| 48 | return_value = p.wait() | ||
| 49 | except Exception as e: | ||
| 50 | sys.stderr.write( "%s hook error: %s\n" % ( hook_name, str( e ) ) ) | ||
| 51 | return_value = 1 | ||
| 52 | return return_value | ||
| 53 | |||
| 54 | if __name__ == '__main__': | ||
| 55 | sys.exit( main() ) | ||
diff --git a/recipes-extended/libvirt/libvirt_4.9.0.bb b/recipes-extended/libvirt/libvirt_4.9.0.bb index ccd4f83f..17ac799e 100644 --- a/recipes-extended/libvirt/libvirt_4.9.0.bb +++ b/recipes-extended/libvirt/libvirt_4.9.0.bb | |||
| @@ -35,12 +35,16 @@ SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.xz;name=libvirt \ | |||
| 35 | file://install-missing-file.patch \ | 35 | file://install-missing-file.patch \ |
| 36 | file://0001-ptest-Remove-Windows-1252-check-from-esxutilstest.patch \ | 36 | file://0001-ptest-Remove-Windows-1252-check-from-esxutilstest.patch \ |
| 37 | file://configure.ac-search-for-rpc-rpc.h-in-the-sysroot.patch \ | 37 | file://configure.ac-search-for-rpc-rpc.h-in-the-sysroot.patch \ |
| 38 | file://hook_support.py \ | ||
| 38 | " | 39 | " |
| 39 | 40 | ||
| 40 | SRC_URI[libvirt.md5sum] = "aaf7b265ac2013d6eb184a86b5f7eeb9" | 41 | SRC_URI[libvirt.md5sum] = "aaf7b265ac2013d6eb184a86b5f7eeb9" |
| 41 | SRC_URI[libvirt.sha256sum] = "4fd4bfe7312b7996a817c7919cf0062de0d5b3c400c93bd30855a46c40dd455a" | 42 | SRC_URI[libvirt.sha256sum] = "4fd4bfe7312b7996a817c7919cf0062de0d5b3c400c93bd30855a46c40dd455a" |
| 42 | 43 | ||
| 43 | inherit autotools gettext update-rc.d pkgconfig ptest systemd | 44 | inherit autotools gettext update-rc.d pkgconfig ptest systemd useradd |
| 45 | USERADD_PACKAGES = "${PN}" | ||
| 46 | GROUPADD_PARAM_${PN} = "-r qemu; -r kvm" | ||
| 47 | USERADD_PARAM_${PN} = "-r -g qemu -G kvm qemu" | ||
| 44 | 48 | ||
| 45 | # Override the default set in autotools.bbclass so that we will use relative pathnames | 49 | # Override the default set in autotools.bbclass so that we will use relative pathnames |
| 46 | # to our local m4 files. This prevents an "Argument list too long" error during configuration | 50 | # to our local m4 files. This prevents an "Argument list too long" error during configuration |
| @@ -180,9 +184,11 @@ PRIVATE_LIBS_${PN}-ptest = " \ | |||
| 180 | # full config | 184 | # full config |
| 181 | PACKAGECONFIG ??= "qemu yajl uml openvz vmware vbox esx iproute2 lxc test \ | 185 | PACKAGECONFIG ??= "qemu yajl uml openvz vmware vbox esx iproute2 lxc test \ |
| 182 | remote macvtap libvirtd netcf udev python ebtables \ | 186 | remote macvtap libvirtd netcf udev python ebtables \ |
| 187 | fuse iproute2 firewalld libpcap \ | ||
| 183 | ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux audit libcap-ng', '', d)} \ | 188 | ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux audit libcap-ng', '', d)} \ |
| 184 | ${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'libxl', '', d)} \ | 189 | ${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'libxl', '', d)} \ |
| 185 | ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'polkit', '', d)} \ | 190 | ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'polkit', '', d)} \ |
| 191 | ${@bb.utils.contains('KARCH', 'arm', '', 'numactl', d)} \ | ||
| 186 | " | 192 | " |
| 187 | 193 | ||
| 188 | # qemu is NOT compatible with mips64 | 194 | # qemu is NOT compatible with mips64 |
| @@ -221,6 +227,10 @@ PACKAGECONFIG[fuse] = "--with-fuse,--without-fuse,fuse," | |||
| 221 | PACKAGECONFIG[audit] = "--with-audit,--without-audit,audit," | 227 | PACKAGECONFIG[audit] = "--with-audit,--without-audit,audit," |
| 222 | PACKAGECONFIG[libcap-ng] = "--with-capng,--without-capng,libcap-ng," | 228 | PACKAGECONFIG[libcap-ng] = "--with-capng,--without-capng,libcap-ng," |
| 223 | PACKAGECONFIG[wireshark] = "--with-wireshark-dissector,--without-wireshark-dissector,wireshark libwsutil," | 229 | PACKAGECONFIG[wireshark] = "--with-wireshark-dissector,--without-wireshark-dissector,wireshark libwsutil," |
| 230 | PACKAGECONFIG[apparmor-profiles] = "--with-apparmor-profiles, --without-apparmor-profiles," | ||
| 231 | PACKAGECONFIG[firewalld] = "--with-firewalld, --without-firewalld," | ||
| 232 | PACKAGECONFIG[libpcap] = "--with-libpcap, --without-libpcap,libpcap,libpcap" | ||
| 233 | PACKAGECONFIG[numad] = "--with-numad, --without-numad," | ||
| 224 | 234 | ||
| 225 | # Enable the Python tool support | 235 | # Enable the Python tool support |
| 226 | require libvirt-python.inc | 236 | require libvirt-python.inc |
| @@ -281,6 +291,10 @@ do_install_append() { | |||
| 281 | 291 | ||
| 282 | # Add hook support for libvirt | 292 | # Add hook support for libvirt |
| 283 | mkdir -p ${D}/etc/libvirt/hooks | 293 | mkdir -p ${D}/etc/libvirt/hooks |
| 294 | for hook in "daemon" "lxc" "network" "qemu" | ||
| 295 | do | ||
| 296 | install -m 0755 ${WORKDIR}/hook_support.py ${D}/etc/libvirt/hooks/${hook} | ||
| 297 | done | ||
| 284 | 298 | ||
| 285 | # Force the main dnsmasq instance to bind only to specified interfaces and | 299 | # Force the main dnsmasq instance to bind only to specified interfaces and |
| 286 | # to not bind to virbr0. Libvirt will run its own instance on this interface. | 300 | # to not bind to virbr0. Libvirt will run its own instance on this interface. |
| @@ -290,11 +304,19 @@ do_install_append() { | |||
| 290 | for i in `find ${D}${libdir} -type f -name *.la`; do | 304 | for i in `find ${D}${libdir} -type f -name *.la`; do |
| 291 | sed -i -e 's#-L${B}/src/.libs##g' $i | 305 | sed -i -e 's#-L${B}/src/.libs##g' $i |
| 292 | done | 306 | done |
| 307 | |||
| 308 | sed -i -e 's/^\(unix_sock_group\ =\ \).*/\1"kvm"/' ${D}/etc/libvirt/libvirtd.conf | ||
| 309 | sed -i -e 's/^\(unix_sock_rw_perms\ =\ \).*/\1"0776"/' ${D}/etc/libvirt/libvirtd.conf | ||
| 310 | chown -R qemu:qemu ${D}/${localstatedir}/lib/libvirt/qemu | ||
| 311 | echo "d qemu qemu 0755 ${localstatedir}/cache/libvirt/qemu none" \ | ||
| 312 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
| 293 | } | 313 | } |
| 294 | 314 | ||
| 295 | EXTRA_OECONF += " \ | 315 | EXTRA_OECONF += " \ |
| 296 | --with-init-script=systemd \ | 316 | --with-init-script=systemd \ |
| 297 | --with-test-suite \ | 317 | --with-test-suite \ |
| 318 | --with-qemu-user=qemu \ | ||
| 319 | --with-qemu-group=qemu \ | ||
| 298 | " | 320 | " |
| 299 | 321 | ||
| 300 | EXTRA_OEMAKE = "BUILD_DIR=${B} DEST_DIR=${D}${PTEST_PATH} PTEST_DIR=${PTEST_PATH} SYSTEMD_UNIT_DIR=${systemd_system_unitdir}" | 322 | EXTRA_OEMAKE = "BUILD_DIR=${B} DEST_DIR=${D}${PTEST_PATH} PTEST_DIR=${PTEST_PATH} SYSTEMD_UNIT_DIR=${systemd_system_unitdir}" |
| @@ -318,6 +340,7 @@ pkg_postinst_${PN}() { | |||
| 318 | if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then | 340 | if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then |
| 319 | /etc/init.d/populate-volatile.sh update | 341 | /etc/init.d/populate-volatile.sh update |
| 320 | fi | 342 | fi |
| 343 | mkdir -m 711 -p $D/data/images | ||
| 321 | } | 344 | } |
| 322 | 345 | ||
| 323 | python () { | 346 | python () { |
