diff --git a/confluent_client/doc/man/imgutil.ronn b/confluent_client/doc/man/imgutil.ronn index c2578ce2..2705cefc 100644 --- a/confluent_client/doc/man/imgutil.ronn +++ b/confluent_client/doc/man/imgutil.ronn @@ -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. diff --git a/imgutil/imgutil b/imgutil/imgutil index df8410a8..2422f30b 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -1366,7 +1366,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 ' @@ -1425,6 +1425,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) @@ -1558,6 +1559,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' @@ -1836,6 +1844,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)