dom0/qvm-core: implemented guiagent_installed preference for HVm

This commit is contained in:
Olivier Medoc 2013-01-10 19:25:41 +01:00 committed by Marek Marczykowski
parent 9ebfd63bef
commit 1f513edd2f
2 changed files with 45 additions and 20 deletions

View File

@ -2287,6 +2287,7 @@ class QubesHVm(QubesVm):
attrs['maxmem'].pop('save') attrs['maxmem'].pop('save')
attrs['timezone'] = { 'default': 'localtime', 'save': 'str(self.timezone)' } attrs['timezone'] = { 'default': 'localtime', 'save': 'str(self.timezone)' }
attrs['qrexec_installed'] = { 'default': False, 'save': 'str(self.qrexec_installed)' } attrs['qrexec_installed'] = { 'default': False, 'save': 'str(self.qrexec_installed)' }
attrs['guiagent_installed'] = { 'default' : False, 'save': 'str(self.guiagent_installed)' }
attrs['_start_guid_first']['eval'] = 'True' attrs['_start_guid_first']['eval'] = 'True'
return attrs return attrs
@ -2306,6 +2307,10 @@ class QubesHVm(QubesVm):
# HVM doesn't support dynamic memory management # HVM doesn't support dynamic memory management
self.maxmem = self.memory self.maxmem = self.memory
# Disable qemu GUID if the user installed qubes gui agent
if self.guiagent_installed:
self._start_guid_first = False
@property @property
def type(self): def type(self):
return "HVM" return "HVM"
@ -2471,6 +2476,10 @@ class QubesHVm(QubesVm):
return -1 return -1
def start_guid(self, verbose = True, notify_function = None): def start_guid(self, verbose = True, notify_function = None):
# If user force the guiagent, start_guid will mimic a standard QubesVM
if self.guiagent_installed:
super(QubesHVm, self).start_guid(verbose, notify_function)
else:
if verbose: if verbose:
print >> sys.stderr, "--> Starting Qubes GUId..." print >> sys.stderr, "--> Starting Qubes GUId..."
@ -2482,15 +2491,12 @@ class QubesHVm(QubesVm):
if self.qrexec_installed: if self.qrexec_installed:
super(QubesHVm, self).start_qrexec_daemon(**kwargs) super(QubesHVm, self).start_qrexec_daemon(**kwargs)
if self._start_guid_first:
if kwargs.get('verbose'): if kwargs.get('verbose'):
print >> sys.stderr, "--> Waiting for user '%s' login..." % self.default_user print >> sys.stderr, "--> Waiting for user '%s' login..." % self.default_user
p = self.run('QUBESRPC qubes.WaitForSession', user="SYSTEM", passio_popen=True, gui=False, wait=True) # TODO retrieve the notify_function from kwargs ?
p.communicate(input=self.default_user) self.wait_for_session(**kwargs)
retcode = subprocess.call([qubes_clipd_path])
if retcode != 0:
print >> sys.stderr, "ERROR: Cannot start qclipd!"
def pause(self): def pause(self):
if dry_run: if dry_run:
@ -2507,6 +2513,10 @@ class QubesHVm(QubesVm):
super(QubesHVm, self).unpause() super(QubesHVm, self).unpause()
def is_guid_running(self): def is_guid_running(self):
# If user force the guiagent, is_guid_running will mimic a standard QubesVM
if self.guiagent_installed:
return super(QubesHVm, self).is_guid_running()
else:
xid = self.stubdom_xid xid = self.stubdom_xid
if xid < 0: if xid < 0:
return False return False
@ -2877,7 +2887,7 @@ class QubesVmCollection(dict):
"uses_default_netvm", "label", "memory", "vcpus", "pcidevs", "uses_default_netvm", "label", "memory", "vcpus", "pcidevs",
"maxmem", "kernel", "uses_default_kernel", "kernelopts", "uses_default_kernelopts", "maxmem", "kernel", "uses_default_kernel", "kernelopts", "uses_default_kernelopts",
"mac", "services", "include_in_backups", "debug", "mac", "services", "include_in_backups", "debug",
"default_user", "qrexec_timeout", "qrexec_installed", "drive" ) "default_user", "qrexec_timeout", "qrexec_installed", "guiagent_installed", "drive" )
for attribute in common_attr_list: for attribute in common_attr_list:
kwargs[attribute] = element.get(attribute) kwargs[attribute] = element.get(attribute)
@ -2942,6 +2952,9 @@ class QubesVmCollection(dict):
if "qrexec_installed" in kwargs: if "qrexec_installed" in kwargs:
kwargs["qrexec_installed"] = True if kwargs["qrexec_installed"] == "True" else False kwargs["qrexec_installed"] = True if kwargs["qrexec_installed"] == "True" else False
if "guiagent_installed" in kwargs:
kwargs["guiagent_installed"] = True if kwargs["guiagent_installed"] == "True" else False
if "drive" in kwargs and kwargs["drive"] == "None": if "drive" in kwargs and kwargs["drive"] == "None":
kwargs["drive"] = None kwargs["drive"] = None

View File

@ -84,6 +84,9 @@ def do_list(vm):
if hasattr(vm, 'qrexec_installed'): if hasattr(vm, 'qrexec_installed'):
print fmt.format("qrexec_installed", str(vm.qrexec_installed)) print fmt.format("qrexec_installed", str(vm.qrexec_installed))
if hasattr(vm, 'guiagent_installed'):
print fmt.format("guiagent_installed", str(vm.guiagent_installed))
if hasattr(vm, 'qrexec_timeout'): if hasattr(vm, 'qrexec_timeout'):
print fmt.format("qrexec timeout", str(vm.qrexec_timeout)) print fmt.format("qrexec timeout", str(vm.qrexec_timeout))
@ -336,6 +339,14 @@ def set_qrexec_installed(vms, vm, args):
vm.qrexec_installed = bool(eval(args[0].capitalize())) vm.qrexec_installed = bool(eval(args[0].capitalize()))
return True return True
def set_guiagent_installed(vms, vm, args):
if len (args) != 1:
print >> sys.stderr, "Missing value (True/False)!"
return False
vm.guiagent_installed = bool(eval(args[0].capitalize()))
return True
def set_qrexec_timeout(vms, vm, args): def set_qrexec_timeout(vms, vm, args):
if len (args) != 1: if len (args) != 1:
print >> sys.stderr, "Missing timeout value (seconds)!" print >> sys.stderr, "Missing timeout value (seconds)!"
@ -373,6 +384,7 @@ properties = {
"debug": set_debug, "debug": set_debug,
"default_user": set_default_user, "default_user": set_default_user,
"qrexec_installed": set_qrexec_installed, "qrexec_installed": set_qrexec_installed,
"guiagent_installed": set_guiagent_installed,
"qrexec_timeout": set_qrexec_timeout, "qrexec_timeout": set_qrexec_timeout,
"timezone": set_timezone, "timezone": set_timezone,
} }