]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Use real defaults for user and group in qemu.conf
authorAndrea Bolognani <abologna@redhat.com>
Mon, 28 Mar 2022 13:26:11 +0000 (15:26 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 1 Apr 2022 13:32:48 +0000 (15:32 +0200)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/meson.build
src/qemu/qemu.conf.in [moved from src/qemu/qemu.conf with 99% similarity]
src/qemu/test_libvirtd_qemu.aug.in

index 39f0f615cc28741424518fe7b960992cc1edf16b..96952cc52db5caeb53fc92e599b68ba304fc938c 100644 (file)
@@ -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(),
similarity index 99%
rename from src/qemu/qemu.conf
rename to src/qemu/qemu.conf.in
index 71fd125699c702171f17b91d4496adb041c6fdef..04b77401363a3869f43f36099a112d1ec99ac9e6 100644 (file)
 #       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.
index 20a89ade3225330008b513941b9eced22fe39b07..757d21c33f84e34ac3a9b6f534b3fba6a51b3756 100644 (file)
@@ -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"