From 31d1696215ae949e6475d771ef69c3ee3f41e04d Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 3 May 2017 16:14:42 +0200 Subject: [PATCH] Catch a race condition in VirtualBox when editing and linking Fix #993 --- gns3server/compute/virtualbox/virtualbox_vm.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gns3server/compute/virtualbox/virtualbox_vm.py b/gns3server/compute/virtualbox/virtualbox_vm.py index 55de04dd..ecd7ef2c 100644 --- a/gns3server/compute/virtualbox/virtualbox_vm.py +++ b/gns3server/compute/virtualbox/virtualbox_vm.py @@ -968,9 +968,13 @@ class VirtualBoxVM(BaseNode): adapter_number=adapter_number)) if self.ubridge: - yield from self._add_ubridge_udp_connection("VBOX-{}-{}".format(self._id, adapter_number), - self._local_udp_tunnels[adapter_number][1], - nio) + try: + yield from self._add_ubridge_udp_connection("VBOX-{}-{}".format(self._id, adapter_number), + self._local_udp_tunnels[adapter_number][1], + nio) + except KeyError: + raise VirtualBoxError("Adapter {adapter_number} doesn't exist on VirtualBox VM '{name}'".format(name=self.name, + adapter_number=adapter_number)) yield from self._control_vm("setlinkstate{} on".format(adapter_number + 1)) else: vm_state = yield from self._get_vm_state()