From 2e0f012952259f3b6995f1af7cfef497ba4cf4d7 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Fri, 24 Feb 2017 13:58:03 +0100 Subject: [PATCH] Improve ACPI shutdown for virtualbox --- gns3server/compute/virtualbox/virtualbox_vm.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gns3server/compute/virtualbox/virtualbox_vm.py b/gns3server/compute/virtualbox/virtualbox_vm.py index e1d520dc..77466ec9 100644 --- a/gns3server/compute/virtualbox/virtualbox_vm.py +++ b/gns3server/compute/virtualbox/virtualbox_vm.py @@ -303,6 +303,16 @@ class VirtualBoxVM(BaseNode): if self.acpi_shutdown: # use ACPI to shutdown the VM result = yield from self._control_vm("acpipowerbutton") + trial = 0 + while True: + vm_state = yield from self._get_vm_state() + if vm_state == "poweroff": + break + yield from asyncio.sleep(1) + trial += 1 + if trial >= 120: + yield from self._control_vm("poweroff") + break self.status = "stopped" log.debug("ACPI shutdown result: {}".format(result)) else: