diff --git a/dispvm/qfile-daemon-dvm b/dispvm/qfile-daemon-dvm index 423500b6..209e2228 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() @@ -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()