From 3af71ab65d6349da33d708c34967f35fc90805fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 8 Feb 2016 20:23:51 +0100 Subject: [PATCH] storage: fix handling netvm and adminvm @woju what was consensus on 'servicevms' dir? Since "being network provider" is no longer separate type and can be changed during VM lifetime, maybe we should abandon that idea? Or maybe just set it as VM property (some storage pool config argument) - that way mgmt stack could put all the sys-* VMs into separate directory, regardless of the type. --- qubes/storage/__init__.py | 4 +++- qubes/vm/qubesvm.py | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index 65fa3f31..5cba5e42 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -526,9 +526,11 @@ class Pool(object): elif vm.is_disposablevm(): subdir = 'appvms' return os.path.join(pool_dir, subdir, vm.template.name + '-dvm') + elif isinstance(vm, qubes.vm.adminvm.AdminVM): + subdir = 'servicevms' else: raise qubes.exc.QubesException( - 'unknown vm type: {!r}'.format(vm.type())) + 'unknown vm type: {!r}'.format(str(vm.__class__))) return os.path.join(pool_dir, subdir, vm.name) diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index f9a5ae5c..4c212079 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -398,6 +398,12 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): DeprecationWarning) return isinstance(self, qubes.vm.dispvm.DispVM) + def is_netvm(self): + warnings.warn('vm.is_netvm() is deprecated, use isinstance()', + DeprecationWarning) + return isinstance(self, qubes.vm.mix.net.NetVMMixin) \ + and self.provides_network + # network-related