From 078a6d8d346b48edde5c970e5d7fa043e156b683 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 3 May 2017 16:01:51 +0200 Subject: [PATCH] Fix a race condition when editing a qemu vm and connecting it Fix #997 --- gns3server/compute/qemu/qemu_vm.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index ae901516..21e761df 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1131,9 +1131,13 @@ class QemuVM(BaseNode): adapter_number=adapter_number)) if self.ubridge: - yield from self._add_ubridge_udp_connection("QEMU-{}-{}".format(self._id, adapter_number), - self._local_udp_tunnels[adapter_number][1], - nio) + try: + yield from self._add_ubridge_udp_connection("QEMU-{}-{}".format(self._id, adapter_number), + self._local_udp_tunnels[adapter_number][1], + nio) + except IndexError: + raise QemuError('Adapter {adapter_number} does not exist on QEMU VM "{name}"'.format(name=self._name, + adapter_number=adapter_number)) elif self.is_running(): raise QemuError("Sorry, adding a link to a started Qemu VM is not supported without using uBridge.")