Skip to content

fix: patch RPATH on staged libs to fix libvirt_iohelper missing libxml2#179

Merged
gboutry merged 1 commit into
canonical:mainfrom
hemanthnakkina:server-suspend
Apr 29, 2026
Merged

fix: patch RPATH on staged libs to fix libvirt_iohelper missing libxml2#179
gboutry merged 1 commit into
canonical:mainfrom
hemanthnakkina:server-suspend

Conversation

@hemanthnakkina
Copy link
Copy Markdown
Collaborator

@hemanthnakkina hemanthnakkina commented Apr 29, 2026

libvirt_iohelper is spawned by virFileWrapperFdNew() with a minimal environment containing only LIBVIRT_LOG_OUTPUTS=1:stderr. The parent libvirtd's LD_LIBRARY_PATH is never propagated to the child, so staged shared libraries (libxml2, libyajl, libicuuc, etc.) in usr/lib/x86_64-linux-gnu/ are not found, causing server suspend to fail:

operation failed: .../libvirt_iohelper: error while loading shared
libraries: libxml2.so.2: cannot open shared object file: No such
file or directory

Fix by adding build-attributes: [enable-patchelf] to the libvirt part.
Snapcraft sets RPATH (old DT_RPATH tag, not RUNPATH) with $ORIGIN on
libvirt-built ELF files, enabling the dynamic linker to locate staged
libraries transitively — without requiring a build-time patchelf script.

Fixes: https://bugs.launchpad.net/snap-openstack/+bug/2150555

Assisted-by: Claude:claude-4.6-sonnet

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the snap build to ensure libvirt_iohelper can reliably resolve staged shared-library dependencies at runtime (without relying on LD_LIBRARY_PATH) by embedding an RPATH into staged ELF shared libraries during the prime step.

Changes:

  • Add patchelf as a build dependency for the libvirt part.
  • Add an override-prime step that uses patchelf to add an arch-aware RPATH pointing at /snap/<name>/current/usr/lib/<multiarch-triplet> for staged shared libraries under usr/lib.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread snap/snapcraft.yaml Outdated
Comment thread snap/snapcraft.yaml Outdated
Copy link
Copy Markdown
Collaborator

@gboutry gboutry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this cannot be solved from updating the build command?

https://documentation.ubuntu.com/snapcraft/stable/how-to/debugging/use-the-classic-linter/

libvirt_iohelper is spawned by virFileWrapperFdNew() with a minimal
environment containing only LIBVIRT_LOG_OUTPUTS=1:stderr. The parent
libvirtd's LD_LIBRARY_PATH is never propagated to the child, so staged
shared libraries (libxml2, libyajl, libicuuc, etc.) in
usr/lib/x86_64-linux-gnu/ are not found, causing server suspend to fail:

   operation failed: .../libvirt_iohelper: error while loading shared
   libraries: libxml2.so.2: cannot open shared object file: No such
   file or directory

Fix by adding build-attributes: [enable-patchelf] to the libvirt part.
 Snapcraft sets RPATH (old DT_RPATH tag, not RUNPATH) with $ORIGIN on
 libvirt-built ELF files, enabling the dynamic linker to locate staged
 libraries transitively — without requiring a build-time patchelf script.

Fixes: https://bugs.launchpad.net/snap-openstack/+bug/2150555

Assisted-by: Claude:claude-4.6-sonnet
Signed-off-by: Hemanth Nakkina <hemanth.nakkina@canonical.com>
@hemanthnakkina
Copy link
Copy Markdown
Collaborator Author

I wonder if this cannot be solved from updating the build command?

https://documentation.ubuntu.com/snapcraft/stable/how-to/debugging/use-the-classic-linter/

Yes it worked.. pushed the new change

@hemanthnakkina hemanthnakkina requested a review from gboutry April 29, 2026 09:46
@gboutry gboutry merged commit 63d3241 into canonical:main Apr 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants