summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>2025-01-30 10:55:45 -0700
committerMark Hatle <mark.hatle@amd.com>2025-03-30 14:16:15 -0600
commitb5a776ec18e26562eff67f86ae3b5ff9bf67fc45 (patch)
tree6e2de61545593ae61324b857699c17b8eea76baf
parent166b86d36dda24d2bbaa2fd2ffbbc16fbd0e58da (diff)
downloadmeta-xilinx-b5a776ec18e26562eff67f86ae3b5ff9bf67fc45.tar.gz
qemu-system-aarch64-multiarch: Add support for custom machine path
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 /<custom-mach-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 <sandeep.gundlupet-raju@amd.com> Signed-off-by: Mark Hatle <mark.hatle@amd.com>
-rw-r--r--meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch30
1 files 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 @@
1#!/usr/bin/env python3 1#!/usr/bin/env python3
2 2
3# Xilinx QEMU wrapper to launch both PMU and APU instances (multiarch) 3# Copyright (C) 2017-2022, Xilinx, Inc. All rights reserved.
4# Copyright (C) 2022-2025, Advanced Micro Devices, Inc. All rights reserved.
5#
6#
7# SPDX-License-Identifier: MIT
8
9# AMD QEMU wrapper to launch both PMU and APU instances (multiarch)
10
4import os 11import os
5import subprocess 12import subprocess
6import sys 13import sys
@@ -9,13 +16,13 @@ import re
9import shutil 16import shutil
10 17
11binpath = os.path.dirname(os.path.abspath(__file__)) 18binpath = os.path.dirname(os.path.abspath(__file__))
12mach_path = tempfile.mkdtemp()
13 19
14# Separate PMU and APU arguments 20# Separate PMU and APU arguments
15APU_args = sys.argv[1:] 21APU_args = sys.argv[1:]
16PMU_args = [] 22PMU_args = []
17PLM_args = [] 23PLM_args = []
18bootbin_arg = None 24bootbin_arg = None
25mach_path_arg = None
19 26
20if '-pmu-args' in APU_args: 27if '-pmu-args' in APU_args:
21 pmu_args_idx = APU_args.index('-pmu-args') 28 pmu_args_idx = APU_args.index('-pmu-args')
@@ -32,12 +39,25 @@ if '-bootbin' in APU_args:
32 bootbin_arg = APU_args[bootbin_args_idx+1] 39 bootbin_arg = APU_args[bootbin_args_idx+1]
33 del APU_args[bootbin_args_idx:bootbin_args_idx+2] 40 del APU_args[bootbin_args_idx:bootbin_args_idx+2]
34 41
42if '-machine-path' in APU_args:
43 mach_path_args_idx = APU_args.index('-machine-path')
44 mach_path_arg = APU_args[mach_path_args_idx+1]
45 del APU_args[mach_path_args_idx:mach_path_args_idx+2]
46
47if mach_path_arg:
48 if not os.path.isdir(mach_path_arg):
49 sys.exit(f'\nERROR: Missing machine path for qemu: {mach_path_arg}')
50 else:
51 mach_path = os.path.realpath(mach_path_arg)
52else:
53 mach_path = tempfile.mkdtemp()
54
35if PMU_args and PLM_args: 55if PMU_args and PLM_args:
36 sys.exit("\nError: -pmu-args can not be used with -plm-args\n") 56 sys.exit("\nError: -pmu-args can not be used with -plm-args\n")
37 57
38help_options = ['-h', '-help', '--help'] 58help_options = ['-h', '-help', '--help']
39def help(status): 59def help(status):
40 print("AMD FPGA QEMU multiarch wrapper\nVersion 2024.2\n\nUsage:") 60 print("AMD FPGA QEMU multiarch wrapper\nVersion 2025.1\n\nUsage:")
41 print(f" {sys.argv[0]} <APU options> [-pmu-args <pmu options>]") 61 print(f" {sys.argv[0]} <APU options> [-pmu-args <pmu options>]")
42 print(f" {sys.argv[0]} <APU options> [-plm-args <plm options>]\n") 62 print(f" {sys.argv[0]} <APU options> [-plm-args <plm options>]\n")
43 if status == 0: 63 if status == 0:
@@ -147,5 +167,7 @@ if apu_cmd and process_apu.wait():
147 if mb_cmd and process_mb.wait(): 167 if mb_cmd and process_mb.wait():
148 error_msg += '\nQEMU MB instance failed:\n%s' % process_mb.stderr.read().decode() 168 error_msg += '\nQEMU MB instance failed:\n%s' % process_mb.stderr.read().decode()
149 169
150shutil.rmtree(mach_path) 170if not mach_path_arg:
171 shutil.rmtree(mach_path)
172
151sys.exit(error_msg) 173sys.exit(error_msg)