From 5704b41a45f78c72c6ff28dffc962c292eb40a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 1 Apr 2014 01:10:35 +0200 Subject: [PATCH] hvm: seamless_gui_mode setting, including runtime change support (#810) --- core-modules/01QubesHVm.py | 29 +++++++++++++++++++++++++++++ qvm-tools/qvm-prefs | 23 +++++++++++++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/core-modules/01QubesHVm.py b/core-modules/01QubesHVm.py index e892497c..bd760071 100644 --- a/core-modules/01QubesHVm.py +++ b/core-modules/01QubesHVm.py @@ -70,6 +70,9 @@ class QubesHVm(QubesVm): attrs['guiagent_installed'] = { 'default' : False, 'attr': '_guiagent_installed', 'save': lambda: str(self._guiagent_installed) } + attrs['seamless_gui_mode'] = { 'default': False, + 'attr': '_seamless_gui_mode', + 'save': lambda: str(self._seamless_gui_mode) } attrs['_start_guid_first']['func'] = lambda x: True attrs['services']['default'] = "{'meminfo-writer': False}" @@ -140,6 +143,23 @@ class QubesHVm(QubesVm): print >>sys.stderr, "WARNING: When guiagent_installed set in template, it will be propagated to the VM" self._guiagent_installed = value + @property + def seamless_gui_mode(self): + if not self.guiagent_installed: + return False + return self._seamless_gui_mode + + @seamless_gui_mode.setter + def seamless_gui_mode(self, value): + if self._seamless_gui_mode == value: + return + if not self.guiagent_installed and value: + raise ValueError("Seamless GUI mode requires GUI agent installed") + + self._seamless_gui_mode = value + if self.is_running(): + self.send_gui_mode() + @property def drive(self): return self._drive @@ -456,6 +476,15 @@ class QubesHVm(QubesVm): print >> sys.stderr, "--> Waiting for user '%s' login..." % self.default_user self.wait_for_session(notify_function=kwargs.get('notify_function', None)) + self.send_gui_mode() + + def send_gui_mode(self): + if self.seamless_gui_mode: + service_input = "SEAMLESS" + else: + service_input = "FULLSCREEN" + + self.run_service("qubes.SetGuiMode", input=service_input) def create_xenstore_entries(self, xid = None): if dry_run: diff --git a/qvm-tools/qvm-prefs b/qvm-tools/qvm-prefs index c8df775d..c9e54455 100755 --- a/qvm-tools/qvm-prefs +++ b/qvm-tools/qvm-prefs @@ -86,11 +86,14 @@ def do_list(vm): if hasattr(vm, 'qrexec_installed'): print fmt.format("qrexec_installed", str(vm.qrexec_installed)) + if hasattr(vm, 'qrexec_timeout'): + print fmt.format("qrexec_timeout", str(vm.qrexec_timeout)) + if hasattr(vm, 'guiagent_installed'): print fmt.format("guiagent_installed", str(vm.guiagent_installed)) - if hasattr(vm, 'qrexec_timeout'): - print fmt.format("qrexec_timeout", str(vm.qrexec_timeout)) + if hasattr(vm, 'seamless_gui_mode'): + print fmt.format("seamless_gui_mode", str(vm.seamless_gui_mode)) if hasattr(vm, 'drive'): print fmt.format("drive", str(vm.drive)) @@ -370,6 +373,21 @@ def set_guiagent_installed(vms, vm, args): vm.guiagent_installed = bool(eval(args[0].capitalize())) return True +def set_seamless_gui_mode(vms, vm, args): + if len(args) != 1: + print >> sys.stderr, "Missing value (true/false)!" + return False + + if not args[0].lower() in ['true', 'false']: + print >> sys.stderr, "Invalid value, expected 'true' or 'false'" + return False + + if args[0].lower() == 'true': + vm.seamless_gui_mode = True + else: + vm.seamless_gui_mode = False + return True + def set_autostart(vms, vm, args): if len (args) != 1: print >> sys.stderr, "Missing value (True/False)!" @@ -416,6 +434,7 @@ properties = { "default_user": set_default_user, "qrexec_installed": set_qrexec_installed, "guiagent_installed": set_guiagent_installed, + "seamless_gui_mode": set_seamless_gui_mode, "qrexec_timeout": set_qrexec_timeout, "timezone": set_timezone, "internal": set_internal,