Bug 2032365

Summary: libvirt-daemon scriptlet fails to disable units and close sockets during package removal
Product: Red Hat Enterprise Linux 9 Reporter: smitterl
Component: libvirtAssignee: Daniel Berrangé <berrange>
libvirt sub component: General QA Contact: yafu <yafu>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: unspecified CC: berrange, jdenemar, jjaburek, pkrempa, virt-maint, xuzhang, yafu, yanqzhan
Version: 9.0Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-8.0.0-0rc1.1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 12:45:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version: 8.0.0
Embargoed:

Description smitterl 2021-12-14 12:07:53 UTC
Description of problem:
When removing all libvirt\* packages, log and lock sockets are not cleaned up.

Version-Release number of selected component (if applicable):
libvirt-7.10.0-1.el9.s390x

How reproducible:
100%

Steps to Reproduce:
1. yum install -y libvirt qemu-kvm
2. reboot
3. start and destroy a vm
4.
 a. yum remove -y libvirt\*
 b. systemctl list-units --type=socket |grep virt

Actual results:
Ad a.
-----
...
  Running scriptlet: libvirt-daemon-7.10.0-1.el9.s390x                                                                  19/20 
Removed /etc/systemd/system/sockets.target.wants/virtproxyd.socket.
Failed to disable unit: Unit file virtlogd-ro.socket does not exist.
Failed to disable unit: Unit file virtlockdd.service does not exist.

  Erasing          : libvirt-daemon-7.10.0-1.el9.s390x                                                                  19/20 
...

Ad b.
-----
● virtlockd-admin.socket          not-found active listening virtlockd-admin.socket
● virtlockd.socket                not-found active listening virtlockd.socket
● virtlogd-admin.socket           not-found active running   virtlogd-admin.socket
● virtlogd.socket                 not-found active running   virtlogd.socket

Expected results:
Sockets are closed/removed.

Additional notes:
1. After re-installation a vm can be started if all sockets are started for the primary and secondary drivers (qemu network nodedev nwfilter secret storage interface).
2. During package update, the "Failed to disable unit" doesn't reproduce. A vm can be started without issues.

Comment 1 Daniel Berrangé 2021-12-14 16:26:22 UTC
(In reply to smitterl from comment #0)
>   Running scriptlet: libvirt-daemon-7.10.0-1.el9.s390x                      
> 19/20 
> Removed /etc/systemd/system/sockets.target.wants/virtproxyd.socket.
> Failed to disable unit: Unit file virtlogd-ro.socket does not exist.
> Failed to disable unit: Unit file virtlockdd.service does not exist.

Opps, there's a typo here  'virtlockdd' should 'virtlockd'.

https://listman.redhat.com/archives/libvir-list/2021-December/msg00646.html

Also, there's no -ro.socket for virtlogd / virtlockd so we need
to stop refering to that

https://listman.redhat.com/archives/libvir-list/2021-December/msg00651.html

Comment 2 Daniel Berrangé 2021-12-16 17:55:01 UTC
I've confirmed that those two mistakes in the %preun script are what resulted in the systemd socket units being left active after uninstall. So pulling in the two upstream fixes should address this.

Comment 5 yafu 2021-12-23 07:50:25 UTC
Verified pass with libvirt-8.0.0-1.

Comment 9 Jiri Denemark 2022-01-18 08:26:43 UTC
*** Bug 2041626 has been marked as a duplicate of this bug. ***

Comment 10 yafu 2022-01-20 03:10:14 UTC
Test with libvirt-8.0.0-1.el9.x86_64.

Test steps:
1.Install libvirt pkgs:
#yum -y install libvirt*

2.Start virtqemud:
#systemctl start virtqemud

3.Start a guest:
#virsh start vm1

4.Check virtlogd* status:
# systemctl -a | grep -i virtlogd
  virtlogd.service                                                                                               loaded    active   running   Virtual machine log manager
  virtlogd-admin.socket                                                                                          loaded    active   running   Virtual machine log manager socket
  virtlogd.socket      
                                                                                          loaded    active   running   Virtual machine log manager socket

5.Remove libvirt pkgs:
#yum -y remove libvirt*

6.Check daemons installed by libvirt pkgs:
#systemctl -a | grep -i virt
...
● libvirtd.service                                                                                               not-found inactive dead      libvirtd.service
...
● virtnetworkd.service                                                                                           not-found inactive dead      virtnetworkd.service
...                                                                                              
● virt-guest-shutdown.target                                                                                     not-found inactive dead      virt-guest-shutdown.target
...

7.Install libvirt pkgs again:
#yum -y install libvirt*

8.Start virtqemud service:
#systemctl start virtqemud

9.Start a guest:
#virsh start vm1
Domain 'vm1' started

10.Check virtlogd* service status:
# systemctl -a | grep -i virtlogd
  virtlogd.service                                                                                               loaded    active   running   Virtual machine log manager
  virtlogd-admin.socket                                                                                          loaded    active   running   Virtual machine log manager socket
  virtlogd.socket                                                                                                loaded    active   running   Virtual machine log manager socket


Hi Daniel,
In step4, after removing libvirt pkgs, still show some service info installed by libvirt pkgs. Would you help to check it please?
Thanks.

Comment 11 Daniel Berrangé 2022-01-20 09:05:40 UTC
(In reply to yafu from comment #10)
> Test with libvirt-8.0.0-1.el9.x86_64.
> 
> Test steps:
> 1.Install libvirt pkgs:
> #yum -y install libvirt*
> 
> 2.Start virtqemud:
> #systemctl start virtqemud
> 
> 3.Start a guest:
> #virsh start vm1
> 
> 4.Check virtlogd* status:
> # systemctl -a | grep -i virtlogd
>   virtlogd.service                                                          
> loaded    active   running   Virtual machine log manager
>   virtlogd-admin.socket                                                     
> loaded    active   running   Virtual machine log manager socket
>   virtlogd.socket      
>                                                                             
> loaded    active   running   Virtual machine log manager socket
> 
> 5.Remove libvirt pkgs:
> #yum -y remove libvirt*
> 
> 6.Check daemons installed by libvirt pkgs:
> #systemctl -a | grep -i virt
> ...
> ● libvirtd.service                                                          
> not-found inactive dead      libvirtd.service
> ...
> ● virtnetworkd.service                                                      
> not-found inactive dead      virtnetworkd.service
> ...                                                                         
> 
> ● virt-guest-shutdown.target                                                
> not-found inactive dead      virt-guest-shutdown.target
> ...
> 
> 7.Install libvirt pkgs again:
> #yum -y install libvirt*
> 
> 8.Start virtqemud service:
> #systemctl start virtqemud
> 
> 9.Start a guest:
> #virsh start vm1
> Domain 'vm1' started
> 
> 10.Check virtlogd* service status:
> # systemctl -a | grep -i virtlogd
>   virtlogd.service                                                          
> loaded    active   running   Virtual machine log manager
>   virtlogd-admin.socket                                                     
> loaded    active   running   Virtual machine log manager socket
>   virtlogd.socket                                                           
> loaded    active   running   Virtual machine log manager socket
> 
> 
> Hi Daniel,
> In step4, after removing libvirt pkgs, still show some service info
> installed by libvirt pkgs. Would you help to check it please?
> Thanks.

You started a guest in step (3), but didn't stop it before un-installing libvirt RPMs. It is not a valid scenario to have a guest running while un-installing libvirt. It is possible is is the cause of the behaviour, so could you re-test ensuring any guests and/or virtual networks are stopped before un-installing.

Comment 12 yafu 2022-01-21 08:50:16 UTC
(In reply to Daniel Berrangé from comment #11)
> (In reply to yafu from comment #10)
> > Test with libvirt-8.0.0-1.el9.x86_64.
> > 
> > Test steps:
> > 1.Install libvirt pkgs:
> > #yum -y install libvirt*
> > 
> > 2.Start virtqemud:
> > #systemctl start virtqemud
> > 
> > 3.Start a guest:
> > #virsh start vm1
> > 
> > 4.Check virtlogd* status:
> > # systemctl -a | grep -i virtlogd
> >   virtlogd.service                                                          
> > loaded    active   running   Virtual machine log manager
> >   virtlogd-admin.socket                                                     
> > loaded    active   running   Virtual machine log manager socket
> >   virtlogd.socket      
> >                                                                             
> > loaded    active   running   Virtual machine log manager socket
> > 
> > 5.Remove libvirt pkgs:
> > #yum -y remove libvirt*
> > 
> > 6.Check daemons installed by libvirt pkgs:
> > #systemctl -a | grep -i virt
> > ...
> > ● libvirtd.service                                                          
> > not-found inactive dead      libvirtd.service
> > ...
> > ● virtnetworkd.service                                                      
> > not-found inactive dead      virtnetworkd.service
> > ...                                                                         
> > 
> > ● virt-guest-shutdown.target                                                
> > not-found inactive dead      virt-guest-shutdown.target
> > ...
> > 
> > 7.Install libvirt pkgs again:
> > #yum -y install libvirt*
> > 
> > 8.Start virtqemud service:
> > #systemctl start virtqemud
> > 
> > 9.Start a guest:
> > #virsh start vm1
> > Domain 'vm1' started
> > 
> > 10.Check virtlogd* service status:
> > # systemctl -a | grep -i virtlogd
> >   virtlogd.service                                                          
> > loaded    active   running   Virtual machine log manager
> >   virtlogd-admin.socket                                                     
> > loaded    active   running   Virtual machine log manager socket
> >   virtlogd.socket                                                           
> > loaded    active   running   Virtual machine log manager socket
> > 
> > 
> > Hi Daniel,
> > In step4, after removing libvirt pkgs, still show some service info
> > installed by libvirt pkgs. Would you help to check it please?
> > Thanks.
> 
> You started a guest in step (3), but didn't stop it before un-installing
> libvirt RPMs. It is not a valid scenario to have a guest running while
> un-installing libvirt. It is possible is is the cause of the behaviour, so
> could you re-test ensuring any guests and/or virtual networks are stopped
> before un-installing.

No service left if i removed libvirt pkgs with guests and virtnetworkd service stopped.
Thanks for your clarification.

Comment 13 yafu 2022-01-21 08:51:04 UTC
Move the bug to Verified according to comment 10 - 12.

Comment 15 errata-xmlrpc 2022-05-17 12:45:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: libvirt), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2390