Exemple #1
0
def launch_end(names, args, virt_io, vmid, config):

    board_name = names['board_name']
    uos_type = names['uos_types'][vmid]
    mem_size = args["mem_size"][vmid]

    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS") and not is_nuc_whl_linux(names, vmid):
        print("debug=0", file=config)
        print("", file=config)
        print('while getopts "hdC" opt', file=config)
        print("do", file=config)
        print("	case $opt in", file=config)
        print("		d) debug=1", file=config)
        print("			;;", file=config)
        print("		C)", file=config)
        print("			;;", file=config)
        print("		h) help", file=config)
        print("			exit 1", file=config)
        print("			;;", file=config)
        print("		?) help", file=config)
        print("			exit 1", file=config)
        print("			;;", file=config)
        print("	esac", file=config)
        print("done", file=config)
        print("", file=config)

    if is_mount_needed(virt_io, vmid):
        i = 0
        for mount_flag in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]:
            if not mount_flag:
                i += 1
                continue
            blk = virt_io['block'][vmid][i]
            root_fs = blk.split(':')[0]
            print('if [ ! -b "{}" ]; then'.format(root_fs), file=config)
            print('  echo "no {} data partition, exit"'.format(root_fs), file=config)
            print("  exit", file=config)
            print("fi", file=config)
            print("mkdir -p /data{}".format(i), file=config)
            print("mount {} /data{}".format(root_fs, i), file=config)
            print("", file=config)
            i += 1

    sos_vmid = launch_cfg_lib.get_sos_vmid()
    if args['cpu_sharing'] == "SCHED_NOOP" or common.VM_TYPES[vmid+sos_vmid] == "POST_RT_VM":
        off_line_cpus(args, vmid, uos_type, config)

    uos_launch(names, args, virt_io, vmid, config)
Exemple #2
0
def off_line_cpus(args, vmid, uos_type, config):
    """
    :param args: the dictionary of argument for acrn-dm
    :param vmid: ID of the vm
    :param uos_type: the type of UOS
    :param config: it is a file pointer to write offline cpu information
    """
    pcpu_id_list = get_cpu_affinity_list(args["cpu_affinity"], vmid)
    if not pcpu_id_list:
        sos_vmid = launch_cfg_lib.get_sos_vmid()
        cpu_affinity = common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "cpu_affinity", "pcpu_id")
        pcpu_id_list = get_cpu_affinity_list(cpu_affinity, sos_vmid+vmid)

    if not pcpu_id_list:
        key = "scenario config error"
        launch_cfg_lib.ERR_LIST[key] = "No available cpu to offline and pass it to vm {}".format(vmid)

    print('offline_path="/sys/class/vhm/acrn_vhm"', file=config)
    print("", file=config)

    print("# Check the device file of /dev/acrn_hsm to determine the offline_path", file=config)
    print('if [ -e "/dev/acrn_hsm" ]; then', file=config)
    print('offline_path="/sys/class/acrn/acrn_hsm"', file=config)
    print('fi', file=config)
    print("", file=config)
    print("# offline pinned vCPUs from SOS before launch UOS", file=config)
    print("for i in `ls -d /sys/devices/system/cpu/cpu[{}]`; do".format('..'.join(pcpu_id_list)), file=config)
    print("        online=`cat $i/online`", file=config)
    print('        idx=`echo $i | tr -cd "[1-99]"`', file=config)
    print("        echo cpu$idx online=$online", file=config)
    print('        if [ "$online" = "1" ]; then', file=config)
    print("             echo 0 > $i/online", file=config)
    print("             online=`cat $i/online`", file=config)
    print("             # during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod", file=config)
    print('             while [ "$online" = "1" ]; do', file=config)
    print("                     sleep 1", file=config)
    print("                     echo 0 > $i/online", file=config)
    print("                     online=`cat $i/online`", file=config)
    print("             done", file=config)
    print("             echo $idx > ${offline_path}/offline_cpu", file=config)
    print("        fi", file=config)
    print("done", file=config)
    print("", file=config)
Exemple #3
0
def off_line_cpus(args, vmid, user_vm_type, config):
    """
    :param args: the dictionary of argument for acrn-dm
    :param vmid: ID of the vm
    :param user_vm_type: the type of User VM
    :param config: it is a file pointer to write offline cpu information
    """
    pcpu_id_list = get_cpu_affinity_list(args["cpu_affinity"], vmid)
    if not pcpu_id_list:
        sos_vmid = launch_cfg_lib.get_sos_vmid()
        cpu_affinity = common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "cpu_affinity", "pcpu_id")
        pcpu_id_list = get_cpu_affinity_list(cpu_affinity, sos_vmid+vmid)

    if not pcpu_id_list:
        key = "scenario config error"
        launch_cfg_lib.ERR_LIST[key] = "No available cpu to offline and pass it to vm {}".format(vmid)

    print("# offline pinned vCPUs from Service VM before launch User VM", file=config)
    print('cpu_path="/sys/devices/system/cpu"', file=config)
    print("for i in `ls ${cpu_path}`; do", file=config)
    print("    for j in {}; do".format(' '.join([str(i) for i in pcpu_id_list])), file=config)
    print('        if [ "cpu"$j = $i ]; then', file=config)
    print('            online=`cat ${cpu_path}/$i/online`', file=config)
    print('            idx=`echo $i | tr -cd "[0-9]"`', file=config)
    print('            echo $i online=$online', file=config)
    print('            if [ "$online" = "1" ] && [ "$idx" != "0" ]; then', file=config)
    print("                echo 0 > ${cpu_path}/$i/online", file=config)
    print("                online=`cat ${cpu_path}/$i/online`", file=config)
    print("                # during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod", file=config)
    print('                while [ "$online" = "1" ]; do', file=config)
    print("                    sleep 1", file=config)
    print("                    echo 0 > ${cpu_path}/$i/online", file=config)
    print("                    online=`cat ${cpu_path}/$i/online`", file=config)
    print("                done", file=config)
    print("                echo $idx > /sys/devices/virtual/misc/acrn_hsm/remove_cpu", file=config)
    print("            fi", file=config)
    print("        fi", file=config)
    print("    done", file=config)
    print("done", file=config)
    print("", file=config)
Exemple #4
0
def dm_arg_set(names, sel, virt_io, dm, vmid, config):

    uos_type = names['uos_types'][vmid]
    board_name = names['board_name']

    boot_image_type(dm, vmid, config)

    # uuid get
    scenario_uuid = launch_cfg_lib.get_scenario_uuid(vmid)
    sos_vmid = launch_cfg_lib.get_sos_vmid()

    # clearlinux/android/alios
    print('acrn-dm -A -m $mem_size -s 0:0,hostbridge -U {} \\'.format(scenario_uuid), file=config)
    if launch_cfg_lib.is_linux_like(uos_type) or uos_type in ("ANDROID", "ALIOS"):
        if uos_type in ("ANDROID", "ALIOS"):
            print('   $npk_virt \\', file=config)
            print("   -s {},virtio-rpmb \\".format(launch_cfg_lib.virtual_dev_slot("virtio-rpmb")), file=config)
            print("   --enable_trusty \\", file=config)
        # mac_seed
        print("   --mac_seed $mac_seed \\", file=config)

    if dm['rtos_type'][vmid] != "no":
        if virt_io:
            print("   --virtio_poll 1000000 \\", file=config)

        if dm['rtos_type'][vmid] == "Soft RT":
            print("   --rtvm \\", file=config)

        if dm['rtos_type'][vmid] == "Hard RT":
            print("   --lapic_pt \\", file=config)

    # windows
    if uos_type == "WINDOWS":
        print("   --windows \\", file=config)

    # pm_channel set
    if dm['pm_channel'][vmid] and dm['pm_channel'][vmid] != None:
        pm_key = dm['pm_channel'][vmid]
        if pm_key == "vuart1(tty)":
            vuart_base = launch_cfg_lib.get_vuart1_from_scenario(sos_vmid + vmid)
            if vuart_base == "INVALID_COM_BASE":
                err_key = "uos:id={}:poweroff_channel".format(vmid)
                launch_cfg_lib.ERR_LIST[err_key] = "vuart1 of VM{} in scenario file should select 'SOS_COM2_BASE'".format(sos_vmid + vmid)
                return
        print("   {} \\".format(launch_cfg_lib.PM_CHANNEL_DIC[pm_key]), file=config)

    # set logger_setting for all VMs
    print("   $logger_setting \\", file=config)

    # XHCI args set
    xhci_args_set(dm, vmid, config)

    # VIRTIO args set
    virtio_args_set(dm, virt_io, vmid, config)

    # GVT args set
    gvt_arg_set(dm, vmid, uos_type, config)

    # vbootloader setting
    vboot_arg_set(dm, vmid, config)

    # pcpu-list args set
    pcpu_arg_set(dm, vmid, config)

    for value in sel.bdf.values():
        if value[vmid]:
            print("   $intr_storm_monitor \\", file=config)
            break

    if uos_type != "PREEMPT-RT LINUX":
        print("   -s 1:0,lpc \\", file=config)

    # redirect console
    if dm['vuart0'][vmid] == "Enable":
        print("   -l com1,stdio \\", file=config)

    if launch_cfg_lib.is_linux_like(uos_type) or uos_type in ("ANDROID", "ALIOS"):
        if uos_type != "PREEMPT-RT LINUX":
            print("   -s {},virtio-hyper_dmabuf \\".format(launch_cfg_lib.virtual_dev_slot("virtio-hyper_dmabuf")), file=config)
        if board_name == "apl-mrb":
            print("   -i /run/acrn/ioc_$vm_name,0x20 \\", file=config)
            print("   -l com2,/run/acrn/ioc_$vm_name \\", file=config)

        if not is_nuc_whl_linux(names, vmid):
            print("   -s {},wdt-i6300esb \\".format(launch_cfg_lib.virtual_dev_slot("wdt-i6300esb")), file=config)

    set_dm_pt(names, sel, vmid, config)
    print("   $vm_name", file=config)
    print("}", file=config)
Exemple #5
0
def dm_arg_set(names, sel, virt_io, dm, vmid, config):

    uos_type = names['uos_types'][vmid]
    board_name = names['board_name']

    boot_image_type(dm, vmid, config)

    # uuid get
    sos_vmid = launch_cfg_lib.get_sos_vmid()
    scenario_uuid = launch_cfg_lib.get_scenario_uuid(vmid, sos_vmid)

    # clearlinux/android/alios
    print('acrn-dm -A -m $mem_size -s 0:0,hostbridge -U {} \\'.format(
        scenario_uuid),
          file=config)
    if launch_cfg_lib.is_linux_like(uos_type) or uos_type in ("ANDROID",
                                                              "ALIOS"):
        if uos_type in ("ANDROID", "ALIOS"):
            print('   $npk_virt \\', file=config)
            print("   -s {},virtio-rpmb \\".format(
                launch_cfg_lib.virtual_dev_slot("virtio-rpmb")),
                  file=config)
            print("   --enable_trusty \\", file=config)
        # mac_seed
        print("   --mac_seed $mac_seed \\", file=config)

    if dm['rtos_type'][vmid] != "no":
        if virt_io:
            print("   --virtio_poll 1000000 \\", file=config)

        if dm['rtos_type'][vmid] == "Soft RT":
            print("   --rtvm \\", file=config)

        if dm['rtos_type'][vmid] == "Hard RT":
            print("   --lapic_pt \\", file=config)

    # windows
    if uos_type == "WINDOWS":
        print("   --windows \\", file=config)

    # pm_channel set
    if dm['pm_channel'][vmid] and dm['pm_channel'][vmid] != None:
        pm_key = dm['pm_channel'][vmid]
        pm_vuart = "--pm_notify_channel uart"
        if vmid in dm["allow_trigger_s5"] and dm["allow_trigger_s5"][
                vmid] == 'y':
            pm_vuart = pm_vuart + ",allow_trigger_s5 "
        else:
            pm_vuart = pm_vuart + " "
        if pm_key == "vuart1(tty)":
            vuart_base = launch_cfg_lib.get_vuart1_from_scenario(sos_vmid +
                                                                 vmid)
            if vuart_base == "INVALID_COM_BASE":
                err_key = "uos:id={}:poweroff_channel".format(vmid)
                launch_cfg_lib.ERR_LIST[
                    err_key] = "vuart1 of VM{} in scenario file should select 'SOS_COM2_BASE'".format(
                        sos_vmid + vmid)
                return
            scenario_cfg_lib.get_sos_vuart_settings()
            print("   {} \\".format(pm_vuart +
                                    launch_cfg_lib.PM_CHANNEL_DIC[pm_key] +
                                    scenario_cfg_lib.SOS_UART1_VALID_NUM),
                  file=config)
        elif pm_key == "vuart1(pty)":
            print("   {} \\".format(pm_vuart +
                                    launch_cfg_lib.PM_CHANNEL_DIC[pm_key]),
                  file=config)
        else:
            print("   {} \\".format(launch_cfg_lib.PM_CHANNEL_DIC[pm_key]),
                  file=config)

    # set logger_setting for all VMs
    print("   $logger_setting \\", file=config)

    # GVT args set
    gvt_arg_set(dm, vmid, uos_type, config)

    # XHCI args set
    xhci_args_set(dm, vmid, config)

    # VIRTIO args set
    virtio_args_set(dm, virt_io, vmid, config)

    # vbootloader setting
    vboot_arg_set(dm, vmid, config)

    # pcpu-list args set
    pcpu_arg_set(dm, vmid, config)

    # shm regions args set
    shm_arg_set(dm, vmid, config)

    # ssram set
    ssram_enabled = 'n'
    try:
        ssram_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE,
                                               "FEATURES", "SSRAM",
                                               "SSRAM_ENABLED")
    except:
        pass
    if uos_type == "PREEMPT-RT LINUX" and ssram_enabled == 'y':
        print("   --ssram \\", file=config)

    for value in sel.bdf.values():
        if value[vmid]:
            print("   $intr_storm_monitor \\", file=config)
            break

    if uos_type != "PREEMPT-RT LINUX":
        print("   -s 1:0,lpc \\", file=config)

    # redirect console
    if dm['vuart0'][vmid] == "Enable":
        print("   -l com1,stdio \\", file=config)

    if launch_cfg_lib.is_linux_like(uos_type) or uos_type in ("ANDROID",
                                                              "ALIOS"):
        if board_name == "apl-mrb":
            print("   -i /run/acrn/ioc_$vm_name,0x20 \\", file=config)
            print("   -l com2,/run/acrn/ioc_$vm_name \\", file=config)

        if not is_nuc_whl_linux(names, vmid):
            print("   -s {},wdt-i6300esb \\".format(
                launch_cfg_lib.virtual_dev_slot("wdt-i6300esb")),
                  file=config)

    set_dm_pt(names, sel, vmid, config, dm)

    if dm['console_vuart'][vmid] == "Enable":
        print("   -s {},uart,vuart_idx:0 \\".format(
            launch_cfg_lib.virtual_dev_slot("console_vuart")),
              file=config)
    for vuart_id in dm["communication_vuarts"][vmid]:
        if not vuart_id:
            break
        print("   -s {},uart,vuart_idx:{} \\".format(
            launch_cfg_lib.virtual_dev_slot(
                "communication_vuart_{}".format(vuart_id)), vuart_id),
              file=config)

    print("   $vm_name", file=config)
    print("}", file=config)
Exemple #6
0
def dm_arg_set(names, sel, virt_io, dm, vmid, config):

    uos_type = names['uos_types'][vmid]
    board_name = names['board_name']

    # vboot loader for vsbl
    boot_image_type(dm, vmid, config)
    root_img = dm['rootfs_img'][vmid]

    # uuid get
    scenario_uuid = launch_cfg_lib.get_scenario_uuid()
    sos_vmid = launch_cfg_lib.get_sos_vmid()
    if not str(sos_vmid).isnumeric():
        sos_vmid = 0
        key = "launch config err:"
        launch_cfg_lib.ERR_LIST[
            key] = "There is no SOS_VM in scenario config file!"

    # clearlinux/android/alios
    dm_str = 'acrn-dm -A -m $mem_size -s 0:0,hostbridge -U {}'.format(
        scenario_uuid[vmid + sos_vmid])
    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        if uos_type == "CLEARLINUX":
            print("{} \\".format(dm_str), file=config)
        else:
            print('{} $npk_virt \\'.format(dm_str), file=config)

    if board_name == "apl-up2" or is_nuc_whl_clr(names, vmid):
        print("   $logger_setting \\", file=config)

    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        if uos_type in ("ANDROID", "ALIOS"):
            print("   -s {},virtio-rpmb \\".format(
                launch_cfg_lib.virtual_dev_slot("virtio-rpmb")),
                  file=config)
        if board_name == "apl-up2":
            print("   --pm_notify_channel power_button \\", file=config)
        if board_name == "apl-mrb":
            print("   --pm_notify_channel ioc \\", file=config)

    if is_nuc_whl_clr(names, vmid):
        print("   --pm_notify_channel uart \\", file=config)
        print('   --pm_by_vuart pty,/run/acrn/life_mngr_$vm_name  \\',
              file=config)
        print('   -l com2,/run/acrn/life_mngr_$vm_name \\', file=config)
        print("   -s {},virtio-net,tap0 \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-net")),
              file=config)

    # mac_seed
    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        print("   --mac_seed $mac_seed \\", file=config)

    # hard rt os
    if uos_type == "PREEMPT-RT LINUX":
        print("{} \\".format(dm_str), file=config)
        print("   --lapic_pt \\", file=config)
        print("   --rtvm \\", file=config)
        print("   --virtio_poll 1000000 \\", file=config)
        print("   --pm_notify_channel uart --pm_by_vuart tty,/dev/ttyS1 \\",
              file=config)

    # vxworks
    if uos_type == "VXWORKS":
        print("{} \\".format(dm_str), file=config)
        print("   --virtio_poll 1000000 \\", file=config)
        print("   --lapic_pt \\", file=config)

    # zephyr
    if uos_type == "ZEPHYR":
        print("{} \\".format(dm_str), file=config)

    # windows
    if uos_type == "WINDOWS":
        print("{} \\".format(dm_str), file=config)
        print("   --windows \\", file=config)

    # WA: XHCI args set
    xhci_args_set(dm, vmid, config)

    # VIRTIO args set
    vritio_args_set(virt_io, vmid, config)

    # GVT args set
    gvt_arg_set(uos_type, config)

    # vbootloader setting
    vboot_arg_set(dm, vmid, config)

    # redirect console
    if dm['console_type'][vmid] == "com1(ttyS0)":
        print("   -s 1:0,lpc \\", file=config)
        print("   -l com1,stdio \\", file=config)
        print("   -s {},{} \\".format(
            launch_cfg_lib.virtual_dev_slot("com1(ttyS0)"),
            launch_cfg_lib.RE_CONSOLE_MAP['com1(ttyS0)']),
              file=config)
    else:
        print("   -s {},{} \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-console(hvc0)"),
            launch_cfg_lib.RE_CONSOLE_MAP['virtio-console(hvc0)']),
              file=config)

    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        if board_name in ("apl-mrb", "apl-up2"):
            print("   -s {},virtio-net,$tap \\".format(
                launch_cfg_lib.virtual_dev_slot("virtio-net")),
                  file=config)

    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        print("   -s {},virtio-hyper_dmabuf \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-hyper_dmabuf")),
              file=config)
        if board_name == "apl-mrb":
            print("   -i /run/acrn/ioc_$vm_name,0x20 \\", file=config)
            print("   -l com2,/run/acrn/ioc_$vm_name \\", file=config)

        if sel:
            print("   $intr_storm_monitor \\", file=config)

        if not is_nuc_whl_clr(names, vmid):
            print("   -s {},wdt-i6300esb \\".format(
                launch_cfg_lib.virtual_dev_slot("wdt-i6300esb")),
                  file=config)
            #print("   -s {},xhci,1-1:1-2:1-3:2-1:2-2:2-3:cap=apl \\".format(launch_cfg_lib.virtual_dev_slot("xhci")), file=config)

    if dm['vbootloader'][vmid] and dm['vbootloader'][vmid] == "vsbl":
        print("   -s {},virtio-blk$boot_dev_flag,/data/{} \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-blk"), root_img),
              file=config)
    elif dm['vbootloader'][vmid] and dm['vbootloader'][vmid] == "ovmf":
        print("   -s {},virtio-blk,{} \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-blk"), root_img),
              file=config)

    if uos_type in ("ANDROID", "ALIOS"):
        print("   --enable_trusty \\", file=config)

    set_dm_pt(names, sel, vmid, config)
    print("   $vm_name", file=config)
    print("}", file=config)
def vm_cpu_affinity_check(scenario_file, launch_file, cpu_affinity):
    """
    Check cpu number of per vm
    :param : vm cpu_affinity item in xml
    :return: error informations
    """
    err_dic = {}
    use_cpus = []
    cpu_sharing_enabled = True

    cpu_sharing = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "SCHEDULER")
    if cpu_sharing == "SCHED_NOOP":
        cpu_sharing_enabled = False

    # validate cpu_affinity config with scenario file
    sos_vmid = launch_cfg_lib.get_sos_vmid()
    scenario_cpu_aff = common.get_leaf_tag_map(scenario_file, "cpu_affinity", "pcpu_id")
    scenario_vm_names = {v: k for k, v in common.get_leaf_tag_map(scenario_file, 'name').items()}
    if launch_file:
        launch_vm_names = common.get_leaf_tag_map(launch_file, 'vm_name')
        for vm_id, cpu_ids in cpu_affinity.items():
            launch_vm_name = launch_vm_names[vm_id - sos_vmid]
            if launch_vm_name not in scenario_vm_names:
                # Dynamic VM, skip scenario cpu affinity subset check
                continue
            abs_vmid = scenario_vm_names[launch_vm_name]
            for vm_cpu in cpu_ids:
                if vm_cpu is None:
                    key = "vm:id={},{}".format(abs_vmid - sos_vmid, 'pcpu_id')
                    err_dic[key] = "This vm cpu_affinity is empty. " \
                                   "Please update your launch file accordingly."
                if vm_cpu not in scenario_cpu_aff[abs_vmid]:
                    key = "vm:id={},{}".format(abs_vmid - sos_vmid, 'pcpu_id')
                    err_dic[key] = "This pCPU is not included in this VM's allowed CPU pool. " \
                                   "Please update your scenario file accordingly or remove it from this list."

    if err_dic:
        return err_dic

    for vm_i,cpu in cpu_affinity.items():
        if cpu is not None and cpu in use_cpus and not cpu_sharing_enabled:
            key = "vm:id={},{}".format(vm_i, 'pcpu_id')
            err_dic[key] = "The same pCPU was configured in <pcpu_id>/<cpu_affinity>, but CPU sharing is disabled by 'SCHED_NOOP'. Please enable CPU sharing or update your CPU affinity configuration."
            return err_dic
        else:
            use_cpus.append(cpu)

    sos_vm_cpus = []
    pre_launch_cpus = []
    post_launch_cpus = []
    for vm_i, load_order in common.LOAD_ORDER.items():
        if vm_i not in cpu_affinity.keys():
            continue
        elif VM_DB[load_order]['load_type'] == "PRE_LAUNCHED_VM":
            cpus = [x for x in cpu_affinity[vm_i] if not None]
            pre_launch_cpus.extend(cpus)
        elif VM_DB[load_order]['load_type'] == "POST_LAUNCHED_VM":
            cpus = [x for x in cpu_affinity[vm_i] if not None]
            post_launch_cpus.extend(cpus)
        elif VM_DB[load_order]['load_type'] == "SERVICE_VM":
            cpus = [x for x in cpu_affinity[vm_i] if not None]
            sos_vm_cpus.extend(cpus)

        # duplicate cpus assign the same VM check
        cpus_vm_i = cpu_affinity[vm_i]
        for cpu_id in cpus_vm_i:
            if cpus_vm_i.count(cpu_id) >= 2:
                key = "vm:id={},{}".format(vm_i, 'pcpu_id')
                err_dic[key] = "VM should not use the same pcpu id:{}".format(cpu_id)
                return err_dic

    if pre_launch_cpus:
        if "SERVICE_VM" in common.LOAD_ORDER and not sos_vm_cpus:
            key = "Service VM cpu_affinity"
            err_dic[key] = "Should assign CPU id for Service VM"

        for pcpu in pre_launch_cpus:
            if pre_launch_cpus.count(pcpu) >= 2:
                key = "Pre launched VM cpu_affinity"
                err_dic[key] = "Pre_launched_vm vm should not have the same cpus assignment"

    return err_dic
Exemple #8
0
def dm_arg_set(names, sel, virt_io, dm, vmid, config):

    uos_type = names['uos_types'][vmid]
    board_name = names['board_name']

    boot_image_type(dm, vmid, config)

    # uuid get
    scenario_uuid = launch_cfg_lib.get_scenario_uuid()
    sos_vmid = launch_cfg_lib.get_sos_vmid()
    if not str(sos_vmid).isnumeric():
        sos_vmid = 0
        key = "launch config err:"
        launch_cfg_lib.ERR_LIST[
            key] = "There is no SOS_VM in scenario config file!"

    # clearlinux/android/alios
    dm_str = 'acrn-dm -A -m $mem_size -s 0:0,hostbridge -U {}'.format(
        scenario_uuid[vmid + sos_vmid])
    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        if uos_type == "CLEARLINUX":
            print("{} \\".format(dm_str), file=config)
        else:
            print('{} $npk_virt \\'.format(dm_str), file=config)

    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        if uos_type in ("ANDROID", "ALIOS"):
            print("   -s {},virtio-rpmb \\".format(
                launch_cfg_lib.virtual_dev_slot("virtio-rpmb")),
                  file=config)

    # mac_seed
    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        print("   --mac_seed $mac_seed \\", file=config)

    # hard rt os
    if uos_type == "PREEMPT-RT LINUX":
        print("{} \\".format(dm_str), file=config)
        print("   --lapic_pt \\", file=config)
        print("   --rtvm \\", file=config)
        print("   --virtio_poll 1000000 \\", file=config)

    # vxworks
    if uos_type == "VXWORKS":
        print("{} \\".format(dm_str), file=config)
        print("   --virtio_poll 1000000 \\", file=config)
        print("   --lapic_pt \\", file=config)

    # zephyr
    if uos_type == "ZEPHYR":
        print("{} \\".format(dm_str), file=config)

    # windows
    if uos_type == "WINDOWS":
        print("{} \\".format(dm_str), file=config)
        print("   --windows \\", file=config)

    # pm_channel set
    if dm['pm_channel'][vmid] and dm['pm_channel'][vmid] != None:
        pm_key = dm['pm_channel'][vmid]
        if pm_key == "vuart1(tty)":
            vuart_base = launch_cfg_lib.get_vuart1_from_scenario(sos_vmid +
                                                                 vmid)
            if vuart_base == "INVALID_COM_BASE":
                err_key = "uos:id={}:poweroff_channel".format(vmid)
                launch_cfg_lib.ERR_LIST[
                    err_key] = "vuart1 of VM{} in scenario file should select 'SOS_COM2_BASE'".format(
                        sos_vmid + vmid)
                return
        print("   {} \\".format(launch_cfg_lib.PM_CHANNEL_DIC[pm_key]),
              file=config)

    # set logger_setting for all VMs
    print("   $logger_setting \\", file=config)

    # XHCI args set
    xhci_args_set(dm, vmid, config)

    # VIRTIO args set
    virtio_args_set(dm, virt_io, vmid, config)

    # GVT args set
    gvt_arg_set(dm, vmid, uos_type, config)

    # vbootloader setting
    vboot_arg_set(dm, vmid, config)

    # redirect console
    if dm['vuart0'][vmid] == "Enable":
        print("   -s 1:0,lpc \\", file=config)
        print("   -l com1,stdio \\", file=config)

    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        print("   -s {},virtio-hyper_dmabuf \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-hyper_dmabuf")),
              file=config)
        if board_name == "apl-mrb":
            print("   -i /run/acrn/ioc_$vm_name,0x20 \\", file=config)
            print("   -l com2,/run/acrn/ioc_$vm_name \\", file=config)

        if sel:
            print("   $intr_storm_monitor \\", file=config)

        if not is_nuc_whl_clr(names, vmid):
            print("   -s {},wdt-i6300esb \\".format(
                launch_cfg_lib.virtual_dev_slot("wdt-i6300esb")),
                  file=config)

    if uos_type in ("ANDROID", "ALIOS"):
        print("   --enable_trusty \\", file=config)

    set_dm_pt(names, sel, vmid, config)
    print("   $vm_name", file=config)
    print("}", file=config)
Exemple #9
0
def dm_arg_set(names, sel, dm, vmid, config):

    uos_type = names['uos_types'][vmid]
    board_name = names['board_name']

    # vbootlaoder for vsbl
    boot_image_type(dm, vmid, config)

    # uuid get
    scenario_uuid = launch_cfg_lib.get_scenario_uuid()
    sos_vmid = launch_cfg_lib.get_sos_vmid()

    # clearlinux/android/alios
    dm_str = 'acrn-dm -A -m $mem_size $boot_GVT_option"$GVT_args" -s 0:0,hostbridge  -s 1:0,lpc -U {}'.format(
        scenario_uuid[vmid + sos_vmid])
    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        if uos_type == "CLEARLINUX":
            print("{} \\".format(dm_str), file=config)
        else:
            print('{} $npk_virt \\'.format(dm_str), file=config)

    if board_name == "apl-up2" or is_nuc_clr(names, vmid):
        print("   $logger_setting \\", file=config)

    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        if uos_type in ("ANDROID", "ALIOS"):
            print("   -s {},virtio-rpmb \\".format(
                launch_cfg_lib.virtual_dev_slot("virtio-rpmb")),
                  file=config)
        if board_name == "apl-up2":
            print("   --pm_notify_channel power_button \\", file=config)
        if board_name == "apl-mrb":
            print("   --pm_notify_channel ioc \\", file=config)

    if is_nuc_clr(names, vmid):
        print("   --pm_notify_channel uart \\", file=config)
        print('   --pm_by_vuart pty,/run/acrn/life_mngr_$vm_name  \\',
              file=config)
        print('   -l com2,/run/acrn/life_mngr_$vm_name \\', file=config)
        print("   -s {},virtio-net,tap0 \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-net")),
              file=config)

    # mac_seed
    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        print("   --mac_seed $mac_seed \\", file=config)

    # hard rt os
    if uos_type == "PREEMPT-RT LINUX":
        print("acrn-dm -A -m $mem_size -s 0:0,hostbridge -U {} \\".format(
            scenario_uuid[vmid + sos_vmid]),
              file=config)
        #print("   -k /usr/lib/kernel/default-iot-lts2018-preempt-rt \\", file=config)
        print("   -k /usr/lib/kernel/default-iot-lts2018-preempt-rt \\",
              file=config)
        print("   --lapic_pt \\", file=config)
        print("   --rtvm \\", file=config)
        print("   --virtio_poll 1000000 \\", file=config)
        print("   --pm_notify_channel uart --pm_by_vuart tty,/dev/ttyS1 \\",
              file=config)

    # vxworks
    if uos_type == "VXWORKS":
        print("acrn-dm -A -m $mem_size -s 0:0,hostbridge -U {} \\".format(
            scenario_uuid[vmid + sos_vmid]),
              file=config)
        print("   -s {},virtio-blk,./VxWorks.img \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-blk")),
              file=config)
        print("   --virtio_poll 1000000 \\", file=config)
        print("   --lapic_pt \\", file=config)

    # zephyr
    if uos_type == "ZEPHYR":
        print("acrn-dm -A -m $mem_size -s 0:0,hostbridge -s 1:0,lpc -U {} \\".
              format(scenario_uuid[vmid + sos_vmid]),
              file=config)
        print("   -s {},virtio-blk,./zephyr.img \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-blk")),
              file=config)

    # windows
    if uos_type == "WINDOWS":
        print("acrn-dm -A -m $mem_size -s 0:0,hostbridge -s 1:0,lpc -U {} \\".
              format(scenario_uuid[vmid + sos_vmid]),
              file=config)
        print('   -s 2,pci-gvt -G "$3"  \\', file=config)
        print("   -s {},virtio-blk,./win10-ltsc.img \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-blk")),
              file=config)

# vbootloader of ovmf
#if uos_type != "PREEMPT-RT LINUX" and dm['vbootloader'][vmid] == "ovmf":
    if dm['vbootloader'][vmid] == "ovmf":
        print("   --ovmf /usr/share/acrn/bios/OVMF.fd \\", file=config)

    # redirect console
    if dm['console_type'][vmid] == "com1(ttyS0)":
        print("   -l com1,stdio \\", file=config)
        print("   -s {},{} \\".format(
            launch_cfg_lib.virtual_dev_slot("com1(ttyS0)"),
            launch_cfg_lib.RE_CONSOLE_MAP['com1(ttyS0)']),
              file=config)
    else:
        print("   -s {},{} \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-console(hvc0)"),
            launch_cfg_lib.RE_CONSOLE_MAP['virtio-console(hvc0)']),
              file=config)

    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        if board_name in ("apl-mrb", "apl-up2"):
            print("   -s {},virtio-net,$tap \\".format(
                launch_cfg_lib.virtual_dev_slot("virtio-net")),
                  file=config)

    if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
        print("   -s {},virtio-hyper_dmabuf \\".format(
            launch_cfg_lib.virtual_dev_slot("virtio-hyper_dmabuf")),
              file=config)
        if board_name == "apl-mrb":
            print("   -i /run/acrn/ioc_$vm_name,0x20 \\", file=config)
            print("   -l com2,/run/acrn/ioc_$vm_name \\", file=config)

        if not is_nuc_clr(names, vmid):
            print("   -s {},wdt-i6300esb \\".format(
                launch_cfg_lib.virtual_dev_slot("wdt-i6300esb")),
                  file=config)
            print("   $intr_storm_monitor \\", file=config)
            if dm['vbootloader'][vmid] == "vsbl":
                print("   $boot_image_option \\", file=config)
            print(
                "   -s {},virtio-blk$boot_dev_flag,/data/$5/$5.img \\".format(
                    launch_cfg_lib.virtual_dev_slot("virtio-blk")),
                file=config)
            print("   -s {},xhci,1-1:1-2:1-3:2-1:2-2:2-3:cap=apl \\".format(
                launch_cfg_lib.virtual_dev_slot("xhci")),
                  file=config)
        else:
            print("   -s {},virtio-blk,/home/clear/uos/uos.img \\".format(
                launch_cfg_lib.virtual_dev_slot("virtio-blk")),
                  file=config)

    if uos_type in ("ANDROID", "ALIOS"):
        print("   --enable_trusty \\", file=config)

    set_dm_pt(names, sel, vmid, config)
    if uos_type != "PREEMPT-RT LINUX":
        print("   $vm_name", file=config)
    else:
        print("   hard_rtvm", file=config)
    print("}", file=config)