Skip to content

Commit c3ce365

Browse files
committed
libvirt: add auto-discovery support for device passthrough pools
Add a new flag in HostDevicePoolSchema to let lisa auto discover the device pool.
1 parent fc9e0e0 commit c3ce365

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

lisa/sut_orchestrator/libvirt/libvirt_device_pool.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,21 @@ def get_rootfs_nvme_iommu_group(self) -> str:
180180
sysfs_path, context="rootfs NVMe"
181181
)
182182

183+
def auto_discover_pool(self, pool_type: HostDevicePoolType) -> None:
184+
self.available_host_devices[pool_type] = {}
185+
candidates = self._get_passthrough_device_candidates(pool_type)
186+
if not candidates:
187+
raise LisaException(
188+
f"Auto-discovery found no eligible devices for pool type "
189+
f"'{pool_type.value}' on the host. Verify that devices of "
190+
f"this type exist and are not excluded (primary NIC, etc)."
191+
)
192+
self.host_node.log.debug(
193+
f"Auto-discovered {len(candidates)} device(s) for pool "
194+
f"'{pool_type.value}': {candidates}"
195+
)
196+
self._create_pool(pool_type, candidates)
197+
183198
def create_device_pool(
184199
self,
185200
pool_type: HostDevicePoolType,

lisa/sut_orchestrator/util/device_pool.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def _validate_supported_pool_types(
8282
)
8383

8484
def _configure_passthrough_pool(self, config: HostDevicePoolSchema) -> None:
85+
if config.auto_discover:
86+
self.auto_discover_pool(config.type)
87+
return
88+
8589
devices = config.devices
8690
if self._is_vendor_device_id_list(devices):
8791
vendor_device_list = cast(List[VendorDeviceIdIdentifier], devices)
@@ -99,6 +103,9 @@ def _configure_passthrough_pool(self, config: HostDevicePoolSchema) -> None:
99103
f"Unknown device identifier of type: {type(devices)}" f", value: {devices}"
100104
)
101105

106+
def auto_discover_pool(self, pool_type: HostDevicePoolType) -> None:
107+
raise NotImplementedError()
108+
102109
def _is_vendor_device_id_list(self, devices: Any) -> bool:
103110
if not isinstance(devices, list):
104111
return False

lisa/sut_orchestrator/util/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class DeviceLocationPathIdentifier:
4444
@dataclass
4545
class HostDevicePoolSchema:
4646
type: HostDevicePoolType = HostDevicePoolType.PCI_NIC
47+
auto_discover: bool = False
4748
devices: Union[
4849
List[VendorDeviceIdIdentifier],
4950
PciAddressIdentifier,

0 commit comments

Comments
 (0)