Browse Source

qvm-block: fix listing non-internal volumes

In case of LVM (at least), "internal" flag is initialized only when
listing volume attached to given VM, but not when listing them from the
pool. This looks like a limitation (bug?) of pool driver, it looks like
much nicer fix is to handle the flag in qvm-block tool (which list VMs
volumes anyway), than in LVM storage pool driver (which would need to
keep second copy of volumes list - just like file driver).

QubesOS/qubes-issues#2256
Marek Marczykowski-Górecki 7 years ago
parent
commit
b59463e8e8
2 changed files with 10 additions and 4 deletions
  1. 3 0
      qubes/storage/lvm.py
  2. 7 4
      qubes/tools/qvm_block.py

+ 3 - 0
qubes/storage/lvm.py

@@ -272,6 +272,9 @@ class ThinPool(qubes.storage.Pool):
                 continue
             if vol_info['pool_lv'] != self.thin_pool:
                 continue
+            if vid.endswith('-snap'):
+                # implementation detail volume
+                continue
             config = {
                 'pool': self.name,
                 'vid': vid,

+ 7 - 4
qubes/tools/qvm_block.py

@@ -115,11 +115,14 @@ def list_volumes(args):
     for domain in domains:  # gather the domain names
         try:
             for volume in domain.attached_volumes:
-                if not args.internal and volume.internal:
-                    continue
                 try:
-                    volume_data = vd_dict[volume.pool][volume.vid]
-                    volume_data.domains += [(domain.name, volume.name)]
+                    if not args.internal and volume.internal:
+                        # some pools (LVM) may set 'internal' flag only when
+                        # listing volumes of specific domain
+                        del vd_dict[volume.pool][volume.vid]
+                    else:
+                        volume_data = vd_dict[volume.pool][volume.vid]
+                        volume_data.domains += [(domain.name, volume.name)]
                 except KeyError:
                     # Skipping volume
                     continue