diff --git a/dispvm/qfile-daemon-dvm b/dispvm/qfile-daemon-dvm index f8aa8f36..fd25c24f 100755 --- a/dispvm/qfile-daemon-dvm +++ b/dispvm/qfile-daemon-dvm @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # import os @@ -30,12 +30,14 @@ from qubes.qubes import QubesVmCollection from qubes.qubes import QubesException from qubes.qubes import QubesDaemonPidfile from qubes.qubes import QubesDispVmLabels -from qubes.notify import tray_notify,tray_notify_error,tray_notify_init +from qubes.notify import tray_notify, tray_notify_error, tray_notify_init + current_savefile = '/var/run/qubes/current-savefile' current_dvm_conf = '/var/run/qubes/current-dvm.conf' current_savefile_vmdir = '/var/lib/qubes/dvmdata/vmdir' + class QfileDaemonDvm: def __init__(self, name): self.name = name @@ -50,15 +52,16 @@ class QfileDaemonDvm: qvm_collection = QubesVmCollection() qvm_collection.lock_db_for_writing() - tar_process = subprocess.Popen(['bsdtar', '-C', current_savefile_vmdir, - '-xSUf', os.path.join(current_savefile_vmdir, 'saved-cows.tar')]) + tar_process = subprocess.Popen( + ['bsdtar', '-C', current_savefile_vmdir, + '-xSUf', os.path.join(current_savefile_vmdir, 'saved-cows.tar')]) qvm_collection.load() print >>sys.stderr, "time=%s, collection loaded" % (str(time.time())) vm = qvm_collection.get_vm_by_name(self.name) if vm is None: - sys.stderr.write( 'Domain ' + self.name + ' does not exist ?') + sys.stderr.write('Domain ' + self.name + ' does not exist ?') qvm_collection.unlock_db() return None label = vm.label @@ -68,10 +71,12 @@ class QfileDaemonDvm: disp_templ = self.get_disp_templ() vm_disptempl = qvm_collection.get_vm_by_name(disp_templ) if vm_disptempl is None: - sys.stderr.write( 'Domain ' + disp_templ + ' does not exist ?') + sys.stderr.write('Domain ' + disp_templ + ' does not exist ?') qvm_collection.unlock_db() return None - dispvm=qvm_collection.add_new_vm('QubesDisposableVm', disp_template=vm_disptempl, label=label) + dispvm = qvm_collection.add_new_vm('QubesDisposableVm', + disp_template=vm_disptempl, + label=label) print >>sys.stderr, "time=%s, VM created" % (str(time.time())) # By default inherit firewall rules from calling VM if os.path.exists(vm.firewall_conf): @@ -105,22 +110,26 @@ class QfileDaemonDvm: dvmdata_dir = '/var/lib/qubes/dvmdata/' if not os.path.isfile(current_savefile): return False - if not os.path.isfile(dvmdata_dir+'default-savefile') or not os.path.isfile(dvmdata_dir+'savefile-root'): + if not os.path.isfile(dvmdata_dir+'default-savefile') or \ + not os.path.isfile(dvmdata_dir+'savefile-root'): return False dvm_mtime = os.stat(current_savefile).st_mtime root_mtime = os.stat(dvmdata_dir+'savefile-root').st_mtime if dvm_mtime < root_mtime: - template_name = os.path.basename(os.path.dirname(os.readlink(dvmdata_dir+'savefile-root'))) + template_name = os.path.basename( + os.path.dirname(os.readlink(dvmdata_dir+'savefile-root'))) if subprocess.call(["xl", "domid", template_name], stdout=open(os.devnull, "w")) == 0: tray_notify("For optimum performance, you should not " - "start DispVM when its template is running.", "red") + "start DispVM when its template is running.", "red") return False return True def get_dvm(self): if not self.dvm_setup_ok(): - if os.system("/usr/lib/qubes/qubes-update-dispvm-savefile-with-progress.sh >/dev/null /dev/null >sys.stderr, "time=%s, qfile-daemon-dvm init" % (str(time.time())) tray_notify_init() @@ -154,9 +164,9 @@ def main(): if dispvm is not None: 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]) + user+':exec /usr/lib/qubes/qubes-rpc-multiplexer ' + + exec_index + " " + src_vmname]) dispvm.force_shutdown() qfile.remove_disposable_from_qdb(dispvm.name) -main() - +main() \ No newline at end of file