Merge remote-tracking branch 'qubesos/pr/34'

* qubesos/pr/34:
  qfile-daemon-dvm: Implement LAUNCH and FINISH actions
  qfile-daemon-dvm: Call static method by class name
  qfile-daemon-dvm: Move dispVM killing into cleanup function
This commit is contained in:
Marek Marczykowski-Górecki 2016-06-30 01:43:57 +02:00
commit 03210f6cfe
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -150,7 +150,7 @@ class QfileDaemonDvm:
return self.do_get_dvm()
@staticmethod
def remove_disposable_from_qdb(name):
def finish_disposable(name):
qvm_collection = QubesVmCollection()
qvm_collection.lock_db_for_writing()
qvm_collection.load()
@ -158,6 +158,12 @@ class QfileDaemonDvm:
if vm is None:
qvm_collection.unlock_db()
return False
try:
vm.force_shutdown()
except QubesException:
# VM already destroyed
pass
qvm_collection.pop(vm.qid)
qvm_collection.save()
qvm_collection.unlock_db()
@ -165,6 +171,10 @@ class QfileDaemonDvm:
def main():
exec_index = sys.argv[1]
if exec_index == "FINISH":
QfileDaemonDvm.finish_disposable(sys.argv[2])
return
src_vmname = sys.argv[2]
user = sys.argv[3]
# accessed directly by get_dvm()
@ -177,15 +187,14 @@ def main():
qfile = QfileDaemonDvm(src_vmname)
dispvm = qfile.get_dvm()
if dispvm is not None:
if exec_index == "LAUNCH":
print dispvm.name
return
print >>sys.stderr, "time=%s, starting VM process" % (str(time.time()))
subprocess.call(['/usr/lib/qubes/qrexec-client', '-d', dispvm.name,
user+':exec /usr/lib/qubes/qubes-rpc-multiplexer ' +
exec_index + " " + src_vmname])
try:
dispvm.force_shutdown()
except QubesException:
# VM already destroyed
pass
qfile.remove_disposable_from_qdb(dispvm.name)
QfileDaemonDvm.finish_disposable(dispvm.name)
main()