Bug 2136591

Summary: libvirt-guests needs virsh
Product: Red Hat Enterprise Linux 8 Reporter: FS3000 <fs3000>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: yalzhang <yalzhang>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.6CC: jdenemar, jsuchane, virt-maint, yalzhang
Target Milestone: rcKeywords: Triaged, Upstream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-8.0.0-12.module+el8.8.0+17545+95582d4e Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-16 08:16:35 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.10.0
Embargoed:
Deadline: 2022-12-19   

Description FS3000 2022-10-20 18:09:01 UTC
Description of problem:
The libvirt-guests service depends on virsh to execute commands. However, virsh (libvirt-client) doesn't get installed when installing  libvirt-daemon. 


Version-Release number of selected component (if applicable):
libvirt-daemon-8.0.0-5.4.module+el8.6.0+16370+bb85faee.x86_64


How reproducible:
Everytime.


Steps to Reproduce:
1. Manually execute /usr/libexec/libvirt-guests.sh stop|start
2.
3.


Actual results:
Fails with "Can't connect to default. Skipping" error.


Expected results:
To sucessfully run using virsh.


Additional info:
libvirt-client should be installed when intalling libvirt-daemon.

Comment 1 Jaroslav Suchanek 2022-10-21 11:13:45 UTC
The recommended way for installing libvirt in RHEL-8 is through libvirt meta-package,

# yum module install virt
# yum install libvirt

(our official documentation is using virt-install as example, which would pull in all packages including libvirt-client and libvirt-daemon,
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_virtualization/getting-started-with-virtualization-in-rhel-8_configuring-and-managing-virtualization)

Thus I would say, it's not recommended/supported to install specific libvirt subpackages.

Jirka, any other idea?

Comment 2 FS3000 2022-10-29 11:54:05 UTC
Alright, but  not everyone installs according to the docs, specially for such a common thing. The fix this is so easy, just make libvirt-client a dependency for libvirt-daemon.

Comment 3 Jiri Denemark 2022-11-03 14:18:33 UTC
There's certainly nothing bad about installing individual subpackages,
although optional dependencies will need to be handled manually. Using virtual
packages (libvirt, libvirt-daemon-kvm, ...) will install even the optional
dependencies.

Anyway, this is quite irrelevant for the libvirt-guests issue as that is
included in the libvirt-daemon package, but completely useless until
libvirt-client is installed. This issue was introduced ~6 years ago when
libvirt-libs package was separated from libvirt-client so that libvirt-daemon
can only depend on libvirt-libs (with a false observation saying it does not
need anything else from libvirt-client). That said, the change made sense as
you really don't need to have client binaries installed if you only want to
run libvirtd and access it via network or various language bindings. So just
adding libvirt-client back as a dependence for libvirt-daemon would be a step
back.

Let's see if I can come up with a solution that would work for both use cases.
I already have an idea how to deal with this, but need to check if it's
feasible and reasonable.

Comment 4 Jiri Denemark 2022-11-08 09:45:28 UTC
This issue has just been fixed upstream by

commit 9995ff1352a1ca239b324b3256484ecfed863fb5
Refs: v8.9.0-131-g9995ff1352
Author:     Jiri Denemark <jdenemar>
AuthorDate: Thu Nov 3 17:11:19 2022 +0100
Commit:     Jiri Denemark <jdenemar>
CommitDate: Tue Nov 8 10:35:18 2022 +0100

    spec: libvirt-daemon: Add optional dependency on *-client

    The libvirt-daemon subpackage contains libvirt-guests.sh script (used by
    libvirt-guests service), which requires virsh to actually work. But
    since dynamic libraries were separated from libvirt-client to
    libvirt-libs more than 6 years ago, libvirt-daemon no longer requires
    virsh to be installed. So unless libvirt-client is explicitly installed
    (either manually or by installing the libvirt meta package),
    libvirt-guests will not work.

    Just adding libvirt-client as a dependency of libvirt-daemon would go
    against the original idea behind splitting libvirt-client: users may not
    want to install or use any client binaries on the host where the daemon
    runs (either they just use various language bindings or access the
    daemon remotely). To solve this we could possibly turn libvirt-daemon
    into an empty package and separate the daemons and libvirt-guests into
    subpackages to make sure we support both use cases, but marking
    libvirt-client as Recommended for libvirt-daemon does the same job in a
    much simpler way.

    https://bugzilla.redhat.com/show_bug.cgi?id=2136591

    Signed-off-by: Jiri Denemark <jdenemar>
    Reviewed-by: Martin Kletzander <mkletzan>
    Reviewed-by: Andrea Bolognani <abologna>

Comment 5 FS3000 2022-11-11 15:03:14 UTC
I understand the dillema. I say that, if libvirt-guests is going to be installed with the daemon package, then make it work somehow regardless of how the package was installed. Otherwise what's the pont of having it there?
From what i undersand, if the libvirt-guests service isn't running, guests are forcibly shut down just like if you pressed and holded the power button. In fact, i just checked, the -guests service is disabled by default. How can this be ok?

Is there any good reason for not wanting the client binaries installed? I guess, anyone that really don't want them in the system, can always forcibly remove the client. And run the risk of having guests hammered down when rebooting/shuting down the host.

Comment 6 Jiri Denemark 2022-11-11 15:47:36 UTC
Right, and that's exactly how the Recommended dependency works. The
libvirt-client package will be installed as a dependency of libvirt-daemon on
upgrade or fresh installation. But RPM will allow libvirt-client to be removed
afterwards and in that case it will no longer be installed when libvirt-daemon
is upgraded.

Comment 7 FS3000 2022-11-11 17:19:46 UTC
Sounds great!

Now, do you still think it is ok to leave libvirt-guest service disabled by default?

Comment 9 yalzhang@redhat.com 2022-12-14 06:19:09 UTC
Hi Jiri,

Even though libvirt-client is installed, there is still such error "Can't connect to default. Skipping.". Please help to check it. Thank you!

Reproduce on libvirt 8.0.0-5:

1. install libvirt-daemon, libvirt-client will not be installed:
# yum install -y libvirt-daemon
Last metadata expiration check: 1:59:07 ago on Tue 13 Dec 2022 10:50:58 PM EST.
Dependencies resolved.
=====================================================================================================================================
 Package                         Architecture         Version                                               Repository          Size
=====================================================================================================================================
Installing:
 libvirt-daemon                  x86_64               8.0.0-5.module+el8.6.0+14480+c0a3aa0f                 app                417 k
Installing dependencies:
 cyrus-sasl                      x86_64               2.1.27-6.el8_5                                        base                96 k
 cyrus-sasl-gssapi               x86_64               2.1.27-6.el8_5                                        base                50 k
 iproute-tc                      x86_64               5.15.0-4.el8                                          base               464 k
 iptables-libs                   x86_64               1.8.4-22.el8                                          base               108 k
 libvirt-libs                    x86_64               8.0.0-5.module+el8.6.0+14480+c0a3aa0f                 app                4.7 M
 numad                           x86_64               0.5-26.20150602git.el8                                base                41 k
 yajl                            x86_64               2.1.0-10.el8                                          app                 41 k
Installing weak dependencies:
 nmap-ncat                       x86_64               2:7.70-6.el8                                          app                237 k

Transaction Summary
=====================================================================================================================================
Install  9 Packages

Total download size: 6.1 M
Installed size: 27 M
Downloading Packages:
......

2. run the command in command 0:
# /usr/libexec/libvirt-guests.sh start
# /usr/libexec/libvirt-guests.sh stop
Can't connect to default. Skipping.

Test on libvirt-8.0.0-12.module+el8.8.0+17545+95582d4e.x86_64:
1. install libvirt-daemon, check the libvirt-client will be installed as dependency: 
# yum install -y libvirt-daemon
Last metadata expiration check: 2:17:07 ago on Tue 13 Dec 2022 10:37:36 PM EST.
Dependencies resolved.
=====================================================================================================================================
 Package                         Architecture         Version                                               Repository          Size
=====================================================================================================================================
Installing:
 libvirt-daemon                  x86_64               8.0.0-12.module+el8.8.0+17545+95582d4e                ci                 419 k
Installing dependencies:
 autogen-libopts                 x86_64               5.18.12-8.el8                                         app                 75 k
 cyrus-sasl                      x86_64               2.1.27-6.el8_5                                        base                96 k
 cyrus-sasl-gssapi               x86_64               2.1.27-6.el8_5                                        base                50 k
 gnutls-dane                     x86_64               3.6.16-5.el8_6                                        app                 52 k
 gnutls-utils                    x86_64               3.6.16-5.el8_6                                        app                348 k
 iproute-tc                      x86_64               5.18.0-1.el8                                          base               466 k
 iptables-libs                   x86_64               1.8.4-24.el8                                          base               109 k
 libvirt-libs                    x86_64               8.0.0-12.module+el8.8.0+17545+95582d4e                ci                 4.7 M
 numad                           x86_64               0.5-26.20150602git.el8                                base                41 k
 yajl                            x86_64               2.1.0-11.el8                                          app                 41 k
Installing weak dependencies:
 libvirt-client                  x86_64               8.0.0-12.module+el8.8.0+17545+95582d4e                ci                 415 k
 nmap-ncat                       x86_64               2:7.70-8.el8                                          app                237 k
Enabling module streams:
 virt                                                 rhel                                                                          

Transaction Summary
=====================================================================================================================================
Install  13 Packages

Total download size: 7.0 M
Installed size: 29 M
Downloading Packages:
......
# rpm -qa | grep libvirt
libvirt-daemon-8.0.0-12.module+el8.8.0+17545+95582d4e.x86_64
libvirt-client-8.0.0-12.module+el8.8.0+17545+95582d4e.x86_64
libvirt-libs-8.0.0-12.module+el8.8.0+17545+95582d4e.x86_64

2. Try the command in comment 0:
# /usr/libexec/libvirt-guests.sh start
# /usr/libexec/libvirt-guests.sh stop
Can't connect to default. Skipping.

3. try to start and stop the service, there will be the same error in the log
# systemctl start libvirt-guests
# systemctl stop libvirt-guests
[root@rhel88 ~]# systemctl status libvirt-guests
● libvirt-guests.service - Suspend/Resume Running libvirt Guests
   Loaded: loaded (/usr/lib/systemd/system/libvirt-guests.service; disabled; vendor preset: disabled)
   Active: inactive (dead) since Wed 2022-12-14 01:17:13 EST; 2s ago
     Docs: man:libvirtd(8)
           https://libvirt.org
  Process: 1502 ExecStop=/usr/libexec/libvirt-guests.sh stop (code=exited, status=0/SUCCESS)
  Process: 1485 ExecStart=/usr/libexec/libvirt-guests.sh start (code=exited, status=0/SUCCESS)
 Main PID: 1485 (code=exited, status=0/SUCCESS)

Dec 14 01:17:01 rhel88 systemd[1]: Starting Suspend/Resume Running libvirt Guests...
Dec 14 01:17:01 rhel88 systemd[1]: Started Suspend/Resume Running libvirt Guests.
Dec 14 01:17:13 rhel88 systemd[1]: Stopping Suspend/Resume Running libvirt Guests...
Dec 14 01:17:13 rhel88 libvirt-guests.sh[1514]: Can't connect to default. Skipping.
Dec 14 01:17:13 rhel88 systemd[1]: libvirt-guests.service: Succeeded.
Dec 14 01:17:13 rhel88 systemd[1]: Stopped Suspend/Resume Running libvirt Guests.

Comment 12 Jiri Denemark 2022-12-14 14:04:46 UTC
(In reply to yalzhang from comment #9)
> # rpm -qa | grep libvirt
> libvirt-daemon-8.0.0-12.module+el8.8.0+17545+95582d4e.x86_64
> libvirt-client-8.0.0-12.module+el8.8.0+17545+95582d4e.x86_64
> libvirt-libs-8.0.0-12.module+el8.8.0+17545+95582d4e.x86_64
> 
> 2. Try the command in comment 0:
> # /usr/libexec/libvirt-guests.sh start
> # /usr/libexec/libvirt-guests.sh stop
> Can't connect to default. Skipping.

That's correct, you don't have any local hypervisor driver installed. You'd
need to install, e.g., libvirt-daemon-kvm instead of libvirt-daemon to get all
dependencies to run QEMU/KVM domains.

Comment 13 yalzhang@redhat.com 2022-12-15 03:10:38 UTC
Hi Jiri, Thank you. After libvirt-daemon-kvm installed, no error occurs. The result is as expected, set the bug as verified.
[root@rhel88 ~]# /usr/libexec/libvirt-guests.sh start
[root@rhel88 ~]# /usr/libexec/libvirt-guests.sh stop

Running guests on default URI: no running guests.

Comment 15 errata-xmlrpc 2023-05-16 08:16:35 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 (Moderate: virt:rhel and virt-devel:rhel security, bug fix, and enhancement update), 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/RHSA-2023:2757