运维记之openEuler20.03源码编译qemu

不出意外的话,源码编译一定会出意外,openEuler20.03源码编译qemu失败!事情是这样的:
Who:数字基建质检员Yison
What:源码编译qemu
When:2022/05/09
Where:openEuler20.03-LTS虚拟机
Why:打工仔啦,生活所迫!
How:如下

  1. 下载qemu的源码rpm包
cd /root/ && wget https://repo.huaweicloud.com/openeuler/openEuler-20.03-LTS-SP3/source/Packages/qemu-4.1.0-62.oe1.src.rpm
  1. 下载打包工具
yum install rpmdevtools rpm-build
  1. 配置打包路径
rpmdev-setuptree
  1. 解开qemu的源码rpm包,并安装构建qemu包的依赖
cd /root/rpmbuild/SOURCES/ && rpm2cpio /root/qemu-4.1.0-62.oe1.src.rpm|cpio -ivd && yum builddep qemu.spec
  1. 开始打包qemu包
cd /root/rpmbuild/SPECS/ && cp /root/rpmbuild/SOURCES/qemu.spec . && rpmbuild -ba qemu.spec

经过漫长的等待,报了如下错误:

+ strip /root/rpmbuild/BUILDROOT/qemu-4.1.0-62.ky10.aarch64/usr/lib64/qemu/block-rbd.so
strip: '/root/rpmbuild/BUILDROOT/qemu-4.1.0-62.ky10.aarch64/usr/lib64/qemu/block-rbd.so': No such file
error: Bad exit status from /var/tmp/rpm-tmp.xl1iNj (%install)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.xl1iNj (%install)

第一步,在qemu.spec文件搜索strip关键词,发现有之前的打包人增加了strip 动态库的操作如下,但归根结底还是没有rbd,但百度告诉我rbd是KVM虚拟机的存储接口,这很重要,必须拿下,不能放弃这功能!

strip %{buildroot}%{_libdir}/%{name}/block-rbd.so
strip %{buildroot}%{_libdir}/%{name}/block-iscsi.so
strip %{buildroot}%{_libdir}/%{name}/block-curl.so
strip %{buildroot}%{_libdir}/%{name}/block-ssh.so

第二步,查看configure执行配置过程发现rbd没有检测到

vhost-net support yes
vhost-crypto support yes
vhost-scsi support yes
vhost-vsock support yes
vhost-user support yes
Trace backends    log
spice support     no
rbd support       no
xfsctl support    yes
smartcard support no
libusb            yes
usb net redir     yes
OpenGL support    no

第三步,执行”rpm -qa|grep rbd“查看rbd相关包,发现含有librbd1和librbd1-devel,这就奇怪了,明明有包!执行"yum info librbd"发现是ceph的子包,猜测会不会rbd support得安装ceph?我尝试安装了,编译还是检测"rbd support no"。configure脚本不应该有问题,那只有2种可能?1 是存在rbd,但是configure不认识;2 是rbd不存在。
librbd-devel包都有,概率上来讲,1的可能性大一点。

第四步,切换builddep安装的4.19.90-2112.8.0.0131.oe1.aarch64内核,检查内核模块,发现有rbd.ko,执行"modprobe rbd",然后再执行configure脚本检测一下。还是"rbd support no",我已经没有耐心了!!!

无敌是多么寂寞!!!
终极解决方法:查看源码的config.log发现如下信息,大致意思是librados.so调用pthread_cond_clockwait函数,但是glibc没有定义。执行"yum update glibc",然后再执行configure脚本,结果"rbd support yes"!!!

cc -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -fPIE -DPIE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -std=gnu99 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/openEuler/openEuler-hardened-cc1 -fasynchronous-unwind-tables -fstack-clash-protection -fPIE -DPIE -fPIC -Wexpansion-to-defined -Wendif-labels -Wno-shift-negative-value -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-strong -I/usr/include/p11-kit-1 -I/usr/include/libpng16 -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -Wl,-z,relro -Wl,-z,now -pie -g -Wl,--build-id -pie -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -lrbd -lrados
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/7.3.0/../../../../lib64/librados.so: undefined reference to `pthread_cond_clockwait@GLIBC_2.28'
collect2: error: ld returned 1 exit status

你可能感兴趣的:(linux,运维,服务器)