config_tools: Update GPU passthrough support

1. Remove gvt_args field.
2. Add passthrough GPU devices support.
3. Add sriov device support.

Tracked-On: #6290
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
Weiyi Feng 2021-11-02 15:11:52 +08:00 committed by wenlingz
parent f65a87585b
commit 20f1dfd9c3
9 changed files with 143 additions and 62 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ build
*.log
*.warnings
*.pyc
/offline-tools/

View File

@ -207,7 +207,7 @@ the launch scripts will be generated into misc/acrn-config/xmls/config-xmls/[boa
{% elif elem|list != [] %}
{% if 'multiselect' not in elem.attrib or elem.attrib['multiselect'] != 'true' %}
{% set first_multi_child = {'block': 0, 'network': 0, 'input': 0, 'pcpu_id': 0, 'shm_region': 0,
'passthrough_devices': 0, 'virtio_devices': 0, 'communication_vuart': 0} %}
'passthrough_devices': 0, 'virtio_devices': 0, 'sriov_devices': 0, 'communication_vuart': 0} %}
{% for sub_elem in elem|list %}
{% set sub_elem_text = '' if sub_elem.text == None else sub_elem.text %}
{% if 'configurable' not in sub_elem.attrib or sub_elem.attrib['configurable'] != '0' %}

View File

@ -492,7 +492,7 @@ def save_launch():
rename = False
try:
if generator is None or not (generator.startswith('add_vm:') or generator.startswith('remove_vm:')):
(error_list, pthru_sel, virtio, dm_value) = validate_launch_setting(
(error_list, pthru_sel, virtio, dm_value, sriov) = validate_launch_setting(
os.path.join(current_app.config.get('CONFIG_PATH'), xml_configs[1], xml_configs[0]+'.xml'),
scenario_file_path,
tmp_launch_file)

View File

@ -221,18 +221,15 @@ def interrupt_storm(pt_sel, config):
print("", file=config)
def gvt_arg_set(dm, vmid, user_vm_type, config):
def gpu_pt_arg_set(dm, sel, vmid, config):
gpu_bdf = sel.bdf["gpu"][vmid]
gvt_args = dm['gvt_args'][vmid]
gpu_bdf = launch_cfg_lib.get_gpu_bdf()
if gvt_args == "gvtd" and gpu_bdf is not None:
if gpu_bdf:
bus = int(gpu_bdf[0:2], 16)
dev = int(gpu_bdf[3:5], 16)
fun = int(gpu_bdf[6:7], 16)
print(' -s 2,passthru,{}/{}/{} \\'.format(bus, dev, fun), file=config)
elif gvt_args:
print(' -s 2,pci-gvt -G "$2" \\', file=config)
def log_level_set(user_vm_type, config):
@ -297,7 +294,6 @@ def mem_size_set(args, vmid, config):
def user_vm_launch(names, args, virt_io, vmid, config):
gvt_args = args['gvt_args'][vmid]
user_vm_type = names['user_vm_types'][vmid]
launch_uos = common.undline_name(user_vm_type).lower()
board_name = names['board_name']
@ -317,10 +313,7 @@ def user_vm_launch(names, args, virt_io, vmid, config):
print("fi", file=config)
if is_mount_needed(virt_io, vmid):
print("", file=config)
if gvt_args == "gvtd" or not gvt_args:
print('launch_{} {} "{}" $debug'.format(launch_uos, vmid, vmid), file=config)
else:
print('launch_{} {} "{}" "{}" $debug'.format(launch_uos, vmid, gvt_args, vmid), file=config)
print('launch_{} {} "{}" $debug'.format(launch_uos, vmid, vmid), file=config)
print("", file=config)
i = 0
for mount_flag in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]:
@ -332,23 +325,14 @@ def user_vm_launch(names, args, virt_io, vmid, config):
else:
print("else", file=config)
if gvt_args == "gvtd" or not gvt_args:
print(' launch_{} {}'.format(launch_uos, vmid), file=config)
elif gvt_args:
print(' launch_{} {} "{}"'.format(launch_uos, vmid, gvt_args), file=config)
print(' launch_{} {}'.format(launch_uos, vmid), file=config)
print("fi", file=config)
return
elif not is_mount_needed(virt_io, vmid):
if gvt_args == "gvtd" or not gvt_args:
print('launch_{} {}'.format(launch_uos, vmid), file=config)
else:
print('launch_{} {} "{}"'.format(launch_uos, vmid, gvt_args), file=config)
print('launch_{} {}'.format(launch_uos, vmid), file=config)
else:
print("", file=config)
if gvt_args == "gvtd" or not gvt_args:
print('launch_{} {} "{}" $debug'.format(launch_uos, vmid, vmid), file=config)
else:
print('launch_{} {} "{}" "{}" $debug'.format(launch_uos, vmid, gvt_args, vmid), file=config)
print('launch_{} {} "{}" $debug'.format(launch_uos, vmid, vmid), file=config)
print("", file=config)
i = 0
for mount_flag in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]:
@ -528,6 +512,28 @@ def virtio_args_set(dm, virt_io, vmid, config):
launch_cfg_lib.virtual_dev_slot("virtio-console"),
virt_io['console'][vmid]), file=config)
def sriov_args_set(dm, sriov, vmid, config):
# sriov-gpu
gpu_bdf = sriov['gpu'][vmid]
if gpu_bdf:
bus = int(gpu_bdf[0:2], 16)
dev = int(gpu_bdf[3:5], 16)
fun = int(gpu_bdf[6:7], 16)
print(' -s 2,passthru,{}/{}/{},igd-vf \\'.format(bus, dev, fun), file=config)
# sriov-net
if sriov['network'][vmid]:
net_bdf = sriov['network'][vmid]
bus = int(net_bdf[0:2], 16)
dev = int(net_bdf[3:5], 16)
fun = int(net_bdf[6:7], 16)
print(" -s {},passthru,{}/{}/{} \\".format(
launch_cfg_lib.virtual_dev_slot("sriov-net{}".format(net_bdf)), bus, dev, fun
), file=config)
def get_cpu_affinity_list(cpu_affinity, vmid):
pcpu_id_list = ''
for user_vmid,cpus in cpu_affinity.items():
@ -545,7 +551,7 @@ def pcpu_arg_set(dm, vmid, config):
print(" --cpu_affinity {} \\".format(','.join(pcpu_id_list)), file=config)
def dm_arg_set(names, sel, virt_io, dm, vmid, config):
def dm_arg_set(names, sel, virt_io, dm, sriov, vmid, config):
user_vm_type = names['user_vm_types'][vmid]
board_name = names['board_name']
@ -604,8 +610,11 @@ def dm_arg_set(names, sel, virt_io, dm, vmid, config):
# set logger_setting for all VMs
print(" $logger_setting \\", file=config)
# GVT args set
gvt_arg_set(dm, vmid, user_vm_type, config)
# GPU PT args set
gpu_pt_arg_set(dm, sel, vmid, config)
# SRIOV args set
sriov_args_set(dm, sriov, vmid, config)
# XHCI args set
xhci_args_set(dm, vmid, config)
@ -631,7 +640,9 @@ def dm_arg_set(names, sel, virt_io, dm, vmid, config):
if user_vm_type == "PREEMPT-RT LINUX" and ssram_enabled == 'y':
print(" --ssram \\", file=config)
for value in sel.bdf.values():
for key, value in sel.bdf.items():
if key == 'gpu':
continue
if value[vmid]:
print(" $intr_storm_monitor \\", file=config)
break
@ -666,27 +677,27 @@ def dm_arg_set(names, sel, virt_io, dm, vmid, config):
print("}", file=config)
def gen(names, pt_sel, virt_io, dm, vmid, config):
def gen(names, pt_sel, virt_io, dm, sriov, vmid, config):
board_name = names['board_name']
user_vm_type = names['user_vm_types'][vmid]
# passthrough bdf/vpid dictionay
pt.gen_pt_head(names, dm, pt_sel, vmid, config)
pt.gen_pt_head(names, dm, sriov, pt_sel, vmid, config)
# gen launch header
launch_begin(names, virt_io, vmid, config)
tap_user_vm_net(names, virt_io, vmid, config)
# passthrough device
pt.gen_pt(names, dm, pt_sel, vmid, config)
pt.gen_pt(names, dm, sriov, pt_sel, vmid, config)
wa_usage(user_vm_type, config)
mem_size_set(dm, vmid, config)
interrupt_storm(pt_sel, config)
log_level_set(user_vm_type, config)
# gen acrn-dm args
dm_arg_set(names, pt_sel, virt_io, dm, vmid, config)
dm_arg_set(names, pt_sel, virt_io, dm, sriov, vmid, config)
# gen launch end
launch_end(names, dm, virt_io, vmid, config)

View File

@ -6,7 +6,7 @@
import os
import sys
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
from launch_item import AvailablePthru, PthruSelected, VirtioDeviceSelect, AcrnDmArgs
from launch_item import AvailablePthru, PthruSelected, VirtioDeviceSelect, AcrnDmArgs, SriovDeviceInput
import board_cfg_lib
import launch_cfg_lib
import com
@ -32,6 +32,7 @@ def get_launch_item_values(board_info, scenario_info=None):
# pre passthrough device for ui
launch_item_values["user_vm,passthrough_devices,usb_xdci"] = pthru.avl["usb_xdci"]
launch_item_values["uos,passthrough_devices,gpu"] = pthru.avl["gpu"]
launch_item_values["user_vm,passthrough_devices,ipu"] = pthru.avl["ipu"]
launch_item_values["user_vm,passthrough_devices,ipu_i2c"] = pthru.avl["ipu_i2c"]
launch_item_values["user_vm,passthrough_devices,cse"] = pthru.avl["cse"]
@ -88,12 +89,16 @@ def validate_launch_setting(board_info, scenario_info, launch_info):
virtio.get_virtio()
virtio.check_virtio()
sriov = SriovDeviceInput(launch_info)
sriov.get_sriov()
sriov.check_sriov(pt_sel)
# acrn dm arguments
dm = AcrnDmArgs(board_info, scenario_info, launch_info)
dm.get_args()
dm.check_item()
return (launch_cfg_lib.ERR_LIST, pt_sel, virtio, dm)
return (launch_cfg_lib.ERR_LIST, pt_sel, virtio, dm, sriov)
def ui_entry_api(board_info, scenario_info, launch_info, out=''):
@ -132,7 +137,7 @@ def get_names():
return (err_dic, names)
def generate_script_file(names, pt_sel, virt_io, dm, vmid, config):
def generate_script_file(names, pt_sel, virt_io, dm, sriov, vmid, config):
user_vm_type = names['user_vm_types'][vmid]
board_name = names['board_name']
@ -143,7 +148,7 @@ def generate_script_file(names, pt_sel, virt_io, dm, vmid, config):
board_name.upper(), scenario_name.upper(), user_vm_type.upper())
print("{}".format(header_info), file=config)
com.gen(names, pt_sel, virt_io, dm, vmid, config)
com.gen(names, pt_sel, virt_io, dm, sriov, vmid, config)
if launch_cfg_lib.ERR_LIST:
return launch_cfg_lib.ERR_LIST
@ -193,7 +198,7 @@ def main(args):
return err_dic
# validate launch config file
(err_dic, pt_sel, virt_io, dm) = validate_launch_setting(board_info_file, scenario_info_file, launch_info_file)
(err_dic, pt_sel, virt_io, dm, sriov) = validate_launch_setting(board_info_file, scenario_info_file, launch_info_file)
if err_dic:
return err_dic
@ -210,27 +215,28 @@ def main(args):
board_name = names['board_name']
if output_folder:
if os.path.isabs(output_folder):
output = os.path.join(output_folder + '/' + board_name, 'output/')
output = os.path.join(output_folder, board_name, 'output')
else:
output = os.path.join(ACRN_PATH + output_folder + '/' + board_name, 'output/')
output = os.path.join(ACRN_PATH, output_folder, board_name, 'output')
else:
output = os.path.join(ACRN_CONFIG_DEF + board_name, 'output/')
output = os.path.join(ACRN_CONFIG_DEF, board_name, 'output')
output = os.path.abspath(output)
common.mkdir(output)
# generate launch script
if vm_th:
script_name = "launch_uos_id{}.sh".format(vm_th)
launch_script_file = output + script_name
launch_script_file = os.path.join(output, script_name)
with open(launch_script_file, mode = 'w', newline=None, encoding='utf-8') as config:
err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, vm_th, config)
err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, sriov.dev, vm_th, config)
if err_dic:
return err_dic
else:
for post_vm_i in post_num_list:
script_name = "launch_uos_id{}.sh".format(post_vm_i)
launch_script_file = output + script_name
launch_script_file = os.path.join(output, script_name)
with open(launch_script_file, mode = 'w', newline='\n', encoding='utf-8') as config:
err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, post_vm_i, config)
err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, sriov.dev, post_vm_i, config)
if err_dic:
return err_dic

View File

@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: BSD-3-Clause
#
import re
import common
import board_cfg_lib
@ -20,7 +21,6 @@ class AcrnDmArgs:
self.args["user_vm_type"] = common.get_leaf_tag_map(self.launch_info, "user_vm_type")
self.args["rtos_type"] = common.get_leaf_tag_map(self.launch_info, "rtos_type")
self.args["mem_size"] = common.get_leaf_tag_map(self.launch_info, "mem_size")
self.args["gvt_args"] = common.get_leaf_tag_map(self.launch_info, "gvt_args")
self.args["vbootloader"] = common.get_leaf_tag_map(self.launch_info, "vbootloader")
self.args["vuart0"] = common.get_leaf_tag_map(self.launch_info, "vuart0")
self.args["cpu_sharing"] = common.get_hv_item_tag(self.scenario_info, "FEATURES", "SCHEDULER")
@ -70,6 +70,7 @@ class AvailablePthru():
def get_pci_dev(self):
self.avl["usb_xdci"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['usb_xdci'])
self.avl["gpu"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['gpu'])
self.avl["ipu"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu'])
self.avl["ipu_i2c"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu_i2c'])
self.avl["cse"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['cse'])
@ -84,6 +85,7 @@ class AvailablePthru():
def insert_nun(self):
self.avl["usb_xdci"].insert(0, '')
self.avl["gpu"].insert(0, '')
self.avl["ipu"].insert(0, '')
self.avl["ipu_i2c"].insert(0, '')
self.avl["cse"].insert(0, '')
@ -110,6 +112,7 @@ class PthruSelected():
def get_bdf(self):
self.bdf["usb_xdci"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "usb_xdci")
self.bdf["gpu"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "gpu")
self.bdf["ipu"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "ipu")
self.bdf["ipu_i2c"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "ipu_i2c")
self.bdf["cse"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "cse")
@ -124,6 +127,7 @@ class PthruSelected():
def get_vpid(self):
self.vpid["usb_xdci"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["usb_xdci"])
self.vpid["gpu"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["gpu"])
self.vpid["ipu"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["ipu"])
self.vpid["ipu_i2c"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["ipu_i2c"])
self.vpid["cse"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["cse"])
@ -153,6 +157,7 @@ class PthruSelected():
def check_item(self):
launch_cfg_lib.pt_devs_check(self.bdf["usb_xdci"], self.vpid["usb_xdci"], "usb_xdci")
launch_cfg_lib.pt_devs_check(self.bdf["gpu"], self.vpid["gpu"], "gpu")
launch_cfg_lib.pt_devs_check(self.bdf["ipu"], self.vpid["ipu"], "ipu")
launch_cfg_lib.pt_devs_check(self.bdf["ipu_i2c"], self.vpid["ipu_i2c"], "ipu_i2c")
launch_cfg_lib.pt_devs_check(self.bdf["cse"], self.vpid["cse"], "cse")
@ -185,3 +190,19 @@ class VirtioDeviceSelect():
def check_virtio(self):
launch_cfg_lib.check_block_mount(self.dev["block"])
class SriovDeviceInput():
dev = {}
def __init__(self, launch_info):
self.launch_info = launch_info
def get_sriov(self):
self.dev["gpu"] = common.get_leaf_tag_map(self.launch_info, "sriov", "gpu")
temp = common.get_leaf_tag_map(self.launch_info, "sriov", "network")
temp = {k: v[0] if v[0] else '' for k, v in temp.items()}
self.dev["network"] = temp
def check_sriov(self, pt_sel):
launch_cfg_lib.check_sriov_param(self.dev, pt_sel)

View File

@ -200,18 +200,23 @@ def media_pt(user_vm_type, sel, vmid, config):
audio_pt(user_vm_type, sel, vmid, config)
def gen_pt(names, dm, sel, vmid, config):
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)
# pass thru GPU
if dm['gvt_args'][vmid] == "gvtd":
# 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]:
@ -227,7 +232,7 @@ def gen_pt(names, dm, sel, vmid, config):
media_pt(user_vm_type, sel, vmid, config)
def gen_pt_head(names, dm, sel, vmid, config):
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]
@ -242,9 +247,13 @@ def gen_pt_head(names, dm, sel, vmid, config):
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)
# 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)
@ -252,9 +261,10 @@ def gen_pt_head(names, dm, sel, vmid, config):
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":
gpu_bdf = launch_cfg_lib.get_gpu_bdf()
print('["gpu"]="0000:{}"'.format(gpu_bdf), 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)

View File

@ -568,8 +568,12 @@ def round_up(addr, mem_align):
def mkdir(path):
if not os.path.exists(path):
import platform
try:
subprocess.check_call('mkdir -p {}'.format(path), shell=True, stdout=subprocess.PIPE)
if platform.system().lower() == 'windows':
os.makedirs(path)
else:
subprocess.check_call('mkdir -p {}'.format(path), shell=True, stdout=subprocess.PIPE)
except subprocess.CalledProcessError:
print_red("{} file create failed!".format(path), err=True)

View File

@ -5,6 +5,8 @@
import os
import getopt
import re
import common
import board_cfg_lib
import scenario_cfg_lib
@ -21,6 +23,7 @@ LINUX_LIKE_OS = ['CLEARLINUX', 'PREEMPT-RT LINUX', 'YOCTO', 'UBUNTU', 'GENERIC L
PT_SUB_PCI = {}
PT_SUB_PCI['usb_xdci'] = ['USB controller']
PT_SUB_PCI['gpu'] = ['VGA compatible controller']
PT_SUB_PCI['ipu'] = ['Multimedia controller']
PT_SUB_PCI['ipu_i2c'] = ['Signal processing controller']
PT_SUB_PCI['cse'] = ['Communication controller']
@ -35,7 +38,7 @@ PT_SUB_PCI['sata'] = ['SATA controller']
PT_SUB_PCI['nvme'] = ['Non-Volatile memory controller']
# passthrough devices for board
PASSTHRU_DEVS = ['usb_xdci', 'ipu', 'ipu_i2c', 'cse', 'audio', 'sata',
PASSTHRU_DEVS = ['usb_xdci', 'gpu', 'ipu', 'ipu_i2c', 'cse', 'audio', 'sata',
'nvme', 'audio_codec', 'sd_card', 'ethernet', 'wifi', 'bluetooth']
PT_SLOT = {
@ -483,6 +486,22 @@ def check_block_mount(virtio_blk_dic):
MOUNT_FLAG_DIC[vmid] = mount_flags
def check_sriov_param(sriov_dev, pt_sel):
for dev_type in ['gpu', 'network']:
for vm_id, dev_bdf in sriov_dev[dev_type].items():
if not dev_bdf:
continue
pt_devname = dev_type
if pt_devname == 'network':
pt_devname = 'ethernet'
if pt_sel.bdf[pt_devname][vm_id]:
ERR_LIST[
'vmid:{} sriov {}'.format(vm_id, dev_type)
] = 'this vm has {} passthrough and sriov {} at same time!'.format(pt_devname, dev_type)
if not re.match(r'^[\da-fA-F]{2}:[0-3][\da-fA-F]\.[0-7]$', dev_bdf):
ERR_LIST['vmid:{} sriov {}'.format(vm_id, dev_type)] = 'sriov {} bdf error'.format(dev_type)
def bdf_duplicate_check(bdf_dic):
"""
Check if exist duplicate slot
@ -516,17 +535,22 @@ def get_gpu_bdf():
gpu_bdf = gpu_bdf[0:7]
return gpu_bdf
def get_gpu_vpid():
def get_vpid_by_bdf(bdf):
vpid = ''
vpid_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<PCI_VID_PID>", "</PCI_VID_PID>")
gpu_bdf = get_gpu_bdf()
for vpid_line in vpid_lines:
if gpu_bdf in vpid_line:
if bdf in vpid_line:
vpid = " ".join(vpid_line.split()[2].split(':'))
return vpid
def get_gpu_vpid():
gpu_bdf = get_gpu_bdf()
return get_vpid_by_bdf(gpu_bdf)
def user_vm_cpu_affinity(user_vmid_cpu_affinity):
cpu_affinity = {}
@ -547,6 +571,8 @@ def check_slot(slot_db):
# get slot values for Passthrough devices
for dev in PASSTHRU_DEVS:
if dev == 'gpu':
continue
for user_vmid,slot_str in slot_db[dev].items():
if not slot_str:
continue
@ -554,6 +580,8 @@ def check_slot(slot_db):
# update slot values and replace the fun=0 if there is no fun 0 in bdf list
for dev in PASSTHRU_DEVS:
if dev == 'gpu':
continue
for user_vmid,slot_str in slot_db[dev].items():
if not slot_str or ':' not in str(slot_str):
continue