dispvm: code style - whitespace fixes
This commit is contained in:
		
							parent
							
								
									6ecc263534
								
							
						
					
					
						commit
						4e4a4a60c3
					
				| @ -30,12 +30,14 @@ from qubes.qubes import QubesVmCollection | |||||||
| from qubes.qubes import QubesException | from qubes.qubes import QubesException | ||||||
| from qubes.qubes import QubesDaemonPidfile | from qubes.qubes import QubesDaemonPidfile | ||||||
| from qubes.qubes import QubesDispVmLabels | 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_savefile = '/var/run/qubes/current-savefile' | ||||||
| current_dvm_conf = '/var/run/qubes/current-dvm.conf' | current_dvm_conf = '/var/run/qubes/current-dvm.conf' | ||||||
| current_savefile_vmdir = '/var/lib/qubes/dvmdata/vmdir' | current_savefile_vmdir = '/var/lib/qubes/dvmdata/vmdir' | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| class QfileDaemonDvm: | class QfileDaemonDvm: | ||||||
|     def __init__(self, name): |     def __init__(self, name): | ||||||
|         self.name = name |         self.name = name | ||||||
| @ -50,7 +52,8 @@ class QfileDaemonDvm: | |||||||
|         qvm_collection = QubesVmCollection() |         qvm_collection = QubesVmCollection() | ||||||
|         qvm_collection.lock_db_for_writing() |         qvm_collection.lock_db_for_writing() | ||||||
| 
 | 
 | ||||||
|         tar_process = subprocess.Popen(['bsdtar', '-C', current_savefile_vmdir, |         tar_process = subprocess.Popen( | ||||||
|  |             ['bsdtar', '-C', current_savefile_vmdir, | ||||||
|              '-xSUf', os.path.join(current_savefile_vmdir, 'saved-cows.tar')]) |              '-xSUf', os.path.join(current_savefile_vmdir, 'saved-cows.tar')]) | ||||||
| 
 | 
 | ||||||
|         qvm_collection.load() |         qvm_collection.load() | ||||||
| @ -58,7 +61,7 @@ class QfileDaemonDvm: | |||||||
| 
 | 
 | ||||||
|         vm = qvm_collection.get_vm_by_name(self.name) |         vm = qvm_collection.get_vm_by_name(self.name) | ||||||
|         if vm is None: |         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() |             qvm_collection.unlock_db() | ||||||
|             return None |             return None | ||||||
|         label = vm.label |         label = vm.label | ||||||
| @ -68,10 +71,12 @@ class QfileDaemonDvm: | |||||||
|         disp_templ = self.get_disp_templ() |         disp_templ = self.get_disp_templ() | ||||||
|         vm_disptempl = qvm_collection.get_vm_by_name(disp_templ) |         vm_disptempl = qvm_collection.get_vm_by_name(disp_templ) | ||||||
|         if vm_disptempl is None: |         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() |             qvm_collection.unlock_db() | ||||||
|             return None |             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())) |         print >>sys.stderr, "time=%s, VM created" % (str(time.time())) | ||||||
|         # By default inherit firewall rules from calling VM |         # By default inherit firewall rules from calling VM | ||||||
|         if os.path.exists(vm.firewall_conf): |         if os.path.exists(vm.firewall_conf): | ||||||
| @ -105,12 +110,14 @@ class QfileDaemonDvm: | |||||||
|         dvmdata_dir = '/var/lib/qubes/dvmdata/' |         dvmdata_dir = '/var/lib/qubes/dvmdata/' | ||||||
|         if not os.path.isfile(current_savefile): |         if not os.path.isfile(current_savefile): | ||||||
|             return False |             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 |             return False | ||||||
|         dvm_mtime = os.stat(current_savefile).st_mtime |         dvm_mtime = os.stat(current_savefile).st_mtime | ||||||
|         root_mtime = os.stat(dvmdata_dir+'savefile-root').st_mtime |         root_mtime = os.stat(dvmdata_dir+'savefile-root').st_mtime | ||||||
|         if dvm_mtime < root_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], |             if subprocess.call(["xl", "domid", template_name], | ||||||
|                                stdout=open(os.devnull, "w")) == 0: |                                stdout=open(os.devnull, "w")) == 0: | ||||||
|                 tray_notify("For optimum performance, you should not " |                 tray_notify("For optimum performance, you should not " | ||||||
| @ -120,7 +127,9 @@ class QfileDaemonDvm: | |||||||
| 
 | 
 | ||||||
|     def get_dvm(self): |     def get_dvm(self): | ||||||
|         if not self.dvm_setup_ok(): |         if not self.dvm_setup_ok(): | ||||||
|             if os.system("/usr/lib/qubes/qubes-update-dispvm-savefile-with-progress.sh >/dev/null </dev/null" ) != 0: |             if os.system("/usr/lib/qubes/" | ||||||
|  |                          "qubes-update-dispvm-savefile-with-progress.sh" | ||||||
|  |                          " >/dev/null </dev/null") != 0: | ||||||
|                 tray_notify_error("DVM savefile creation failed") |                 tray_notify_error("DVM savefile creation failed") | ||||||
|                 return None  |                 return None  | ||||||
|         return self.do_get_dvm() |         return self.do_get_dvm() | ||||||
| @ -137,12 +146,13 @@ class QfileDaemonDvm: | |||||||
|         qvm_collection.save() |         qvm_collection.save() | ||||||
|         qvm_collection.unlock_db() |         qvm_collection.unlock_db() | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| def main(): | def main(): | ||||||
|     global notify_object |     global notify_object | ||||||
|     exec_index = sys.argv[1] |     exec_index = sys.argv[1] | ||||||
|     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() | ||||||
|     #  sys.argv[4] - override label |     #  sys.argv[4] - override label | ||||||
|     #  sys.argv[5] - override firewall |     #  sys.argv[5] - override firewall | ||||||
| 
 | 
 | ||||||
| @ -154,9 +164,9 @@ def main(): | |||||||
|     if dispvm is not None: |     if dispvm is not None: | ||||||
|         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 ' + exec_index + " " + src_vmname]) |                          user+':exec /usr/lib/qubes/qubes-rpc-multiplexer ' + | ||||||
|  |                          exec_index + " " + src_vmname]) | ||||||
|         dispvm.force_shutdown() |         dispvm.force_shutdown() | ||||||
|         qfile.remove_disposable_from_qdb(dispvm.name) |         qfile.remove_disposable_from_qdb(dispvm.name) | ||||||
| 
 | 
 | ||||||
| main() | main() | ||||||
|   |  | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Marek Marczykowski-Górecki
						Marek Marczykowski-Górecki