[PATCH v5 1/3] libvirt.spec: relocate pre script of daemon-driver-qemu

Olaf Hering posted 3 patches 4 years, 1 month ago
There is a newer version of this series
[PATCH v5 1/3] libvirt.spec: relocate pre script of daemon-driver-qemu
Posted by Olaf Hering 4 years, 1 month ago
Reduce the delta in an upcoming change.
No change in behavior intended.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 libvirt.spec.in | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index f6c705564a..4675e67d15 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1466,6 +1466,21 @@ fi
 
 
 %if %{with_qemu}
+%pre daemon-driver-qemu
+# We want soft static allocation of well-known ids, as disk images
+# are commonly shared across NFS mounts by id rather than name; see
+# https://fedoraproject.org/wiki/Packaging:UsersAndGroups
+getent group kvm >/dev/null || groupadd -f -g 36 -r kvm
+getent group qemu >/dev/null || groupadd -f -g 107 -r qemu
+if ! getent passwd qemu >/dev/null; then
+  if ! getent passwd 107 >/dev/null; then
+    useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
+  else
+    useradd -r -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
+  fi
+fi
+exit 0
+
 %post daemon-driver-qemu
     %if %{with_modular_daemons}
 %libvirt_daemon_systemd_post virtqemud
@@ -1587,23 +1602,6 @@ done
 %libvirt_daemon_perform_restart libvirtd
 %libvirt_daemon_perform_restart virtnwfilterd
 
-%if %{with_qemu}
-%pre daemon-driver-qemu
-# We want soft static allocation of well-known ids, as disk images
-# are commonly shared across NFS mounts by id rather than name; see
-# https://fedoraproject.org/wiki/Packaging:UsersAndGroups
-getent group kvm >/dev/null || groupadd -f -g 36 -r kvm
-getent group qemu >/dev/null || groupadd -f -g 107 -r qemu
-if ! getent passwd qemu >/dev/null; then
-  if ! getent passwd 107 >/dev/null; then
-    useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
-  else
-    useradd -r -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
-  fi
-fi
-exit 0
-%endif
-
 %if %{with_lxc}
 %pre login-shell
 getent group virtlogin >/dev/null || groupadd -r virtlogin

Re: [PATCH v5 1/3] libvirt.spec: relocate pre script of daemon-driver-qemu
Posted by Jim Fehlig 4 years, 1 month ago
On 12/16/21 08:14, Olaf Hering wrote:
> Reduce the delta in an upcoming change.
> No change in behavior intended.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> ---
>   libvirt.spec.in | 32 +++++++++++++++-----------------
>   1 file changed, 15 insertions(+), 17 deletions(-)

IMO, putting the RPM scriptlet code within one conditional is a good change 
regardless of the outcome of this series.

> diff --git a/libvirt.spec.in b/libvirt.spec.in
> index f6c705564a..4675e67d15 100644
> --- a/libvirt.spec.in
> +++ b/libvirt.spec.in
> @@ -1466,6 +1466,21 @@ fi
>   
>   
>   %if %{with_qemu}
> +%pre daemon-driver-qemu
> +# We want soft static allocation of well-known ids, as disk images
> +# are commonly shared across NFS mounts by id rather than name; see
> +# https://fedoraproject.org/wiki/Packaging:UsersAndGroups
> +getent group kvm >/dev/null || groupadd -f -g 36 -r kvm
> +getent group qemu >/dev/null || groupadd -f -g 107 -r qemu
> +if ! getent passwd qemu >/dev/null; then
> +  if ! getent passwd 107 >/dev/null; then
> +    useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
> +  else
> +    useradd -r -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
> +  fi
> +fi
> +exit 0
> +
>   %post daemon-driver-qemu
>       %if %{with_modular_daemons}
>   %libvirt_daemon_systemd_post virtqemud
> @@ -1587,23 +1602,6 @@ done
>   %libvirt_daemon_perform_restart libvirtd
>   %libvirt_daemon_perform_restart virtnwfilterd
>   
> -%if %{with_qemu}
> -%pre daemon-driver-qemu
> -# We want soft static allocation of well-known ids, as disk images
> -# are commonly shared across NFS mounts by id rather than name; see
> -# https://fedoraproject.org/wiki/Packaging:UsersAndGroups
> -getent group kvm >/dev/null || groupadd -f -g 36 -r kvm
> -getent group qemu >/dev/null || groupadd -f -g 107 -r qemu
> -if ! getent passwd qemu >/dev/null; then
> -  if ! getent passwd 107 >/dev/null; then
> -    useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
> -  else
> -    useradd -r -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
> -  fi
> -fi
> -exit 0
> -%endif
> -

Same could be said for the below lxc %pre scriptlet

>   %if %{with_lxc}
>   %pre login-shell
>   getent group virtlogin >/dev/null || groupadd -r virtlogin

Regards,
Jim