From afb2a65744efc0dfaab34504e4f6b60779b2203b Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Tue, 28 Jun 2016 13:26:10 +0000 Subject: [PATCH 1/3] qfile-daemon-dvm: Move dispVM killing into cleanup function --- dispvm/qfile-daemon-dvm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dispvm/qfile-daemon-dvm b/dispvm/qfile-daemon-dvm index 423500b6..c2ae9898 100755 --- a/dispvm/qfile-daemon-dvm +++ b/dispvm/qfile-daemon-dvm @@ -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() @@ -181,11 +187,6 @@ def main(): 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) + qfile.finish_disposable(dispvm.name) main() From 142cb9e2406dc3cbe6ce9ec98ff7c06bf0a2a41d Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Tue, 28 Jun 2016 13:27:03 +0000 Subject: [PATCH 2/3] qfile-daemon-dvm: Call static method by class name --- dispvm/qfile-daemon-dvm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dispvm/qfile-daemon-dvm b/dispvm/qfile-daemon-dvm index c2ae9898..c79e82e1 100755 --- a/dispvm/qfile-daemon-dvm +++ b/dispvm/qfile-daemon-dvm @@ -187,6 +187,6 @@ def main(): subprocess.call(['/usr/lib/qubes/qrexec-client', '-d', dispvm.name, user+':exec /usr/lib/qubes/qubes-rpc-multiplexer ' + exec_index + " " + src_vmname]) - qfile.finish_disposable(dispvm.name) + QfileDaemonDvm.finish_disposable(dispvm.name) main() From b964e8c33fd2a23e972022bb042fc72d006f30c2 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Tue, 28 Jun 2016 13:36:16 +0000 Subject: [PATCH 3/3] qfile-daemon-dvm: Implement LAUNCH and FINISH actions If the action is LAUNCH instead of qubes.SomeService, then just start the dispVM, write (only) its name to stdout, and quit. If the action is FINISH, then kill and remove the named dispVM. --- dispvm/qfile-daemon-dvm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dispvm/qfile-daemon-dvm b/dispvm/qfile-daemon-dvm index c79e82e1..209e2228 100755 --- a/dispvm/qfile-daemon-dvm +++ b/dispvm/qfile-daemon-dvm @@ -171,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() @@ -183,6 +187,10 @@ 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 ' +