[PATCH v1] meson: recognize sles when guessing default_qemu_user

Olaf Hering olaf at aepfle.de
Wed Jan 26 13:31:01 UTC 2022

Tue, 25 Jan 2022 10:11:01 -0800 Andrea Bolognani <abologna at redhat.com>:

> Do you mean that if the user has passed
>   -Dqemu_user=... -Dqemu_group=...
> to meson we could skip the detection logic? That'd be nice, but I'm
> afraid it might make the code less readable for very little gain.

The whole thing will be just a whitespace change because it goes into its own block:

    qemu_user = get_option('qemu_user')
    qemu_group = get_option('qemu_group')
    if qemu_user == '' or qemu_group == ''
      if host_machine.system() in [ 'freebsd', 'darwin' ]
        default_qemu_user = 'root'
        default_qemu_group = 'wheel'
        os_release = run_command('grep', '^ID=', '/etc/os-release', check: true).stdout()
        if os_release.contains('arch')
          default_qemu_user = 'nobody'
          default_qemu_group = '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('sles') or
          default_qemu_user = 'qemu'
          default_qemu_group = 'qemu'
        elif os_release.contains('debian')
          default_qemu_user = 'libvirt-qemu'
          default_qemu_group = 'libvirt-qemu'
        elif os_release.contains('ubuntu')
          default_qemu_user = 'libvirt-qemu'
          default_qemu_group = 'kvm'
          default_qemu_user = 'root'
          default_qemu_group = 'root'
        # 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, check: false).returncode() != 0 and
            run_command('getent', 'group', default_qemu_group, check: false).returncode() != 0)
          default_qemu_user = 'root'
          default_qemu_group = 'root'
      qemu_group = default_qemu_group
      qemu_user = default_qemu_user
    conf.set_quoted('QEMU_USER', qemu_user)
    conf.set_quoted('QEMU_GROUP', qemu_group)

This looks like an opportunity to get rid of default_qemu_user/group.

The getent part is bogus because it forces the user/group to be present on the system
which is building libvirt. This build system is usually not the system which runs libvirt.
Please fix bug this as well.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: Digitale Signatur von OpenPGP
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220126/fd9c3558/attachment-0001.sig>

More information about the libvir-list mailing list