Skip to content

Commit

Permalink
Set Qemu uuid for csr1000v
Browse files Browse the repository at this point in the history
Fix #711
  • Loading branch information
julien-duponchelle committed Oct 3, 2016
1 parent 99bdf37 commit f3d2557
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gns3server/compute/qemu/qemu_vm.py
Expand Up @@ -694,7 +694,7 @@ def initrd(self, initrd):
:param initrd: QEMU initrd path
"""

initrd = self.manager.get_abs_image_path(initrd)
initrd = self.manager.get_abs_image_path(initrd)

log.info('QEMU VM "{name}" [{id}] has set the QEMU initrd path to {initrd}'.format(name=self._name,
id=self._id,
Expand Down Expand Up @@ -1480,6 +1480,7 @@ def _build_command(self):
(to be passed to subprocess.Popen())
"""

additional_options = self._options.strip()
command = [self.qemu_path]
command.extend(["-name", self._name])
command.extend(["-m", "{}M".format(self._ram)])
Expand All @@ -1496,6 +1497,8 @@ def _build_command(self):
command.extend(cdrom_option)
command.extend((yield from self._disk_options()))
command.extend(self._linux_boot_options())
if "-uuid" not in additional_options:
command.extend(["-uuid", self._id])
if self._console_type == "telnet":
command.extend(self._serial_options())
elif self._console_type == "vnc":
Expand All @@ -1505,7 +1508,6 @@ def _build_command(self):
command.extend(self._monitor_options())
command.extend((yield from self._network_options()))
command.extend(self._graphic())
additional_options = self._options.strip()
if additional_options:
try:
command.extend(shlex.split(additional_options))
Expand Down
21 changes: 21 additions & 0 deletions tests/compute/qemu/test_qemu_vm.py
Expand Up @@ -431,6 +431,8 @@ def test_build_command(vm, loop, fake_qemu_binary, port_manager):
"cpus=1",
"-boot",
"order=c",
"-uuid",
vm.id,
"-serial",
"telnet:127.0.0.1:{},server,nowait".format(vm.console),
"-net",
Expand All @@ -440,6 +442,19 @@ def test_build_command(vm, loop, fake_qemu_binary, port_manager):
]


def test_build_command_manual_uuid(vm, loop, fake_qemu_binary, port_manager):
"""
If user has set a uuid we keep it
"""

vm.options = "-uuid e1c307a4-896f-11e6-81a5-3c07547807cc"
os.environ["DISPLAY"] = "0:0"
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
cmd = loop.run_until_complete(asyncio.async(vm._build_command()))
assert "e1c307a4-896f-11e6-81a5-3c07547807cc" in cmd
assert vm.id not in cmd


def test_build_command_kvm(linux_platform, vm, loop, fake_qemu_binary, port_manager):
"""
Qemu 2.4 introduce an issue with KVM
Expand All @@ -460,6 +475,8 @@ def test_build_command_kvm(linux_platform, vm, loop, fake_qemu_binary, port_mana
"-enable-kvm",
"-boot",
"order=c",
"-uuid",
vm.id,
"-serial",
"telnet:127.0.0.1:{},server,nowait".format(vm.console),
"-net",
Expand Down Expand Up @@ -491,6 +508,8 @@ def test_build_command_kvm_2_4(linux_platform, vm, loop, fake_qemu_binary, port_
"smm=off",
"-boot",
"order=c",
"-uuid",
vm.id,
"-serial",
"telnet:127.0.0.1:{},server,nowait".format(vm.console),
"-net",
Expand Down Expand Up @@ -525,6 +544,8 @@ def test_build_command_two_adapters(vm, loop, fake_qemu_binary, port_manager):
"cpus=1",
"-boot",
"order=c",
"-uuid",
vm.id,
"-serial",
"telnet:127.0.0.1:{},server,nowait".format(vm.console),
"-net",
Expand Down

0 comments on commit f3d2557

Please sign in to comment.