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