!23 310b 适配davinci_manager_docker改名,修复挂载so的bug

Merge pull request !23 from funnyfunny8/master
This commit is contained in:
Atlas_kang
2023-07-06 11:01:26 +00:00
committed by Gitee
6 changed files with 81 additions and 76 deletions

View File

@@ -7,7 +7,6 @@
/var/slogd /var/slogd
/usr/lib64/libsemanage.so.2 /usr/lib64/libsemanage.so.2
/usr/lib64/libmmpa.so /usr/lib64/libmmpa.so
/usr/lib64/libcrypto.so.1.1
/usr/lib64/libdrvdsmi.so /usr/lib64/libdrvdsmi.so
/usr/lib64/libdcmi.so /usr/lib64/libdcmi.so
/usr/lib64/libstackcore.so /usr/lib64/libstackcore.so
@@ -18,5 +17,4 @@
/usr/lib64/libaicpu_sharder.so /usr/lib64/libaicpu_sharder.so
/usr/lib64/libadump.so /usr/lib64/libadump.so
/usr/lib64/libtsd_eventclient.so /usr/lib64/libtsd_eventclient.so
/usr/lib64/aicpu_kernels /usr/lib64/aicpu_kernels
/usr/lib64/libyaml-0.so.2

View File

@@ -40,6 +40,21 @@ function save_install_args() {
} >> "${INSTALL_PATH}"/ascend_docker_runtime_install.info } >> "${INSTALL_PATH}"/ascend_docker_runtime_install.info
} }
function add_so() {
if grep -qi "ubuntu" "/etc/os-release"; then
echo "[info]: os is Ubuntu"
echo -e "\n/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo "/usr/lib/aarch64-linux-gnu/libyaml-0.so.2" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
elif grep -qi "euler" "/etc/os-release"; then
echo "[info]: os is Euler/OpenEuler"
echo -e "\n/usr/lib64/libcrypto.so.1.1" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo "/usr/lib64/libyaml-0.so.2" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
else
echo "ERROR: not support this os"
exit
fi
}
function install() function install()
{ {
echo 'installing ascend docker runtime' echo 'installing ascend docker runtime'
@@ -89,20 +104,10 @@ function install()
cp -f ./base.list_A200ISoC ${ASCEND_RUNTIME_CONFIG_DIR}/base.list cp -f ./base.list_A200ISoC ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
elif [ "${a500a2}" == "y" ]; then elif [ "${a500a2}" == "y" ]; then
cp -f ./base.list_A500A2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list cp -f ./base.list_A500A2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
add_so
elif [ "${a200ia2}" == "y" ]; then elif [ "${a200ia2}" == "y" ]; then
cp -f ./base.list_A200IA2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list cp -f ./base.list_A200IA2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
if grep -qi "ubuntu" "/etc/os-release"; then add_so
echo "[info]: A200IA2 os is Ubuntu"
echo -e "\n/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo "/usr/lib/aarch64-linux-gnu/libyaml-0.so.2.0.6" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
elif grep -qi "euler" "/etc/os-release"; then
echo "[info]: A200IA2 os is Euler/OpenEuler"
echo -e "\n/usr/lib64/libcrypto.so.1.1.1m" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo "/usr/lib64/libyaml-0.so.2.0.9" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
else
echo "ERROR: not support this os"
exit
fi
else else
cp -f ./base.list ${ASCEND_RUNTIME_CONFIG_DIR}/base.list cp -f ./base.list ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
fi fi
@@ -185,6 +190,7 @@ function upgrade()
elif [ "$(grep "a500a2=y" "${INSTALL_PATH}"/ascend_docker_runtime_install.info)" == "a500a2=y" ]; then elif [ "$(grep "a500a2=y" "${INSTALL_PATH}"/ascend_docker_runtime_install.info)" == "a500a2=y" ]; then
a500a2=y a500a2=y
cp -f ./base.list_A500A2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list cp -f ./base.list_A500A2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
add_so
elif [ "$(grep "a200=y" "${INSTALL_PATH}"/ascend_docker_runtime_install.info)" == "a200=y" ]; then elif [ "$(grep "a200=y" "${INSTALL_PATH}"/ascend_docker_runtime_install.info)" == "a200=y" ]; then
a200=y a200=y
cp -f ./base.list_A200 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list cp -f ./base.list_A200 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
@@ -194,18 +200,7 @@ function upgrade()
elif [ "x$(grep "a200ia2=y" "${INSTALL_PATH}"/ascend_docker_runtime_install.info)" == "xa200ia2=y" ]; then elif [ "x$(grep "a200ia2=y" "${INSTALL_PATH}"/ascend_docker_runtime_install.info)" == "xa200ia2=y" ]; then
a200ia2=y a200ia2=y
cp -f ./base.list_A200IA2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list cp -f ./base.list_A200IA2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
if grep -qi "ubuntu" "/etc/os-release"; then add_so
echo "[info]: A200IA2 os is Ubuntu"
echo -e "\n/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo -e "/usr/lib/aarch64-linux-gnu/libyaml-0.so.2.0.6" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
elif grep -qi "euler" "/etc/os-release"; then
echo "[info]: A200IA2 os is Euler/OpenEuler"
echo -e "\n/usr/lib64/libcrypto.so.1.1.1m" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo -e "/usr/lib64/libyaml-0.so.2.0.9" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
else
echo "ERROR: not support this os"
exit
fi
else else
cp -f ./base.list ${ASCEND_RUNTIME_CONFIG_DIR}/base.list cp -f ./base.list ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
fi fi

View File

@@ -194,9 +194,8 @@ static bool CheckWhiteList(const char* fileName)
{"/usr/lib64/libmpi_dvpp_adapter.so"}, {"/usr/lib64/libaicpu_scheduler.so"}, {"/usr/lib64/libmpi_dvpp_adapter.so"}, {"/usr/lib64/libaicpu_scheduler.so"},
{"/usr/lib64/libaicpu_processer.so"}, {"/usr/lib64/libaicpu_prof.so"}, {"/usr/lib64/libaicpu_sharder.so"}, {"/usr/lib64/libaicpu_processer.so"}, {"/usr/lib64/libaicpu_prof.so"}, {"/usr/lib64/libaicpu_sharder.so"},
{"/usr/lib64/libadump.so"}, {"/usr/lib64/libtsd_eventclient.so"}, {"/usr/lib64/libadump.so"}, {"/usr/lib64/libtsd_eventclient.so"},
{"/usr/lib64/aicpu_kernels"}, {"/usr/lib64/libyaml-0.so.2"}, {"/usr/lib64/libcrypto.so.1.1.1m"}, {"/usr/lib64/aicpu_kernels"}, {"/usr/lib64/libyaml-0.so.2"},
{"/usr/lib64/libyaml-0.so.2.0.9"}, {"/usr/lib/aarch64-linux-gnu/libyaml-0.so.2.0.6"}, {"/usr/lib/aarch64-linux-gnu/libyaml-0.so.2"}, {"/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1"}
{"/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1"}
}; };
for (size_t iLoop = 0; iLoop < WHITE_LIST_NUM; iLoop++) { for (size_t iLoop = 0; iLoop < WHITE_LIST_NUM; iLoop++) {

View File

@@ -415,8 +415,8 @@ func main() {
log.Fatal("command error") log.Fatal("command error")
} }
if err := doPrestartHook(); err != nil { if err := doPrestartHook(); err != nil {
hwlog.RunLog.Errorf("ascend docker hook failed") hwlog.RunLog.Errorf("ascend docker hook failed: %#v", err)
hwlog.OpLog.Errorf("%v ascend docker hook failed", logPrefixWords) hwlog.OpLog.Errorf("%v ascend docker hook failed: %#v", logPrefixWords, err)
log.Fatal(fmt.Errorf("failed in runtime.doProcess ")) log.Fatal(fmt.Errorf("failed in runtime.doProcess: %#v", err))
} }
} }

View File

@@ -81,21 +81,24 @@ const (
// Ascend910 ascend 910 chip // Ascend910 ascend 910 chip
Ascend910 = "Ascend910" Ascend910 = "Ascend910"
devicePath = "/dev/" devicePath = "/dev/"
davinciName = "davinci" davinciName = "davinci"
davinciManager = "davinci_manager" virtualDavinciName = "vdavinci"
devmmSvm = "devmm_svm" davinciManager = "davinci_manager"
hisiHdc = "hisi_hdc" davinciManagerDocker = "davinci_manager_docker"
svm0 = "svm0" notRenameDeviceType = ""
tsAisle = "ts_aisle" devmmSvm = "devmm_svm"
upgrade = "upgrade" hisiHdc = "hisi_hdc"
sys = "sys" svm0 = "svm0"
vdec = "vdec" tsAisle = "ts_aisle"
vpc = "vpc" upgrade = "upgrade"
pngd = "pngd" sys = "sys"
venc = "venc" vdec = "vdec"
dvppCmdList = "dvpp_cmdlist" vpc = "vpc"
logDrv = "log_drv" pngd = "pngd"
venc = "venc"
dvppCmdList = "dvpp_cmdlist"
logDrv = "log_drv"
) )
type args struct { type args struct {
@@ -346,20 +349,23 @@ func getValueByKey(data []string, name string) string {
return "" return ""
} }
func addDeviceToSpec(spec *specs.Spec, dPath string, vdevice bool) error { func addDeviceToSpec(spec *specs.Spec, dPath string, deviceType string) error {
device, err := oci.DeviceFromPath(dPath) device, err := oci.DeviceFromPath(dPath)
if err != nil { if err != nil {
return fmt.Errorf("failed to get %s info : %#v", dPath, err) return fmt.Errorf("failed to get %s info : %#v", dPath, err)
} }
if vdevice { switch deviceType {
re := regexp.MustCompile("[0-9]+") case virtualDavinciName:
vDeviceNumber := re.FindAllString(dPath, -1) vDeviceNumber := regexp.MustCompile("[0-9]+").FindAllString(dPath, -1)
if len(vDeviceNumber) != 1 { if len(vDeviceNumber) != 1 {
return fmt.Errorf("error vdevice : %s", dPath) return fmt.Errorf("invalid vdavinci path: %s", dPath)
} }
vPath := devicePath + davinciName + vDeviceNumber[0] device.Path = devicePath + davinciName + vDeviceNumber[0]
device.Path = vPath case davinciManagerDocker:
device.Path = devicePath + davinciManager
default:
// do nothing
} }
spec.Linux.Devices = append(spec.Linux.Devices, *device) spec.Linux.Devices = append(spec.Linux.Devices, *device)
@@ -390,12 +396,20 @@ func addAscend310BManagerDevice(spec *specs.Spec) error {
for _, device := range Ascend310BManageDevices { for _, device := range Ascend310BManageDevices {
dPath := devicePath + device dPath := devicePath + device
if err := addDeviceToSpec(spec, dPath, false); err != nil { if err := addDeviceToSpec(spec, dPath, notRenameDeviceType); err != nil {
hwlog.RunLog.Warnf("failed to add %s to spec : %#v", dPath, err) hwlog.RunLog.Warnf("failed to add %s to spec : %#v", dPath, err)
} }
} }
return nil davinciManagerPath := devicePath + davinciManagerDocker
if _, err := os.Stat(davinciManagerPath); err != nil {
hwlog.RunLog.Warnf("failed to get davinci manager docker, err: %#v", err)
davinciManagerPath = devicePath + davinciManager
if _, err := os.Stat(davinciManagerPath); err != nil {
return fmt.Errorf("failed to get davinci manager, err: %#v", err)
}
}
return addDeviceToSpec(spec, davinciManagerPath, davinciManagerDocker)
} }
func addCommonManagerDevice(spec *specs.Spec) error { func addCommonManagerDevice(spec *specs.Spec) error {
@@ -406,7 +420,7 @@ func addCommonManagerDevice(spec *specs.Spec) error {
for _, device := range commonManagerDevices { for _, device := range commonManagerDevices {
dPath := devicePath + device dPath := devicePath + device
if err := addDeviceToSpec(spec, dPath, false); err != nil { if err := addDeviceToSpec(spec, dPath, notRenameDeviceType); err != nil {
return fmt.Errorf("failed to add common manage device to spec : %#v", err) return fmt.Errorf("failed to add common manage device to spec : %#v", err)
} }
} }
@@ -415,11 +429,6 @@ func addCommonManagerDevice(spec *specs.Spec) error {
} }
func addManagerDevice(spec *specs.Spec) error { func addManagerDevice(spec *specs.Spec) error {
managerPath := devicePath + davinciManager
if err := addDeviceToSpec(spec, managerPath, false); err != nil {
return fmt.Errorf("add davinci_manager to spec error: %#v", err)
}
chipName, err := dcmi.GetChipName() chipName, err := dcmi.GetChipName()
if err != nil { if err != nil {
return fmt.Errorf("get chip name error: %#v", err) return fmt.Errorf("get chip name error: %#v", err)
@@ -427,10 +436,11 @@ func addManagerDevice(spec *specs.Spec) error {
devType := GetDeviceTypeByChipName(chipName) devType := GetDeviceTypeByChipName(chipName)
hwlog.RunLog.Infof("device type is: %s", devType) hwlog.RunLog.Infof("device type is: %s", devType)
if devType == Ascend310B { if devType == Ascend310B {
if err = addAscend310BManagerDevice(spec); err != nil { return addAscend310BManagerDevice(spec)
return fmt.Errorf("add 310B manage device error: %#v", err) }
}
return nil if err := addDeviceToSpec(spec, devicePath+davinciManager, notRenameDeviceType); err != nil {
return fmt.Errorf("add davinci_manager to spec error: %#v", err)
} }
productType, err := dcmi.GetProductType(&dcmi.NpuWorker{}) productType, err := dcmi.GetProductType(&dcmi.NpuWorker{})
@@ -462,16 +472,14 @@ func addDevice(spec *specs.Spec) error {
return fmt.Errorf("failed to parse device : %#v", err) return fmt.Errorf("failed to parse device : %#v", err)
} }
hwlog.RunLog.Infof("devices is: %#v", devices) hwlog.RunLog.Infof("devices is: %#v", devices)
devciename := davinciName deviceName := davinciName
vdevice := false
virtual := getValueByKey(spec.Process.Env, ascendRuntimeOptions) virtual := getValueByKey(spec.Process.Env, ascendRuntimeOptions)
if strings.Contains(virtual, "VIRTUAL") { if strings.Contains(virtual, "VIRTUAL") {
devciename = "v" + devciename deviceName = virtualDavinciName
vdevice = true
} }
for _, deviceId := range devices { for _, deviceId := range devices {
dPath := devicePath + devciename + strconv.Itoa(deviceId) dPath := devicePath + deviceName + strconv.Itoa(deviceId)
if err = addDeviceToSpec(spec, dPath, vdevice); err != nil { if err = addDeviceToSpec(spec, dPath, deviceName); err != nil {
return fmt.Errorf("failed to add davinci device to spec: %v", err) return fmt.Errorf("failed to add davinci device to spec: %v", err)
} }
} }

View File

@@ -397,17 +397,22 @@ func TestAddDeviceToSpec0(t *testing.T) {
}, },
} }
err := addDeviceToSpec(&spec, devPath, false) err := addDeviceToSpec(&spec, devPath, notRenameDeviceType)
assert.Nil(t, err) assert.Nil(t, err)
assert.Contains(t, spec.Linux.Devices[0].Path, devPath) assert.Contains(t, spec.Linux.Devices[0].Path, devPath)
} }
func TestAddAscend310BManagerDevice(t *testing.T) { func TestAddAscend310BManagerDevice(t *testing.T) {
statStub := gomonkey.ApplyFunc(addDeviceToSpec, func(spec *specs.Spec, dPath string, vdevice bool) error { statStub := gomonkey.ApplyFunc(addDeviceToSpec, func(spec *specs.Spec, dPath string, deviceType string) error {
return nil return nil
}) })
defer statStub.Reset() defer statStub.Reset()
pathStub := gomonkey.ApplyFunc(os.Stat, func(name string) (os.FileInfo, error) {
return nil, nil
})
defer pathStub.Reset()
spec := specs.Spec{ spec := specs.Spec{
Linux: &specs.Linux{ Linux: &specs.Linux{
Devices: []specs.LinuxDevice{}, Devices: []specs.LinuxDevice{},
@@ -422,7 +427,7 @@ func TestAddAscend310BManagerDevice(t *testing.T) {
} }
func TestAddCommonManagerDevice(t *testing.T) { func TestAddCommonManagerDevice(t *testing.T) {
statStub := gomonkey.ApplyFunc(addDeviceToSpec, func(spec *specs.Spec, dPath string, vdevice bool) error { statStub := gomonkey.ApplyFunc(addDeviceToSpec, func(spec *specs.Spec, dPath string, deviceType string) error {
return nil return nil
}) })
defer statStub.Reset() defer statStub.Reset()