Bug 2081022

Summary: Build regression on ppc64le with c9s qemu-kvm 7.0.0-1 changes
Product: Red Hat Enterprise Linux 9 Reporter: Murilo Opsfelder Araujo <mopsfelder>
Component: qemu-kvmAssignee: Miroslav Rezanina <mrezanin>
qemu-kvm sub component: General QA Contact: Min Deng <mdeng>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: unspecified CC: bstinson, coli, dgibson, gkurz, jinzhao, juzhang, jwboyer, lijin, lvivier, mopsfelder, mrezanin, virt-maint
Version: CentOS StreamKeywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: ppc64le   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-7.0.0-2.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 09:54:42 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
[PATCH] Fix for 0005-Enable-disable-devices-for-RHEL.patch none

Description Murilo Opsfelder Araujo 2022-05-02 14:58:13 UTC
Created attachment 1876533 [details]
[PATCH] Fix for 0005-Enable-disable-devices-for-RHEL.patch

Description of problem:

The 0005-Enable-disable-devices-for-RHEL.patch patch in the c9s qemu-kvm package breaks the build on ppc64le:

    ../target/ppc/cpu-models.c:904:2: error: #endif without #if
    #endif
     ^
    1 error generated.


It was introduced with qemu-7.0.0-1 changes by package commit:

    https://gitlab.com/redhat/centos-stream/rpms/qemu-kvm/-/commit/8b49639415ab24e0992f9c7e3a3f62a4778b0765

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

qemu-7.0.0-1


How reproducible: Always


Steps to Reproduce:
1. centpkg clone -a rpms/qemu-kvm && cd qemu-kvm
2. Enable building ppc64-softmmu on ppc64le (e.g.: https://gitlab.com/mopsfelder/centos-stream-rpms-qemu-kvm/-/commit/7c2c8556552adb8b9d5c0d8d830c8f25e9eddfc8):

diff --git a/qemu-kvm.spec b/qemu-kvm.spec
index b75c653..e202ece 100644
--- a/qemu-kvm.spec
+++ b/qemu-kvm.spec
@@ -54,9 +54,6 @@
 %endif

 %global tools_only 0
-%ifarch %{power64}
-    %global tools_only 1
-%endif

 %ifnarch %{ix86} x86_64
     %global have_usbredir 0

3. centpkg mockbuild --root centos-stream-9-ppc64le

Actual results:

Build breaks:

    ../target/ppc/cpu-models.c:904:2: error: #endif without #if
    #endif
     ^
    1 error generated.


Expected results:

All RPMs should get built successfully.

Additional info:

I have a fix for this issue at https://gitlab.com/mopsfelder/centos-stream-rpms-qemu-kvm/-/commit/4d544d840b673ebca12996ccc851ecdecfb61572.patch, which is attached to this bug as 0001-Fix-for-0005-Enable-disable-devices-for-RHEL.patch.txt.

Previous version qemu-kvm 6.2.0-13 built successfully (https://gitlab.com/redhat/centos-stream/rpms/qemu-kvm/-/commit/cfef67ad49a2296ea0c5fb9a799650245133cca9).

Comment 1 John Ferlan 2022-05-04 11:32:04 UTC
Mirek - since you set ITM and bugs w/ ITM should have an owner, assigning to you.

Comment 2 Min Deng 2022-05-05 01:43:15 UTC
Hi Murilo,
Thanks for reporting this bug. Actually *qemu 7.0* is not supported on ppc64le(RHEL). Per Mirek, "C9S allow some of custom usage of CentOS 9 Stream". I will help to reproduce it.
Thanks. 
Min

Comment 4 Min Deng 2022-05-06 11:27:49 UTC
Steps to reproduce,
1. git clone https://gitlab.com/redhat/centos-stream/src/qemu-kvm.git
2. ./configure
3. #clang -m64 -mlittle-endian ... ./target/ppc/cpu-models.c
./target/ppc/cpu-models.c:22:10: fatal error: 'qemu/osdep.h' file not found
#include "qemu/osdep.h"
         ^~~~~~~~~~~~~~
1 error generated.
...

QE realized it need many libraries to compile the final build, but my host is not a build server. In the code, it missed something was like" #if defined..." in cpu-models.c at the following lines.
-------------------------------------------------------------
798                                                          --missed
799     /* PowerPC MPC603 microcontrollers */
800     { "mpc8240", "603" }.
...

...
904     { "apollo7pm", "7457a_v1.0" },
905 #endif

Hi David and Laurent,

Is it enough for QE to verify the bug ? Can you guys help to tell it if you prefer to use other ways? 

Thanks
Min

Comment 5 Laurent Vivier 2022-05-06 16:35:20 UTC
(In reply to Min Deng from comment #4)
> Steps to reproduce,
> 1. git clone https://gitlab.com/redhat/centos-stream/src/qemu-kvm.git
> 2. ./configure
> 3. #clang -m64 -mlittle-endian ... ./target/ppc/cpu-models.c
> ./target/ppc/cpu-models.c:22:10: fatal error: 'qemu/osdep.h' file not found
> #include "qemu/osdep.h"

This is not the expected error.

In the centos-stream repo, you can use the following command to install the missing package:

  git clone https://gitlab.com/redhat/centos-stream/src/qemu-kvm.git
  cd qemu-kvm
  git checkout qemu-kvm-7.0.0-1.el9

  make -C .distro rh-env-prep

Then you can build locally the package with:

  patch -p1
diff --git a/.distro/qemu-kvm.spec b/.distro/qemu-kvm.spec
index 38d4980d12..d654c578e0 100644
--- a/.distro/qemu-kvm.spec
+++ b/.distro/qemu-kvm.spec
@@ -54,9 +54,6 @@
 %endif
 
 %global tools_only 0
-%ifarch %{power64}
-    %global tools_only 1
-%endif
 
 %ifnarch %{ix86} x86_64
     %global have_usbredir 0

And

  rm .distro/rpmbuild/SRPMS/*
  make -C .distro rh-srpm
  rpmbuild --rebuild .distro/rpmbuild/SRPMS/qemu-kvm-7.0.0-*.src.rpm
...
../target/ppc/cpu-models.c:904:2: error: #endif without #if
 #endif
  ^~~~~
cc1: error: unrecognized command line option '-Wno-string-plus-int' [-Werror]
cc1: all warnings being treated as errors

Then you can do:

 git checkout -f qemu-kvm-7.0.0-2.el9

 patch -p1
diff --git a/.distro/qemu-kvm.spec b/.distro/qemu-kvm.spec
index 38d4980d12..d654c578e0 100644
--- a/.distro/qemu-kvm.spec
+++ b/.distro/qemu-kvm.spec
@@ -54,9 +54,6 @@
 %endif
 
 %global tools_only 0
-%ifarch %{power64}
-    %global tools_only 1
-%endif
 
 %ifnarch %{ix86} x86_64
     %global have_usbredir 0

 rm .distro/rpmbuild/SRPMS/*
 make -C .distro rh-srpm
 rpmbuild --rebuild .distro/rpmbuild/SRPMS/qemu-kvm-7.0.0-*.src.rpm
...
libqemu-ppc64-softmmu.fa.p/monitor_misc.c.o:(.data.rel+0x1158): undefined reference to `hmp_info_via'
collect2: error: ld returned 1 exit status

It fails, but it's another bug...

that can be fixed by:

  patch -p1
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index adfa085a9b..204aa18059 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -880,7 +880,7 @@ SRST
     Show intel SGX information.
 ERST
 
-#if defined(TARGET_M68K) || defined(TARGET_PPC)
+#if 0
     {
         .name         = "via",
         .args_type    = "",

  git commit -m"disable hmp_info_via" hmp-commands-info.hx
  rm .distro/rpmbuild/SRPMS/*
  rpmbuild --rebuild .distro/rpmbuild/SRPMS/qemu-kvm-7.0.0-*.src.rpm

Then you can check we have the expected CPUs:

$ /usr/libexec/qemu-kvm -version
QEMU emulator version 7.0.0 (qemu-kvm-7.0.0-2.el8.lvivier202205061220)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
$ /usr/libexec/qemu-kvm -cpu help
PowerPC power7_v2.3      PVR 003f0203
PowerPC power7           (alias for power7_v2.3)
PowerPC power7+_v2.1     PVR 004a0201
PowerPC power7+          (alias for power7+_v2.1)
PowerPC power8e_v2.1     PVR 004b0201
PowerPC power8e          (alias for power8e_v2.1)
PowerPC power8nvl_v1.0   PVR 004c0100
PowerPC power8nvl        (alias for power8nvl_v1.0)
PowerPC power8_v2.0      PVR 004d0200
PowerPC power8           (alias for power8_v2.0)
PowerPC power9_v1.0      PVR 004e0100
PowerPC power9_v2.0      PVR 004e1200
PowerPC power9           (alias for power9_v2.0)
PowerPC power10_v1.0     PVR 00800100
PowerPC power10_v2.0     PVR 00800200
PowerPC power10          (alias for power10_v2.0)

PowerPC host

Comment 6 Min Deng 2022-05-07 08:40:59 UTC
Thanks Laurent,
Reproduced the issues now
[2033/2619] clang -m64 -mlittle-endian -Ilibqemu-ppc64-softmmu.fa.p -I. -I.. -Itarget/ppc -I../target/ppc -I../capstone/include/capstone -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/pixman-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -fcolor-diagnostics -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -isystem /root/rpmbuild/BUILD/qemu-7.0.0/linux-headers -isystem linux-headers -iquote . -iquote /root/rpmbuild/BUILD/qemu-7.0.0 -iquote /root/rpmbuild/BUILD/qemu-7.0.0/include -iquote /root/rpmbuild/BUILD/qemu-7.0.0/disas/libvixl -iquote /root/rpmbuild/BUILD/qemu-7.0.0/tcg/ppc -pthread -DSTAP_SDT_V2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg -fstack-protector-strong -m64 -mcpu=power9 -mtune=power9 -fasynchronous-unwind-tables -fstack-clash-protection -Wno-string-plus-int -fPIE -isystem../linux-headers -isystemlinux-headers -DNEED_CPU_H '-DCONFIG_TARGET="ppc64-softmmu-config-target.h"' '-DCONFIG_DEVICES="ppc64-softmmu-config-devices.h"' -MD -MQ libqemu-ppc64-softmmu.fa.p/target_ppc_cpu-models.c.o -MF libqemu-ppc64-softmmu.fa.p/target_ppc_cpu-models.c.o.d -o libqemu-ppc64-softmmu.fa.p/target_ppc_cpu-models.c.o -c ../target/ppc/cpu-models.c
FAILED: libqemu-ppc64-softmmu.fa.p/target_ppc_cpu-models.c.o 
clang -m64 -mlittle-endian -Ilibqemu-ppc64-softmmu.fa.p -I. -I.. -Itarget/ppc -I../target/ppc -I../capstone/include/capstone -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/pixman-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -fcolor-diagnostics -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -isystem /root/rpmbuild/BUILD/qemu-7.0.0/linux-headers -isystem linux-headers -iquote . -iquote /root/rpmbuild/BUILD/qemu-7.0.0 -iquote /root/rpmbuild/BUILD/qemu-7.0.0/include -iquote /root/rpmbuild/BUILD/qemu-7.0.0/disas/libvixl -iquote /root/rpmbuild/BUILD/qemu-7.0.0/tcg/ppc -pthread -DSTAP_SDT_V2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg -fstack-protector-strong -m64 -mcpu=power9 -mtune=power9 -fasynchronous-unwind-tables -fstack-clash-protection -Wno-string-plus-int -fPIE -isystem../linux-headers -isystemlinux-headers -DNEED_CPU_H '-DCONFIG_TARGET="ppc64-softmmu-config-target.h"' '-DCONFIG_DEVICES="ppc64-softmmu-config-devices.h"' -MD -MQ libqemu-ppc64-softmmu.fa.p/target_ppc_cpu-models.c.o -MF libqemu-ppc64-softmmu.fa.p/target_ppc_cpu-models.c.o.d -o libqemu-ppc64-softmmu.fa.p/target_ppc_cpu-models.c.o -c ../target/ppc/cpu-models.c
../target/ppc/cpu-models.c:904:2: error: #endif without #if
#endif
 ^

Comment 7 Min Deng 2022-05-07 09:18:13 UTC
Verified the bug with the target branch qemu-kvm-7.0.0-2.el9
Steps please refer to #comment6
Building qemu-kvm successfully finally
Wrote: /root/rpmbuild/RPMS/ppc64le/qemu-kvm-docs-7.0.0-2.el9.root202205070459.ppc64le.rpm
Wrote: /root/rpmbuild/RPMS/ppc64le/qemu-img-debuginfo-7.0.0-2.el9.root202205070459.ppc64le.rpm
Wrote: /root/rpmbuild/RPMS/ppc64le/qemu-kvm-core-7.0.0-2.el9.root202205070459.ppc64le.rpm
Wrote: /root/rpmbuild/RPMS/ppc64le/qemu-kvm-core-debuginfo-7.0.0-2.el9.root202205070459.ppc64le.rpm
Wrote: /root/rpmbuild/RPMS/ppc64le/qemu-kvm-debugsource-7.0.0-2.el9.root202205070459.ppc64le.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.tBhaR7
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd qemu-7.0.0
+ /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/qemu-kvm-7.0.0-2.el9.root202205070459.ppc64le
+ RPM_EC=0
++ jobs -p
+ exit 0
Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.4YXStJ
+ umask 022
+ cd /root/rpmbuild/BUILD
+ rm -rf qemu-7.0.0
+ RPM_EC=0
++ jobs -p
+ exit 0

Comment 12 Min Deng 2022-05-16 01:29:39 UTC
Base on comment 7, we can move it to be verified status. Thanks.

Comment 14 Min Deng 2022-05-18 03:21:31 UTC
The verification of this bug included rebuild test, thanks !

Comment 16 errata-xmlrpc 2022-11-15 09:54:42 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: qemu-kvm 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-2022:7967