package/libvirt: add lxc and qemu options
authorJared Bents <jared.bents@rockwellcollins.com>
Fri, 11 Jun 2021 14:07:32 +0000 (09:07 -0500)
committerArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Thu, 22 Jul 2021 21:15:01 +0000 (23:15 +0200)
Update to add lxc and qemu options for libvirt under the daemon
config option

Signed-off-by: Jared Bents <jared.bents@rockwellcollins.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
package/libvirt/Config.in
package/libvirt/libvirt.mk

index deb1636c9f85136ba3994b380731d9c39874f55d..1d17fc1621f3bc0cc476e975c6c053c535dae63b 100644 (file)
@@ -56,4 +56,32 @@ config BR2_PACKAGE_LIBVIRT_DAEMON
          Build the libvirt daemon (libvirtd) otherwise build only the
          utility programs.
 
+# Stateful drivers are useful only when building the daemon.
+if BR2_PACKAGE_LIBVIRT_DAEMON
+
+config BR2_PACKAGE_LIBVIRT_QEMU
+       bool "qemu"
+       depends on BR2_PACKAGE_LIBSECCOMP_ARCH_SUPPORTS # libseccomp
+       depends on BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET
+       select BR2_PACKAGE_HWDATA         # libpciaccess
+       select BR2_PACKAGE_HWDATA_PCI_IDS # libpciaccess
+       select BR2_PACKAGE_LIBSECCOMP
+       select BR2_PACKAGE_QEMU
+       select BR2_PACKAGE_QEMU_SYSTEM if BR2_PACKAGE_QEMU_CUSTOM_TARGETS = ""
+       select BR2_PACKAGE_YAJL
+       help
+         QEMU/KVM support
+
+config BR2_PACKAGE_LIBVIRT_LXC
+       bool "lxc"
+       depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 # lxc
+       select BR2_PACKAGE_LXC
+       help
+         Linux Container support
+
+comment "lxc needs a toolchain w/ gcc >= 4.7"
+       depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_7
+
+endif
+
 endif
index a8099c936a0a9c86d806b917156a7595b5bd0353..eeedfbdc51ba05be0919f59df08279d0d7019fb4 100644 (file)
@@ -24,9 +24,7 @@ LIBVIRT_CONF_OPTS = \
        -Ddriver_hyperv=disabled \
        -Ddriver_interface=enabled \
        -Ddriver_libxl=disabled \
-       -Ddriver_lxc=disabled \
        -Ddriver_openvz=disabled \
-       -Ddriver_qemu=disabled \
        -Ddriver_remote=enabled \
        -Ddriver_secrets=enabled \
        -Ddriver_vbox=disabled \
@@ -193,6 +191,19 @@ else
 LIBVIRT_CONF_OPTS += -Dssh2=disabled
 endif
 
+ifeq ($(BR2_PACKAGE_LIBVIRT_LXC),y)
+LIBVIRT_CONF_OPTS += -Dlogin_shell=enabled -Ddriver_lxc=enabled
+LIBVIRT_DEPENDENCIES += lxc
+else
+LIBVIRT_CONF_OPTS += -Dlogin_shell=disabled -Ddriver_lxc=disabled
+endif
+
+ifeq ($(BR2_PACKAGE_LIBVIRT_QEMU),y)
+LIBVIRT_CONF_OPTS += -Ddriver_qemu=enabled -Dqemu_user=qemu -Dqemu_group=kvm
+else
+LIBVIRT_CONF_OPTS += -Ddriver_qemu=disabled -Dqemu_user=no -Dqemu_group=no
+endif
+
 else # BR2_PACKAGE_LIBVIRT_DAEMON
 
 LIBVIRT_CONF_OPTS += -Dlibvirtd=disabled -Ddriver_network=disabled
@@ -218,13 +229,29 @@ define LIBVIRT_PERMISSIONS
        /var/lib/libvirt/filesystems             d  711  root  root  -  -  -  -  -
        /var/lib/libvirt/images                  d  711  root  root  -  -  -  -  -
        /var/lib/libvirt/network                 d  700  root  root  -  -  -  -  -
+       /var/lib/libvirt/qemu                    d  751  qemu  kvm   -  -  -  -  -
+       /var/lib/libvirt/qemu/autostart          d  700  root  root  -  -  -  -  -
+       /var/lib/libvirt/qemu/networks           d  700  root  root  -  -  -  -  -
+       /var/lib/libvirt/qemu/networks/autostart d  700  root  root  -  -  -  -  -
+       /var/lib/libvirt/qemu/channel            d  755  qemu  kvm   -  -  -  -  -
+       /var/lib/libvirt/qemu/channel/target     d  755  qemu  kvm   -  -  -  -  -
+       /var/lib/libvirt/qemu/dump               d  755  qemu  kvm   -  -  -  -  -
+       /var/lib/libvirt/qemu/nvram              d  755  qemu  kvm   -  -  -  -  -
+       /var/lib/libvirt/qemu/save               d  755  qemu  kvm   -  -  -  -  -
+       /var/lib/libvirt/qemu/snapshot           d  755  qemu  kvm   -  -  -  -  -
        /var/lib/libvirt/secrets                 d  700  root  root  -  -  -  -  -
        /var/lib/libvirt/storage                 d  755  root  root  -  -  -  -  -
        /var/lib/libvirt/storage/autostart       d  755  root  root  -  -  -  -  -
        /var/cache/libvirt                       d  711  root  root  -  -  -  -  -
+       /var/cache/libvirt/lxc                   d  750  root  root  -  -  -  -  -
+       /var/cache/libvirt/qemu                  d  750  qemu  kvm   -  -  -  -  -
+       /var/cache/libvirt/qemu/capabilities     d  755  root  root  -  -  -  -  -
        /var/log/libvirt                         d  700  root  root  -  -  -  -  -
+       /var/log/libvirt/lxc                     d  750  root  root  -  -  -  -  -
+       /var/log/libvirt/qemu                    d  750  root  root  -  -  -  -  -
        /var/log/swtpm                           d  755  root  root  -  -  -  -  -
        /var/log/swtpm/libvirt                   d  755  root  root  -  -  -  -  -
+       /var/log/swtpm/libvirt/qemu              d  711  root  root  -  -  -  -  -
 endef
 
 # libvirt may need to create persistent files (e.g. VM definitions) in these
@@ -235,14 +262,22 @@ endef
 define LIBVIRT_CREATE_SYMLINKS
        $(INSTALL) -m 700 -d $(TARGET_DIR)/etc/libvirt
        $(INSTALL) -m 755 -d $(TARGET_DIR)/var/lib/libvirt
+       $(INSTALL) -m 751 -d $(TARGET_DIR)/var/lib/libvirt/qemu
        $(INSTALL) -m 700 -d $(TARGET_DIR)/var/lib/libvirt/secrets
        $(INSTALL) -m 755 -d $(TARGET_DIR)/var/lib/libvirt/storage
+       ln -s -f ../../var/lib/libvirt/qemu $(TARGET_DIR)/etc/libvirt/
        ln -s -f ../../var/lib/libvirt/secrets $(TARGET_DIR)/etc/libvirt/
        ln -s -f ../../var/lib/libvirt/storage $(TARGET_DIR)/etc/libvirt/
 endef
 
 LIBVIRT_PRE_INSTALL_TARGET_HOOKS += LIBVIRT_CREATE_SYMLINKS
 
+ifeq ($(BR2_PACKAGE_LIBVIRT_QEMU),y)
+define LIBVIRT_USERS
+       qemu -1 kvm -1 * - - - Libvirt qemu/kvm daemon
+endef
+endif
+
 ifeq ($(BR2_PACKAGE_LIBVIRT_DAEMON),y)
 define LIBVIRT_INSTALL_INIT_SYSV
        $(INSTALL) -D -m 0755 package/libvirt/S91virtlogd $(TARGET_DIR)/etc/init.d/S91virtlogd