From bc5ec98cd5f7faed6fbdc3dad3f652aa97bebdcd Mon Sep 17 00:00:00 2001 From: ziajka Date: Fri, 16 Jun 2017 10:03:33 +0200 Subject: [PATCH] Spice support * QEMU VNC options tests * QEMU - SPICE support at build options and schemas * SPICE console_type for nodes --- gns3server/compute/qemu/qemu_vm.py | 10 ++++++++++ gns3server/schemas/node.py | 2 +- gns3server/schemas/qemu.py | 6 +++--- tests/compute/qemu/test_qemu_vm.py | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index fc830cae..62bc99a4 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1305,6 +1305,14 @@ class QemuVM(BaseNode): else: return [] + def _spice_options(self): + + if self._console: + return ["-spice", + "addr={},port={},disable-ticketing".format(self._manager.port_manager.console_host, self._console)] + else: + return [] + def _monitor_options(self): if self._monitor: @@ -1584,6 +1592,8 @@ class QemuVM(BaseNode): command.extend(self._serial_options()) elif self._console_type == "vnc": command.extend(self._vnc_options()) + elif self._console_type == "spice": + command.extend(self._spice_options()) else: raise QemuError("Console type {} is unknown".format(self._console_type)) command.extend(self._monitor_options()) diff --git a/gns3server/schemas/node.py b/gns3server/schemas/node.py index 6e8f4e2a..28add3ef 100644 --- a/gns3server/schemas/node.py +++ b/gns3server/schemas/node.py @@ -144,7 +144,7 @@ NODE_OBJECT_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["vnc", "telnet", "http", None] + "enum": ["vnc", "telnet", "http", "spice", None] }, "properties": { "description": "Properties specific to an emulator", diff --git a/gns3server/schemas/qemu.py b/gns3server/schemas/qemu.py index fee56de5..f67f808a 100644 --- a/gns3server/schemas/qemu.py +++ b/gns3server/schemas/qemu.py @@ -63,7 +63,7 @@ QEMU_CREATE_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["telnet", "vnc"] + "enum": ["telnet", "vnc", "spice"] }, "hda_disk_image": { "description": "QEMU hda disk image path", @@ -244,7 +244,7 @@ QEMU_UPDATE_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["telnet", "vnc"] + "enum": ["telnet", "vnc", "spice"] }, "linked_clone": { "description": "Whether the VM is a linked clone or not", @@ -541,7 +541,7 @@ QEMU_OBJECT_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["telnet", "vnc"] + "enum": ["telnet", "vnc", "spice"] }, "initrd": { "description": "QEMU initrd path", diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py index 9c5c7953..a7032439 100644 --- a/tests/compute/qemu/test_qemu_vm.py +++ b/tests/compute/qemu/test_qemu_vm.py @@ -359,6 +359,20 @@ def test_bios_option(vm, tmpdir, loop, fake_qemu_img_binary): assert ' '.join(['-bios', str(tmpdir / "test.img")]) in ' '.join(options) +def test_vnc_option(vm, tmpdir, loop, fake_qemu_img_binary): + vm._console_type = 'vnc' + vm._console = 5905 + options = loop.run_until_complete(asyncio.async(vm._build_command())) + assert '-vnc 127.0.0.1:5' in ' '.join(options) + + +def test_spice_option(vm, tmpdir, loop, fake_qemu_img_binary): + vm._console_type = 'spice' + vm._console = 5905 + options = loop.run_until_complete(asyncio.async(vm._build_command())) + assert '-spice addr=127.0.0.1,port=5905,disable-ticketing' in ' '.join(options) + + def test_disk_options_multiple_disk(vm, tmpdir, loop, fake_qemu_img_binary): vm._hda_disk_image = str(tmpdir / "test0.qcow2")