From 5be003d53904fe3585dbc63e9cc4585e4dd32961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 21 Oct 2018 04:44:47 +0200 Subject: [PATCH] vm/dispvm: fix DispVM cleanup First unregister the domain from collection, and only then call remove_from_disk(). Removing it from collection prevent further calls being made to it. Or if anything else keep a reference to it (for example as a netvm), then abort the operation. Additionally this makes it unnecessary to take startup lock when cleaning it up in tests. --- qubes/tests/__init__.py | 7 ------- qubes/vm/dispvm.py | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/qubes/tests/__init__.py b/qubes/tests/__init__.py index c3f3a2fd..78777599 100644 --- a/qubes/tests/__init__.py +++ b/qubes/tests/__init__.py @@ -789,13 +789,6 @@ class SystemTestCase(QubesTestCase): vmname = vm.name app = vm.app - # avoid race with DispVM.auto_cleanup=True - try: - self.loop.run_until_complete( - asyncio.wait_for(vm.startup_lock.acquire(), 10)) - except asyncio.TimeoutError: - pass - try: # XXX .is_running() may throw libvirtError if undefined if vm.is_running(): diff --git a/qubes/vm/dispvm.py b/qubes/vm/dispvm.py index 2179dd9f..0c6389f3 100644 --- a/qubes/vm/dispvm.py +++ b/qubes/vm/dispvm.py @@ -142,8 +142,8 @@ class DispVM(qubes.vm.qubesvm.QubesVM): def _auto_cleanup(self): '''Do auto cleanup if enabled''' if self.auto_cleanup and self in self.app.domains: - yield from self.remove_from_disk() del self.app.domains[self] + yield from self.remove_from_disk() self.app.save() @classmethod @@ -193,8 +193,8 @@ class DispVM(qubes.vm.qubesvm.QubesVM): pass # if auto_cleanup is set, this will be done automatically if not self.auto_cleanup: - yield from self.remove_from_disk() del self.app.domains[self] + yield from self.remove_from_disk() self.app.save() @asyncio.coroutine