From 98a82ff47e55f92d8d3ef2407c45bb9861803d10 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Mon, 7 Jun 2021 22:30:18 +0000 Subject: [PATCH] aarch64: use single qemu-img thread Work around a bug on aarch64[1] where `qemu-img` would hang about a third of the time when converting images. To be able to activate the work-around based on the environment, i.e. only on certain distributions, introduce an environment variable, `OSBUILD_QEMU_IMG_COROUTINES`, that is set in the runner and then picked up in the assembler. [1] https://bugs.launchpad.net/qemu/+bug/1805256 --- assemblers/org.osbuild.qemu | 5 +++++ runners/org.osbuild.rhel82 | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/assemblers/org.osbuild.qemu b/assemblers/org.osbuild.qemu index ecee8450..ac536b48 100755 --- a/assemblers/org.osbuild.qemu +++ b/assemblers/org.osbuild.qemu @@ -699,6 +699,11 @@ def main(tree, output_dir, options, loop_client): if compat: extra_args["qcow2"] += ["-o", f"compat={compat}"] + coroutines = os.environ.get("OSBUILD_QEMU_IMG_COROUTINES") + if coroutines: + print(f"qemu-img coroutines: {coroutines}") + extra_args[fmt] += ["-m", coroutines] + subprocess.run([ "qemu-img", "convert", diff --git a/runners/org.osbuild.rhel82 b/runners/org.osbuild.rhel82 index 4d823d8d..3d8f5fde 100755 --- a/runners/org.osbuild.rhel82 +++ b/runners/org.osbuild.rhel82 @@ -1,12 +1,26 @@ #!/usr/libexec/platform-python import os +import platform import subprocess import sys import osbuild.api +def quirks(): + # Platform specific quirks + env = os.environ.copy() + + if platform.machine() == "aarch64": + # Work around a bug in qemu-img on aarch64 that can lead to qemu-img + # hangs when more then one coroutine is use (which is the default) + # See https://bugs.launchpad.net/qemu/+bug/1805256 + env["OSBUILD_QEMU_IMG_COROUTINES"] = "1" + + return env + + def ldconfig(): # ld.so.conf must exist, or `ldconfig` throws a warning subprocess.run(["touch", "/etc/ld.so.conf"], check=True) @@ -57,7 +71,11 @@ def main(): nsswitch() python_alternatives() - r = subprocess.run(sys.argv[1:], check=False) + env = quirks() + + r = subprocess.run(sys.argv[1:], + env=env, + check=False) sys.exit(r.returncode)