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 2073195

Summary: python3 seems borked on s390x Cloud Image (on qemu 6.2.0)
Product: Red Hat Enterprise Linux 9 Reporter: František Zatloukal <fzatlouk>
Component: python3.9Assignee: Python Maintainers <python-maint>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: low    
Version: 9.0CC: andrew.lukoshko, dhorak, jferlan, mhroncok, thuth, torsava, vstinner
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: s390x   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-05 08:55:03 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:
Bug Depends On: 2080519    
Bug Blocks:    

Description František Zatloukal 2022-04-07 21:01:57 UTC
Created attachment 1871384 [details]
libvirt domain xml template

Description of problem:
It seems python3 is completely non-functional in rhel-guest-image-9.0-9.0.0.20220407.1.s390x.qcow2 [0]

Version-Release number of selected component (if applicable):
python3-3.9.10-2.el9.s390x

How reproducible:
Always

Steps to Reproduce:
1. Have el9 loud image s390x image virtualized on x86_64 (so, kvm-less, it may also happen on bare metal, idk)
2. Try to execute python3 or any python application

Actual results:
# python3
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib64'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib64/python39.zip',
    '/usr/lib64python3.9',
    '/usr/lib64/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000003ff861f6720 (most recent call first):
<no Python frame>

Expected results:
python3 should work

Additional info:
[0] https://download.eng.brq.redhat.com/rhel-9/development/RHEL-9/RHEL-9.0.0-20220407.d.1/compose/BaseOS/s390x/images/rhel-guest-image-9.0-9.0.0.20220407.1.s390x.qcow2

Happened also at least in rhel-guest-image-9.0-20220325.0.s390x.qcow2 . I am not seeing the same issue with Fedora 36/rawhide s390x on x86_64 images.

Comment 2 František Zatloukal 2022-04-07 21:27:57 UTC
Seems the issue might be missing "/" in sys.path ? ("'/usr/lib64python3.9'," seems suspicious...)

Comment 3 Miro Hrončok 2022-04-08 11:35:40 UTC
The missing / in '/usr/lib64python3.9' would indeed explain the ModuleNotFoundError. Does this happen with isolated mode? python3 -I

Comment 4 František Zatloukal 2022-04-08 11:48:44 UTC
(In reply to Miro Hrončok from comment #3)
> The missing / in '/usr/lib64python3.9' would indeed explain the
> ModuleNotFoundError. Does this happen with isolated mode? python3 -I

The result is the same:

# python3 -I
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 1
  environment = 0
  user site = 0
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib64'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib64/python39.zip',
    '/usr/lib64python3.9',
    '/usr/lib64/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000003ff8a576720 (most recent call first):
<no Python frame>

Comment 5 Tomas Orsava 2022-04-20 12:18:44 UTC
Hi Frantisek,
we are not able to reproduce the issue. Can you still reproduce it consistently?

Would you be able to reproduce it on some network machine (e.g. beaker) and give us access?

Alternatively, could you verify the RPMs in question are installed correctly on the affected system? The command is to do this is:

$ rpm -V python3 python3-libs

Comment 6 Victor Stinner 2022-04-20 12:57:14 UTC
I cannot reproduce the issue on a RHEL9 s390x machine provided by Beaker.

Which python3 and python3-libs packages are you used? Where do these packages come from in the cloud image?

# python -m site
sys.path = [
    '/root',
    '/usr/lib64/python39.zip',
    '/usr/lib64/python3.9',
    '/usr/lib64/python3.9/lib-dynload',
    '/usr/lib64/python3.9/site-packages',
    '/usr/lib/python3.9/site-packages',
]
USER_BASE: '/root/.local' (doesn't exist)
USER_SITE: '/root/.local/lib/python3.9/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

# env python -I -EsS
Python 3.9.10 (main, Feb  9 2022, 00:00:00) 
[GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] on linux
>>> 

# virt-what 
ibm_systemz
ibm_systemz-zvm

# uname -m
s390x

# cat /etc/redhat-release 
Red Hat Enterprise Linux release 9.0 (Plow)

# rpm -q python3 python3-libs
python3-3.9.10-2.el9.s390x
python3-libs-3.9.10-2.el9.s390x

# rpm -Vv python3|grep /usr/bin/python
.........    /usr/bin/python3
.........    /usr/bin/python3.9

# rpm -Vv python3-libs|grep libpython
.........    /usr/lib64/libpython3.9.so.1.0
.........    /usr/lib64/libpython3.so


---


If I set PYTHONHOME env var to the wrong patch, well, I get trigger the "Python path configuration" fatal error:

# PYTHONHOME=/bug python3
Python path configuration:
  PYTHONHOME = '/bug'
  PYTHONPATH = (not set)
  (...)
  sys.path = [
    '/bug/lib64/python39.zip',
    '/bug/lib64/python3.9',
    '/bug/lib64/python3.9/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
(...)

But your output says "PYTHONHOME = (not set)" and "PYTHONPATH = (not set)". So your issue is not caused by an environment variable. Moreover, you still reproduce the issue with -I option (isolate) which ignores PYTHON environment variables like PYTHONHOME.

Comment 7 Andrew Lukoshko 2022-04-22 08:45:13 UTC
We have the same bugreport for AlmaLinux 9 Beta x390x:
https://bugs.almalinux.org/view.php?id=216

Comment 8 Miro Hrončok 2022-04-25 11:48:51 UTC
Copying a reporducer from there:

qemu-system-s390x \
    -machine s390-ccw-virtio \
    -device virtio-rng \
    -cpu max,zpci=on \
    -m 4096 -smp 2 \
    -serial mon:stdio -display none \
    -boot menu=on \
    -net nic,macaddr=52:54:00:12:34:56,model=virtio \
    -net tap,ifname=tap0,script=no,downscript=no \
    -device virtio-blk-ccw,id=dev-disk0,drive=disk0 \
    -drive id=disk0,file=dasd/almalinux.qcow2,if=none \
    -device virtio-scsi \
    -device scsi-cd,drive=c1,bootindex=1 \
    -drive file=AlmaLinux-9.0-beta-1-s390x-minimal.iso,format=raw,if=none,id=c1

Comment 9 Miro Hrončok 2022-04-25 18:39:04 UTC
I still cannot reproduce this, sorry. I run Fedora 35 if it matters.

I've downloaded and sha256sum-verified http://almalinux-mirror.dal1.hivelocity.net/9.0-beta/isos/s390x/AlmaLinux-9.0-beta-1-s390x-minimal.iso

I've run:

$ sudo dnf install /usr/bin/tunctl
$ sudo tunctl -t tap0 -u <my_usrname>

$ qemu-img create -f qcow2 almalinux.qcow2 4G

$ qemu-system-s390x \
    -machine s390-ccw-virtio \
    -device virtio-rng \
    -cpu max,zpci=on \
    -m 4096 -smp 2 \
    -serial mon:stdio -display none \
    -boot menu=on \
    -net nic,model=virtio \
    -net tap,ifname=tap0,script=no,downscript=no \
    -device virtio-blk-ccw,id=dev-disk0,drive=disk0 \
    -drive id=disk0,file=almalinux.qcow2,if=none \
    -device virtio-scsi \
    -device scsi-cd,drive=c1,bootindex=1 \
    -drive file=AlmaLinux-9.0-beta-1-s390x-minimal.iso,format=raw,if=none,id=c1

Booting to Anaconda proceeded and I could continue the installation. I could even switch to Shell and run Python just fine.

I've run the same command with CentOS-Stream-9-latest-s390x-boot.iso from https://www.centos.org/centos-stream/ -- still no issue.

Could somebody who can reproduce this issue with CentOS 9 Stream, Alma, RHEL, or anywhere provide a complete reproducer, step by step, command by command? Don't assume I know how you run qemu (for example, even the current reproducer provided in the Alma bug ended with dasd/almalinux.qcow2 file not found first and I had to quess how to create the file -- include the command I need to run to create it please).

Comment 10 Miro Hrončok 2022-04-30 11:19:56 UTC
> Have el9 loud image s390x image virtualized on x86_64 

Frnatišek,
on what operating system do you virtualize? Is it Fedora or RHEL or something else entirely? What version?

Comment 11 Miro Hrončok 2022-05-01 19:34:06 UTC
I've been told by another channel that this happened on Fedora 36 (has qemu 6.2.0). The AlamaLinux thing also happened on qemu 6.2.0 (on Gentoo).


"""I think this is because Almalinux 9 s390x binaries are compiled with -march z14
(see perl -V output), but versions of Qemu less than 7.0 emulate a z13 model
2975 CPU.  From version 7.0, qemu s390x emulates a z15 model 8561."""


I was not able to reproduce on Fedora 35 with qemu 6.1.0, but I can reproduce this on Fedora 36. This is how:

$ qemu-img create -f qcow2 almalinux.qcow2 4G
$ qemu-system-s390x \
    -machine s390-ccw-virtio \
    -device virtio-rng \
    -cpu max,zpci=on \
    -m 4096 -smp 2 \
    -serial mon:stdio -display none \
    -boot menu=on \
    -net nic,model=virtio \
    -device virtio-blk-ccw,id=dev-disk0,drive=disk0 \
    -drive id=disk0,file=almalinux.qcow2,if=none \
    -device virtio-scsi \
    -device scsi-cd,drive=c1,bootindex=1 \
    -drive file=AlmaLinux-9.0-beta-1-s390x-minimal.iso,format=raw,if=none,id=c1

(I removed the -net tap... argument thing as it complicated things and was not needed to reproduce.)


The bug reproduces, with AlmaLinux-9.0-beta-1-s390x-minimal.iso as well as with CentOS-Stream-9-latest-s390x-boot.iso.


I do not really understand why an older version of qemu works, 6.2.0 doesn't and 7.0.0 does, if this is about Z14, but at least I pinpointed it down to qemu version.

What worries me is bz2080519 which says this also happens on Fedora 34 which was not compiled with -march z14.

Comment 12 Dan Horák 2022-05-02 08:36:24 UTC
As there is no such problem with python3 when running on real hw, this is most likely an emulation issue, please move under qemu. cross-arch emulation is definitely not a supported scenario.

Comment 13 Tomas Orsava 2022-05-04 12:50:37 UTC
Hi John,
could you or somebody else from your SST please confirm if it is correct that RHEL 9 s390x images are not supported on qemu versions < 7?

Thank you!

Comment 14 John Ferlan 2022-05-04 21:40:41 UTC
Passing question along to Thomas Huth who knows more about s390x than I do.

Comment 15 Thomas Huth 2022-05-05 06:39:32 UTC
(In reply to Tomas Orsava from comment #13)
> could you or somebody else from your SST please confirm if it is correct
> that RHEL 9 s390x images are not supported on qemu versions < 7?

If you ask for the support status: Guest emulation (TCG) is not supported at all in RHEL, neither on x86, nor on s390x, we only support KVM in downstream RHEL.

Having said that, do you still need a fix for QEMU 6.2.0, or are you fine with QEMU 7.0.0 ? In case you need it, it could be worth a try to bisect the issue to find out which patch fixed it in QEMU 7.0.0.

Comment 16 Miro Hrončok 2022-05-05 08:55:03 UTC
> do you still need a fix for QEMU 6.2.0

We do not. Closing in favor of bz2080519, as this is not a RHEL issue.

Thank you, Thomas.

Comment 17 Miro Hrončok 2022-05-05 22:26:42 UTC
Whether or not s390x Z14 is supported in qemu 6.2, this particular problem is fixed by a qemu fix, so I am marking this as duplicate instead.

*** This bug has been marked as a duplicate of bug 2080519 ***