Skip to content

Commit 1376ddc

Browse files
committed
Exclude tapdev and xvd block devices from SR disk selection
The lsblk-based SR disk discovery now filters by device major number, excluding tapdev (254) and xvd (202) device types. tapdev devices are used internally by the host storage stack and should never be selected for SR creation — they are not physical disks. xvd devices are Xen virtual block devices that appear when a VM or the dom0 itself has attached virtual disks; they are not suitable as SR backing storage either. Without this filter, a host running as a VM (nested virtualization scenario) or a host with active tapdisk mappings could report xvd or tapdev devices as candidate disks, causing SR creation on an inappropriate backing device. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent eb64569 commit 1376ddc

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)