config_tool: add vm_name field for launch config
add vm_name field for launch config Tracked-On: #6685 Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
parent
7bf25a9d0d
commit
86f1477482
|
@ -31,7 +31,7 @@ def tap_user_vm_net(names, virt_io, vmid, config):
|
|||
user_vm_type = names['user_vm_types'][vmid]
|
||||
board_name = names['board_name']
|
||||
|
||||
vm_name = common.undline_name(user_vm_type).lower()
|
||||
vm_name = names['user_vm_names'][vmid]
|
||||
|
||||
if launch_cfg_lib.is_linux_like(user_vm_type) or user_vm_type in ("ANDROID", "ALIOS"):
|
||||
i = 0
|
||||
|
@ -50,7 +50,7 @@ def tap_user_vm_net(names, virt_io, vmid, config):
|
|||
|
||||
print("#vm-name used to generate user-vm-mac address", file=config)
|
||||
print("mac=$(cat /sys/class/net/e*/address)", file=config)
|
||||
print("vm_name=post_vm_id$1", file=config)
|
||||
print("vm_name=\"{}\"".format(vm_name), file=config)
|
||||
print("mac_seed=${mac:0:17}-${vm_name}", file=config)
|
||||
print("", file=config)
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
|
||||
from launch_item import AvailablePthru, PthruSelected, VirtioDeviceSelect, AcrnDmArgs, SriovDeviceInput
|
||||
|
@ -123,6 +124,10 @@ def get_names():
|
|||
user_vm_types = launch_cfg_lib.get_user_vm_type()
|
||||
names['user_vm_types'] = user_vm_types
|
||||
|
||||
# get user_vm name
|
||||
user_vm_names = launch_cfg_lib.get_user_vm_names()
|
||||
names['user_vm_names'] = user_vm_names
|
||||
|
||||
# get board name
|
||||
(err_dic, board_name) = common.get_board_name()
|
||||
if err_dic:
|
||||
|
@ -195,6 +200,17 @@ def main(args):
|
|||
if post_num > post_vm_count:
|
||||
err_dic['xm config err:'] = "launch xml user vmid config is bigger than scenario post vm count"
|
||||
|
||||
# validate vm_names
|
||||
scenario_names = common.get_leaf_tag_map(scenario_info_file, "name").values()
|
||||
for user_vm_id, vm_name in launch_cfg_lib.get_user_vm_names().items():
|
||||
if not re.match(r"^\S{1,15}$", vm_name):
|
||||
err_name = 'user_vm id="{}" name error:'.format(user_vm_id)
|
||||
err_dic[err_name] = 'vm_name only allowed 1-15 characters with letters, numbers & symbols ' \
|
||||
'(not include space)'
|
||||
if vm_name not in scenario_names:
|
||||
err_name = 'user_vm id="{}" name not found error:'.format(user_vm_id)
|
||||
err_dic[err_name] = 'user_vm id="{}" vm_name not found in it scenario file:'.format(user_vm_id)
|
||||
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
|
|
|
@ -256,6 +256,11 @@ def get_user_vm_type():
|
|||
return user_vm_types
|
||||
|
||||
|
||||
def get_user_vm_names():
|
||||
user_vm_names = common.get_leaf_tag_map(common.LAUNCH_INFO_FILE, "vm_name")
|
||||
return user_vm_names
|
||||
|
||||
|
||||
def is_bdf_format(bdf_str):
|
||||
bdf_len = 7
|
||||
status = True
|
||||
|
|
Loading…
Reference in New Issue