diff options
author | Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com> | 2025-01-30 10:55:45 -0700 |
---|---|---|
committer | Mark Hatle <mark.hatle@amd.com> | 2025-03-30 14:16:15 -0600 |
commit | b5a776ec18e26562eff67f86ae3b5ff9bf67fc45 (patch) | |
tree | 6e2de61545593ae61324b857699c17b8eea76baf | |
parent | 166b86d36dda24d2bbaa2fd2ffbbc16fbd0e58da (diff) | |
download | meta-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-multiarch | 30 |
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 | |||
4 | import os | 11 | import os |
5 | import subprocess | 12 | import subprocess |
6 | import sys | 13 | import sys |
@@ -9,13 +16,13 @@ import re | |||
9 | import shutil | 16 | import shutil |
10 | 17 | ||
11 | binpath = os.path.dirname(os.path.abspath(__file__)) | 18 | binpath = os.path.dirname(os.path.abspath(__file__)) |
12 | mach_path = tempfile.mkdtemp() | ||
13 | 19 | ||
14 | # Separate PMU and APU arguments | 20 | # Separate PMU and APU arguments |
15 | APU_args = sys.argv[1:] | 21 | APU_args = sys.argv[1:] |
16 | PMU_args = [] | 22 | PMU_args = [] |
17 | PLM_args = [] | 23 | PLM_args = [] |
18 | bootbin_arg = None | 24 | bootbin_arg = None |
25 | mach_path_arg = None | ||
19 | 26 | ||
20 | if '-pmu-args' in APU_args: | 27 | if '-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 | ||
42 | if '-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 | |||
47 | if 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) | ||
52 | else: | ||
53 | mach_path = tempfile.mkdtemp() | ||
54 | |||
35 | if PMU_args and PLM_args: | 55 | if 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 | ||
38 | help_options = ['-h', '-help', '--help'] | 58 | help_options = ['-h', '-help', '--help'] |
39 | def help(status): | 59 | def 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 | ||
150 | shutil.rmtree(mach_path) | 170 | if not mach_path_arg: |
171 | shutil.rmtree(mach_path) | ||
172 | |||
151 | sys.exit(error_msg) | 173 | sys.exit(error_msg) |