mirror of
https://github.com/xcat2/confluent.git
synced 2026-11-19 08:52:20 +00:00
Emulate aarch64 as a Neoverse N1 cpu in imgutil
The default 'max' cpu of qemu-user emulates SVE and pointer
authentication, which aarch64 binaries use and which is expensive to
emulate. Default QEMU_CPU to neoverse-n1 for aarch64 builds and exec,
unless it is already set. neoverse-n1 needs qemu 7.1 or later, the
documentation says how to choose another cpu.
Building an EL10 image with mlnx-ofa_kernel-dkms and doca-ofed-userspace
on an EL10 x86_64 host with qemu 10.2:
DOCA build Total
aarch64, master 3270 s (54.5 min)
aarch64, branch 2399 s (40 min), −27%
x86_64, native 251 s (4 min)
Older qemu-user-static, such as qemu 8.2 of Ubuntu 24.04, emulates
pointer authentication much more slowly, so builds there can get up to
ten times faster.
This commit is contained in:
@@ -54,7 +54,10 @@
|
||||
with the F (fix-binary) flag; on Ubuntu this is provided by the
|
||||
qemu-user-static package (qemu-user-binfmt as of Ubuntu 26.04). For EL,
|
||||
the architecture is also detected automatically when building from a `-s`
|
||||
source tree.
|
||||
source tree. An aarch64 image is emulated as a Neoverse N1 cpu, which needs
|
||||
qemu 7.1 or later and is much faster to emulate than the default cpu of
|
||||
qemu. To emulate another cpu, set `QEMU_CPU`, for example
|
||||
`QEMU_CPU=cortex-a72` for older qemu. The same applies to `imgutil exec`.
|
||||
|
||||
* `-y`, `--non-interactive`:
|
||||
Avoid prompting for confirmation.
|
||||
|
||||
+10
-1
@@ -1212,7 +1212,7 @@ def main():
|
||||
buildp.add_argument('-a', '--addpackagelist', action='append', default=[],
|
||||
help='A list of additional packages to include, may be specified multiple times')
|
||||
buildp.add_argument('-s', '--source', help='Directory to pull installation from, typically a subdirectory of /var/lib/confluent/distributions. By default, the repositories for the build system are used. For Ubuntu, this is not supported, the build system repositories are always used.')
|
||||
buildp.add_argument('--arch', default=None, help='Target architecture to build for (e.g. aarch64). When it differs from the build host architecture, statically linked qemu-user emulator registered in binfmt_misc with the F flag is required')
|
||||
buildp.add_argument('--arch', default=None, help='Target architecture to build for (e.g. aarch64). When it differs from the build host architecture, statically linked qemu-user emulator registered in binfmt_misc with the F flag is required. aarch64 is emulated as a Neoverse N1 cpu (qemu 7.1 or later), set QEMU_CPU to choose another')
|
||||
buildp.add_argument('-y', '--non-interactive', help='Avoid prompting for confirmation', action='store_true')
|
||||
buildp.add_argument('--selinux', action='store_true',
|
||||
help='Install the targeted SELinux policy and leave SELinux enforcing '
|
||||
@@ -1271,6 +1271,7 @@ def exec_root(args):
|
||||
pass
|
||||
if imgarch and imgarch != os.uname().machine:
|
||||
check_binfmt(imgarch, args)
|
||||
set_qemu_cpu(imgarch)
|
||||
exitcode = run_constrained(exec_root_backend, args)
|
||||
if exitcode:
|
||||
sys.exit(exitcode)
|
||||
@@ -1404,6 +1405,13 @@ qemu_arch_map = {
|
||||
}
|
||||
|
||||
|
||||
def set_qemu_cpu(targetarch):
|
||||
# The default 'max' cpu of qemu-user emulates SVE and pointer
|
||||
# authentication, which slows down the image build considerably
|
||||
if targetarch == 'aarch64' and 'QEMU_CPU' not in os.environ:
|
||||
os.environ['QEMU_CPU'] = 'neoverse-n1'
|
||||
|
||||
|
||||
def check_binfmt(targetarch, args):
|
||||
qname = qemu_arch_map.get(targetarch, 'qemu-' + targetarch)
|
||||
binfmtdir = '/proc/sys/fs/binfmt_misc'
|
||||
@@ -1682,6 +1690,7 @@ def build_root(args):
|
||||
oshandler.arch, hostarch))
|
||||
sys.exit(1)
|
||||
check_binfmt(oshandler.arch, args)
|
||||
set_qemu_cpu(oshandler.arch)
|
||||
if args.selinux and not oshandler.selinuxsupport:
|
||||
sys.stderr.write('--selinux is not supported for {0} images\n'.format(oshandler.oscategory))
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user