From 88c1019ee3a0336481bb506b1bc8b0d880a1164d Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 7 Feb 2025 16:09:11 +0100 Subject: [PATCH] vng: support --nvgpu and --qemu-opts When passing arguments to virtme-run, --qemu-opts has to be the last one, because it will take all args set after that. In other words, --nvgpu was not supposed to be passed after --qemu-opts. While at it, re-order functions and add a comment to avoid re-doing the same mistake. Note that an alternative would be to call virtme-run with --qemu-opt instead of --qemu-opts (with 's'). But a comment should be enough. Signed-off-by: Matthieu Baerts (NGI0) --- virtme_ng/run.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/virtme_ng/run.py b/virtme_ng/run.py index 4a60e84..060eed4 100644 --- a/virtme_ng/run.py +++ b/virtme_ng/run.py @@ -1200,6 +1200,12 @@ def _get_virtme_cpus(self, args): cpus = args.cpus self.virtme_param["cpus"] = f"--cpus {cpus}" + def _get_virtme_nvgpu(self, args): + if args.nvgpu is not None: + self.virtme_param["nvgpu"] = f"--nvgpu 'vfio-pci,host={args.nvgpu}'" + else: + self.virtme_param["nvgpu"] = "" + def _get_virtme_qemu_opts(self, args): qemu_args = "" if args.qemu_opts is not None: @@ -1214,12 +1220,6 @@ def _get_virtme_qemu_opts(self, args): else: self.virtme_param["qemu_opts"] = "" - def _get_virtme_nvgpu(self, args): - if args.nvgpu is not None: - self.virtme_param["nvgpu"] = f"--nvgpu 'vfio-pci,host={args.nvgpu}'" - else: - self.virtme_param["nvgpu"] = "" - def run(self, args): """Execute a kernel inside virtme-ng.""" self._get_virtme_name(args) @@ -1260,9 +1260,9 @@ def run(self, args): self._get_virtme_gdb(args) self._get_virtme_snaps(args) self._get_virtme_busybox(args) + self._get_virtme_nvgpu(args) self._get_virtme_qemu(args) self._get_virtme_qemu_opts(args) - self._get_virtme_nvgpu(args) # Start VM using virtme-run cmd = ( @@ -1305,9 +1305,10 @@ def run(self, args): + f'{self.virtme_param["gdb"]} ' + f'{self.virtme_param["snaps"]} ' + f'{self.virtme_param["busybox"]} ' + + f'{self.virtme_param["nvgpu"]} ' + f'{self.virtme_param["qemu"]} ' + f'{self.virtme_param["qemu_opts"]} ' - + f'{self.virtme_param["nvgpu"]} ' + # Important: qemu_opts has to be the last one ) check_call(cmd, shell=True)