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,26 +2476,27 @@ 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 verbose: # If user force the guiagent, start_guid will mimic a standard QubesVM
print >> sys.stderr, "--> Starting Qubes GUId..." if self.guiagent_installed:
super(QubesHVm, self).start_guid(verbose, notify_function)
else:
if verbose:
print >> sys.stderr, "--> Starting Qubes GUId..."
retcode = subprocess.call ([qubes_guid_path, "-d", str(self.stubdom_xid), "-c", self.label.color, "-i", self.label.icon, "-l", str(self.label.index)]) retcode = subprocess.call ([qubes_guid_path, "-d", str(self.stubdom_xid), "-c", self.label.color, "-i", self.label.icon, "-l", str(self.label.index)])
if (retcode != 0) : if (retcode != 0) :
raise QubesException("Cannot start qubes_guid!") raise QubesException("Cannot start qubes_guid!")
def start_qrexec_daemon(self, **kwargs): def start_qrexec_daemon(self, **kwargs):
if self.qrexec_installed: if self.qrexec_installed:
super(QubesHVm, self).start_qrexec_daemon(**kwargs) super(QubesHVm, self).start_qrexec_daemon(**kwargs)
if kwargs.get('verbose'): if self._start_guid_first:
print >> sys.stderr, "--> Waiting for user '%s' login..." % self.default_user if kwargs.get('verbose'):
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,12 +2513,16 @@ class QubesHVm(QubesVm):
super(QubesHVm, self).unpause() super(QubesHVm, self).unpause()
def is_guid_running(self): def is_guid_running(self):
xid = self.stubdom_xid # If user force the guiagent, is_guid_running will mimic a standard QubesVM
if xid < 0: if self.guiagent_installed:
return False return super(QubesHVm, self).is_guid_running()
if not os.path.exists('/var/run/qubes/guid_running.%d' % xid): else:
return False xid = self.stubdom_xid
return True if xid < 0:
return False
if not os.path.exists('/var/run/qubes/guid_running.%d' % xid):
return False
return True
class QubesVmCollection(dict): class QubesVmCollection(dict):
""" """
@ -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,
} }