From nobody Sun Feb 8 23:32:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594893856; cv=none; d=zohomail.com; s=zohoarc; b=Q9d64+y5ceT6KwcaabLlfqUgjhCR4PfTOgT5LZrAr86PEtJ5H/cFwrfmyvwKtuFsLO51pPUfDRydp5RXopdb5vxQcREYR0XDeZYg/dPJMF+Dt2R2LVkeuTEjQOBHi8waUzgmfnds8yIw6RC04CWO6GsRTBxAZOC/7W+QrWDG6bA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594893856; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7Y3uw3KsEoU86WZGZYJGHaFzL8K+2YM+C24EGByDqOI=; b=nqbpSE+LFSjq6RKNE8gFIGAtGHWP/3iY6q0WYpm66F4JwzUfivunwlk4h05+dsltbRkO29kCEW6XF9zPogwAIhQ+XmcvB59vORU8Oz2pTfFyr+tGDQNue6Kmuwc9FsxrhpmAMQ7oNqI+QlYhm1q4mO7AALgQ69TDdpEGTff9A9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594893856716175.165244873785; Thu, 16 Jul 2020 03:04:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-J3uNRNqHPza1OuNFAMQU0Q-1; Thu, 16 Jul 2020 06:03:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6FBE1106B20A; Thu, 16 Jul 2020 10:02:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BDCA1053B01; Thu, 16 Jul 2020 10:02:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1703B180599D; Thu, 16 Jul 2020 10:02:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06GA2lPi016686 for ; Thu, 16 Jul 2020 06:02:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0C0322DE73; Thu, 16 Jul 2020 10:02:47 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A59E2B6E2 for ; Thu, 16 Jul 2020 10:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594893855; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7Y3uw3KsEoU86WZGZYJGHaFzL8K+2YM+C24EGByDqOI=; b=BtNxc7RRNC6f+lF3uG1Nj+AiMEtsrWGglL5z5bAo4+x53Wx4JUsa+N7qLuf3I3VZ0wOXTo 9o6V+Y6xM6vEZzttZRodq2JHHA57mZnMjoIL3CLZmEDJPoU65CLuJjP/xpslaaYPfWF2nN rxbB0ebnUz4Nhce21w8mT66FrsM9Zis= X-MC-Unique: J3uNRNqHPza1OuNFAMQU0Q-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 088/351] meson: add qemu driver build options Date: Thu, 16 Jul 2020 11:55:24 +0200 Message-Id: <368a216d8ace0d4b022636010326bd0f49d4986b.1594891445.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- configure.ac | 8 --- m4/virt-driver-qemu.m4 | 132 ----------------------------------------- meson.build | 127 +++++++++++++++++++++++++++++++++++++++ meson_options.txt | 3 + 4 files changed, 130 insertions(+), 140 deletions(-) delete mode 100644 m4/virt-driver-qemu.m4 diff --git a/configure.ac b/configure.ac index 30b84856d38..d0189c8701a 100644 --- a/configure.ac +++ b/configure.ac @@ -85,7 +85,6 @@ AM_CONDITIONAL([WITH_MACOS], [test "$with_macos" =3D "yes= "]) =20 # Stateful drivers are useful only when building the daemon. if test "$with_libvirtd" =3D "no" ; then - with_qemu=3Dno with_vbox=3Dno fi =20 @@ -103,7 +102,6 @@ dnl dnl Virtualization drivers check dnl =20 -LIBVIRT_DRIVER_ARG_QEMU LIBVIRT_DRIVER_ARG_VMWARE LIBVIRT_DRIVER_ARG_VBOX LIBVIRT_DRIVER_ARG_VZ @@ -111,7 +109,6 @@ LIBVIRT_DRIVER_ARG_TEST LIBVIRT_DRIVER_ARG_NETWORK LIBVIRT_DRIVER_ARG_INTERFACE =20 -LIBVIRT_DRIVER_CHECK_QEMU LIBVIRT_DRIVER_CHECK_VMWARE LIBVIRT_DRIVER_CHECK_VBOX LIBVIRT_DRIVER_CHECK_VZ @@ -311,7 +308,6 @@ AC_MSG_NOTICE([=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([Drivers]) AC_MSG_NOTICE([]) -LIBVIRT_DRIVER_RESULT_QEMU LIBVIRT_DRIVER_RESULT_VMWARE LIBVIRT_DRIVER_RESULT_VBOX LIBVIRT_DRIVER_RESULT_VZ @@ -366,7 +362,3 @@ LIBVIRT_RESULT_LOGIN_SHELL LIBVIRT_RESULT_HOST_VALIDATE LIBVIRT_RESULT_TLS_PRIORITY AC_MSG_NOTICE([]) -AC_MSG_NOTICE([Privileges]) -AC_MSG_NOTICE([]) -LIBVIRT_RESULT_QEMU_PRIVILEGES -AC_MSG_NOTICE([]) diff --git a/m4/virt-driver-qemu.m4 b/m4/virt-driver-qemu.m4 deleted file mode 100644 index 886261fce5c..00000000000 --- a/m4/virt-driver-qemu.m4 +++ /dev/null @@ -1,132 +0,0 @@ -dnl The QEMU driver -dnl -dnl Copyright (C) 2016 Red Hat, Inc. -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library. If not, see -dnl . -dnl - -AC_DEFUN([LIBVIRT_DRIVER_ARG_QEMU], [ - LIBVIRT_ARG_WITH_FEATURE([QEMU], [QEMU/KVM], [check]) - LIBVIRT_ARG_WITH([QEMU_USER], [username to run QEMU system instance as], - ['platform dependent']) - LIBVIRT_ARG_WITH([QEMU_GROUP], [groupname to run QEMU system instance as= ], - ['platform dependent']) -]) - -AC_DEFUN([LIBVIRT_DRIVER_CHECK_QEMU], [ - dnl There is no way qemu driver will work without JSON support - AC_REQUIRE([LIBVIRT_CHECK_YAJL]) - if test "$with_qemu:$with_yajl" =3D "yes:no"; then - AC_MSG_ERROR([YAJL 2 is required to build QEMU driver]) - fi - if test "$with_qemu" =3D "check"; then - with_qemu=3D$with_yajl - fi - - if test "$with_qemu" =3D "yes" ; then - AC_DEFINE_UNQUOTED([WITH_QEMU], 1, [whether QEMU driver is enabled]) - fi - AM_CONDITIONAL([WITH_QEMU], [test "$with_qemu" =3D "yes"]) - - if test $with_freebsd =3D yes || test $with_macos =3D yes; then - default_qemu_user=3Droot - default_qemu_group=3Dwheel - else - # Try to integrate gracefully with downstream packages by running QEMU - # processes using the same user and group they would - case $(grep ^ID=3D /etc/os-release 2>/dev/null) in - *arch*) - default_qemu_user=3Dnobody - default_qemu_group=3Dnobody - ;; - *centos*|*fedora*|*gentoo*|*rhel*|*suse*) - default_qemu_user=3Dqemu - default_qemu_group=3Dqemu - ;; - *debian*) - default_qemu_user=3Dlibvirt-qemu - default_qemu_group=3Dlibvirt-qemu - ;; - *ubuntu*) - default_qemu_user=3Dlibvirt-qemu - default_qemu_group=3Dkvm - ;; - *) - default_qemu_user=3Droot - default_qemu_group=3Droot - ;; - esac - # If the expected user and group don't exist, or we haven't hit any - # of the cases above because we're running on an unknown OS, the only - # sensible fallback is root:root - AC_MSG_CHECKING([for QEMU credentials ($default_qemu_user:$default_qem= u_group)]) - if getent passwd "$default_qemu_user" >/dev/null 2>&1 && \ - getent group "$default_qemu_group" >/dev/null 2>&1; then - AC_MSG_RESULT([ok]) - else - AC_MSG_RESULT([not found, using root:root instead]) - default_qemu_user=3Droot - default_qemu_group=3Droot - fi - fi - - if test "x$with_qemu_user" =3D "xplatform dependent" ; then - QEMU_USER=3D"$default_qemu_user" - else - QEMU_USER=3D"$with_qemu_user" - fi - if test "x$with_qemu_group" =3D "xplatform dependent" ; then - QEMU_GROUP=3D"$default_qemu_group" - else - QEMU_GROUP=3D"$with_qemu_group" - fi - AC_DEFINE_UNQUOTED([QEMU_USER], ["$QEMU_USER"], [QEMU user account]) - AC_DEFINE_UNQUOTED([QEMU_GROUP], ["$QEMU_GROUP"], [QEMU group account]) - - AC_PATH_PROG([QEMU_BRIDGE_HELPER], [qemu-bridge-helper], - [/usr/libexec/qemu-bridge-helper], - [/usr/libexec:/usr/lib/qemu:/usr/lib]) - AC_DEFINE_UNQUOTED([QEMU_BRIDGE_HELPER], ["$QEMU_BRIDGE_HELPER"], - [QEMU bridge helper]) - AC_PATH_PROG([QEMU_PR_HELPER], [qemu-pr-helper], - [/usr/bin/qemu-pr-helper], - [/usr/bin:/usr/libexec]) - AC_DEFINE_UNQUOTED([QEMU_PR_HELPER], ["$QEMU_PR_HELPER"], - [QEMU PR helper]) - AC_PATH_PROG([QEMU_SLIRP_HELPER], [slirp-helper], - [/usr/bin/slirp-helper], - [/usr/bin:/usr/libexec]) - AC_DEFINE_UNQUOTED([QEMU_SLIRP_HELPER], ["$QEMU_SLIRP_HELPER"], - [QEMU slirp helper]) - - AC_PATH_PROG([QEMU_DBUS_DAEMON], [dbus-daemon], - [/usr/bin/dbus-daemon], - [/usr/bin:/usr/libexec]) - AC_DEFINE_UNQUOTED([QEMU_DBUS_DAEMON], ["$QEMU_DBUS_DAEMON"], - [QEMU dbus daemon]) -]) - -AC_DEFUN([LIBVIRT_DRIVER_RESULT_QEMU], [ - LIBVIRT_RESULT([QEMU], [$with_qemu]) -]) - -AC_DEFUN([LIBVIRT_RESULT_QEMU_PRIVILEGES], [ - if test "$QEMU_USER" =3D "root"; then - LIBVIRT_RESULT([QEMU], [$QEMU_USER:$QEMU_GROUP], - [!!! running QEMU as root is strongly discouraged !!!]) - else - LIBVIRT_RESULT([QEMU], [$QEMU_USER:$QEMU_GROUP]) - fi -]) diff --git a/meson.build b/meson.build index cae9743f5b2..b7710bd0fcb 100644 --- a/meson.build +++ b/meson.build @@ -1689,6 +1689,121 @@ elif get_option('driver_openvz').enabled() error('OpenVZ driver can be enabled on Linux only') endif =20 +if not get_option('driver_qemu').disabled() + use_qemu =3D true + + if not yajl_dep.found() + use_qemu =3D false + if get_option('driver_qemu').enabled() + error('YAJL 2 is required to build QEMU driver') + endif + endif + + if not conf.has('WITH_LIBVIRTD') + use_qemu =3D false + if get_option('driver_qemu').enabled() + error('libvirtd is required to build QEMU driver') + endif + endif + + if use_qemu + conf.set('WITH_QEMU', 1) + + if host_machine.system() in ['freebsd', 'darwin'] + default_qemu_user =3D 'root' + default_qemu_group =3D 'wheel' + else + os_release =3D run_command('grep', '^ID=3D', '/etc/os-release').stdo= ut() + if os_release.contains('arch') + default_qemu_user =3D 'nobody' + default_qemu_group =3D 'nobody' + elif ( os_release.contains('centos') or + os_release.contains('fedora') or + os_release.contains('gentoo') or + os_release.contains('rhel') or + os_release.contains('suse')) + default_qemu_user =3D 'qemu' + default_qemu_group =3D 'qemu' + elif os_release.contains('debian') + default_qemu_user =3D 'libvirt-qemu' + default_qemu_group =3D 'libvirt-qemu' + elif os_release.contains('ubuntu') + default_qemu_user =3D 'libvirt-qemu' + default_qemu_group =3D 'kvm' + else + default_qemu_user =3D 'root' + default_qemu_group =3D 'root' + endif + # If the expected user and group don't exist, or we haven't hit any + # of the cases above bacuse we're running on an unknown OS, the only + # sensible fallback is root:root + if ( run_command('getent', 'passwd', default_qemu_user).returncode()= !=3D 0 and + run_command('getent', 'group', default_qemu_group).returncode()= !=3D 0 ) + default_qemu_user =3D 'root' + default_qemu_group =3D 'root' + endif + endif + qemu_user =3D get_option('qemu_user') + if qemu_user =3D=3D '' + qemu_user =3D default_qemu_user + endif + qemu_group =3D get_option('qemu_group') + if qemu_group =3D=3D '' + qemu_group =3D default_qemu_group + endif + conf.set_quoted('QEMU_USER', qemu_user) + conf.set_quoted('QEMU_GROUP', qemu_group) + + qemu_bridge_prog =3D find_program( + 'qemu-bridge-helper', + dirs: [ '/usr/libexec', '/usr/lib/qemu', '/usr/lib' ], + required: false + ) + if qemu_bridge_prog.found() + qemu_bridge_path =3D qemu_bridge_prog.path() + else + qemu_bridge_path =3D '/usr/libexec/qemu-bridge-helper' + endif + conf.set_quoted('QEMU_BRIDGE_HELPER', qemu_bridge_path) + + qemu_pr_prog =3D find_program( + 'qemu-pr-helper', + dirs: [ '/usr/bin', '/usr/libexec' ], + required: false + ) + if qemu_pr_prog.found() + qemu_pr_path =3D qemu_pr_prog.path() + else + qemu_pr_path =3D '/usr/bin/qemu-pr-helper' + endif + conf.set_quoted('QEMU_PR_HELPER', qemu_pr_path) + + qemu_slirp_prog =3D find_program( + 'slirp-helper', + dirs: [ '/usr/bin', '/usr/libexec' ], + required: false + ) + if qemu_slirp_prog.found() + qemu_slirp_path =3D qemu_slirp_prog.path() + else + qemu_slirp_path =3D '/usr/bin/slirp-helper' + endif + conf.set_quoted('QEMU_SLIRP_HELPER', qemu_slirp_path) + + qemu_dbus_daemon_prog =3D find_program( + 'dbus-daemon', + dirs: [ '/usr/bin', '/usr/libexec' ], + required: false + ) + if qemu_dbus_daemon_prog.found() + qemu_dbus_daemon_path =3D qemu_dbus_daemon_prog.path() + else + qemu_dbus_daemon_path =3D '/usr/bin/dbus-daemon' + endif + conf.set_quoted('QEMU_DBUS_DAEMON', qemu_dbus_daemon_path) + endif +endif + =20 # define top include directory =20 @@ -1709,6 +1824,7 @@ configure_file(output: 'meson-config.h', configuratio= n: conf) # print configuration summary =20 driver_summary =3D { + 'QEMU': conf.has('WITH_QEMU'), 'OpenVZ': conf.has('WITH_OPENVZ'), 'libxl': conf.has('WITH_LIBXL'), 'LXC': conf.has('WITH_LXC'), @@ -1783,3 +1899,14 @@ devtools_summary =3D { 'wireshark_dissector': wireshark_dep.found(), } summary(devtools_summary, section: 'Developer Tools', bool_yn: true) + +if conf.has('WITH_QEMU') + qemu_warn =3D '' + if qemu_user =3D=3D 'root' + qemu_warn =3D ' !!! running QEMU as root is strongly discouraged !!!' + endif + priv_summary =3D { + 'QEMU': '@0@:@1@@2@'.format(qemu_user, qemu_group, qemu_warn), + } + summary(priv_summary, section: 'Privileges') +endif diff --git a/meson_options.txt b/meson_options.txt index dbe56561752..4f8cddd0aee 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -54,5 +54,8 @@ option('driver_libvirtd', type: 'feature', value: 'auto',= description: 'libvirtd option('driver_libxl', type: 'feature', value: 'auto', description: 'libxe= nlight driver') option('driver_lxc', type: 'feature', value: 'auto', description: 'Linux C= ontainer driver') option('driver_openvz', type: 'feature', value: 'auto', description: 'Open= VZ driver') +option('driver_qemu', type: 'feature', value: 'auto', description: 'QEMU/K= VM driver') +option('qemu_user', type: 'string', value: '', description: 'username to r= un QEMU system instance as') +option('qemu_group', type: 'string', value: '', description: 'groupname to= run QEMU system instance as') option('driver_remote', type: 'feature', value: 'enabled', description: 'r= emote driver') option('remote_default_mode', type: 'combo', choices: ['legacy', 'direct']= , value: 'legacy', description: 'remote driver default mode') --=20 2.26.2