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
1 change: 1 addition & 0 deletions selftests/unit/test_env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_regex(self):
"0.12.1",
"qemu-kvm-0.12.1.2-2.503.el6_9.3",
),
"QEMU emulator version 10.1.3": ("10.1.3", None),
}
for version, expected in list(versions_expected.items()):
match = re.match(QEMU_VERSION_RE, version)
Expand Down
5 changes: 2 additions & 3 deletions virttest/env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@
postprocess_vm_on_hook = None
postprocess_vm_off_hook = None

#: QEMU version regex. Attempts to extract the simple and extended version
#: information from the output produced by `qemu -version`
QEMU_VERSION_RE = r"QEMU (?:PC )?emulator version\s([0-9]+\.[0-9]+\.[0-9]+)\s?\((.*?)\)"
#: QEMU version regex (same compiled pattern as `utils_qemu.QEMU_VERSION_RE`).
QEMU_VERSION_RE = utils_qemu.QEMU_VERSION_RE

THREAD_ERROR = False

Expand Down
8 changes: 5 additions & 3 deletions virttest/test_setup/requirement_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ def _get_qemu_version(qemu_cmd):
version_line = version_output.split("\n")[0]
matches = re.match(env_process.QEMU_VERSION_RE, version_line)
if matches:
return "%s (%s)" % matches.groups()
else:
return "Unknown"
ver, extra = matches.groups()
if extra:
return "%s (%s)" % (ver, extra)
return ver
return "Unknown"

def setup(self):
# Get the KVM userspace version
Expand Down
2 changes: 1 addition & 1 deletion virttest/utils_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from avocado.utils import process

QEMU_VERSION_RE = re.compile(
r"QEMU (?:PC )?emulator version\s" r"([0-9]+\.[0-9]+\.[0-9]+)" r"(?:\s\((.*?)\))?"
r"QEMU (?:PC )?emulator version\s" r"([0-9]+\.[0-9]+\.[0-9]+)" r"(?:\s*\((.*?)\))?"
)
DEVICE_CATEGORY_RE = re.compile(r"([A-Z]\S+) devices:")

Expand Down
Loading