[libvirt PATCH] qemu: Use real defaults for user and group in qemu.conf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The default values used by the library are determined at configure
time based on a number of factors, and we should reflect them in
the installed configuration file to make the comments it contains
more useful.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/263
Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/qemu/meson.build                 | 30 +++++++++++++++++++++++++---
 src/qemu/{qemu.conf => qemu.conf.in} |  4 ++--
 src/qemu/test_libvirtd_qemu.aug.in   |  4 ++--
 3 files changed, 31 insertions(+), 7 deletions(-)
 rename src/qemu/{qemu.conf => qemu.conf.in} (99%)

diff --git a/src/qemu/meson.build b/src/qemu/meson.build
index 39f0f615cc..96952cc52d 100644
--- a/src/qemu/meson.build
+++ b/src/qemu/meson.build
@@ -130,12 +130,36 @@ if conf.has('WITH_QEMU')
     ],
   }
 
-  virt_conf_files += files('qemu.conf')
+  qemu_user_group_conf = configuration_data({
+    'QEMU_USER': qemu_user,
+    'QEMU_GROUP': qemu_group,
+  })
+  qemu_conf = configure_file(
+    input: 'qemu.conf.in',
+    output: 'qemu.conf',
+    configuration: qemu_user_group_conf,
+  )
+
+  qemu_user_group_hack_conf = configuration_data({
+    'QEMU_USER': qemu_user,
+    'QEMU_GROUP': qemu_group,
+    # This hack is necessary because the output file is going to be
+    # used as input for another configure_file() call later, which
+    # will take care of substituting @CONFIG@ with useful data
+    'CONFIG': '@CONFIG@',
+  })
+  test_libvirtd_qemu_aug_tmp = configure_file(
+    input: 'test_libvirtd_qemu.aug.in',
+    output: 'test_libvirtd_qemu.aug.tmp',
+    configuration: qemu_user_group_hack_conf,
+  )
+
+  virt_conf_files += qemu_conf
   virt_aug_files += files('libvirtd_qemu.aug')
   virt_test_aug_files += {
     'name': 'test_libvirtd_qemu.aug',
-    'aug': files('test_libvirtd_qemu.aug.in'),
-    'conf': files('qemu.conf'),
+    'aug': test_libvirtd_qemu_aug_tmp,
+    'conf': qemu_conf,
     'test_name': 'libvirtd_qemu',
     'test_srcdir': meson.current_source_dir(),
     'test_builddir': meson.current_build_dir(),
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf.in
similarity index 99%
rename from src/qemu/qemu.conf
rename to src/qemu/qemu.conf.in
index 71fd125699..04b7740136 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf.in
@@ -516,11 +516,11 @@
 #       user = "+0"     # Super user (uid=0)
 #       user = "100"    # A user named "100" or a user with uid=100
 #
-#user = "root"
+#user = "@QEMU_USER@"
 
 # The group for QEMU processes run by the system instance. It can be
 # specified in a similar way to user.
-#group = "root"
+#group = "@QEMU_GROUP@"
 
 # Whether libvirt should dynamically change file ownership
 # to match the configured user/group above. Defaults to 1.
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 20a89ade32..757d21c33f 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -47,8 +47,8 @@ module Test_libvirtd_qemu =
 { "security_driver" = "selinux" }
 { "security_default_confined" = "1" }
 { "security_require_confined" = "1" }
-{ "user" = "root" }
-{ "group" = "root" }
+{ "user" = "@QEMU_USER@" }
+{ "group" = "@QEMU_GROUP@" }
 { "dynamic_ownership" = "1" }
 { "remember_owner" = "1" }
 { "cgroup_controllers"
-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux