|
1 | 1 | from zenlib.util import colorize as c_ |
2 | 2 | from zenlib.util import contains |
3 | 3 |
|
4 | | -__version__ = "0.1.1" |
| 4 | +__version__ = "0.1.2" |
5 | 5 |
|
6 | 6 | VM_PRODUCT_NAMES = { |
7 | 7 | "Virtual Machine": ["virtio_blk"], |
@@ -30,16 +30,22 @@ def get_platform_info(self): |
30 | 30 |
|
31 | 31 | @contains("hostonly", "hostonly is not enabled, skipping VM detection.", log_level=30) |
32 | 32 | 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 | +
|
34 | 37 | Sets the `virtual_machine` attribute to True if a VM is detected, to be used by other modules. |
35 | 38 | """ |
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) |
39 | 42 |
|
40 | 43 | if kmods: |
41 | 44 | self.logger.info( |
42 | 45 | 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)}" |
43 | 46 | ) |
44 | 47 | 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