From b59463e8e89d4cf06dc67956083b7ddb026c8f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= <marmarek@invisiblethingslab.com> Date: Fri, 4 Nov 2016 13:19:49 +0100 Subject: [PATCH] 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 --- qubes/storage/lvm.py | 3 +++ qubes/tools/qvm_block.py | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/qubes/storage/lvm.py b/qubes/storage/lvm.py index a8bf6432..933d62f9 100644 --- a/qubes/storage/lvm.py +++ b/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, diff --git a/qubes/tools/qvm_block.py b/qubes/tools/qvm_block.py index 9385a009..92019f46 100644 --- a/qubes/tools/qvm_block.py +++ b/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