def ext_pillar(minion_id, pillar, *args, **kwargs): qc = QubesVmCollection() qc.lock_db_for_reading() qc.load() qc.unlock_db() vm = qc.get_vm_by_name(minion_id) if vm is None: return {} qvm_pillar = {} if vm.qid == 0: qvm_pillar['type'] = 'admin' elif vm.is_template(): qvm_pillar['type'] = 'template' elif vm.template is None: qvm_pillar['type'] = 'standalone' else: qvm_pillar['type'] = 'app' if vm.template: qvm_pillar['template'] = vm.template.name if vm.netvm: qvm_pillar['netvm'] = vm.netvm.name # TODO: consider other properties; target VM will learn them! return {'qubes': qvm_pillar}
def main(): global qubes_host qubes_host = QubesHost() global app app = QApplication(sys.argv) app.setOrganizationName("The Qubes Project") app.setOrganizationDomain("http://qubes-os.org") app.setApplicationName("Qubes Restore VMs") sys.excepthook = handle_exception qvm_collection = QubesVmCollection() qvm_collection.lock_db_for_reading() qvm_collection.load() qvm_collection.unlock_db() global restore_window restore_window = RestoreVMsWindow() restore_window.show() app.exec_() app.exit()
def app_main(): global qubes_host qubes_host = QubesHost() global app app = QApplication(sys.argv) app.setOrganizationName("The Qubes Project") app.setOrganizationDomain("http://qubes-os.org") app.setApplicationName("Qubes Backup VMs") sys.excepthook = handle_exception qvm_collection = QubesVmCollection() qvm_collection.lock_db_for_reading() qvm_collection.load() qvm_collection.unlock_db() global backup_window backup_window = BackupVMsWindow() backup_window.show() app.exec_() app.exit()
def vm(self, value): # pylint: disable=C0103 ''' Get Qubes VM object from qvm.collection and set it here. ''' if value: qvm_collection = QubesVmCollection() qvm_collection.lock_db_for_reading() qvm_collection.load() qvm_collection.unlock_db() qvm = qvm_collection.get_vm_by_name(value) if qvm and qvm.qid in qvm_collection: self._vm = qvm # pylint: disable=W0212 return self._vm = None # pylint: disable=W0212
def main(): global qubes_host qubes_host = QubesHost() global app app = QApplication(sys.argv) app.setOrganizationName("The Qubes Project") app.setOrganizationDomain("http://qubes-os.org") app.setApplicationName("Qubes VM Settings") sys.excepthook = handle_exception qvm_collection = QubesVmCollection() qvm_collection.lock_db_for_reading() qvm_collection.load() qvm_collection.unlock_db() vm = None tab = "basic" if len(sys.argv) > 1: vm = qvm_collection.get_vm_by_name(sys.argv[1]) if vm is None or vm.qid not in qvm_collection: QMessageBox.critical(None, "Qubes VM Settings Error", "A VM with the name '{0}' does not exist in the system.".format(sys.argv[1])) sys.exit(1) if len(sys.argv) > 2: tab_arg = sys.argv[2] print tab_arg if tab_arg in VMSettingsWindow.tabs_indices: tab = tab_arg else: QMessageBox.warning(None, "Qubes VM Settings Error", "There is no such tab as '{0}'. Opening default tab instead.".format(tab_arg)) else: vms_list = [vm.name for vm in qvm_collection.values() if (vm.is_appvm() or vm.is_template())] vmname = QInputDialog.getItem(None, "Select VM", "Select VM:", vms_list, editable = False) if not vmname[1]: sys.exit(1) vm = qvm_collection.get_vm_by_name(vmname[0]) global settings_window settings_window = VMSettingsWindow(vm, app, qvm_collection, tab) settings_window.show() app.exec_() app.exit()
def main(): global qubes_host qubes_host = QubesHost() global app app = QApplication(sys.argv) app.setOrganizationName("The Qubes Project") app.setOrganizationDomain("http://qubes-os.org") app.setApplicationName("Qubes VM Settings") sys.excepthook = handle_exception qvm_collection = QubesVmCollection() qvm_collection.lock_db_for_reading() qvm_collection.load() qvm_collection.unlock_db() vm = None tab = "basic" if len(sys.argv) > 1: vm = qvm_collection.get_vm_by_name(sys.argv[1]) if vm is None or vm.qid not in qvm_collection: QMessageBox.critical(None, "Qubes VM Settings Error", "A VM with the name '{0}' does not exist in the system.".format(sys.argv[1])) sys.exit(1) if len(sys.argv) > 2: tab_arg = sys.argv[2] print tab_arg if tab_arg in VMSettingsWindow.tabs_indices: tab = tab_arg else: QMessageBox.warning(None, "Qubes VM Settings Error", "There is no such tab as '{0}'. Opening default tab instead.".format(tab_arg)) else: vms_list = [vm.name for vm in qvm_collection.values() if (vm.is_appvm() or vm.is_template())] vmname = QInputDialog.getItem(None, "Select VM", "Select VM:", vms_list, editable = False) if not vmname[1]: sys.exit(1) vm = qvm_collection.get_vm_by_name(vmname[0]) global settings_window settings_window = VMSettingsWindow(vm, app, qvm_collection, tab) settings_window.show() app.exec_() app.exit()
def notify_vms(): monitor_layout = get_monitor_layout() if len(monitor_layout) == 0: return qc = QubesVmCollection() qc.lock_db_for_reading() qc.load() qc.unlock_db() pipes = [] for vm in qc.values(): if vm.qid == 0: continue if vm.is_running(): pipes.append(notify_vm(vm, monitor_layout)) for p in pipes: p.wait()
def notify_vms(): monitor_layout = get_monitor_layout() if len(monitor_layout) == 0: return qc = QubesVmCollection() qc.lock_db_for_reading() qc.load() qc.unlock_db() pipes = [] for vm in qc.values(): if vm.qid == 0: continue if vm.is_running(): pipes.append(notify_vm(vm, monitor_layout)) for p in pipes: p.wait()
def notify_vm_by_name(vmname): monitor_layout = get_monitor_layout() if len(monitor_layout) == 0: return qc = QubesVmCollection() qc.lock_db_for_reading() qc.load() qc.unlock_db() vm = qc.get_vm_by_name(vmname) if not vm: print >>sys.stderr, "No such VM!" return 1 if not vm.is_running(): print >>sys.stderr, "VM not running!" return 1 pipe = notify_vm(vm, monitor_layout) pipe.wait() return 0
def notify_vm_by_name(vmname): monitor_layout = get_monitor_layout() if len(monitor_layout) == 0: return qc = QubesVmCollection() qc.lock_db_for_reading() qc.load() qc.unlock_db() vm = qc.get_vm_by_name(vmname) if not vm: print >> sys.stderr, "No such VM!" return 1 if not vm.is_running(): print >> sys.stderr, "VM not running!" return 1 pipe = notify_vm(vm, monitor_layout) pipe.wait() return 0
frontend=sys.argv[3].split('-') if len(frontend)!=2: print 'Error: frontendvm-device must be in <controller>-<port> format' sys.exit(1) (controller, port)=frontend if len(sys.argv)>4: backendvm_xid=int(sys.argv[4]) backendvm_name=xen.lowlevel.xl.ctx().domid_to_name(backendvm_xid) else: backendvm_xid=0 cmd = "/usr/lib/qubes/vusb-ctl.py unbind '%s'" % backendvm_device if backendvm_xid == 0: os.system("sudo %s" % cmd) else: from qubes.qubes import QubesVmCollection qvm_collection = QubesVmCollection() qvm_collection.lock_db_for_reading() qvm_collection.load() qvm_collection.unlock_db() # launch qvm_collection.get_vm_by_name(backendvm_name).run(cmd, user="******") # FIXME: command injection os.system("xenstore-write /local/domain/%s/backend/vusb/%s/%s/port/%s ''" % (backendvm_xid, frontendvm_xid, controller, port))