Bug 2233744

Summary: The path to the guest agent socket file can become too long and cause problems [rhel-9.2.0.z]
Product: Red Hat Enterprise Linux 9 Reporter: RHEL Program Management Team <pgm-rhel-tools>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
libvirt sub component: General QA Contact: Lili Zhu <lizhu>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: unspecified CC: aasserzo, acardace, bbenshab, bstinson, ibezukh, jdenemar, jhopper, jlejosne, jsuchane, jwboyer, kbidarka, lmen, mprivozn, qixuan.wang, smitterl, virt-maint, yadu, yalzhang, ycui, ymankad
Version: CentOS StreamKeywords: Triaged, ZStream
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-9.0.0-10.3.el9_2 Doc Type: Bug Fix
Doc Text:
Cause: When there's no path provided for a guest <channel/> libvirt generates one. But it uses a very long prefix for that ("/var/lib/libvirt/qemu/channel/target/") which makes it very easy to hit the limit for socket paths. Consequence: Users are unable to connect to the host side of the socket. Fix: The location of the socket was moved under "/var/run/". Result: The path is now much shorter and users can connect to the socket just fine.
Story Points: ---
Clone Of: 2173980 Environment:
Last Closed: 2023-09-12 10:13:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2173980    
Bug Blocks:    

Comment 1 Michal Privoznik 2023-08-23 12:45:45 UTC
To POST:

https://gitlab.com/redhat/rhel/src/libvirt/-/merge_requests/121

Comment 7 yalzhang@redhat.com 2023-09-01 10:24:43 UTC
Test on libvirt-9.0.0-10.3.el9_2.x86_64, the result is as expected

1. Start the vm and check the guest agent socket path:
<channel type="unix">
  <target type="virtio" name="org.qemu.guest_agent.0"/>
  <address type="virtio-serial" controller="0" bus="0" port="1"/>
</channel>

After vm started with root user, check the socket path:
<channel type="unix">
  <source mode="bind" path="/run/libvirt/qemu/channel/1-rhel/org.qemu.guest_agent.0"/>
  <target type="virtio" name="org.qemu.guest_agent.0" state="connected"/>
  <alias name="channel3"/>
  <address type="virtio-serial" controller="0" bus="0" port="1"/>
</channel>

After vm started with unprivileged user test(uid: 1000), check the socket path:
<channel type="unix">
  <source mode="bind" path="/run/user/1000/libvirt/qemu/run/channel/1-test/org.qemu.guest_agent.0"/>
  <target type="virtio" name="org.qemu.guest_agent.0" state="connected"/>
  <alias name="channel0"/>
  <address type="virtio-serial" controller="0" bus="0" port="1"/>
</channel>

2. The socket path updated as expected(delete the "target/domain-" and place the channel target dir into state dir):
With root(domain name is “rhel”):
Before: /var/lib/libvirt/qemu/channel/target/domain-2-rhel/org.qemu.guest_agent.0   length=73
After: /run/libvirt/qemu/channel/1-rhel/org.qemu.guest_agent.0                      length=55

With unprivileged user test(domain name is “test”):
Before: /home/test/.config/libvirt/qemu/channel/target/domain-2-test/org.qemu.guest_agent.0  length= 83
After: /run/user/1000/libvirt/qemu/run/channel/1-test/org.qemu.guest_agent.0                 length= 69

For root user, the socket path length decrease by 18; for non-root user, it decrease by 14;

3. Check the guest agent function - pass
4. Domain lifecycle test - pass
5. Hotplug and unplug - pass
6. Migration and cross migration - pass

Comment 11 errata-xmlrpc 2023-09-12 10:13:31 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 (libvirt bug fix 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/RHBA-2023:5089