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
This commit is contained in:
Marek Marczykowski-Górecki 2016-11-04 13:19:49 +01:00
parent 1a7f2892d1
commit b59463e8e8
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 10 additions and 4 deletions

View File

@ -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,

View File

@ -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