Skip to content

Commit afa444f

Browse files
xcp/dmv.py: Add module docstring and extend a function docstring
Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent d923ac8 commit afa444f

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

xcp/dmv.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@
2020
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2121
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2222
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+
"""
24+
Driver Multiversion (DMV) Management for XenServer
25+
26+
This module provides functionality to manage multiple hardware driver variants
27+
across different kernel versions. It enables detection, selection, and activation
28+
of appropriate driver modules based on hardware presence and system configuration.
29+
30+
Features:
31+
- Scans /lib/modules/<version>/dmv and /lib/modules/<version>/updates for dmv drivers.
32+
- Detects active and loaded driver modules
33+
- Matches hardware PCI IDs to supported driver variants
34+
- Manages symlinks and updates for selected drivers
35+
- Provides structured information about available drivers and their status
36+
37+
Main Classes:
38+
- DriverMultiVersion: Handles driver variant selection and info parsing
39+
- DriverMultiVersionManager: Aggregates and manages DMV data across the system
40+
41+
Typical Usage:
42+
manager = DriverMultiVersionManager(runtime=True)
43+
manager.parse_dmv_list()
44+
dmv_info = manager.get_dmv_list()
45+
"""
2346

2447
import os
2548
import subprocess
@@ -42,7 +65,7 @@ def get_all_kabi_dirs():
4265
for kabi_ver in os.listdir(modules_root):
4366
updates_dir = os.path.join(modules_root, kabi_ver, "updates")
4467
dmv_dir = os.path.join(modules_root, kabi_ver, "dmv")
45-
# not checking if updates_dir and dmv_dir exist here, will check later when use them
68+
# No check if the directories exist. On use, we check if they exist
4669
dirs.append((kabi_ver, updates_dir, dmv_dir))
4770
return dirs
4871

@@ -138,7 +161,16 @@ def pci_matches(present_pci_id, driver_pci_ids):
138161
return False
139162

140163
def hardware_present(lspci_out, pci_ids):
141-
"""Check if supported hardware is fitted"""
164+
"""
165+
Checks if any of the specified PCI IDs are present in the output of `lspci -nm`.
166+
167+
Args:
168+
lspci_out (str): The output string from the `lspci -nm` command.
169+
pci_ids (list or set): A collection of PCI IDs to search for in the output.
170+
171+
Returns:
172+
bool: True if any of the given PCI IDs are found in the `lspci_out`, False otherwise.
173+
"""
142174
if not pci_ids or not lspci_out:
143175
return False
144176

0 commit comments

Comments
 (0)