ソースを参照

qvm-ls: fix total VM size reporting

There is no vm.storage object in qubesadmin module.
Marek Marczykowski-Górecki 6 年 前
コミット
7db2ed82ea
2 ファイル変更5 行追加1 行削除
  1. 1 1
      qubesadmin/tools/qvm_ls.py
  2. 4 0
      qubesadmin/vm/__init__.py

+ 1 - 1
qubesadmin/tools/qvm_ls.py

@@ -351,7 +351,7 @@ Column('MEMORY',
     doc='Memory currently used by VM')
 
 Column('DISK',
-    attr=(lambda vm: vm.storage.get_disk_utilization() / 1024 / 1024),
+    attr=(lambda vm: vm.get_disk_utilization() // 1024 // 1024),
     doc='Total disk utilisation.')
 
 

+ 4 - 0
qubesadmin/vm/__init__.py

@@ -257,6 +257,10 @@ class QubesVM(qubesadmin.base.PropertyHolder):
                     vm=self.name, vm_name=volname)
         return self._volumes
 
+    def get_disk_utilization(self):
+        '''Get total disk usage of the VM'''
+        return sum(vol.usage for vol in self.volumes.values())
+
     def run_service(self, service, **kwargs):
         '''Run service on this VM