def get_current_gpu_pci_ids(root):
    adv_config = query_config_table("system_advanced", os.path.join(root, FREENAS_DATABASE[1:]), "adv_")
    to_isolate = [gpu for gpu in get_gpus() if gpu["addr"]["pci_slot"] in adv_config.get("isolated_gpu_pci_ids", [])]
    return [dev["pci_id"] for gpu in to_isolate for dev in gpu["devices"]]
Exemple #2
0
#!/usr/bin/env python3
import math
import psutil

from middlewared.utils import osc
from middlewared.utils.db import query_config_table

if __name__ == "__main__":
    advanced = query_config_table("system_advanced", prefix="adv_")

    # We need to allow tpm in grub as sedutil-cli requires it
    # TODO: Please remove kernel flag to use cgroups v1 when nvidia device plugin starts working
    #  with it ( https://github.com/NVIDIA/k8s-device-plugin/issues/235 )
    # We set mpt3sas argument because of https://jira.ixsystems.com/browse/NAS-109947, let's please
    # remove setting it once it is fixed upstream. ( https://bugzilla.redhat.com/show_bug.cgi?id=1878332 )
    config = [
        'GRUB_DISTRIBUTOR="TrueNAS Scale"',
        'GRUB_CMDLINE_LINUX_DEFAULT="libata.allow_tpm=1 systemd.unified_cgroup_hierarchy=0 '
        'amd_iommu=on iommu=pt kvm_amd.npt=1 kvm_amd.avic=1 intel_iommu=on mpt3sas.max_queue_depth=10000"',
    ]

    terminal = ["console"]
    cmdline = []
    if advanced["serialconsole"]:
        config.append(
            f'GRUB_SERIAL_COMMAND="serial --speed={advanced["serialspeed"]} --word=8 --parity=no --stop=1"'
        )
        terminal.append("serial")

        cmdline.append(
            f"console={advanced['serialport']},{advanced['serialspeed']} console=tty1"