def tap_uos_net(names, vmid, config): uos_type = names['uos_types'][vmid] board_name = names['board_name'] vm_name = launch_cfg_lib.undline_name(uos_type).lower() if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"): if board_name in ("apl-mrb", "apl-up2"): print('if [ ! -f "/data/{}/{}.img" ]; then'.format( vm_name, vm_name), file=config) print(' echo "no /data/{}/{}.img, exit"'.format(vm_name, vm_name), file=config) print(" exit", file=config) print("fi", file=config) print("", file=config) print("#vm-name used to generate uos-mac address", file=config) print("mac=$(cat /sys/class/net/e*/address)", file=config) print("vm_name=vm$1", file=config) print("mac_seed=${mac:9:8}-${vm_name}", file=config) print("", file=config) if uos_type in ("VXWORKS", "ZEPHYR", "WINDOWS", "PREEMPT-RT LINUX"): print("vm_name={}_vm$1".format(vm_name), file=config) if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"): if board_name in ("apl-mrb", "apl-up2"): print("# create a unique tap device for each VM", file=config) print("tap=tap_$3", file=config) print('tap_exist=$(ip a | grep "$tap" | awk \'{print $1}\')', file=config) print('if [ "$tap_exist"x != "x" ]; then', file=config) print(' echo "tap device existed, reuse $tap"', file=config) print("else", file=config) print(" ip tuntap add dev $tap mode tap", file=config) print("fi", file=config) print("", file=config) print("# if acrn-br0 exists, add VM's unique tap device under it", file=config) print("br_exist=$(ip a | grep acrn-br0 | awk '{print $1}')", file=config) print('if [ "$br_exist"x != "x" -a "$tap_exist"x = "x" ]; then', file=config) print( ' echo "acrn-br0 bridge aleady exists, adding new tap device to it..."', file=config) print(' ip link set "$tap" master acrn-br0', file=config) print(' ip link set dev "$tap" down', file=config) print(' ip link set dev "$tap" up', file=config) print("fi", file=config) print("", file=config) print("#check if the vm is running or not", file=config) print("vm_ps=$(pgrep -a -f acrn-dm)", file=config) print('result=$(echo $vm_ps | grep -w "${vm_name}")', file=config) print('if [[ "$result" != "" ]]; then', file=config) print(' echo "$vm_name is running, can\'t create twice!"', file=config) print(" exit", file=config) print("fi", file=config) print("", file=config)
def launch_begin(names, virt_io, vmid, config): board_name = names['board_name'] uos_type = names['uos_types'][vmid] launch_uos = launch_cfg_lib.undline_name(uos_type).lower() tap_network(virt_io, vmid, config) run_container(board_name, uos_type, config) print("function launch_{}()".format(launch_uos), file=config) print("{", file=config)
def tap_uos_net(names, virt_io, vmid, config): uos_type = names['uos_types'][vmid] board_name = names['board_name'] vm_name = launch_cfg_lib.undline_name(uos_type).lower() if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"): 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] rootfs_img = blk.split(':')[1].strip(':') print('if [ ! -f "/data{}/{}" ]; then'.format(i, rootfs_img), file=config) print(' echo "no /data{}/{}, exit"'.format(i, rootfs_img), file=config) print(" exit", file=config) print("fi", file=config) print("", file=config) i += 1 print("#vm-name used to generate uos-mac address", file=config) print("mac=$(cat /sys/class/net/e*/address)", file=config) print("vm_name=vm$1", file=config) print("mac_seed=${mac:9:8}-${vm_name}", file=config) print("", file=config) if uos_type in ("VXWORKS", "ZEPHYR", "WINDOWS", "PREEMPT-RT LINUX"): print("vm_name={}_vm$1".format(vm_name), file=config) for net in virt_io['network'][vmid]: if net: net_name = net if ',' in net: net_name = net.split(',')[0] print("tap_net tap_{}".format(net_name), file=config) print("#check if the vm is running or not", file=config) print("vm_ps=$(pgrep -a -f acrn-dm)", file=config) print('result=$(echo $vm_ps | grep -w "${vm_name}")', file=config) print('if [[ "$result" != "" ]]; then', file=config) print(' echo "$vm_name is running, can\'t create twice!"', file=config) print(" exit", file=config) print("fi", file=config) print("", file=config)
def uos_launch(names, args, virt_io, vmid, config): gvt_args = args['gvt_args'][vmid] uos_type = names['uos_types'][vmid] launch_uos = launch_cfg_lib.undline_name(uos_type).lower() board_name = names['board_name'] if 'nuc' in board_name: board_name = 'nuc' if uos_type == "CLEARLINUX" and board_name in ("apl-mrb", "nuc"): print('if [ "$1" = "-C" ];then', file=config) print(' if [ $(hostname) = "runc" ]; then', file=config) print(' echo "Already in container exit!"', file=config) print(" exit", file=config) print(" fi", file=config) print(' echo "runc_container"', file=config) print(" run_container", file=config) if board_name == "apl-mrb": print(" exit", file=config) print("fi", file=config) else: print("else", file=config) print(' launch_{} 1 "{}"'.format(launch_uos, gvt_args), file=config) print("fi", file=config) else: if uos_type in ("VXWORKS", "PREEMPT-RT LINUX", "ZEPHYR"): print("launch_{} 1".format(launch_uos), file=config) if uos_type in ("CLEARLINUX", "WINDOWS"): print('launch_{} 1 "{}"'.format(launch_uos, gvt_args), file=config) if is_mount_needed(virt_io, vmid): print("", file=config) print('launch_{} {} "{}" "{}" $debug'.format(launch_uos, vmid, gvt_args, vmid), file=config) print("", file=config) i = 0 for mount_flag in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]: if not mount_flag: i += 1 continue print("umount /data{}".format(i), file=config) i += 1
def tap_uos_net(names, virt_io, vmid, config): uos_type = names['uos_types'][vmid] board_name = names['board_name'] vm_name = launch_cfg_lib.undline_name(uos_type).lower() if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"): if board_name in ("apl-mrb", "apl-up2"): print('if [ ! -f "/data/{}/{}.img" ]; then'.format( vm_name, vm_name), file=config) print(' echo "no /data/{}/{}.img, exit"'.format(vm_name, vm_name), file=config) print(" exit", file=config) print("fi", file=config) print("", file=config) print("#vm-name used to generate uos-mac address", file=config) print("mac=$(cat /sys/class/net/e*/address)", file=config) print("vm_name=vm$1", file=config) print("mac_seed=${mac:9:8}-${vm_name}", file=config) print("", file=config) if uos_type in ("VXWORKS", "ZEPHYR", "WINDOWS", "PREEMPT-RT LINUX"): print("vm_name={}_vm$1".format(vm_name), file=config) for net in virt_io['network'][vmid]: if net: net_name = net if ',' in net: net_name = net.split(',')[0] print("tap_net {}".format(net_name), file=config) print("#check if the vm is running or not", file=config) print("vm_ps=$(pgrep -a -f acrn-dm)", file=config) print('result=$(echo $vm_ps | grep -w "${vm_name}")', file=config) print('if [[ "$result" != "" ]]; then', file=config) print(' echo "$vm_name is running, can\'t create twice!"', file=config) print(" exit", file=config) print("fi", file=config) print("", file=config)
def launch_begin(board_name, uos_type, config): launch_uos = launch_cfg_lib.undline_name(uos_type).lower() run_container(board_name, uos_type, config) print("function launch_{}()".format(launch_uos), file=config) print("{", file=config)