Skip to content

Commit f974188

Browse files
authored
Merge pull request #339 from desultory/dev
add product kmods for vms to kmod_auto so they can be tolerated missing
2 parents 315bdb8 + ff97ed0 commit f974188

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/ugrd/kmod/platform.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from zenlib.util import colorize as c_
22
from zenlib.util import contains
33

4-
__version__ = "0.1.1"
4+
__version__ = "0.1.2"
55

66
VM_PRODUCT_NAMES = {
77
"Virtual Machine": ["virtio_blk"],
@@ -30,16 +30,22 @@ def get_platform_info(self):
3030

3131
@contains("hostonly", "hostonly is not enabled, skipping VM detection.", log_level=30)
3232
def autodetect_virtual_machine(self):
33-
"""Detects if the system is running in a virtual machine, adds relevant kernel modules to the list.
33+
"""Detects if the system is running in a virtual machine, using DMI information.
34+
Uses the system vendor to add required kmods
35+
uses the product name to add additional kmods.
36+
3437
Sets the `virtual_machine` attribute to True if a VM is detected, to be used by other modules.
3538
"""
36-
kmods = set()
37-
kmods.update(VM_PRODUCT_NAMES.get(self["_dmi_product_name"], []))
38-
kmods.update(VM_VENDOR_NAMES.get(self["_dmi_system_vendor"], []))
39+
vendor_kmods = VM_VENDOR_NAMES.get(self["_dmi_system_vendor"], [])
40+
product_kmods = VM_PRODUCT_NAMES.get(self["_dmi_product_name"], [])
41+
kmods = set(vendor_kmods + product_kmods)
3942

4043
if kmods:
4144
self.logger.info(
4245
f"[{c_(self['_dmi_system_vendor'], color='cyan', bold=True)}]({c_(self['_dmi_product_name'], color='cyan', bright=True)}) Detected VM kmods: {c_((' ').join(kmods), color='magenta', bright=True)}"
4346
)
4447
self["virtual_machine"] = True
45-
self["kmod_init"] = list(kmods)
48+
if vendor_kmods:
49+
self["kmod_init"] = vendor_kmods
50+
if product_kmods:
51+
self["_kmod_auto"] = product_kmods

0 commit comments

Comments
 (0)