From b5a776ec18e26562eff67f86ae3b5ff9bf67fc45 Mon Sep 17 00:00:00 2001 From: Sandeep Gundlupet Raju Date: Thu, 30 Jan 2025 10:55:45 -0700 Subject: qemu-system-aarch64-multiarch: Add support for custom machine path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some use case user would like to provide custom machine path for qemu boot. By default we will create a temporary files using the tempfile.mkdtemp method, when user provides a custom machine path from runqemu command line args then skip the tempfile.mkdtemp method. Here is how user can specify a custom machine path from qemuparams option. $ runqemu nographic qemuparams="-machine-path /" Also note when using custom machine path its user responsibility to clean that path before running the runqemu launch. QEMU machine-path option is a socket path. Being a socket path it’s limited to a max of 107 characters. Since we’re passing in a path, the socket itself is part of the path so it’s probably closer to 90 characters. Also add missing Copyright and SPDX-License-Identifier. Signed-off-by: Sandeep Gundlupet Raju Signed-off-by: Mark Hatle --- .../qemu/files/qemu-system-aarch64-multiarch | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch b/meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch index 77b13aa2..f1a0c7d3 100644 --- a/meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch +++ b/meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch @@ -1,6 +1,13 @@ #!/usr/bin/env python3 -# Xilinx QEMU wrapper to launch both PMU and APU instances (multiarch) +# Copyright (C) 2017-2022, Xilinx, Inc. All rights reserved. +# Copyright (C) 2022-2025, Advanced Micro Devices, Inc. All rights reserved. +# +# +# SPDX-License-Identifier: MIT + +# AMD QEMU wrapper to launch both PMU and APU instances (multiarch) + import os import subprocess import sys @@ -9,13 +16,13 @@ import re import shutil binpath = os.path.dirname(os.path.abspath(__file__)) -mach_path = tempfile.mkdtemp() # Separate PMU and APU arguments APU_args = sys.argv[1:] PMU_args = [] PLM_args = [] bootbin_arg = None +mach_path_arg = None if '-pmu-args' in APU_args: pmu_args_idx = APU_args.index('-pmu-args') @@ -32,12 +39,25 @@ if '-bootbin' in APU_args: bootbin_arg = APU_args[bootbin_args_idx+1] del APU_args[bootbin_args_idx:bootbin_args_idx+2] +if '-machine-path' in APU_args: + mach_path_args_idx = APU_args.index('-machine-path') + mach_path_arg = APU_args[mach_path_args_idx+1] + del APU_args[mach_path_args_idx:mach_path_args_idx+2] + +if mach_path_arg: + if not os.path.isdir(mach_path_arg): + sys.exit(f'\nERROR: Missing machine path for qemu: {mach_path_arg}') + else: + mach_path = os.path.realpath(mach_path_arg) +else: + mach_path = tempfile.mkdtemp() + if PMU_args and PLM_args: sys.exit("\nError: -pmu-args can not be used with -plm-args\n") help_options = ['-h', '-help', '--help'] def help(status): - print("AMD FPGA QEMU multiarch wrapper\nVersion 2024.2\n\nUsage:") + print("AMD FPGA QEMU multiarch wrapper\nVersion 2025.1\n\nUsage:") print(f" {sys.argv[0]} [-pmu-args ]") print(f" {sys.argv[0]} [-plm-args ]\n") if status == 0: @@ -147,5 +167,7 @@ if apu_cmd and process_apu.wait(): if mb_cmd and process_mb.wait(): error_msg += '\nQEMU MB instance failed:\n%s' % process_mb.stderr.read().decode() -shutil.rmtree(mach_path) +if not mach_path_arg: + shutil.rmtree(mach_path) + sys.exit(error_msg) -- cgit v1.2.3-54-g00ecf