Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion virtme/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def make_parser() -> argparse.ArgumentParser:
help='Use the specified busybox binary.')

g = parser.add_argument_group(title='Virtualizer settings')
g.add_argument('--qemu-bin', action='store', default=None,
help="Use specified QEMU binary.")
g.add_argument('-q', '--qemu-opt', action='append', default=[],
help="Add a single QEMU argument. Use this when --qemu-opts's greedy behavior is problematic.'")
g.add_argument('--qemu-opts', action='store', nargs=argparse.REMAINDER,
Expand Down Expand Up @@ -285,7 +287,7 @@ def do_it() -> int:
arch = architectures.get(args.arch)
is_native = (args.arch == uname.machine)

qemu = qemu_helpers.Qemu(arch.qemuname)
qemu = qemu_helpers.Qemu(args.qemu_bin, arch.qemuname)
qemu.probe()

need_initramfs = args.force_initramfs or qemu.cannot_overmount_virtfs
Expand Down
18 changes: 12 additions & 6 deletions virtme/qemu_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ class Qemu(object):
qemubin: str
version: Optional[str]

def __init__(self, arch) -> None:
def __init__(self, qemubin, arch) -> None:
self.arch = arch

qemubin = shutil.which('qemu-system-%s' % arch)
if qemubin is None and arch == os.uname().machine:
qemubin = shutil.which('qemu-kvm')
if qemubin is None:
raise ValueError('cannot find qemu for %s' % arch)
if not qemubin:
qemubin = shutil.which('qemu-system-%s' % arch)
if qemubin is None and arch == os.uname().machine:
qemubin = shutil.which('qemu-kvm')
if qemubin is None:
raise ValueError('cannot find qemu for %s' % arch)
else:
if not os.path.isfile(qemubin):
raise ValueError('specified qemu binary "%s" does not exist' % qemubin)
if not os.access(qemubin, os.X_OK):
raise ValueError('specified qemu binary "%s" is not executable' % qemubin)

self.qemubin = qemubin
self.version = None
Expand Down