From d0dc98def2946de23064503254a8e000e60f39cb Mon Sep 17 00:00:00 2001 From: Alexey Chubukov Date: Wed, 27 Dec 2023 04:31:19 +0400 Subject: [PATCH] qemu minimal image builder --- .gitignore | 6 ++ Dockerfile.qemu | 147 ++---------------------------------------- Dockerfile.qemu-build | 139 +++++++++++++++++++++++++++++++++++++++ Makefile | 16 +++-- build.sh | 66 +++++++++++++++++++ deps | 79 +++++++++++++++++++++++ 6 files changed, 307 insertions(+), 146 deletions(-) create mode 100644 .gitignore create mode 100644 Dockerfile.qemu-build create mode 100644 build.sh create mode 100644 deps diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c1ab060 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +libvirt-image +qemu-build +qemu-binary +qemu-* +config.log +opt diff --git a/Dockerfile.qemu b/Dockerfile.qemu index 3e1cbff..66edec1 100644 --- a/Dockerfile.qemu +++ b/Dockerfile.qemu @@ -1,142 +1,5 @@ -FROM almalinux:8 -RUN dnf distro-sync -y && \ - dnf install 'dnf-command(config-manager)' -y && \ - dnf config-manager --set-enabled -y powertools && \ - dnf install -y centos-release-advanced-virtualization && \ - dnf install -y epel-release && \ - dnf install -y epel-next-release && \ - dnf install -y \ - SDL2-devel \ - alsa-lib-devel \ - bash \ - bc \ - bison \ - brlapi-devel \ - bzip2 \ - bzip2-devel \ - ca-certificates \ - capstone-devel \ - ccache \ - clang \ - ctags \ - cyrus-sasl-devel \ - daxctl-devel \ - dbus-daemon \ - device-mapper-multipath-devel \ - diffutils \ - findutils \ - flex \ - fuse3-devel \ - gcc \ - gcc-c++ \ - gettext \ - git \ - glib2-devel \ - glib2-static \ - glibc-langpack-en \ - glibc-static \ - glusterfs-api-devel \ - gnutls-devel \ - gtk3-devel \ - hostname \ - jemalloc-devel \ - json-c-devel \ - libaio-devel \ - libasan \ - libattr-devel \ - libbpf-devel \ - libcacard-devel \ - libcap-ng-devel \ - libcmocka-devel \ - libcurl-devel \ - libdrm-devel \ - libepoxy-devel \ - libfdt-devel \ - libffi-devel \ - libgcrypt-devel \ - libiscsi-devel \ - libjpeg-devel \ - libnfs-devel \ - libpmem-devel \ - libpng-devel \ - librbd-devel \ - libseccomp-devel \ - libselinux-devel \ - libslirp-devel \ - libssh-devel \ - libtasn1-devel \ - libubsan \ - liburing-devel \ - libusbx-devel \ - libxdp-devel \ - libzstd-devel \ - llvm \ - lttng-ust-devel \ - lzo-devel \ - make \ - mesa-libgbm-devel \ - mtools \ - ncurses-devel \ - nettle-devel \ - ninja-build \ - nmap-ncat \ - numactl-devel \ - openssh-clients \ - pam-devel \ - pcre-static \ - pipewire-devel \ - pixman-devel \ - pkgconfig \ - pulseaudio-libs-devel \ - python38 \ - python38-PyYAML \ - python38-numpy \ - python38-pip \ - python38-setuptools \ - python38-wheel \ - rdma-core-devel \ - sed \ - snappy-devel \ - socat \ - spice-protocol \ - spice-server-devel \ - swtpm \ - systemd-devel \ - systemtap-sdt-devel \ - tar \ - usbredir-devel \ - util-linux \ - virglrenderer-devel \ - vte291-devel \ - which \ - xfsprogs-devel \ - xorriso \ - zlib-devel \ - zlib-static \ - zstd && \ - dnf autoremove -y && \ - dnf clean all -y && \ - rpm -qa | sort > /packages.txt && \ - mkdir -p /usr/libexec/ccache-wrappers && \ - ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/c++ && \ - ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/cc && \ - ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/clang && \ - ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \ - ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc -RUN /usr/bin/pip3.8 install \ - meson==0.63.2 \ - pillow \ - sphinx \ - sphinx-rtd-theme \ - tomli - -ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" -ENV LANG "en_US.UTF-8" -ENV MAKE "/usr/bin/make" -ENV NINJA "/usr/bin/ninja" -ENV PYTHON "/usr/bin/python3.8" -# As a final step configure the user (if env is defined) -ARG USER -ARG UID -RUN if [ "${USER}" ]; then \ - id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi +curl -LJO https://download.qemu.org/qemu-8.2.0.tar.xz && \ + tar xvJf qemu-8.2.0.tar.xz && \ + cd qemu-8.2.0 && \ + ./configure && \ + make && \ diff --git a/Dockerfile.qemu-build b/Dockerfile.qemu-build new file mode 100644 index 0000000..33b84b6 --- /dev/null +++ b/Dockerfile.qemu-build @@ -0,0 +1,139 @@ +FROM almalinux:8 +MAINTAINER tea@brass.host +RUN dnf distro-sync -y && \ + dnf install 'dnf-command(config-manager)' -y && \ + dnf config-manager --set-enabled -y powertools && \ + dnf install -y centos-release-advanced-virtualization && \ + dnf install -y epel-release && \ + dnf install -y epel-next-release && \ + dnf install -y \ + SDL2-devel \ + alsa-lib-devel \ + bash \ + bc \ + bison \ + brlapi-devel \ + bzip2 \ + bzip2-devel \ + ca-certificates \ + capstone-devel \ + ccache \ + clang \ + ctags \ + cyrus-sasl-devel \ + daxctl-devel \ + dbus-daemon \ + device-mapper-multipath-devel \ + diffutils \ + findutils \ + flex \ + fuse3-devel \ + gcc \ + gcc-c++ \ + gettext \ + git \ + glib2-devel \ + glib2-static \ + glibc-langpack-en \ + glibc-static \ + glusterfs-api-devel \ + gnutls-devel \ + gtk3-devel \ + hostname \ + jemalloc-devel \ + json-c-devel \ + libaio-devel \ + libasan \ + libattr-devel \ + libbpf-devel \ + libcacard-devel \ + libcap-ng-devel \ + libcmocka-devel \ + libcurl-devel \ + libdrm-devel \ + libepoxy-devel \ + libfdt-devel \ + libffi-devel \ + libgcrypt-devel \ + libiscsi-devel \ + libjpeg-devel \ + libnfs-devel \ + libpmem-devel \ + libpng-devel \ + librbd-devel \ + libseccomp-devel \ + libselinux-devel \ + libslirp-devel \ + libssh-devel \ + libtasn1-devel \ + libubsan \ + liburing-devel \ + libusbx-devel \ + libxdp-devel \ + libzstd-devel \ + llvm \ + lttng-ust-devel \ + lzo-devel \ + make \ + mesa-libgbm-devel \ + mtools \ + ncurses-devel \ + nettle-devel \ + ninja-build \ + nmap-ncat \ + numactl-devel \ + openssh-clients \ + pam-devel \ + pcre-static \ + pipewire-devel \ + pixman-devel \ + pkgconfig \ + pulseaudio-libs-devel \ + python38 \ + python38-PyYAML \ + python38-numpy \ + python38-pip \ + python38-setuptools \ + python38-wheel \ + rdma-core-devel \ + sed \ + snappy-devel \ + socat \ + spice-protocol \ + spice-server-devel \ + swtpm \ + systemd-devel \ + systemtap-sdt-devel \ + tar \ + usbredir-devel \ + util-linux \ + virglrenderer-devel \ + vte291-devel \ + which \ + xfsprogs-devel \ + xorriso \ + zlib-devel \ + zlib-static \ + zstd && \ + dnf autoremove -y && \ + dnf clean all -y && \ + rpm -qa | sort > /packages.txt && \ + mkdir -p /usr/libexec/ccache-wrappers && \ + ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/c++ && \ + ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/cc && \ + ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/clang && \ + ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \ + ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc +RUN /usr/bin/pip3.8 install \ + meson==0.63.2 \ + pillow \ + sphinx \ + sphinx-rtd-theme \ + tomli + +ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" +ENV LANG "en_US.UTF-8" +ENV MAKE "/usr/bin/make" +ENV NINJA "/usr/bin/ninja" +ENV PYTHON "/usr/bin/python3.8" +WORKDIR /src diff --git a/Makefile b/Makefile index a7aa605..91137b2 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,17 @@ -all:libvirt +all:libvirt-image -libvirt: +libvirt-image: qemu-binary buildah bud -t repo.brass.host/libvirt/libvirt -f Dockerfile.libvirt + touch libvirt-image -qemu: - buildah bud -t repo.brass.host/libvirt/qemu -f Dockerfile.qemu +qemu-build: + buildah bud -t repo.brass.host/libvirt/qemu-build -f Dockerfile.qemu-build + touch qemu-build + +qemu-binary: qemu-build + podman stop qemu-builder ; podman rm qemu-builder || true + podman run --rm --name qemu-builder -v $(PWD):/src repo.brass.host/libvirt/qemu-build sh ./build.sh + touch qemu-binary + # buildah from almalinux:8 --name "qemu-build" -v $(PWD):/src .PHONY: all qemu libvirt diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..1e02d18 --- /dev/null +++ b/build.sh @@ -0,0 +1,66 @@ +#!/bin/bash +QEMU_VERSION=8.2.0 +set -e +if ! [[ -f qemu-${QEMU_VERSION}.tar.xz ]] +then + curl -LJO https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz +fi +if ! [[ -d qemu-${QEMU_VERSION} ]] +then + tar xvJf qemu-${QEMU_VERSION}.tar.xz +fi +cd qemu-${QEMU_VERSION} +rm -rf build +mkdir -p build +cd build +../configure \ + --prefix=qemu \ + --localstatedir=var \ + --enable-kvm \ + --enable-gnutls \ + --enable-guest-agent \ + --enable-iconv \ + --enable-kvm \ + --enable-libiscsi \ + --enable-libpmem \ + --enable-libssh \ + --enable-libusb \ + --enable-libudev \ + --enable-linux-aio \ + --enable-lzo \ + --enable-malloc-trim \ + --enable-modules \ + --enable-mpath \ + --enable-smartcard \ + --enable-spice \ + --enable-spice-protocol \ + --enable-system \ + --enable-tcg \ + --enable-tools \ + --enable-tpm \ + --enable-trace-backend=dtrace \ + --enable-virtiofsd \ + --enable-vhost-kernel \ + --enable-vhost-net \ + --enable-vhost-user \ + --enable-vhost-user-blk-server \ + --enable-vhost-vdpa \ + --enable-vhost-vsock \ + --enable-vnc \ + --enable-vnc-png \ + --enable-vnc-sasl \ + --enable-werror \ + --enable-xkbcommon \ + --enable-attr \ + --enable-avx2 \ + --enable-cap-ng \ + --enable-capstone=internal \ + --enable-coroutine-pool \ + --enable-curl \ + --enable-debug-info \ + --enable-docs \ + +make -j 8 +make install DESTDIR=/opt +cd /opt +tar -cJf /src/qemu/${QEMU_VERSION}.tar.xz ./ diff --git a/deps b/deps new file mode 100644 index 0000000..c241b07 --- /dev/null +++ b/deps @@ -0,0 +1,79 @@ +edk2-ovmf +ld-linux-x86-64.so.2()(64bit) +ld-linux-x86-64.so.2(GLIBC_2.3)(64bit) +libaio.so.1()(64bit) +libaio.so.1(LIBAIO_0.1)(64bit) +libaio.so.1(LIBAIO_0.4)(64bit) +libc.so.6(GLIBC_2.14)(64bit) +libc.so.6(GLIBC_2.17)(64bit) +libc.so.6(GLIBC_2.28)(64bit) +libc.so.6(GLIBC_2.4)(64bit) +libcapstone.so.4()(64bit) +libcurl.so.4()(64bit) +libepoxy.so.0()(64bit) +libfdt +libfdt.so.1()(64bit) +libfdt.so.1(LIBFDT_1.2)(64bit) +libgbm.so.1()(64bit) +libgcc_s.so.1()(64bit) +libgcc_s.so.1(GCC_3.0)(64bit) +libgcc_s.so.1(GCC_3.3.1)(64bit) +libgcc_s.so.1(GCC_3.4)(64bit) +libgcc_s.so.1(GCC_4.7.0)(64bit) +libgcrypt.so.20()(64bit) +libgcrypt.so.20(GCRYPT_1.6)(64bit) +libgfapi.so.0()(64bit) +libgfapi.so.0(GFAPI_3.4.0)(64bit) +libgfapi.so.0(GFAPI_3.5.0)(64bit) +libgfapi.so.0(GFAPI_6.0)(64bit) +libglib-2.0.so.0()(64bit) +libgmodule-2.0.so.0()(64bit) +libgnutls.so.30()(64bit) +libgnutls.so.30(GNUTLS_3_4)(64bit) +libibverbs.so.1()(64bit) +libibverbs.so.1(IBVERBS_1.0)(64bit) +libibverbs.so.1(IBVERBS_1.1)(64bit) +libiscsi +liblzo2.so.2()(64bit) +libm.so.6()(64bit) +libm.so.6(GLIBC_2.2.5)(64bit) +libnuma.so.1()(64bit) +libnuma.so.1(libnuma_1.1)(64bit) +libpixman-1.so.0()(64bit) +libpmem +libpmem.so.1()(64bit) +libpmem.so.1(LIBPMEM_1.0)(64bit) +libpng16.so.16()(64bit) +libpng16.so.16(PNG16_0)(64bit) +libpthread.so.0()(64bit) +libpthread.so.0(GLIBC_2.12)(64bit) +libpthread.so.0(GLIBC_2.2.5)(64bit) +libpthread.so.0(GLIBC_2.3.2)(64bit) +librados.so.2()(64bit) +librbd.so.1()(64bit) +librdmacm.so.1()(64bit) +librdmacm.so.1(RDMACM_1.0)(64bit) +libsasl2.so.3()(64bit) +libseccomp +libseccomp.so.2()(64bit) +libsnappy.so.1()(64bit) +libssh.so.4()(64bit) +libssh.so.4(LIBSSH_4_5_0)(64bit) +libssh.so.4(LIBSSH_4_7_0)(64bit) +liburing.so.1()(64bit) +libusbredirparser.so.1()(64bit) +libusbredirparser.so.1(USBREDIRPARSER_0.8.0)(64bit) +libusbx +libutil.so.1()(64bit) +libutil.so.1(GLIBC_2.2.5)(64bit) +libz.so.1()(64bit) +libz.so.1(ZLIB_1.2.0)(64bit) +lzo +mesa-dri-drivers +mesa-libEGL +mesa-libGL +qemu-kvm-common(x86-64) +qemu-kvm-ui-opengl(x86-64) +rtld(GNU_HASH) +snappy +usbredir