1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-25 00:08:11 +00:00

Catch error when qemu additional options are invalid

Fix #119
This commit is contained in:
Julien Duponchelle 2015-03-31 22:14:08 +02:00
parent 220d585dcc
commit 026fe3df9b
2 changed files with 11 additions and 1 deletions

View File

@ -1068,7 +1068,10 @@ class QemuVM(BaseVM):
command.extend(self._monitor_options())
additional_options = self._options.strip()
if additional_options:
command.extend(shlex.split(additional_options))
try:
command.extend(shlex.split(additional_options))
except ValueError as e:
QemuError("Invalid additional options: {} error {}".format(additional_options, e))
command.extend(self._network_options())
command.extend(self._graphic())
return command

View File

@ -280,6 +280,13 @@ def test_build_command_without_display(vm, loop, fake_qemu_binary):
assert "-nographic" in cmd
def test_build_command_witht_invalid_options(vm, loop, fake_qemu_binary):
vm.options = "'test"
with pytest.raises(QemuError):
cmd = loop.run_until_complete(asyncio.async(vm._build_command()))
def test_hda_disk_image(vm, tmpdir):
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):