diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index c9c6c6dd..3afef86a 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -149,7 +149,9 @@ class QemuVM(BaseVM): if self._platform == "qemu-kvm": self._platform = "x86_64" else: - self._platform = re.sub(r'^qemu-system-(.*)(w.exe)?$', r'\1', os.path.basename(qemu_path), re.IGNORECASE) + qemu_bin = os.path.basename(qemu_path) + qemu_bin = re.sub(r'(w)?\.(exe|EXE)$', '', qemu_bin) + self._platform = re.sub(r'^qemu-system-(.*)$', r'\1', qemu_bin, re.IGNORECASE) if self._platform.split(".")[0] not in QEMU_PLATFORMS: raise QemuError("Platform {} is unknown".format(self._platform)) log.info('QEMU VM "{name}" [{id}] has set the QEMU path to {qemu_path}'.format(name=self._name, diff --git a/tests/modules/qemu/test_qemu_vm.py b/tests/modules/qemu/test_qemu_vm.py index 0aa8cbcb..ad6e3916 100644 --- a/tests/modules/qemu/test_qemu_vm.py +++ b/tests/modules/qemu/test_qemu_vm.py @@ -240,6 +240,20 @@ def test_set_qemu_path_environ(vm, tmpdir, fake_qemu_binary): assert vm.platform == "x86_64" + +def test_set_qemu_path_windows(vm, tmpdir): + + bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64w.EXE") + open(bin_path, "w+").close() + os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) + + vm.qemu_path = bin_path + + assert vm.qemu_path == bin_path + assert vm.platform == "x86_64" + + + @pytest.mark.skipif(sys.platform.startswith("linux") is False, reason="Supported only on linux") def test_set_qemu_path_kvm_binary(vm, tmpdir, fake_qemu_binary):