Skip to content

Commit

Permalink
vng: support --nvgpu and --qemu-opts
Browse files Browse the repository at this point in the history
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) <[email protected]>
  • Loading branch information
matttbe committed Feb 7, 2025
1 parent 8cb14a8 commit 88c1019
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions virtme_ng/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 88c1019

Please sign in to comment.