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
33 changes: 18 additions & 15 deletions virtme/architectures.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def serial_dev_name(index) -> str:
return 'ttyS%d' % index

@staticmethod
def qemuargs(is_native) -> List[str]:
def qemuargs(is_native, has_watchdog_arg) -> List[str]:
return []

@staticmethod
Expand Down Expand Up @@ -56,8 +56,8 @@ def dtb_path() -> Optional[str]:

class Arch_unknown(Arch):
@staticmethod
def qemuargs(is_native):
return Arch.qemuargs(is_native)
def qemuargs(is_native, has_watchdog_arg):
return Arch.qemuargs(is_native, has_watchdog_arg)

class Arch_x86(Arch):
def __init__(self, name):
Expand All @@ -67,11 +67,14 @@ def __init__(self, name):
self.defconfig_target = '%s_defconfig' % name

@staticmethod
def qemuargs(is_native):
ret = Arch.qemuargs(is_native)
def qemuargs(is_native, has_watchdog_arg):
ret = Arch.qemuargs(is_native, has_watchdog_arg)

# Add a watchdog. This is useful for testing.
ret.extend(['-watchdog', 'i6300esb'])
if has_watchdog_arg:
ret.extend(['-watchdog', 'i6300esb'])
else:
ret.extend(['-device', 'i6300esb'])

if is_native and os.access('/dev/kvm', os.R_OK):
# If we're likely to use KVM, request a full-featured CPU.
Expand Down Expand Up @@ -122,8 +125,8 @@ def __init__(self):
self.defconfig_target = 'vexpress_defconfig'

@staticmethod
def qemuargs(is_native):
ret = Arch.qemuargs(is_native)
def qemuargs(is_native, has_watchdog_arg):
ret = Arch.qemuargs(is_native, has_watchdog_arg)

# Emulate a vexpress-a15.
ret.extend(['-M', 'vexpress-a15'])
Expand Down Expand Up @@ -162,8 +165,8 @@ def __init__(self):
self.gccname = 'aarch64'

@staticmethod
def qemuargs(is_native):
ret = Arch.qemuargs(is_native)
def qemuargs(is_native, has_watchdog_arg):
ret = Arch.qemuargs(is_native, has_watchdog_arg)

if is_native:
ret.extend(['-M', 'virt,gic-version=host'])
Expand Down Expand Up @@ -204,7 +207,7 @@ def __init__(self):
self.gccname = 'ppc64'

def qemuargs(self, is_native):
ret = Arch.qemuargs(is_native)
ret = Arch.qemuargs(is_native, has_watchdog_arg)

ret.extend(['-M', 'pseries'])

Expand All @@ -224,7 +227,7 @@ def __init__(self):
self.gccname = 'riscv64'

def qemuargs(self, is_native):
ret = Arch.qemuargs(is_native)
ret = Arch.qemuargs(is_native, has_watchdog_arg)

ret.extend(['-machine', 'virt'])
ret.extend(['-bios', 'default'])
Expand All @@ -248,7 +251,7 @@ def __init__(self):
self.gccname = 'sparc64'

def qemuargs(self, is_native):
ret = Arch.qemuargs(is_native)
ret = Arch.qemuargs(is_native, has_watchdog_arg)

return ret

Expand All @@ -271,8 +274,8 @@ def __init__(self):
def virtio_dev_type(virtiotype):
return 'virtio-%s-ccw' % virtiotype

def qemuargs(self, is_native):
ret = Arch.qemuargs(is_native)
def qemuargs(self, is_native, has_watchdog_arg):
ret = Arch.qemuargs(is_native, has_watchdog_arg)

# Ask for the latest version of s390-ccw
ret.extend(['-M', 's390-ccw-virtio'])
Expand Down
2 changes: 1 addition & 1 deletion virtme/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def do_it() -> int:
qemuargs.extend(['-machine', 'accel=kvm:tcg'])

# Add architecture-specific options
qemuargs.extend(arch.qemuargs(is_native))
qemuargs.extend(arch.qemuargs(is_native, qemu.has_watchdog_arg))

# Set up / override baseline devices
qemuargs.extend(['-parallel', 'none'])
Expand Down
17 changes: 13 additions & 4 deletions virtme/qemu_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ def probe(self) -> None:
if self.version is None:
self.version = subprocess.check_output([self.qemubin, '--version'])\
.decode('utf-8')
self.cannot_overmount_virtfs = (
re.search(r'version 1\.[012345]', self.version) is not None)

# Parse version parts into a tuple of ints, default to (0,)
m = re.search(r'version ((?:\d\.)*\d)', self.version)
if m is None:
version_parts = (0,)
else:
try:
version_parts = tuple(int(i) for i in m.group(1).split('.'))
except ValueError:
version_parts = (0,)

self.cannot_overmount_virtfs = version_parts <= (1, 5)

# QEMU 4.2+ supports -fsdev multidevs=remap
self.has_multidevs = (
re.search(r'version (?:1\.|2\.|3\.|4\.[01][^\d])', self.version) is None)
self.has_multidevs = version_parts >= (4, 2)

def quote_optarg(self, a: str) -> str:
"""Quote an argument to an option."""
Expand Down