Skip to content

Commit b34ea56

Browse files
authored
Merge pull request #564 from xcp-ng/gln/exclude-tapded-xvd-devices-umyu
Exclude tapdev and xvd block devices from SR disk selection
2 parents b9956a3 + 1376ddc commit b34ea56

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

lib/host.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,33 @@ def rescan_block_devices_info(self) -> None:
701701
RAID_TYPES = {'raid0', 'raid1', 'raid4', 'raid5', 'raid6', 'raid10', 'linear'}
702702
USED_TYPES = RAID_TYPES | {'lvm', 'mpath', 'crypt'}
703703
LSBLK_FIELDS = 'NAME,KNAME,PKNAME,SIZE,LOG-SEC,TYPE,MOUNTPOINT,WWN'
704+
# The device major numbers we have on an xcp-ng host, except 254 (tapdev) and 202 (xvd)
705+
# From /dev/devices:
706+
# 8 sd
707+
# 9 md
708+
# 65 sd
709+
# 66 sd
710+
# 67 sd
711+
# 68 sd
712+
# 69 sd
713+
# 70 sd
714+
# 71 sd
715+
# 128 sd
716+
# 129 sd
717+
# 130 sd
718+
# 131 sd
719+
# 132 sd
720+
# 133 sd
721+
# 134 sd
722+
# 135 sd
723+
# 252 mdp
724+
# 253 device-mapper
725+
# 259 blkext
726+
LSBLK_MAJOR_NUMBERS = '8,9,65,66,67,68,69,70,71,128,129,130,131,132,133,134,135,252,253,259'
704727

705728
devices: list[Host.BlockDeviceInfo] = []
706729

707-
raw = self.ssh(f'lsblk --pairs --bytes --output {LSBLK_FIELDS}')
730+
raw = self.ssh(f'lsblk --pairs --bytes --output {LSBLK_FIELDS} --include {LSBLK_MAJOR_NUMBERS}')
708731

709732
def _split_keys(line: str) -> list[tuple[str, str]]:
710733
return re.findall(r'(\S+)=(".*?"|\S+)', line)

0 commit comments

Comments
 (0)