Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1795973

Summary: libguestfs appliance in RHEL non-AV 8 runs out of memory, especially if the RT kernel is used (but probably with non-RT too)
Product: Red Hat Enterprise Linux 8 Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED CURRENTRELEASE QA Contact: YongkuiGuo <yoguo>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.2CC: dgilbert, fiezzi, ptoscano, tyan, tzheng, xchen, yoguo
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-14 07:34:58 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:
Embargoed:
Attachments:
Description Flags
libguestfs-test-tool output
none
Complete list of installed packages
none
libguestfs-test-tool log with kernel-rt-debug* installed none

Description Richard W.M. Jones 2020-01-29 11:18:08 UTC
Description of problem:

With the following packages installed (note RT kernel):

kernel-rt-4.18.0-172.rt13.29.el8.x86_64
qemu-kvm-2.12.0-96.module+el8.2.0+5387+0c6765ef.x86_64
libguestfs-1.38.4-15.module+el8.2.0+5297+222a20af.x86_64

libguestfs fails to work completely.  guestfsd segfaults
at start up.  Inside virt-rescue commands just hang.

Version-Release number of selected component (if applicable):

See above.

How reproducible:

?

Steps to Reproduce:
1. Run libguestfs-test-tool

Additional info:

Comment 1 Richard W.M. Jones 2020-01-29 11:20:00 UTC
Created attachment 1656213 [details]
libguestfs-test-tool output

Comment 2 Richard W.M. Jones 2020-01-29 11:21:04 UTC
Created attachment 1656214 [details]
Complete list of installed packages

Comment 3 Dr. David Alan Gilbert 2020-01-29 12:25:23 UTC
This isn't rt related; I dropped back to Linux amd-daytona-04.khw1.lab.eng.bos.redhat.com 4.18.0-171.el8.x86_64+debug #1 SMP Fri Jan 17 15:00:12 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

and it's still broken in the same way.

Comment 4 Richard W.M. Jones 2020-01-29 16:14:16 UTC
David, could you check if it's actually using the non-RT kernel for libguestfs?
The output of libguestfs-test-tool can be used to check this.  Libguestfs will
pick the highest numbered installed (not necessarily running) kernel.

Comment 5 Dr. David Alan Gilbert 2020-01-29 17:23:04 UTC
step 1: It works with non-RT kernel but also the rhel-av module; I need to test with non-RT and non-AV

Comment 6 Dr. David Alan Gilbert 2020-01-30 14:18:32 UTC
Yeh you're right, it's fine without rt even with the non-AV qemu

Comment 7 YongkuiGuo 2020-02-04 09:48:03 UTC
I can reproduce this issue only when the following kernel-rt-debug* packages also have been installed.
-----
kernel-rt-debug-modules-extra-4.18.0-172.rt13.29.el8.x86_64
kernel-rt-debug-core-4.18.0-172.rt13.29.el8.x86_64
kernel-rt-debug-modules-4.18.0-172.rt13.29.el8.x86_64
kernel-rt-debug-4.18.0-172.rt13.29.el8.x86_64
kernel-rt-debug-devel-4.18.0-172.rt13.29.el8.x86_64
-----
As long as I removed the above kernel-rt-debug* packages, the libguestfs-test-tool works fine.

Comment 8 Richard W.M. Jones 2020-02-04 10:24:10 UTC
One rather crude way to fix this might be to exclude RT kernels.  We
previously excluded Xen kernels as you can see from the adjacent
test in the patch below.  I don't really like this approach however.
We exclude Xen kernels for a good reason - they cannot boot on qemu -
but there should be no similar problem for RT kernels as far as I
know.  Although RT kernels would normally be used on baremetal, they
should at least work on qemu even if it's not optimal.

commit 5680e912a43092bff0e5e5f62cf6a7886ca564b7 (HEAD -> master)
Author: Richard W.M. Jones <rjones>
Date:   Tue Feb 4 10:21:29 2020 +0000

    kernel: Exclude realtime kernels from consideration (RHBZ#1795973).

diff --git a/src/format_ext2_kernel.ml b/src/format_ext2_kernel.ml
index 98bff3a..d7f3054 100644
--- a/src/format_ext2_kernel.ml
+++ b/src/format_ext2_kernel.ml
@@ -156,6 +156,8 @@ and kernel_filter patterns is_arm all_files =
       ) all_files in
   let files =
     List.filter (fun filename -> find filename "xen" = -1) files in
+  let files =
+    List.filter (fun filename -> find filename "-rt-" = -1) files in
   let files =
     if not is_arm then files
     else (

Comment 10 Richard W.M. Jones 2020-02-04 10:33:02 UTC
(In reply to YongkuiGuo from comment #7)
> I can reproduce this issue only when the following kernel-rt-debug* packages
> also have been installed.
> -----
> kernel-rt-debug-modules-extra-4.18.0-172.rt13.29.el8.x86_64
> kernel-rt-debug-core-4.18.0-172.rt13.29.el8.x86_64
> kernel-rt-debug-modules-4.18.0-172.rt13.29.el8.x86_64
> kernel-rt-debug-4.18.0-172.rt13.29.el8.x86_64
> kernel-rt-debug-devel-4.18.0-172.rt13.29.el8.x86_64
> -----
> As long as I removed the above kernel-rt-debug* packages, the
> libguestfs-test-tool works fine.

Could you attach the output with libguestfs-test-tool when the RT debug
kernels are installed?

Also it would be really useful if you could try this:

  $ virt-rescue --scratch
  ><rescue> ls /

to see if the ls command hangs or segfaults.

Comment 11 YongkuiGuo 2020-02-04 10:42:26 UTC
Created attachment 1657525 [details]
libguestfs-test-tool log with kernel-rt-debug* installed

Comment 12 YongkuiGuo 2020-02-04 10:45:08 UTC
$ virt-rescue --scratch
Formatting '/tmp/libguestfs6QMI2v/overlay2.qcow2', fmt=qcow2 size=4294967296 backing_file=/var/tmp/.guestfs-0/appliance.d/root backing_fmt=raw cluster_size=65536 lazy_refcounts=off refcount_bits=16
[    0.000000] ACPI BIOS Error (bug): A valid RSDP was not found (20190703/tbxfroot-210)
[    1.708688] usbserial: usb_serial_init - registering generic driver failed
[    1.712624] usbserial: usb_serial_init - returning with error -19
supermin: mounting /proc
supermin: ext2 mini initrd starting up: 5.1.19 glibc
insmod: init_module: nfit.ko: No such device
Starting /init script ...
[/usr/lib/tmpfiles.d/mdadm.conf:1] Line references path below legacy directory /var/run/, updating /var/run/mdadm → /run/mdadm; please update the tmpfiles.d/ drop-in file accordingly.
[/usr/lib/tmpfiles.d/systemd.conf:11] Unknown group 'utmp'.
[/usr/lib/tmpfiles.d/systemd.conf:22] Unknown group 'systemd-journal'.
[/usr/lib/tmpfiles.d/systemd.conf:23] Unknown group 'systemd-journal'.
starting version 239
/init: line 116: echo: write error: Invalid argument
/init: line 116: echo: write error: Invalid argument
mdadm: No arrays found in config file or automatically
/init: line 142: lvmetad: command not found
mdadm: No arrays found in config file or automatically
/init: line 152: ldmtool: command not found
/init: line 255:   282 Segmentation fault      $cmd

------------------------------------------------------------

Welcome to virt-rescue, the libguestfs rescue shell.

Note: The contents of / (root) are the rescue appliance.
You have to mount the guest’s partitions under /sysroot
before you can examine them.

><rescue> ls /     --hang

Comment 13 Richard W.M. Jones 2020-02-04 10:47:21 UTC
(In reply to YongkuiGuo from comment #11)
> Created attachment 1657525 [details]
> libguestfs-test-tool log with kernel-rt-debug* installed

Thanks - that is the same as what Dave Gilbert observed - ie. guestfsd
segfaults, ...

> ><rescue> ls /     --hang

... and this is what we both observed too.

Comment 14 Richard W.M. Jones 2020-02-04 11:37:45 UTC
kernel-rt-4.18.0-172.rt13.29.el8.x86_64 => works
kernel-rt-debug-4.18.0-172.rt13.29.el8.x86_64 => broken

Comment 15 Richard W.M. Jones 2020-02-04 12:13:54 UTC
Setting LIBGUESTFS_MEMSIZE=2048 causes both test cases to succeed.  It could
be that the debug kernel uses more memory.

Comment 16 Richard W.M. Jones 2020-02-04 12:17:37 UTC
I suspect the fix for this is simply:

commit ba82fb023de8ff0d271b4b82e3ef12a8d169728e
Author: Richard W.M. Jones <rjones>
Date:   Wed May 16 13:40:27 2018 +0100

    lib: Increase default memory assigned to the appliance.
    
    With recent Linux kernels, adding and partitioning 255 disks causes
    the appliance to run out of memory.  This causes a test failure in
    tests/disks/test-255-disks.sh.  This change gives the appliance enough
    memory to complete the test.

This is not included in libguestfs from RHEL non-AV 8, but it is
included in RHEL AV already.

Comment 17 YongkuiGuo 2020-02-05 02:24:30 UTC
The default memory size is 768M in RHEL-AV(non-aarch64/powerpc).  The command 'LIBGUESTFS_MEMSIZE=768 libguestfs-test-tool' works both kernel-rt and kernel-rt-debug.

Comment 18 YongkuiGuo 2020-02-11 07:35:24 UTC
Hi rjones,
Is there any requirements to cover the RT kernel for libguestfs from QE side? I'd like to know the reason why you use the RT kernel. Thanks.

Comment 19 Richard W.M. Jones 2020-02-11 11:11:30 UTC
(In reply to YongkuiGuo from comment #18)
> Hi rjones,
> Is there any requirements to cover the RT kernel for libguestfs from QE
> side? I'd like to know the reason why you use the RT kernel. Thanks.

While I believe this is not actually a bug related to the RT kernel,
I do think it may be worth including a simple test where we run
libguestfs-test-tool with only an RT kernel installed.  Assuming
that isn't going to be too much work.

I don't know whether or not it's a *requirement* that we test RT kernels.
Maybe we can ask Martin Tessun about that.  But it'd be nice to test
that it doesn't break.

Comment 20 YongkuiGuo 2020-02-11 12:09:29 UTC
(In reply to Richard W.M. Jones from comment #19)
> While I believe this is not actually a bug related to the RT kernel,
> I do think it may be worth including a simple test where we run
> libguestfs-test-tool with only an RT kernel installed.  Assuming
> that isn't going to be too much work.
> 
> I don't know whether or not it's a *requirement* that we test RT kernels.
> Maybe we can ask Martin Tessun about that.  But it'd be nice to test
> that it doesn't break.

Ok, i get it. Thanks.

Comment 21 Richard W.M. Jones 2020-03-10 09:12:27 UTC
Just to update things:

 - Bug is NOT caused by the RT kernel.

 - Bug is caused by the appliance running out of memory.  Using LIBGUESTFS_MEMSIZE=2048
   (for example) will fix the problem.

 - There is an upstream patch which provides more memory to the appliance, but
   it is only applied to RHEL AV branch, but this but was found in RHEL non-AV.

 - We will soon copy the RHEL AV package to RHEL (I think in RHEL 8.3) so
   we don't really need to apply the patch specially to RHEL right now.

I suspect we ought to close this bug.

Comment 22 YongkuiGuo 2020-07-14 03:58:33 UTC
rjones, I tried on RHEL8.3 and there was no problem. We can close this bug.