From 227597cf933fba5de8ae58934bb9b998fa206b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 31 Mar 2014 03:44:01 +0200 Subject: [PATCH] Add 'Requested MEM' column (aka prefmem) (#788) --- mainwindow.ui | 36 ++++++++++++++++++++++++++- qubesmanager/main.py | 58 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 6 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index e22f1e3..cb85695 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -118,7 +118,7 @@ 10 - 15 + 17 false @@ -217,6 +217,16 @@ Memory usage graph + + + Req MEM + + + + + Req MEM Graph + + Size @@ -280,6 +290,8 @@ + + @@ -879,6 +891,28 @@ Last backup + + + true + + + true + + + Requested MEM + + + + + true + + + true + + + Requested MEM Graph + + diff --git a/qubesmanager/main.py b/qubesmanager/main.py index 12c8783..1830284 100755 --- a/qubesmanager/main.py +++ b/qubesmanager/main.py @@ -122,6 +122,7 @@ class QubesManagerFileWatcher(ProcessEvent): class VmRowInTable(object): cpu_graph_hue = 210 mem_graph_hue = 120 + prefmem_graph_hue = 70 def __init__(self, vm, row_no, table, block_manager): self.vm = vm @@ -169,6 +170,28 @@ class VmRowInTable(object): table.setCellWidget(row_no, VmManagerWindow.columns_indices['MEM Graph'], self.mem_widget) table.setItem(row_no, VmManagerWindow.columns_indices['MEM Graph'], self.mem_widget.tableItem) + self.prefmem_usage_widget = VmUsageBarWidget(0, qubes_host.memory_total/1024, "%v MB", + lambda vm, val: vm.last_prefmem/1024, vm, 0, + self.prefmem_graph_hue) + table.setCellWidget(row_no, + VmManagerWindow.columns_indices['Req MEM'], + self.prefmem_usage_widget) + table.setItem(row_no, + VmManagerWindow.columns_indices['Req MEM'], + self.prefmem_usage_widget.tableItem) + + self.prefmem_widget = \ + ChartWidget(vm, + lambda vm, val: vm .last_prefmem*100/qubes_host\ + .memory_total, self.prefmem_graph_hue, 0) + table.setCellWidget(row_no, + VmManagerWindow.columns_indices['Req MEM Graph'], + self.prefmem_widget) + table.setItem(row_no, + VmManagerWindow.columns_indices['Req MEM Graph'], + self.prefmem_widget.tableItem) + + self.size_widget = VmSizeOnDiskItem(vm) table.setItem(row_no, VmManagerWindow.columns_indices['Size'], self.size_widget) @@ -193,6 +216,8 @@ class VmRowInTable(object): self.mem_usage_widget.update_load(self.vm, None) self.load_widget.update_load(self.vm, cpu_load) self.mem_widget.update_load(self.vm, None) + self.prefmem_widget.update_load(self.vm, None) + self.prefmem_usage_widget.update_load(self.vm, None) if update_size_on_disk == True: self.size_widget.update() @@ -240,11 +265,13 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): "CPU Graph": 7, "MEM": 8, "MEM Graph": 9, - "Size": 10, - "Internal": 11, - "IP": 12, - "Backups": 13, - "Last backup": 14, + "Req MEM": 10, + "Req MEM Graph": 11, + "Size": 12, + "Internal": 13, + "IP": 14, + "Backups": 15, + "Last backup": 16, } def __init__(self, parent=None): @@ -256,9 +283,11 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): self.qubes_watch = qubesutils.QubesWatch() self.qvm_collection = QubesVmCollection() + self.meminfo_changed = {} self.blk_manager = QubesBlockDevicesManager(self.qvm_collection) self.blk_manager.tray_message_func = trayIcon.showMessage self.qubes_watch.setup_block_watch(self.blk_manager.block_devs_event) + self.qubes_watch.setup_meminfo_watch(self.meminfo_update_event) self.blk_watch_thread = threading.Thread(target=self.qubes_watch.watch_loop) self.blk_watch_thread.daemon = True self.blk_watch_thread.start() @@ -298,6 +327,10 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): self.columns_actions[ self.columns_indices["CPU Graph"] ] = self.action_cpu_graph self.columns_actions[ self.columns_indices["MEM"] ] = self.action_mem self.columns_actions[ self.columns_indices["MEM Graph"] ] = self.action_mem_graph + self.columns_actions[ self.columns_indices["Req MEM"] ] = self\ + .action_prefmem + self.columns_actions[ self.columns_indices["Req MEM Graph"] ] = self\ + .action_prefmem_graph self.columns_actions[ self.columns_indices["Size"] ] = self.action_size_on_disk self.columns_actions[ self.columns_indices["Internal"] ] = self.action_internal self.columns_actions[ self.columns_indices["IP"] ] = self\ @@ -314,6 +347,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): self.action_cpu_graph.setChecked(False) self.table.setColumnHidden( self.columns_indices["MEM Graph"], True) self.action_mem_graph.setChecked(False) + self.action_prefmem.setChecked(False) + self.action_prefmem_graph.setChecked(False) self.table.setColumnHidden( self.columns_indices["Size"], True) self.action_size_on_disk.setChecked(False) self.table.setColumnHidden( self.columns_indices["Internal"], True) @@ -522,6 +557,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): for vm in vms_list: vm.last_power_state = vm.get_power_state() vm.last_running = vm.last_power_state in ["Running", "Transient"] + vm.last_prefmem = vm.get_prefmem() if vm.last_running: running_count += 1 if vm.internal: @@ -591,6 +627,9 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): self.table.setRowHidden(row_no, False) row_no += 1 + def meminfo_update_event(self, domain_id): + self.meminfo_changed[int(domain_id)] = True + def mark_table_for_update(self): self.reload_table = True @@ -633,6 +672,9 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): "Error starting VM: Cannot execute qrexec-daemon!" \ and vm.is_qrexec_running(): self.clear_error(vm.qid) + if self.meminfo_changed.get(vm.xid, True): + vm.last_prefmem = vm.get_prefmem() + self.meminfo_changed[vm.xid] = False if self.screen_changed == True: reload_table = True @@ -1355,6 +1397,12 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): def on_action_mem_graph_toggled(self, checked): self.showhide_column( self.columns_indices['MEM Graph'], checked) + def on_action_prefmem_toggled(self, checked): + self.showhide_column( self.columns_indices['Req MEM'], checked) + + def on_action_prefmem_graph_toggled(self, checked): + self.showhide_column( self.columns_indices['Req MEM Graph'], checked) + def on_action_size_on_disk_toggled(self, checked): self.showhide_column( self.columns_indices['Size'], checked)