From bee69a98b9bf1d0b94f7ef4d18dc7275391733ee Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sun, 16 Sep 2018 18:42:48 +0000 Subject: [PATCH] Add default_qrexec_timeout to qubes-prefs When a VM (or its template) does not explicitly set a qrexec_timeout, fall back to a global default_qrexec_timeout (with default value 60), instead of hardcoding the fallback value to 60. This makes it easy to set a higher timeout for the whole system, which helps users who habitually launch applications from several (not yet started) VMs at the same time. 60 seconds can be too short for that. --- qubes/app.py | 7 +++++++ qubes/tests/vm/__init__.py | 1 + qubes/tests/vm/qubesvm.py | 9 +++++++++ qubes/vm/qubesvm.py | 3 ++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/qubes/app.py b/qubes/app.py index 36d1f6be..8d0bd15e 100644 --- a/qubes/app.py +++ b/qubes/app.py @@ -718,6 +718,13 @@ class Qubes(qubes.PropertyHolder): setter=_setter_pool, doc='Default storage pool for kernel volumes') + default_qrexec_timeout = qubes.property('default_qrexec_timeout', + load_stage=3, + default=60, + type=int, + doc='''Default time in seconds after which qrexec connection attempt is + deemed failed''') + stats_interval = qubes.property('stats_interval', default=3, type=int, diff --git a/qubes/tests/vm/__init__.py b/qubes/tests/vm/__init__.py index d42148ec..54564b75 100644 --- a/qubes/tests/vm/__init__.py +++ b/qubes/tests/vm/__init__.py @@ -88,6 +88,7 @@ class TestApp(qubes.tests.TestEmitter): self.default_pool_root = 'default' self.default_pool_private = 'default' self.default_pool_kernel = 'linux-kernel' + self.default_qrexec_timeout = 60 self.default_netvm = None self.domains = TestVMsCollection() #: jinja2 environment for libvirt XML templates diff --git a/qubes/tests/vm/qubesvm.py b/qubes/tests/vm/qubesvm.py index 6d2e52ff..308fd782 100644 --- a/qubes/tests/vm/qubesvm.py +++ b/qubes/tests/vm/qubesvm.py @@ -459,6 +459,15 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase): self.assertPropertyInvalidValue(vm, 'qrexec_timeout', '-2') self.assertPropertyInvalidValue(vm, 'qrexec_timeout', '') + def test_272_qrexec_timeout_global_changed(self): + self.app.default_qrexec_timeout = 123 + vm = self.get_vm() + self.assertPropertyDefaultValue(vm, 'qrexec_timeout', 123) + self.assertPropertyValue(vm, 'qrexec_timeout', 3, 3, '3') + del vm.qrexec_timeout + self.assertPropertyDefaultValue(vm, 'qrexec_timeout', 123) + self.assertPropertyValue(vm, 'qrexec_timeout', '3', 3, '3') + def test_280_autostart(self): vm = self.get_vm() # FIXME any better idea to not involve systemctl call at this stage? diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 506cfe99..7955297e 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -510,7 +510,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): # return self._default_user qrexec_timeout = qubes.property('qrexec_timeout', type=int, - default=_default_with_template('qrexec_timeout', 60), + default=_default_with_template('qrexec_timeout', + lambda self: self.app.default_qrexec_timeout), setter=_setter_positive_int, doc='''Time in seconds after which qrexec connection attempt is deemed failed. Operating system inside VM should be able to boot in this