dom0/core: introduce is_guid_running() and use it in is_fully_usable()
To improve code reuse, especially to remove direct checking for "/var/run/qubes/guid_running.{0}" in many places.
This commit is contained in:
parent
6a929190d2
commit
46db1e83f0
@ -650,12 +650,18 @@ class QubesVm(object):
|
|||||||
|
|
||||||
return "NA"
|
return "NA"
|
||||||
|
|
||||||
def is_fully_usable(self):
|
def is_guid_running(self):
|
||||||
xid = self.get_xid()
|
xid = self.get_xid()
|
||||||
if xid < 0:
|
if xid < 0:
|
||||||
return False
|
return False
|
||||||
if not os.path.exists('/var/run/qubes/guid_running.%d' % xid):
|
if not os.path.exists('/var/run/qubes/guid_running.%d' % xid):
|
||||||
return False
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def is_fully_usable(self):
|
||||||
|
# Running gui-daemon implies also VM running
|
||||||
|
if not self.is_guid_running():
|
||||||
|
return False
|
||||||
# currently qrexec daemon doesn't cleanup socket in /var/run/qubes, so
|
# currently qrexec daemon doesn't cleanup socket in /var/run/qubes, so
|
||||||
# it can be left from some other VM
|
# it can be left from some other VM
|
||||||
return True
|
return True
|
||||||
@ -1312,7 +1318,7 @@ class QubesVm(object):
|
|||||||
raise QubesException("Not enough memory to start '{0}' VM! Close one or more running VMs and try again.".format(self.name))
|
raise QubesException("Not enough memory to start '{0}' VM! Close one or more running VMs and try again.".format(self.name))
|
||||||
|
|
||||||
xid = self.get_xid()
|
xid = self.get_xid()
|
||||||
if os.getenv("DISPLAY") is not None and not os.path.isfile("/var/run/qubes/guid_running.{0}".format(xid)):
|
if os.getenv("DISPLAY") is not None and not self.is_guid_running():
|
||||||
self.start_guid(verbose = verbose, notify_function = notify_function)
|
self.start_guid(verbose = verbose, notify_function = notify_function)
|
||||||
|
|
||||||
args = [qrexec_client_path, "-d", str(xid), command]
|
args = [qrexec_client_path, "-d", str(xid), command]
|
||||||
|
Loading…
Reference in New Issue
Block a user