コード例 #1
0
ファイル: pt.py プロジェクト: xiaofst/acrn-hypervisor
def gen_pt_head(names, dm, sel, vmid, config):

    cap_pt = launch_cfg_lib.get_pt_dev()
    uos_type = names['uos_types'][vmid]

    print("# pci devices for passthru", file=config)
    print("declare -A passthru_vpid", file=config)
    print("declare -A passthru_bdf", file=config)
    print("", file=config)

    print("passthru_vpid=(", file=config)
    for pt_dev in cap_pt:
        if not sel.vpid[pt_dev] or not sel.vpid[pt_dev][vmid]:
            continue
        print('["{}"]="{}"'.format(pt_dev, sel.vpid[pt_dev][vmid]),
              file=config)
    if dm['gvt_args'][vmid] == "gvtd":
        gpu_vpid = launch_cfg_lib.get_gpu_vpid()
        print('["gpu"]="{}"'.format(gpu_vpid), file=config)
    print(')', file=config)

    print("passthru_bdf=(", file=config)
    for pt_dev in cap_pt:
        if not sel.bdf[pt_dev] or not sel.bdf[pt_dev][vmid]:
            continue
        print('["{}"]="0000:{}"'.format(pt_dev, sel.bdf[pt_dev][vmid]),
              file=config)
    if dm['gvt_args'][vmid] == "gvtd":
        print('["gpu"]="0000:{}"'.format(launch_cfg_lib.GPU_BDF), file=config)
    print(')', file=config)

    print("", file=config)
コード例 #2
0
ファイル: pt.py プロジェクト: xiaofst/acrn-hypervisor
def gen_pt(names, dm, sel, vmid, config):

    pt_none = True
    cap_pt = launch_cfg_lib.get_pt_dev()
    uos_type = names['uos_types'][vmid]

    # pass thru GPU
    if dm['gvt_args'][vmid] == "gvtd":
        print(
            'echo ${passthru_vpid["gpu"]} > /sys/bus/pci/drivers/pci-stub/new_id',
            file=config)
        print(
            'echo ${passthru_bdf["gpu"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind',
            file=config)
        print(
            'echo ${passthru_bdf["gpu"]} > /sys/bus/pci/drivers/pci-stub/bind',
            file=config)

    for pt_dev in cap_pt:
        if sel.bdf[pt_dev][vmid]:
            pt_none = False
    if pt_none:
        return

    print("modprobe pci_stub", file=config)
    for pt_dev in cap_pt:
        if pt_dev not in MEDIA_DEV:
            pass_through_dev(sel, pt_dev, vmid, config)
            continue

    media_pt(uos_type, sel, vmid, config)
コード例 #3
0
def gen_pt(names, dm, sriov, sel, vmid, config):

    pt_none = True
    cap_pt = launch_cfg_lib.get_pt_dev()
    user_vm_type = names['user_vm_types'][vmid]

    print("modprobe pci_stub", file=config)
    # SRIOV passthru
    if sriov['gpu'][vmid]:
        print('echo ${passthru_vpid["gpu"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
        print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind', file=config)
        print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
    if sriov['network'][vmid]:
        print('echo ${passthru_vpid["network"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
        print('echo ${passthru_bdf["network"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind',
              file=config)
        print('echo ${passthru_bdf["network"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)

    for pt_dev in cap_pt:
        if sel.bdf[pt_dev][vmid]:
            pt_none = False
    if pt_none:
        return

    for pt_dev in cap_pt:
        if pt_dev not in MEDIA_DEV:
            pass_through_dev(sel, pt_dev, vmid, config)
            continue

    media_pt(user_vm_type, sel, vmid, config)
コード例 #4
0
def gen_pt_head(names, sel, vmid, config):

    cap_pt = launch_cfg_lib.get_pt_dev()
    uos_type = names['uos_types'][vmid]
    pt_none = True

    for pt_dev in cap_pt:
        if sel.bdf[pt_dev][vmid]:
            pt_none = False
    if pt_none:
        return

    print("# pci devices for passthru", file=config)
    print("declare -A passthru_vpid", file=config)
    print("declare -A passthru_bdf", file=config)
    print("", file=config)

    print("passthru_vpid=(", file=config)
    for pt_dev in cap_pt:
        if not sel.vpid[pt_dev] or not sel.vpid[pt_dev][vmid]:
            continue
        print('["{}"]="{}"'.format(pt_dev, sel.vpid[pt_dev][vmid]),
              file=config)
    print(')', file=config)

    print("passthru_bdf=(", file=config)
    for pt_dev in cap_pt:
        if not sel.bdf[pt_dev] or not sel.bdf[pt_dev][vmid]:
            continue
        print('["{}"]="0000:{}"'.format(pt_dev, sel.bdf[pt_dev][vmid]),
              file=config)
    print(')', file=config)

    print("", file=config)
コード例 #5
0
def gen_pt(names, sel, vmid, config):

    pt_none = True
    cap_pt = launch_cfg_lib.get_pt_dev()
    uos_type = names['uos_types'][vmid]
    for pt_dev in cap_pt:
        if sel.bdf[pt_dev][vmid]:
            pt_none = False
    if pt_none:
        return

    print("modprobe pci_stub", file=config)
    for pt_dev in cap_pt:
        if pt_dev not in MEDIA_DEV:
            pass_through_dev(sel, pt_dev, vmid, config)
            continue

    media_pt(uos_type, sel, cap_pt, vmid, config)
コード例 #6
0
def gen_pt_head(names, dm, sriov, sel, vmid, config):

    cap_pt = launch_cfg_lib.get_pt_dev()
    user_vm_type = names['user_vm_types'][vmid]

    print("# pci devices for passthru", file=config)
    print("declare -A passthru_vpid", file=config)
    print("declare -A passthru_bdf", file=config)
    print("", file=config)

    print("passthru_vpid=(", file=config)
    for pt_dev in cap_pt:
        if not sel.vpid[pt_dev] or not sel.vpid[pt_dev][vmid]:
            continue
        print('["{}"]="{}"'.format(pt_dev, sel.vpid[pt_dev][vmid]), file=config)

    # SRIOV passthru
    if sriov['gpu'][vmid]:
        print('["gpu"]="{}"'.format(launch_cfg_lib.get_gpu_vpid()), file=config)
    if sriov['network'][vmid]:
        print('["network"]="{}"'.format(launch_cfg_lib.get_vpid_by_bdf(sriov['network'][vmid])), file=config)

    print(')', file=config)

    print("passthru_bdf=(", file=config)
    for pt_dev in cap_pt:
        if not sel.bdf[pt_dev] or not sel.bdf[pt_dev][vmid]:
            continue
        print('["{}"]="0000:{}"'.format(pt_dev, sel.bdf[pt_dev][vmid]), file=config)
    if sriov['gpu'][vmid]:
        print('["gpu"]="0000:{}"'.format(sriov['gpu'][vmid]), file=config)
    if sriov['network'][vmid]:
        print('["network"]="0000:{}"'.format(sriov['network'][vmid]), file=config)
    print(')', file=config)

    print("", file=config)