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
This commit is contained in:
Christian Kellner 2021-06-07 22:30:18 +00:00
parent 1fbe4bb31a
commit 98a82ff47e
2 changed files with 24 additions and 1 deletions

View file

@ -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",

View file

@ -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)