diff --git a/CMakeLists.txt b/CMakeLists.txt index 20569ffe41f2a771bb8ea1730df76a1504faed14..498876807e1c09d3046bfffb2bf3606d15abce77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required (VERSION 3.12.1) -project (lcrd) +cmake_minimum_required (VERSION 2.8) +project (isulad) include(cmake/helper.cmake) @@ -17,7 +17,7 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) message("-- commit id: " ${GIT_COMMIT_HASH}) -add_definitions(-DLCRD_GIT_COMMIT="${GIT_COMMIT_HASH}") +add_definitions(-DISULAD_GIT_COMMIT="${GIT_COMMIT_HASH}") execute_process( COMMAND sh -c "date --rfc-3339 ns | sed -e 's/ /T/'" @@ -25,13 +25,13 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) message("-- build time: " ${BUILD_DATE}) -add_definitions(-DLCRD_BUILD_TIME="${BUILD_DATE}") +add_definitions(-DISULAD_BUILD_TIME="${BUILD_DATE}") -if (NOT LCRD_ROOT_PATH) -add_definitions(-DLCRD_ROOT_PATH="/var/lib/lcrd") +if (NOT ISULAD_ROOT_PATH) +add_definitions(-DISULAD_ROOT_PATH="/var/lib/isulad") endif() -if (NOT LCRD_STATE_PATH) -add_definitions(-DLCRD_STATE_PATH="/var/run/lcrd") +if (NOT ISULAD_STATE_PATH) +add_definitions(-DISULAD_STATE_PATH="/var/run/isulad") endif() if (LIB_INSTALL_DIR) @@ -52,8 +52,8 @@ configure_file( ) configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/lcrd.pc.in" - "${CMAKE_BINARY_DIR}/conf/lcrd.pc" + "${CMAKE_CURRENT_SOURCE_DIR}/isulad.pc.in" + "${CMAKE_BINARY_DIR}/conf/isulad.pc" ) # parse .proto files @@ -85,20 +85,20 @@ IF(ENABLE_LLT) ENDIF(ENABLE_LLT) # install all files -install(FILES ${CMAKE_BINARY_DIR}/conf/lcrd.pc +install(FILES ${CMAKE_BINARY_DIR}/conf/isulad.pc DESTINATION ${LIB_INSTALL_DIR_DEFAULT}/pkgconfig PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE) -install(FILES src/liblcrc.h - DESTINATION include/lcrd) -install(FILES src/connect/client/lcrc_connect.h - DESTINATION include/lcrd) +install(FILES src/libisula.h + DESTINATION include/isulad) +install(FILES src/connect/client/isula_connect.h + DESTINATION include/isulad) install(FILES src/container_def.h - DESTINATION include/lcrd) + DESTINATION include/isulad) install(FILES src/types_def.h - DESTINATION include/lcrd) + DESTINATION include/isulad) install(FILES src/error.h - DESTINATION include/lcrd) + DESTINATION include/isulad) install(FILES src/engines/engine.h - DESTINATION include/lcrd) + DESTINATION include/isulad) # install config files set(conf_prefix "/etc") @@ -108,12 +108,12 @@ endif() install(FILES src/contrib/config/daemon.json DESTINATION ${conf_prefix}/isulad PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE) install(FILES src/contrib/config/config.json src/contrib/config/systemcontainer_config.json - DESTINATION ${conf_prefix}/default/lcrd PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE) + DESTINATION ${conf_prefix}/default/isulad PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE) install(FILES src/contrib/config/seccomp_default.json DESTINATION ${conf_prefix}/isulad PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE) install(FILES src/contrib/config/hooks/default.json - DESTINATION ${conf_prefix}/default/lcrd/hooks PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE) + DESTINATION ${conf_prefix}/default/isulad/hooks PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE) install(FILES src/contrib/sysmonitor/isulad-check.sh - DESTINATION ${conf_prefix}/default/lcrd PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) + DESTINATION ${conf_prefix}/default/isulad PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) install(FILES src/contrib/sysmonitor/isulad-monit DESTINATION ${conf_prefix}/sysmonitor/process PERMISSIONS OWNER_READ OWNER_WRITE) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..feb476cdd9b4b9f9ca079aed844724a604c1fff6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,262 @@ +####################################################################### +##- @Copyright (C) Huawei Technologies., Ltd. 2019. All rights reserved. +# - lcr licensed under the Mulan PSL v1. +# - You can use this software according to the terms and conditions of the Mulan PSL v1. +# - You may obtain a copy of Mulan PSL v1 at: +# - http://license.coscl.org.cn/MulanPSL +# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# - PURPOSE. +# - See the Mulan PSL v1 for more details. +##- @Description: prepare compile container envrionment +##- @Author: lifeng +##- @Create: 2020-01-10 +####################################################################### +# This file describes the isulad compile container image. +# +# Usage: +# +# docker build --build-arg http_proxy=YOUR_HTTP_PROXY_IF_NEEDED \ +# --build-arg https_proxy=YOUR_HTTPS_PROXY_IF_NEEDED \ +# -t YOUR_IMAGE_NAME -f ./Dockerfile . + + +FROM centos:7.6.1810 +MAINTAINER LiFeng + +# Install dependency package +RUN yum clean all && yum swap -y fakesystemd systemd && \ + yum install -y epel-release \ + yum update -y && \ + yum install -y automake \ + autoconf \ + libtool \ + make \ + cmake \ + which \ + gdb \ + strace \ + rpm-build \ + graphviz \ + libcap \ + libcap-devel \ + libxslt \ + docbook2X \ + libselinux \ + libselinux-devel \ + libseccomp \ + libseccomp-devel \ + yajl-devel \ + git \ + bridge-utils \ + dnsmasq \ + libcgroup \ + rsync \ + iptables \ + iproute \ + net-tools \ + unzip \ + tar \ + wget \ + gtest \ + gtest-devel \ + gmock \ + gmock-devel \ + cppcheck \ + python \ + python-pip \ + libcurl-devel \ + zlib-devel \ + glibc-headers \ + openssl-devel \ + gcc \ + gcc-c++ \ + hostname \ + sqlite-devel \ + gpgme \ + gpgme-devel \ + expect \ + systemd-devel \ + systemd-libs \ + go \ + CUnit \ + CUnit-devel \ + valgrind \ + e2fsprogs + +RUN pip install xlrd + +RUN yum clean all && \ + (cd /lib/systemd/system/sysinit.target.wants/; for i in *; \ + do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ + rm -f /lib/systemd/system/multi-user.target.wants/*;\ + rm -f /etc/systemd/system/*.wants/*;\ + rm -f /lib/systemd/system/local-fs.target.wants/*; \ + rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ + rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ + rm -f /lib/systemd/system/basic.target.wants/*;\ + rm -f /lib/systemd/system/anaconda.target.wants/*; + +RUN echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> /etc/bashrc && \ + echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH" >> /etc/bashrc && \ + echo "/usr/lib" >> /etc/ld.so.conf && \ + echo "/usr/local/lib" >> /etc/ld.so.conf + + +# disalbe sslverify +RUN git config --global http.sslverify false + +# Centos has no protobuf, protobuf-devel, grpc, grpc-devel, grpc-plugin +# and we should install them manually. +# install protobuf +RUN set -x && \ + cd ~ && \ + git clone https://gitee.com/src-openeuler/protobuf.git && \ + cd protobuf && \ + tar -xzvf protobuf-all-3.9.0.tar.gz && \ + cd protobuf-3.9.0 && \ + ./autogen.sh && \ + ./configure && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +# install c-ares +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/src-openeuler/c-ares.git && \ + cd c-ares && \ + tar -xzvf c-ares-1.15.0.tar.gz && \ + cd c-ares-1.15.0 && \ + autoreconf -if && \ + ./configure --enable-shared --disable-dependency-tracking && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +# install grpc +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/src-openeuler/grpc.git && \ + cd grpc && \ + tar -xzvf grpc-1.22.0.tar.gz && \ + cd grpc-1.22.0 && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +# install libevent +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/src-openeuler/libevent.git && \ + cd libevent && \ + tar -xzvf libevent-2.1.11-stable.tar.gz && \ + cd libevent-2.1.11-stable && \ + ./autogen.sh && \ + ./configure && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +# install libevhtp +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/src-openeuler/libevhtp.git && \ + cd libevhtp && \ + tar -xzvf libevhtp-1.2.16.tar.gz && \ + cd libevhtp-1.2.16 && \ + patch -p1 -F1 -s < ../0001-support-dynamic-threads.patch && \ + patch -p1 -F1 -s < ../0002-close-openssl.patch && \ + rm -rf build && \ + mkdir build && \ + cd build && \ + cmake -D EVHTP_BUILD_SHARED=on -D EVHTP_DISABLE_SSL=on ../ && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +# install http-parser +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/src-openeuler/http-parser.git && \ + cd http-parser && \ + tar -xzvf http-parser-2.9.2.tar.gz && \ + cd http-parser-2.9.2 && \ + make -j CFLAGS="-Wno-error" && \ + make CFLAGS="-Wno-error" install && \ + ldconfig + +# install libwebsockets +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/src-openeuler/libwebsockets.git && \ + cd libwebsockets && \ + tar -xzvf libwebsockets-2.4.2.tar.gz && \ + cd libwebsockets-2.4.2 && \ + patch -p1 -F1 -s < ../libwebsockets-fix-coredump.patch && \ + mkdir build && \ + cd build && \ + cmake -DLWS_WITH_SSL=0 -DLWS_MAX_SMP=32 -DCMAKE_BUILD_TYPE=Debug ../ && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +# install lxc +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/src-openeuler/lxc.git && \ + cd lxc && \ + ./apply-patches && \ + cd lxc-3.0.3 && \ + ./autogen.sh && \ + ./configure && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +# install lcr +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/openeuler/lcr.git && \ + cd lcr && \ + mkdir build && \ + cd build && \ + cmake ../ && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +# install clibcni +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/openeuler/clibcni.git && \ + cd clibcni && \ + mkdir build && \ + cd build && \ + cmake ../ && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +# install iSulad-kit +RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \ + set -x && \ + cd ~ && \ + git clone https://gitee.com/openeuler/iSulad-kit.git && \ + cd iSulad-kit && \ + ./apply-patch && \ + make -j $(nproc) && \ + make install && \ + ldconfig + +VOLUME [ "/sys/fs/cgroup" ] +CMD ["/usr/sbin/init"] diff --git a/README.md b/README.md index 21f1f276775d85a20211b269aed67dde06ba3049..747289edd5735905514043584107504e329fe698 100644 --- a/README.md +++ b/README.md @@ -17,43 +17,43 @@ yum install -y iSulad ### Run We provide `systemd` service to start `iSulad` ```sh -systemd start lcrd # run the server with systemd command +systemd start isulad # run the server with systemd command ``` You can use direct command to start `iSulad` server: ```sh -$ sudo lcrd # run the server with default socket name and default log level and images manage function +$ sudo isulad # run the server with default socket name and default log level and images manage function ``` ### Operations on containers: -`iSulad` provides command line `lcrd` to talk with server. +`iSulad` provides command line `isulad` to talk with server. Here are some sample commands to manager containers. List all containers in your own environment: ```sh # list containers -$ sudo lcrc ps -a +$ sudo isula ps -a ``` Create a container with busybox named `test` ```sh -# create a container 'test' with image busybox -$ sudo lcrc create -t -n test busybox +# create a container 'test' with image busybox +$ sudo isula create -t -n test busybox ``` Start this container `test` ```sh -# start the container 'test' -$ sudo lcrc start test +# start the container 'test' +$ sudo isula start test ``` Kill the container `test` ```sh -# kill the container 'test' -$ sudo lcrc kill test +# kill the container 'test' +$ sudo isula kill test ``` Remove the container `test` ```sh -# remove the container 'test' -$ sudo lcrc rm test +# remove the container 'test' +$ sudo isula rm test ``` ### Build from source diff --git a/cmake/options.cmake b/cmake/options.cmake index 2004addf59d913294335f619a18f924410eeb159..1bb7534dffd66fa0f1b834d0532b80507667b7d0 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -26,22 +26,22 @@ if (ENABLE_OPENSSL_VERIFY STREQUAL "ON") set(OPENSSL_VERIFY 1) endif() -option(PACKAGE "set lcrd package" ON) +option(PACKAGE "set isulad package" ON) if (PACKAGE STREQUAL "ON") - set(LCRD_PACKAGE "iSulad") + set(ISULAD_PACKAGE "iSulad") endif() -option(VERSION "set lcrd version" ON) +option(VERSION "set isulad version" ON) if (VERSION STREQUAL "ON") - set(LCRD_VERSION "1.1.5") + set(ISULAD_VERSION "1.1.9") endif() -option(DEBUG "set lcrd gcc option" ON) +option(DEBUG "set isulad gcc option" ON) if (DEBUG STREQUAL "ON") add_definitions("-g -O2") endif() -option(GCOV "set lcrd gcov option" OFF) +option(GCOV "set isulad gcov option" OFF) if (GCOV STREQUAL "ON") set(ISULAD_GCOV "ON") endif() diff --git a/cmake/set_build_flags.cmake b/cmake/set_build_flags.cmake index fbe587ce35c2631824b26ce28fbcb8afb7500b83..b36920d0c681e0903e6674be29689ebbaddfde80 100644 --- a/cmake/set_build_flags.cmake +++ b/cmake/set_build_flags.cmake @@ -1,7 +1,10 @@ # set common FLAGS set(CMAKE_C_FLAGS "-fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror -rdynamic") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") + if (GRPC_CONNECTOR OR ENABLE_OCI_IMAGE) set(CMAKE_CXX_FLAGS "-fPIC -std=c++11 -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") endif() set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines -fPIE -pie -shared -pthread") set(CMAKE_EXE_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines -fPIE -pie") diff --git a/config.h.in b/config.h.in index 8ba17ed3e0705a11d72a63e6494046644e12275b..6a9567708267e5fd1686c6ede21709e81cd4d67e 100644 --- a/config.h.in +++ b/config.h.in @@ -1 +1 @@ -#cmakedefine VERSION "@LCRD_VERSION@" +#cmakedefine VERSION "@ISULAD_VERSION@" diff --git a/docs/build_guide.md b/docs/build_guide.md index cb4f3803de107240e365980c77f56f02f19bef07..07fbe3c47679df3cfae3888a4337ee952bf38080 100644 --- a/docs/build_guide.md +++ b/docs/build_guide.md @@ -1,12 +1,18 @@ -## Install Dependencies +# Build iSulad from source + +If you intend to contribute on iSulad. Thanks for your effort. Every contribution is very appreciated for us. + +## Build iSulad based on openEuler distribution + +If you use the openEuler distribution, you can easily install various dependent packages via yum. + +### Install Dependencies ```sh $ sudo yum install -y cmake gcc-c++ systemd-devel yajl-devel libcurl libcurl-devel clibcni clibcni-devel protobuf-devel grpc-devel grpc-plugins http-parser-devel libwebsockets-devel libevhtp-devel libevent-devel lcr lxc-devel ``` - - -## Build steps: +### Build steps: Run the cmds under the iSulad source directory ```sh @@ -17,3 +23,52 @@ $ sudo make $ sudo make install ``` +## Via Docker container + +#### Build image + +You can build `iSulad` via a Linux-based Docker container. You can build an image from the`Dockerfile` in the source directory. From the iSulad source root directory you can run the following command to make your image. + +```sh +$ sudo docker build --build-arg http_proxy=YOUR_HTTP_PROXY_IF_NEED + --build-arg https_proxy=YOUR_HTTPS_PROXY_IF_NEED \ + -t YOUR_IMAGE_NAME -f ./Dockerfile . +``` + +#### Prepare root directory for the iSulad + +Let's prepare a root directory on host, and we will mount this directory into the container. This directory be used by `iSulad` in container. + +```sh +$ sudo mkdir -p /var/lib/isulad +``` + +#### Build iSulad in container + +Let's suppose that you built an image called `iSulad:dev`. + +Then from the iSulad source root directory you can run the following command: + +```sh +$ sudo docker run -tid --name YOUR_CONTAINER_NAME -v /var/lib/isulad:/var/lib/isulad -v `pwd`:/src/isulad --privileged iSulad:dev +``` + +Let's suppose that you run an container named `iSulad_build`. Then you can use the following commands to build iSulad in your container `iSulad_build`: + +```bash +// enter the container +$ sudo docker exec -it iSulad_build bash +// Now you enter the container, so build iSulad in the container by following commands +# cd /src/isulad +# mkdir build +# cd build +# cmake .. +# make +# make install +``` + +Now You can use direct command to start `iSulad` server in the container: + +```sh +$ sudo isulad # run the server with default socket name and default log level and images manage function +``` diff --git a/iSulad.spec b/iSulad.spec index 23ce7b5f77f0a86713839fb8b54b8adba4dd99ce..73cdc7f718089dbeb1fa706f4ad15f7fee761d46 100644 --- a/iSulad.spec +++ b/iSulad.spec @@ -1,5 +1,5 @@ -%global _version 1.1.5 -%global _release 20200106.022952.git939935db +%global _version 1.1.9 +%global _release 20200120.104710.gitdf7191f2 %global is_systemd 1 %global debug_package %{nil} @@ -8,14 +8,14 @@ Version: %{_version} Release: %{_release} Summary: Lightweight Container Runtime Daemon License: Mulan PSL v1 -URL: lcrd +URL: isulad Source: iSulad-1.0.tar.gz BuildRoot: {_tmppath}/iSulad-%{version} ExclusiveArch: x86_64 aarch64 %ifarch x86_64 aarch64 Provides: libhttpclient.so()(64bit) -Provides: liblcrc.so()(64bit) +Provides: libisula.so()(64bit) %endif %if 0%{?is_systemd} @@ -60,120 +60,139 @@ cd build rm -rf %{buildroot} cd build install -d $RPM_BUILD_ROOT/%{_libdir} -install -m 0644 ./src/liblcrc.so %{buildroot}/%{_libdir}/liblcrc.so +install -m 0644 ./src/libisula.so %{buildroot}/%{_libdir}/libisula.so install -m 0644 ./src/http/libhttpclient.so %{buildroot}/%{_libdir}/libhttpclient.so install -d $RPM_BUILD_ROOT/%{_libdir}/pkgconfig -install -m 0640 ./conf/lcrd.pc %{buildroot}/%{_libdir}/pkgconfig/lcrd.pc +install -m 0640 ./conf/isulad.pc %{buildroot}/%{_libdir}/pkgconfig/isulad.pc install -d $RPM_BUILD_ROOT/%{_bindir} -install -m 0755 ./src/lcrc %{buildroot}/%{_bindir}/lcrc -install -m 0755 ./src/lcrd %{buildroot}/%{_bindir}/lcrd +install -m 0755 ./src/isula %{buildroot}/%{_bindir}/isula +install -m 0755 ./src/isulad %{buildroot}/%{_bindir}/isulad -install -d $RPM_BUILD_ROOT/%{_includedir}/lcrd -install -m 0644 ../src/liblcrc.h %{buildroot}/%{_includedir}/lcrd/liblcrc.h -install -m 0644 ../src/connect/client/lcrc_connect.h %{buildroot}/%{_includedir}/lcrd/lcrc_connect.h -install -m 0644 ../src/container_def.h %{buildroot}/%{_includedir}/lcrd/container_def.h -install -m 0644 ../src/types_def.h %{buildroot}/%{_includedir}/lcrd/types_def.h -install -m 0644 ../src/error.h %{buildroot}/%{_includedir}/lcrd/error.h -install -m 0644 ../src/engines/engine.h %{buildroot}/%{_includedir}/lcrd/engine.h +install -d $RPM_BUILD_ROOT/%{_includedir}/isulad +install -m 0644 ../src/libisula.h %{buildroot}/%{_includedir}/isulad/libisula.h +install -m 0644 ../src/connect/client/isula_connect.h %{buildroot}/%{_includedir}/isulad/isula_connect.h +install -m 0644 ../src/container_def.h %{buildroot}/%{_includedir}/isulad/container_def.h +install -m 0644 ../src/types_def.h %{buildroot}/%{_includedir}/isulad/types_def.h +install -m 0644 ../src/error.h %{buildroot}/%{_includedir}/isulad/error.h +install -m 0644 ../src/engines/engine.h %{buildroot}/%{_includedir}/isulad/engine.h install -d $RPM_BUILD_ROOT/%{_sysconfdir}/isulad install -m 0640 ../src/contrib/config/daemon.json %{buildroot}/%{_sysconfdir}/isulad/daemon.json install -m 0640 ../src/contrib/config/seccomp_default.json %{buildroot}/%{_sysconfdir}/isulad/seccomp_default.json -install -d $RPM_BUILD_ROOT/%{_sysconfdir}/default/lcrd -install -m 0640 ../src/contrib/config/config.json %{buildroot}/%{_sysconfdir}/default/lcrd/config.json -install -m 0640 ../src/contrib/config/systemcontainer_config.json %{buildroot}/%{_sysconfdir}/default/lcrd/systemcontainer_config.json -install -m 0550 ../src/contrib/sysmonitor/isulad-check.sh %{buildroot}/%{_sysconfdir}/default/lcrd/isulad-check.sh +install -d $RPM_BUILD_ROOT/%{_sysconfdir}/default/isulad +install -m 0640 ../src/contrib/config/config.json %{buildroot}/%{_sysconfdir}/default/isulad/config.json +install -m 0640 ../src/contrib/config/systemcontainer_config.json %{buildroot}/%{_sysconfdir}/default/isulad/systemcontainer_config.json +install -m 0550 ../src/contrib/sysmonitor/isulad-check.sh %{buildroot}/%{_sysconfdir}/default/isulad/isulad-check.sh mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysmonitor/process cp ../src/contrib/sysmonitor/isulad-monit $RPM_BUILD_ROOT/etc/sysmonitor/process -install -d $RPM_BUILD_ROOT/%{_sysconfdir}/default/lcrd/hooks -install -m 0640 ../src/contrib/config/hooks/default.json %{buildroot}/%{_sysconfdir}/default/lcrd/hooks/default.json +install -d $RPM_BUILD_ROOT/%{_sysconfdir}/default/isulad/hooks +install -m 0640 ../src/contrib/config/hooks/default.json %{buildroot}/%{_sysconfdir}/default/isulad/hooks/default.json install -d $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig install -p -m 0640 ../src/contrib/config/iSulad.sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/iSulad %if 0%{?is_systemd} install -d $RPM_BUILD_ROOT/%{_unitdir} -install -p -m 0640 ../src/contrib/init/lcrd.service $RPM_BUILD_ROOT/%{_unitdir}/lcrd.service +install -p -m 0640 ../src/contrib/init/isulad.service $RPM_BUILD_ROOT/%{_unitdir}/isulad.service %else install -d $RPM_BUILD_ROOT/%{_initddir} -install -p -m 0640 ../src/contrib/init/lcrd.init $RPM_BUILD_ROOT/%{_initddir}/lcrd.init +install -p -m 0640 ../src/contrib/init/isulad.init $RPM_BUILD_ROOT/%{_initddir}/isulad.init %endif %clean rm -rf %{buildroot} +%pre +# support update from lcrd to isulad, will remove in next version +%if 0%{?is_systemd} +systemctl stop lcrd +systemctl disable lcrd +if [ -e %{_sysconfdir}/isulad/daemon.json ];then + sed -i 's#/etc/default/lcrd/hooks#/etc/default/isulad/hooks#g' %{_sysconfdir}/isulad/daemon.json +fi +%else +/sbin/chkconfig --del lcrd +%endif + %post -if ! getent group lcrd > /dev/null; then - groupadd --system lcrd +if ! getent group isulad > /dev/null; then + groupadd --system isulad fi if [ "$1" = "1" ]; then %if 0%{?is_systemd} -systemctl enable lcrd -systemctl start lcrd +systemctl enable isulad +systemctl start isulad %else -/sbin/chkconfig --add lcrd +/sbin/chkconfig --add isulad %endif elif [ "$1" = "2" ]; then %if 0%{?is_systemd} -systemctl status lcrd | grep 'Active:' | grep 'running' +# support update from lcrd to isulad, will remove in next version +if [ -e %{_unitdir}/lcrd.service.rpmsave ]; then + mv %{_unitdir}/lcrd.service.rpmsave %{_unitdir}/isulad.service + sed -i 's/lcrd/isulad/g' %{_unitdir}/isulad.service +fi +systemctl status isulad | grep 'Active:' | grep 'running' if [ $? -eq 0 ]; then - systemctl restart lcrd + systemctl restart isulad +else + systemctl start isulad fi %else -/sbin/service lcrd status | grep 'Active:' | grep 'running' +/sbin/service isulad status | grep 'Active:' | grep 'running' if [ $? -eq 0 ]; then - /sbin/service lcrd restart + /sbin/service isulad restart fi %endif fi -if ! getent group lcrd > /dev/null; then - groupadd --system lcrd +if ! getent group isulad > /dev/null; then + groupadd --system isulad fi %preun %if 0%{?is_systemd} -%systemd_preun lcrd +%systemd_preun isulad %else if [ $1 -eq 0 ] ; then - /sbin/service lcrd stop >/dev/null 2>&1 - /sbin/chkconfig --del lcrd + /sbin/service isulad stop >/dev/null 2>&1 + /sbin/chkconfig --del isulad fi %endif %postun %if 0%{?is_systemd} -%systemd_postun_with_restart lcrd +%systemd_postun_with_restart isulad %else if [ "$1" -ge "1" ] ; then - /sbin/service lcrd condrestart >/dev/null 2>&1 || : + /sbin/service isulad condrestart >/dev/null 2>&1 || : fi %endif %files %attr(0600,root,root) %{_sysconfdir}/sysmonitor/process/isulad-monit -%attr(0550,root,root) %{_sysconfdir}/default/lcrd/isulad-check.sh +%attr(0550,root,root) %{_sysconfdir}/default/isulad/isulad-check.sh %defattr(0640,root,root,0750) %{_sysconfdir}/isulad %{_sysconfdir}/isulad/* %{_sysconfdir}/default/* %defattr(-,root,root,-) %if 0%{?is_systemd} -%{_unitdir}/lcrd.service -%attr(0640,root,root) %{_unitdir}/lcrd.service +%{_unitdir}/isulad.service +%attr(0640,root,root) %{_unitdir}/isulad.service %else -%{_initddir}/lcrd.init -%attr(0640,root,root) %{_initddir}/lcrd.init +%{_initddir}/isulad.init +%attr(0640,root,root) %{_initddir}/isulad.init %endif -%{_includedir}/lcrd/* +%{_includedir}/isulad/* %attr(0755,root,root) %{_libdir}/pkgconfig -%attr(0640,root,root) %{_libdir}/pkgconfig/lcrd.pc +%attr(0640,root,root) %{_libdir}/pkgconfig/isulad.pc %defattr(0550,root,root,0750) %{_bindir}/* %{_libdir}/* @@ -183,7 +202,7 @@ fi %config(noreplace,missingok) %{_sysconfdir}/sysconfig/iSulad %config(noreplace,missingok) %{_sysconfdir}/isulad/daemon.json %if 0%{?is_systemd} -%config(noreplace,missingok) %{_unitdir}/lcrd.service +%config(noreplace,missingok) %{_unitdir}/isulad.service %else -%config(noreplace,missingok) %{_initddir}/lcrd.init +%config(noreplace,missingok) %{_initddir}/isulad.init %endif diff --git a/lcrd.pc.in b/isulad.pc.in similarity index 75% rename from lcrd.pc.in rename to isulad.pc.in index 9973208a6b0e69b3b7df90f071c124b6de68453d..695ba3644f577b17b03bd60c616a4118549d1d3b 100644 --- a/lcrd.pc.in +++ b/isulad.pc.in @@ -3,10 +3,10 @@ libdir=@CMAKE_INSTALL_PREFIX@/lib localstatedir=@CMAKE_INSTALL_PREFIX@/var includedir=@CMAKE_INSTALL_PREFIX@/include -Name: liblcrc +Name: libisula Description: light-weighted container runtime daemon library -Version: @LCRD_VERSION@ +Version: @ISULAD_VERSION@ URL: iSulad -Libs: -L@CMAKE_INSTALL_PREFIX@/lib -llcrc +Libs: -L@CMAKE_INSTALL_PREFIX@/lib -lisula Cflags: -I@CMAKE_INSTALL_PREFIX@/include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 87d7ed640de2efc7c35dc7ddfc381126a27aa3c8..b0222d59982d55db3cdf3883cd2a530bd65b5422 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,47 +103,47 @@ list(REMOVE_DUPLICATES SHARED_SRCS) add_subdirectory(http) -# ------ build liblcrc ------ +# ------ build libisula ------ if (OPENSSL_VERIFY) list(APPEND CONNECTOR ${CMAKE_CURRENT_SOURCE_DIR}/http/certificate.c) endif() -add_library(liblcrc ${LIBTYPE} - ${CMAKE_CURRENT_SOURCE_DIR}/liblcrc.c +add_library(libisula ${LIBTYPE} + ${CMAKE_CURRENT_SOURCE_DIR}/libisula.c ${CMAKE_CURRENT_SOURCE_DIR}/pack_config.c ${CONNECTOR} ${SHARED_SRCS} ) -target_include_directories(liblcrc PUBLIC +target_include_directories(libisula PUBLIC ${SHARED_INCS} ${CONNECTOR_INCS} ${CMAKE_CURRENT_SOURCE_DIR}/http ) -# set liblcrc FLAGS -set_target_properties(liblcrc PROPERTIES PREFIX "") -target_link_libraries(liblcrc ${LIBYAJL_LIBRARY} ${LIBSECUREC_LIBRARY}) +# set libisula FLAGS +set_target_properties(libisula PROPERTIES PREFIX "") +target_link_libraries(libisula ${LIBYAJL_LIBRARY} ${LIBSECUREC_LIBRARY}) if (GRPC_CONNECTOR) - target_link_libraries(liblcrc -Wl,--as-needed -lstdc++ -lcrypto) - target_link_libraries(liblcrc -Wl,--as-needed ${PROTOBUF_LIBRARY}) - target_link_libraries(liblcrc -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY}) + target_link_libraries(libisula -Wl,--as-needed -lstdc++ -lcrypto) + target_link_libraries(libisula -Wl,--as-needed ${PROTOBUF_LIBRARY}) + target_link_libraries(libisula -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY}) else() - target_link_libraries(liblcrc ${EVHTP_LIBRARY} ${EVENT_LIBRARY} ${ZLIB_LIBRARY} -ldl libhttpclient) + target_link_libraries(libisula ${EVHTP_LIBRARY} ${EVENT_LIBRARY} ${ZLIB_LIBRARY} -ldl libhttpclient) endif() -# ------ build liblcrc finish ----- +# ------ build libisula finish ----- add_subdirectory(cmd) -# ------ build lcrc ------- -add_executable(lcrc - ${LCRC_SRCS} +# ------ build isula ------- +add_executable(isula + ${ISULA_SRCS} ) -target_include_directories(lcrc PUBLIC ${LCRC_INCS} ${SHARED_INCS}) -target_link_libraries(lcrc liblcrc -lpthread) -# ------ build lcrc finish ------- +target_include_directories(isula PUBLIC ${ISULA_INCS} ${SHARED_INCS}) +target_link_libraries(isula libisula -lpthread) +# ------ build isula finish ------- -# ------ build lcrd ------- +# ------ build isulad ------- add_subdirectory(services) add_subdirectory(image) add_subdirectory(runtime) @@ -170,9 +170,9 @@ add_subdirectory(plugin) add_subdirectory(map) add_subdirectory(config) -add_executable(lcrd +add_executable(isulad ${CONNECT_SOCKET} ${SHARED_SRCS} - ${LCRD_SRCS} ${SERVICES_SRCS} + ${ISULAD_SRCS} ${SERVICES_SRCS} ${HTTP_SRCS} ${ENGINES_SRCS} ${IMAGE_SRCS} @@ -181,19 +181,19 @@ add_executable(lcrd ${MAP_SRCS} ${CONFIG_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/filters.c ${CMAKE_CURRENT_SOURCE_DIR}/namespace.c - ${CMAKE_CURRENT_SOURCE_DIR}/liblcrd.c + ${CMAKE_CURRENT_SOURCE_DIR}/libisulad.c ${CMAKE_CURRENT_SOURCE_DIR}/sysctl_tools.c ${WEBSOCKET_SERVICE_SRCS} ) -target_include_directories(lcrd PUBLIC +target_include_directories(isulad PUBLIC ${SHARED_INCS} ${CONNECT_SOCKET_INCS} ${SERVICES_INCS} ${IMAGE_INCS} ${RUNTIME_INCS} ${ENGINES_INCS} - ${LCRD_INCS} + ${ISULAD_INCS} ${CMAKE_CURRENT_SOURCE_DIR}/plugin ${CMAKE_CURRENT_SOURCE_DIR}/map ${CMAKE_CURRENT_SOURCE_DIR}/config @@ -201,41 +201,41 @@ target_include_directories(lcrd PUBLIC ${WEBSOCKET_SERVICE_INCS} ) -target_link_libraries(lcrd ${LIBYAJL_LIBRARY} ${LIBSECUREC_LIBRARY} ${SYSTEMD_LIBRARY}) -target_link_libraries(lcrd -ldl ${ZLIB_LIBRARY} -lpthread libhttpclient) +target_link_libraries(isulad ${LIBYAJL_LIBRARY} ${LIBSECUREC_LIBRARY} ${SYSTEMD_LIBRARY}) +target_link_libraries(isulad -ldl ${ZLIB_LIBRARY} -lpthread libhttpclient) if (ENABLE_EMBEDDED_IMAGE) - target_link_libraries(lcrd ${SQLITE3_LIBRARY}) + target_link_libraries(isulad ${SQLITE3_LIBRARY}) endif() if (GRPC_CONNECTOR) message("GRPC iSulad") - target_link_libraries(lcrd -Wl,--as-needed -lstdc++ -lcrypto) - target_link_libraries(lcrd -Wl,--as-needed ${PROTOBUF_LIBRARY}) - target_link_libraries(lcrd -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY}) - target_link_libraries(lcrd ${CLIBCNI_LIBRARY} ${WEBSOCKET_LIBRARY}) + target_link_libraries(isulad -Wl,--as-needed -lstdc++ -lcrypto) + target_link_libraries(isulad -Wl,--as-needed ${PROTOBUF_LIBRARY}) + target_link_libraries(isulad -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY}) + target_link_libraries(isulad ${CLIBCNI_LIBRARY} ${WEBSOCKET_LIBRARY}) else() message("Restful iSulad") - target_link_libraries(lcrd ${EVHTP_LIBRARY} ${EVENT_LIBRARY}) + target_link_libraries(isulad ${EVHTP_LIBRARY} ${EVENT_LIBRARY}) endif() if (ENABLE_OCI_IMAGE) - target_link_libraries(lcrd -Wl,--as-needed -lstdc++) - target_link_libraries(lcrd -Wl,--as-needed ${PROTOBUF_LIBRARY}) - target_link_libraries(lcrd -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY}) + target_link_libraries(isulad -Wl,--as-needed -lstdc++) + target_link_libraries(isulad -Wl,--as-needed ${PROTOBUF_LIBRARY}) + target_link_libraries(isulad -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY}) endif() if (ISULAD_GCOV) - target_link_libraries(lcrc -lgcov) - target_link_libraries(liblcrc -lgcov) - target_link_libraries(lcrd -lgcov) + target_link_libraries(isula -lgcov) + target_link_libraries(libisula -lgcov) + target_link_libraries(isulad -lgcov) endif() -# ------ build lcrd finish ------- +# ------ build isulad finish ------- # ------ install binary -------- -install(TARGETS liblcrc +install(TARGETS libisula LIBRARY DESTINATION ${LIB_INSTALL_DIR_DEFAULT} PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) -install(TARGETS lcrc +install(TARGETS isula RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) -install(TARGETS lcrd +install(TARGETS isulad RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) diff --git a/src/api/image_client/isula_image.proto b/src/api/image_client/isula_image.proto index df84870eb88f92f8a401ee4ebc753d471c336dd0..41a7f7d3ef4bc73c0c5e52670dadd2c5ee454d19 100644 --- a/src/api/image_client/isula_image.proto +++ b/src/api/image_client/isula_image.proto @@ -1,5 +1,5 @@ // ####################################################################### -// ##- @Copyright (C) Huawei Technologies., Ltd. 2019. All rights reserved. +// ##- @Copyright (C) Huawei Technologies., Ltd. 2019-2020. All rights reserved. // # - iSulad licensed under the Mulan PSL v1. // # - You can use this software according to the terms and conditions of the Mulan PSL v1. // # - You may obtain a copy of Mulan PSL v1 at: @@ -10,8 +10,28 @@ // # - See the Mulan PSL v1 for more details. // ##- @Description: generate grpc // ##- @Author: wujing -// ##- @Create: 2019-04-25 +// ##- @Create: 2020-01-26 // ####################################################################### + +/* +Since some of this code is derived from Kubernetes, their copyright +is retained here.... + +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + // To regenerate api.pb.go run hack/update-generated-runtime.sh syntax = 'proto3'; diff --git a/src/api/services/health/health.proto b/src/api/services/health/health.proto index aeebc729df48171ee4b605ae51d6d1cac02d128b..84cf3579f61fc6ffc61c7045937e128a601fd819 100644 --- a/src/api/services/health/health.proto +++ b/src/api/services/health/health.proto @@ -1,5 +1,5 @@ // ####################################################################### -// ##- @Copyright (C) Huawei Technologies., Ltd. 2019. All rights reserved. +// ##- @Copyright (C) Huawei Technologies., Ltd. 2019-2020. All rights reserved. // # - iSulad licensed under the Mulan PSL v1. // # - You can use this software according to the terms and conditions of the Mulan PSL v1. // # - You may obtain a copy of Mulan PSL v1 at: @@ -9,9 +9,30 @@ // # - PURPOSE. // # - See the Mulan PSL v1 for more details. // ##- @Description: generate grpc -// ##- @Author: wujing -// ##- @Create: 2019-04-25 +// ##- @Author: tanyifeng +// ##- @Create: 2020-01-16 // ####################################################################### +// +// Since some of this code is derived from grpc, their copyright +// is retained here.... +// +// Copyright 2015 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto + syntax = "proto3"; option optimize_for = CODE_SIZE; diff --git a/src/api/services/images/images.proto b/src/api/services/images/images.proto index 9863688018e737c77b3dee8d74e396b9ad1a1d41..3d86722f9a84ce7b41ed061670747e5f5ef16e20 100644 --- a/src/api/services/images/images.proto +++ b/src/api/services/images/images.proto @@ -1,5 +1,5 @@ // ####################################################################### -// ##- @Copyright (C) Huawei Technologies., Ltd. 2019. All rights reserved. +// ##- @Copyright (C) Huawei Technologies., Ltd. 2019-2020. All rights reserved. // # - iSulad licensed under the Mulan PSL v1. // # - You can use this software according to the terms and conditions of the Mulan PSL v1. // # - You may obtain a copy of Mulan PSL v1 at: @@ -10,8 +10,29 @@ // # - See the Mulan PSL v1 for more details. // ##- @Description: generate grpc // ##- @Author: wujing -// ##- @Create: 2019-04-25 +// ##- @Create: 2020-01-16 // ####################################################################### + + +/* +Since some of this code is derived from containerd, their copyright +is retained here.... + +Copyright 2013-2016 Docker, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + syntax = "proto3"; option optimize_for = CODE_SIZE; diff --git a/src/api/types/descriptor.proto b/src/api/types/descriptor.proto index 089ab6b4ba7f49e79b9bea2fe7501e49bbfa7c80..5323f0091d39dd6847b9e8d43d84676c2a0cc17d 100644 --- a/src/api/types/descriptor.proto +++ b/src/api/types/descriptor.proto @@ -1,5 +1,5 @@ // ####################################################################### -// ##- @Copyright (C) Huawei Technologies., Ltd. 2019. All rights reserved. +// ##- @Copyright (C) Huawei Technologies., Ltd. 2019-2020. All rights reserved. // # - iSulad licensed under the Mulan PSL v1. // # - You can use this software according to the terms and conditions of the Mulan PSL v1. // # - You may obtain a copy of Mulan PSL v1 at: @@ -10,8 +10,28 @@ // # - See the Mulan PSL v1 for more details. // ##- @Description: generate grpc // ##- @Author: wujing -// ##- @Create: 2019-04-25 +// ##- @Create: 2019-01-16 // ####################################################################### + +/* +Since some of this code is derived from containerd, their copyright +is retained here.... + +Copyright 2013-2016 Docker, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + syntax = "proto3"; option optimize_for = CODE_SIZE; diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 1c8438a7902f911546f33ccaa877900089f541b5..8c18272df51ef93c1f042f74129f43ca96fb4115 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -1,10 +1,10 @@ # get current directory sources files aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} comm_srcs) -add_subdirectory(lcrc) -set(LCRC_SRCS ${comm_srcs} ${CMD_LCRC_SRCS} PARENT_SCOPE) -set(LCRC_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${CMD_LCRC_INCS} PARENT_SCOPE) +add_subdirectory(isula) +set(ISULA_SRCS ${comm_srcs} ${CMD_ISULA_SRCS} PARENT_SCOPE) +set(ISULA_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${CMD_ISULA_INCS} PARENT_SCOPE) -add_subdirectory(lcrd) -set(LCRD_SRCS ${comm_srcs} ${CMD_LCRD_SRCS} PARENT_SCOPE) -set(LCRD_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${CMD_LCRD_INCS} PARENT_SCOPE) +add_subdirectory(isulad) +set(ISULAD_SRCS ${comm_srcs} ${CMD_ISULAD_SRCS} PARENT_SCOPE) +set(ISULAD_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${CMD_ISULAD_INCS} PARENT_SCOPE) diff --git a/src/cmd/commander.c b/src/cmd/commander.c index 84acbd6f70540af3847923cc76154f22b98c0c65..a133956c72dc0a8d2d77de15577d026f6b395cfb 100644 --- a/src/cmd/commander.c +++ b/src/cmd/commander.c @@ -21,14 +21,14 @@ #include #include #include -#include "liblcrd.h" +#include "libisulad.h" #include "utils.h" #include "log.h" -void command_help_lcrd_head() +void command_help_isulad_head() { - fprintf(stdout, "lcrd\n\nlightweight container runtime daemon\n"); + fprintf(stdout, "isulad\n\nlightweight container runtime daemon\n"); } int compare_options(const void *s1, const void *s2) @@ -93,8 +93,8 @@ void command_help(command_t *self) progname++; } - if (self->type != NULL && strcmp(self->type, "lcrd") == 0) { - command_help_lcrd_head(); + if (self->type != NULL && strcmp(self->type, "isulad") == 0) { + command_help_isulad_head(); } fprintf(stdout, "\nUsage: %s %s\n\n", progname, self->usage); fprintf(stdout, "%s\n\n", self->description); diff --git a/src/cmd/lcrc/CMakeLists.txt b/src/cmd/isula/CMakeLists.txt similarity index 64% rename from src/cmd/lcrc/CMakeLists.txt rename to src/cmd/isula/CMakeLists.txt index a422d095f578425d8455240ccfbd9c890c2d3aad..c1d1a47353ee6e6236dd458fff8362bea21864b0 100644 --- a/src/cmd/lcrc/CMakeLists.txt +++ b/src/cmd/isula/CMakeLists.txt @@ -4,19 +4,19 @@ add_subdirectory(information) add_subdirectory(extend) add_subdirectory(stream) add_subdirectory(images) -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} lcrc_srcs) +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} isula_srcs) -set(CMD_LCRC_SRCS - ${lcrc_srcs} - ${LCRC_BASE_SRCS} - ${LCRC_EXTEND_SRCS} - ${LCRC_IMAGES_SRCS} - ${LCRC_INFORMATION_SRCS} - ${LCRC_STREAM_SRCS} +set(CMD_ISULA_SRCS + ${isula_srcs} + ${ISULA_BASE_SRCS} + ${ISULA_EXTEND_SRCS} + ${ISULA_IMAGES_SRCS} + ${ISULA_INFORMATION_SRCS} + ${ISULA_STREAM_SRCS} PARENT_SCOPE ) -set(CMD_LCRC_INCS +set(CMD_ISULA_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/base ${CMAKE_CURRENT_SOURCE_DIR}/extend diff --git a/src/cmd/lcrc/arguments.c b/src/cmd/isula/arguments.c similarity index 99% rename from src/cmd/lcrc/arguments.c rename to src/cmd/isula/arguments.c index 1721aba9fb78e2eb5e5deaca026c062f82e70edc..335c25e474a3498cd7ae2bf3a9f53956d3d27819 100644 --- a/src/cmd/lcrc/arguments.c +++ b/src/cmd/isula/arguments.c @@ -252,7 +252,7 @@ void print_common_help() void client_print_error(uint32_t cc, uint32_t server_errono, const char *errmsg) { switch (server_errono) { - case LCRD_SUCCESS: + case ISULAD_SUCCESS: if (errmsg != NULL) { COMMAND_ERROR("%s", errmsg); } diff --git a/src/cmd/lcrc/arguments.h b/src/cmd/isula/arguments.h similarity index 96% rename from src/cmd/lcrc/arguments.h rename to src/cmd/isula/arguments.h index 308d45cfde3867a25e4e15a24696510fdf5bba0d..4ecc5b6b840aeb6ee99f0f8c8401dbc171fa439e 100644 --- a/src/cmd/lcrc/arguments.h +++ b/src/cmd/isula/arguments.h @@ -13,8 +13,8 @@ * Description: provide container client arguments definition ******************************************************************************/ -#ifndef __LCRC_ARGUMENTS_H -#define __LCRC_ARGUMENTS_H +#ifndef __ISULA_ARGUMENTS_H +#define __ISULA_ARGUMENTS_H #include #include @@ -24,7 +24,7 @@ #include "commander.h" #include "container_def.h" #include "json_common.h" -#include "lcrc_connect.h" +#include "isula_connect.h" /* max arguments can be specify in client */ #define MAX_CLIENT_ARGS 1000 @@ -231,7 +231,7 @@ struct client_arguments { /* notes: we should free the mem in custom_conf by hand */ struct custom_configs custom_conf; - // lcrc run; + // isula run; bool detach; bool interactive; @@ -342,13 +342,13 @@ extern int client_arguments_init(struct client_arguments *args); extern void client_arguments_free(struct client_arguments *args); -extern void lcrd_screen_print(uint32_t cc, uint32_t server_errono, - struct client_arguments *args); +extern void isulad_screen_print(uint32_t cc, uint32_t server_errono, + struct client_arguments *args); extern void client_print_error(uint32_t cc, uint32_t server_errono, const char *errmsg); extern client_connect_config_t get_connect_config(const struct client_arguments *args); -#endif /* __LCRC_ARGUMENTS_H */ +#endif /* __ISULA_ARGUMENTS_H */ diff --git a/src/cmd/lcrc/base/CMakeLists.txt b/src/cmd/isula/base/CMakeLists.txt similarity index 36% rename from src/cmd/lcrc/base/CMakeLists.txt rename to src/cmd/isula/base/CMakeLists.txt index 12ea458aa6d9ef63082e9374d13fc78751aa0ef6..8c19445e730cb6573d212f156158891d728e5736 100644 --- a/src/cmd/lcrc/base/CMakeLists.txt +++ b/src/cmd/isula/base/CMakeLists.txt @@ -1,7 +1,7 @@ # get current directory sources files -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} lcrc_base_srcs) +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} isula_base_srcs) -set(LCRC_BASE_SRCS - ${lcrc_base_srcs} +set(ISULA_BASE_SRCS + ${isula_base_srcs} PARENT_SCOPE ) diff --git a/src/cmd/lcrc/base/create.c b/src/cmd/isula/base/create.c similarity index 93% rename from src/cmd/lcrc/base/create.c rename to src/cmd/isula/base/create.c index d22bd8e4082101c01a406a3899f3eddb5a87a770..7cc41dfb3479cf980e0677c2914e34717b1466b9 100644 --- a/src/cmd/lcrc/base/create.c +++ b/src/cmd/isula/base/create.c @@ -28,10 +28,10 @@ #include "console.h" #include "create.h" #include "commands.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "path.h" #include "pull.h" -#include "liblcrd.h" +#include "libisulad.h" const char g_cmd_create_desc[] = "Create a new container"; const char g_cmd_create_usage[] = "create [OPTIONS] --external-rootfs=PATH|IMAGE [COMMAND] [ARG...]"; @@ -48,7 +48,7 @@ struct client_arguments g_cmd_create_args = { .custom_conf.health_retries = 0, }; -static void request_pack_host_config_limit(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_config_limit(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* pids limit */ if (args->custom_conf.pids_limit != 0) { @@ -60,7 +60,7 @@ static void request_pack_host_config_limit(const struct client_arguments *args, } } -static int request_pack_host_config_storage_opts(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static int request_pack_host_config_storage_opts(const struct client_arguments *args, isula_host_config_t *hostconfig) { size_t i = 0; size_t len = 0; @@ -95,7 +95,7 @@ static int request_pack_host_config_storage_opts(const struct client_arguments * return 0; } -static int request_pack_host_config_sysctls(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static int request_pack_host_config_sysctls(const struct client_arguments *args, isula_host_config_t *hostconfig) { size_t i = 0; size_t len = 0; @@ -127,7 +127,7 @@ static int request_pack_host_config_sysctls(const struct client_arguments *args, return 0; } -static int request_pack_host_config_cgroup(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static int request_pack_host_config_cgroup(const struct client_arguments *args, isula_host_config_t *hostconfig) { if (args == NULL) { return -1; @@ -177,7 +177,7 @@ static int request_pack_host_config_cgroup(const struct client_arguments *args, return 0; } -static int util_env_set_lcrd_enable_plugins(char ***penv, const size_t *penv_len, const char *names) +static int util_env_set_isulad_enable_plugins(char ***penv, const size_t *penv_len, const char *names) { size_t env_len; size_t len = 0; @@ -193,14 +193,14 @@ static int util_env_set_lcrd_enable_plugins(char ***penv, const size_t *penv_len env = *penv; env_len = *penv_len; - arr[0] = LCRD_ENABLE_PLUGINS; + arr[0] = ISULAD_ENABLE_PLUGINS; arr[1] = "="; arr[2] = names; len = 3; - val = util_env_get_val(env, env_len, LCRD_ENABLE_PLUGINS, strlen(LCRD_ENABLE_PLUGINS)); + val = util_env_get_val(env, env_len, ISULAD_ENABLE_PLUGINS, strlen(ISULAD_ENABLE_PLUGINS)); if (val != NULL && strlen(val) != 0) { - arr[3] = LCRD_ENABLE_PLUGINS_SEPERATOR; + arr[3] = ISULAD_ENABLE_PLUGINS_SEPERATOR; arr[4] = val; len = 5; } @@ -210,7 +210,7 @@ static int util_env_set_lcrd_enable_plugins(char ***penv, const size_t *penv_len goto failed; } - if (util_env_set_val(penv, penv_len, LCRD_ENABLE_PLUGINS, strlen(LCRD_ENABLE_PLUGINS), kv)) { + if (util_env_set_val(penv, penv_len, ISULAD_ENABLE_PLUGINS, strlen(ISULAD_ENABLE_PLUGINS), kv)) { goto failed; } @@ -224,7 +224,7 @@ failed: return -1; } -static int request_pack_custom_env(struct client_arguments *args, lcrc_container_config_t *conf) +static int request_pack_custom_env(struct client_arguments *args, isula_container_config_t *conf) { int ret = 0; char *pe = NULL; @@ -244,10 +244,10 @@ static int request_pack_custom_env(struct client_arguments *args, lcrc_container } if (args->custom_conf.accel != NULL) { - pe = util_env_get_val(conf->env, conf->env_len, LCRD_ENABLE_PLUGINS, strlen(LCRD_ENABLE_PLUGINS)); + pe = util_env_get_val(conf->env, conf->env_len, ISULAD_ENABLE_PLUGINS, strlen(ISULAD_ENABLE_PLUGINS)); if (pe == NULL) { - if (util_array_append(&conf->env, LCRD_ENABLE_PLUGINS "=")) { - COMMAND_ERROR("init env LCRD_ENABLE_PLUGINS failed"); + if (util_array_append(&conf->env, ISULAD_ENABLE_PLUGINS "=")) { + COMMAND_ERROR("init env ISULAD_ENABLE_PLUGINS failed"); ret = -1; goto out; } @@ -257,7 +257,7 @@ static int request_pack_custom_env(struct client_arguments *args, lcrc_container conf->accel = args->custom_conf.accel; conf->accel_len = util_array_len((const char **)(args->custom_conf.accel)); - if (util_env_set_lcrd_enable_plugins(&conf->env, &conf->env_len, LCRD_ISULA_ADAPTER)) { + if (util_env_set_isulad_enable_plugins(&conf->env, &conf->env_len, ISULAD_ISULA_ADAPTER)) { COMMAND_ERROR("init accel env failed"); ret = -1; goto out; @@ -315,7 +315,7 @@ out: return ret; } -static int read_env_from_file(const char *path, size_t file_size, lcrc_container_config_t *conf) +static int read_env_from_file(const char *path, size_t file_size, isula_container_config_t *conf) { int ret = 0; FILE *fp = NULL; @@ -365,7 +365,7 @@ out: return ret; } -static int append_env_variables_to_conf(const char *env_file, lcrc_container_config_t *conf) +static int append_env_variables_to_conf(const char *env_file, isula_container_config_t *conf) { int ret = 0; size_t file_size; @@ -392,7 +392,7 @@ out: return ret; } -static int request_pack_custom_env_file(const struct client_arguments *args, lcrc_container_config_t *conf) +static int request_pack_custom_env_file(const struct client_arguments *args, isula_container_config_t *conf) { int ret = 0; size_t i; @@ -414,7 +414,7 @@ out: return ret; } -static void request_pack_custom_user(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_user(const struct client_arguments *args, isula_container_config_t *conf) { if (args->custom_conf.user != NULL) { conf->user = args->custom_conf.user; @@ -423,7 +423,7 @@ static void request_pack_custom_user(const struct client_arguments *args, lcrc_c return; } -static void request_pack_custom_hostname(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_hostname(const struct client_arguments *args, isula_container_config_t *conf) { if (args->custom_conf.hostname != NULL) { conf->hostname = args->custom_conf.hostname; @@ -432,7 +432,7 @@ static void request_pack_custom_hostname(const struct client_arguments *args, lc return; } -static void request_pack_custom_all_devices(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_all_devices(const struct client_arguments *args, isula_container_config_t *conf) { /* alldevices */ if (args->custom_conf.all_devices) { @@ -441,7 +441,7 @@ static void request_pack_custom_all_devices(const struct client_arguments *args, return; } -static void request_pack_custom_system_container(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_system_container(const struct client_arguments *args, isula_container_config_t *conf) { if (args->custom_conf.system_container) { conf->system_container = true; @@ -457,7 +457,7 @@ static void request_pack_custom_system_container(const struct client_arguments * return; } -static void request_pack_custom_mounts(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_mounts(const struct client_arguments *args, isula_container_config_t *conf) { if (args->custom_conf.mounts != NULL) { conf->mounts_len = util_array_len((const char **)(args->custom_conf.mounts)); @@ -466,7 +466,7 @@ static void request_pack_custom_mounts(const struct client_arguments *args, lcrc return; } -static void request_pack_custom_entrypoint(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_entrypoint(const struct client_arguments *args, isula_container_config_t *conf) { if (args->custom_conf.entrypoint != NULL) { conf->entrypoint = args->custom_conf.entrypoint; @@ -475,7 +475,7 @@ static void request_pack_custom_entrypoint(const struct client_arguments *args, return; } -static void request_pack_custom_args(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_args(const struct client_arguments *args, isula_container_config_t *conf) { if (args->argc != 0 && args->argv != NULL) { conf->cmd_len = (size_t)(args->argc); @@ -485,7 +485,7 @@ static void request_pack_custom_args(const struct client_arguments *args, lcrc_c return; } -static void request_pack_custom_log_options(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_log_options(const struct client_arguments *args, isula_container_config_t *conf) { if (args->log_file != NULL) { conf->log_file = args->log_file; @@ -498,13 +498,13 @@ static void request_pack_custom_log_options(const struct client_arguments *args, return; } -static int request_pack_custom_log_accel(struct client_arguments *args, lcrc_container_config_t *conf) +static int request_pack_custom_log_accel(struct client_arguments *args, isula_container_config_t *conf) { int ret = 0; char *accargs = NULL; if (conf->accel != NULL) { - accargs = util_string_join(LCRD_ISULA_ACCEL_ARGS_SEPERATOR, (const char **)conf->accel, conf->accel_len); + accargs = util_string_join(ISULAD_ISULA_ACCEL_ARGS_SEPERATOR, (const char **)conf->accel, conf->accel_len); if (conf->annotations == NULL) { conf->annotations = util_common_calloc_s(sizeof(json_map_string_string)); @@ -515,7 +515,7 @@ static int request_pack_custom_log_accel(struct client_arguments *args, lcrc_con } } - ret = append_json_map_string_string(conf->annotations, LCRD_ISULA_ACCEL_ARGS, accargs); + ret = append_json_map_string_string(conf->annotations, ISULAD_ISULA_ACCEL_ARGS, accargs); if (ret != 0) { COMMAND_ERROR("init accel annotations failed accel=%s", accargs); ret = -1; @@ -529,7 +529,7 @@ out: return ret; } -static void request_pack_custom_work_dir(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_work_dir(const struct client_arguments *args, isula_container_config_t *conf) { /* work dir in container */ if (args->custom_conf.workdir != NULL) { @@ -539,7 +539,7 @@ static void request_pack_custom_work_dir(const struct client_arguments *args, lc return; } -static void request_pack_custom_tty(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_tty(const struct client_arguments *args, isula_container_config_t *conf) { conf->tty = args->custom_conf.tty; conf->open_stdin = args->custom_conf.open_stdin; @@ -550,7 +550,7 @@ static void request_pack_custom_tty(const struct client_arguments *args, lcrc_co return; } -static void request_pack_custom_health_check(const struct client_arguments *args, lcrc_container_config_t *conf) +static void request_pack_custom_health_check(const struct client_arguments *args, isula_container_config_t *conf) { if (args->custom_conf.health_cmd != NULL) { conf->health_cmd = args->custom_conf.health_cmd; @@ -566,7 +566,7 @@ static void request_pack_custom_health_check(const struct client_arguments *args return; } -static int request_pack_custom_conf(struct client_arguments *args, lcrc_container_config_t *conf) +static int request_pack_custom_conf(struct client_arguments *args, isula_container_config_t *conf) { if (args == NULL) { return -1; @@ -622,7 +622,7 @@ static int request_pack_custom_conf(struct client_arguments *args, lcrc_containe return 0; } -static int request_pack_host_ns_change_files(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static int request_pack_host_ns_change_files(const struct client_arguments *args, isula_host_config_t *hostconfig) { int ret = 0; size_t i = 0; @@ -688,7 +688,7 @@ static int request_pack_host_ns_change_files(const struct client_arguments *args return ret; } -static void request_pack_host_caps(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_caps(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* cap add */ if (args->custom_conf.cap_adds != NULL) { @@ -702,7 +702,7 @@ static void request_pack_host_caps(const struct client_arguments *args, lcrc_hos } } -static void request_pack_host_group_add(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_group_add(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* group add */ if (args->custom_conf.group_add != NULL) { @@ -711,7 +711,7 @@ static void request_pack_host_group_add(const struct client_arguments *args, lcr } } -static void request_pack_host_extra_hosts(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_extra_hosts(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* extra hosts */ if (args->custom_conf.extra_hosts != NULL) { @@ -720,7 +720,7 @@ static void request_pack_host_extra_hosts(const struct client_arguments *args, l } } -static void request_pack_host_dns(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_dns(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* dns */ if (args->custom_conf.dns != NULL) { @@ -741,7 +741,7 @@ static void request_pack_host_dns(const struct client_arguments *args, lcrc_host } } -static void request_pack_host_ulimit(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_ulimit(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* ulimit options */ if (args->custom_conf.ulimits != NULL) { @@ -750,7 +750,7 @@ static void request_pack_host_ulimit(const struct client_arguments *args, lcrc_h } } -static void request_pack_host_weight_devices(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_weight_devices(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* blkio weight devices */ if (args->custom_conf.weight_devices != NULL) { @@ -759,7 +759,7 @@ static void request_pack_host_weight_devices(const struct client_arguments *args } } -static void request_pack_host_device_read_bps(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_device_read_bps(const struct client_arguments *args, isula_host_config_t *hostconfig) { if (args->custom_conf.blkio_throttle_read_bps_device != NULL) { hostconfig->blkio_throttle_read_bps_device_len = @@ -768,7 +768,7 @@ static void request_pack_host_device_read_bps(const struct client_arguments *arg } } -static void request_pack_host_device_write_bps(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_device_write_bps(const struct client_arguments *args, isula_host_config_t *hostconfig) { if (args->custom_conf.blkio_throttle_write_bps_device != NULL) { hostconfig->blkio_throttle_write_bps_device_len = @@ -777,14 +777,14 @@ static void request_pack_host_device_write_bps(const struct client_arguments *ar } } -static void request_pack_host_blockio(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_blockio(const struct client_arguments *args, isula_host_config_t *hostconfig) { request_pack_host_weight_devices(args, hostconfig); request_pack_host_device_read_bps(args, hostconfig); request_pack_host_device_write_bps(args, hostconfig); } -static void request_pack_host_devices(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_devices(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* devices */ if (args->custom_conf.devices != NULL) { @@ -793,7 +793,7 @@ static void request_pack_host_devices(const struct client_arguments *args, lcrc_ } } -static void request_pack_host_hugepage_limits(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_hugepage_limits(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* hugepage limits */ if (args->custom_conf.hugepage_limits != NULL) { @@ -802,7 +802,7 @@ static void request_pack_host_hugepage_limits(const struct client_arguments *arg } } -static void request_pack_host_binds(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_binds(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* volumes to binds */ if (args->custom_conf.volumes != NULL) { @@ -811,7 +811,7 @@ static void request_pack_host_binds(const struct client_arguments *args, lcrc_ho } } -static void request_pack_host_hook_spec(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_hook_spec(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* hook-spec file */ if (args->custom_conf.hook_spec != NULL) { @@ -819,14 +819,14 @@ static void request_pack_host_hook_spec(const struct client_arguments *args, lcr } } -static void request_pack_host_restart_policy(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_restart_policy(const struct client_arguments *args, isula_host_config_t *hostconfig) { if (args->restart != NULL) { hostconfig->restart_policy = args->restart; } } -static void request_pack_host_namespaces(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_namespaces(const struct client_arguments *args, isula_host_config_t *hostconfig) { if (args->host_channel != NULL) { hostconfig->host_channel = args->host_channel; @@ -849,7 +849,7 @@ static void request_pack_host_namespaces(const struct client_arguments *args, lc } } -static void request_pack_host_security(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static void request_pack_host_security(const struct client_arguments *args, isula_host_config_t *hostconfig) { /* security opt */ if (args->custom_conf.security != NULL) { @@ -858,7 +858,7 @@ static void request_pack_host_security(const struct client_arguments *args, lcrc } } -static int request_pack_host_config(const struct client_arguments *args, lcrc_host_config_t *hostconfig) +static int request_pack_host_config(const struct client_arguments *args, isula_host_config_t *hostconfig) { int ret = 0; @@ -946,18 +946,18 @@ static int request_pack_host_config(const struct client_arguments *args, lcrc_ho #define IMAGE_NOT_FOUND_ERROR "No such image" -static int do_client_create(const struct client_arguments *args, const lcrc_connect_ops *ops, - const struct lcrc_create_request *request, struct lcrc_create_response *response) +static int do_client_create(const struct client_arguments *args, const isula_connect_ops *ops, + const struct isula_create_request *request, struct isula_create_response *response) { int ret = 0; client_connect_config_t config = get_connect_config(args); ret = ops->container.create(request, response, &config); if (ret != 0) { - if (response->cc == LCRD_ERR_INPUT) { + if (response->cc == ISULAD_ERR_INPUT) { ret = EINVALIDARGS; } else if (response->server_errono || - (response->errmsg && !strcmp(response->errmsg, errno_to_error_message(LCRD_ERR_CONNECT)))) { + (response->errmsg && !strcmp(response->errmsg, errno_to_error_message(ISULAD_ERR_CONNECT)))) { ret = ESERVERERROR; } else { ret = ECOMMON; @@ -966,14 +966,14 @@ static int do_client_create(const struct client_arguments *args, const lcrc_conn return ret; } -static int client_try_to_create(const struct client_arguments *args, const struct lcrc_create_request *request, - struct lcrc_create_response **out_response) +static int client_try_to_create(const struct client_arguments *args, const struct isula_create_request *request, + struct isula_create_response **out_response) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_create_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_create_response *response = NULL; - response = util_common_calloc_s(sizeof(struct lcrc_create_response)); + response = util_common_calloc_s(sizeof(struct isula_create_response)); if (response == NULL) { ERROR("Out of memory"); ret = ECOMMON; @@ -1000,8 +1000,8 @@ static int client_try_to_create(const struct client_arguments *args, const struc } /* retry create */ - lcrc_create_response_free(response); - response = util_common_calloc_s(sizeof(struct lcrc_create_response)); + isula_create_response_free(response); + response = util_common_calloc_s(sizeof(struct isula_create_response)); if (response == NULL) { ERROR("Out of memory"); ret = ECOMMON; @@ -1018,14 +1018,14 @@ out: return ret; } -static void free_alloced_memory_in_host_config(lcrc_host_config_t *hostconfig) +static void free_alloced_memory_in_host_config(isula_host_config_t *hostconfig) { - lcrc_ns_change_files_free(hostconfig); - lcrc_host_config_storage_opts_free(hostconfig); - lcrc_host_config_sysctl_free(hostconfig); + isula_ns_change_files_free(hostconfig); + isula_host_config_storage_opts_free(hostconfig); + isula_host_config_sysctl_free(hostconfig); } -static void free_alloced_memory_in_config(lcrc_container_config_t *custom_conf) +static void free_alloced_memory_in_config(isula_container_config_t *custom_conf) { if (custom_conf == NULL) { return; @@ -1041,10 +1041,10 @@ static void free_alloced_memory_in_config(lcrc_container_config_t *custom_conf) int client_create(struct client_arguments *args) { int ret = 0; - struct lcrc_create_request request = { 0 }; - struct lcrc_create_response *response = NULL; - lcrc_container_config_t custom_conf = { 0 }; - lcrc_host_config_t host_config = { 0 }; + struct isula_create_request request = { 0 }; + struct isula_create_response *response = NULL; + isula_container_config_t custom_conf = { 0 }; + isula_host_config_t host_config = { 0 }; container_cgroup_resources_t cr = { 0 }; request.name = args->name; @@ -1081,7 +1081,7 @@ int client_create(struct client_arguments *args) out: free_alloced_memory_in_host_config(request.hostconfig); free_alloced_memory_in_config(request.config); - lcrc_create_response_free(response); + isula_create_response_free(response); return ret; } diff --git a/src/cmd/lcrc/base/create.h b/src/cmd/isula/base/create.h similarity index 98% rename from src/cmd/lcrc/base/create.h rename to src/cmd/isula/base/create.h index 9bcaf5b23cb370b0fff570256df805a3c8729944..87ad1c1cea2ff03343e5ad85372890e879d8f0a7 100644 --- a/src/cmd/lcrc/base/create.h +++ b/src/cmd/isula/base/create.h @@ -52,7 +52,7 @@ { CMD_OPT_TYPE_STRING_DUP, false, "entrypoint", 0, &(cmdargs).custom_conf.entrypoint, \ "Entrypoint to run when starting the container", NULL }, \ { CMD_OPT_TYPE_STRING, false, "external-rootfs", 0, &(cmdargs).external_rootfs, \ - "Specify the custom rootfs that is not managed by LCRD for the container, directory or block device", NULL }, \ + "Specify the custom rootfs that is not managed by isulad for the container, directory or block device", NULL }, \ { CMD_OPT_TYPE_CALLBACK, false, "files-limit", 0, &(cmdargs).custom_conf.files_limit, \ "Tune container files limit (set -1 for unlimited)", command_convert_llong }, \ { CMD_OPT_TYPE_STRING_DUP, false, "hook-spec", 0, &(cmdargs).custom_conf.hook_spec, \ diff --git a/src/cmd/lcrc/base/kill.c b/src/cmd/isula/base/kill.c similarity index 93% rename from src/cmd/lcrc/base/kill.c rename to src/cmd/isula/base/kill.c index 043d9db92b2b889da9d74fffaada72cfa66cd5f1..62d00dc61d26e4fdeda38b5809bd1d7979d7cb5d 100644 --- a/src/cmd/lcrc/base/kill.c +++ b/src/cmd/isula/base/kill.c @@ -16,7 +16,7 @@ #include "arguments.h" #include "kill.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_kill_desc[] = "Kill one or more running containers"; const char g_cmd_kill_usage[] = "kill [OPTIONS] CONTAINER [CONTAINER...]"; @@ -29,12 +29,12 @@ static int client_kill(const struct client_arguments *args) { int ret = 0; int signal = -1; - lcrc_connect_ops *ops = NULL; - struct lcrc_kill_request request = { 0 }; - struct lcrc_kill_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_kill_request request = { 0 }; + struct isula_kill_response *response = NULL; client_connect_config_t config = { 0 }; - response = util_common_calloc_s(sizeof(struct lcrc_kill_response)); + response = util_common_calloc_s(sizeof(struct isula_kill_response)); if (response == NULL) { ERROR("Kill: Out of memory"); return -1; @@ -65,7 +65,7 @@ static int client_kill(const struct client_arguments *args) } out: - lcrc_kill_response_free(response); + isula_kill_response_free(response); return ret; } diff --git a/src/cmd/lcrc/base/kill.h b/src/cmd/isula/base/kill.h similarity index 100% rename from src/cmd/lcrc/base/kill.h rename to src/cmd/isula/base/kill.h diff --git a/src/cmd/lcrc/base/rename.c b/src/cmd/isula/base/rename.c similarity index 93% rename from src/cmd/lcrc/base/rename.c rename to src/cmd/isula/base/rename.c index 642a85196e28b3df5482b1883ff24d5f9b5a3515..1eaf970562878167ac5fce895793a87876ff761e 100644 --- a/src/cmd/lcrc/base/rename.c +++ b/src/cmd/isula/base/rename.c @@ -16,7 +16,7 @@ #include "arguments.h" #include "log.h" #include "utils.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_rename_desc[] = "Rename a container"; const char g_cmd_rename_usage[] = @@ -27,9 +27,9 @@ struct client_arguments g_cmd_rename_args = { 0 }; static int client_rename(const struct client_arguments *args) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_rename_request request = { 0 }; - struct lcrc_rename_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_rename_request request = { 0 }; + struct isula_rename_response *response = NULL; client_connect_config_t config = { 0 }; response = util_common_calloc_s(sizeof(*response)); @@ -53,7 +53,7 @@ static int client_rename(const struct client_arguments *args) client_print_error(response->cc, response->server_errono, response->errmsg); } out: - lcrc_rename_response_free(response); + isula_rename_response_free(response); return ret; } diff --git a/src/cmd/lcrc/base/rename.h b/src/cmd/isula/base/rename.h similarity index 100% rename from src/cmd/lcrc/base/rename.h rename to src/cmd/isula/base/rename.h diff --git a/src/cmd/lcrc/base/restart.c b/src/cmd/isula/base/restart.c similarity index 92% rename from src/cmd/lcrc/base/restart.c rename to src/cmd/isula/base/restart.c index 745f794c4f7e0cc30ecf920428c66e3febe44dc0..f7b283ec1c3bb653fc51709310b2de7438094586 100644 --- a/src/cmd/lcrc/base/restart.c +++ b/src/cmd/isula/base/restart.c @@ -18,7 +18,7 @@ #include "arguments.h" #include "log.h" #include "utils.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_restart_desc[] = "Restart one or more containers"; const char g_cmd_restart_usage[] = "restart [OPTIONS] CONTAINER [CONTAINER...]"; @@ -31,12 +31,12 @@ struct client_arguments g_cmd_restart_args = { static int client_restart(const struct client_arguments *args) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_restart_request request = { 0 }; - struct lcrc_restart_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_restart_request request = { 0 }; + struct isula_restart_response *response = NULL; client_connect_config_t config = { 0 }; - response = util_common_calloc_s(sizeof(struct lcrc_restart_response)); + response = util_common_calloc_s(sizeof(struct isula_restart_response)); if (response == NULL) { ERROR("Out of memory"); return -1; @@ -57,7 +57,7 @@ static int client_restart(const struct client_arguments *args) client_print_error(response->cc, response->server_errono, response->errmsg); } out: - lcrc_restart_response_free(response); + isula_restart_response_free(response); return ret; } diff --git a/src/cmd/lcrc/base/restart.h b/src/cmd/isula/base/restart.h similarity index 100% rename from src/cmd/lcrc/base/restart.h rename to src/cmd/isula/base/restart.h diff --git a/src/cmd/lcrc/base/rm.c b/src/cmd/isula/base/rm.c similarity index 94% rename from src/cmd/lcrc/base/rm.c rename to src/cmd/isula/base/rm.c index 73fd1d164c7d48809f1ebe266b35140b40025516..25e016dfa7aad592e64e06e97d55d2b2b6ac062e 100644 --- a/src/cmd/lcrc/base/rm.c +++ b/src/cmd/isula/base/rm.c @@ -16,7 +16,7 @@ #include "rm.h" #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "commands.h" #include "console.h" #include "utils.h" @@ -34,12 +34,12 @@ struct client_arguments g_cmd_delete_args = { static int client_delete(const struct client_arguments *args) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_delete_request request = { 0 }; - struct lcrc_delete_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_delete_request request = { 0 }; + struct isula_delete_response *response = NULL; client_connect_config_t config = { 0 }; - response = util_common_calloc_s(sizeof(struct lcrc_delete_response)); + response = util_common_calloc_s(sizeof(struct isula_delete_response)); if (response == NULL) { ERROR("RM: Out of memory"); return -1; @@ -66,7 +66,7 @@ static int client_delete(const struct client_arguments *args) } out: - lcrc_delete_response_free(response); + isula_delete_response_free(response); return ret; } diff --git a/src/cmd/lcrc/base/rm.h b/src/cmd/isula/base/rm.h similarity index 100% rename from src/cmd/lcrc/base/rm.h rename to src/cmd/isula/base/rm.h diff --git a/src/cmd/lcrc/base/run.c b/src/cmd/isula/base/run.c similarity index 93% rename from src/cmd/lcrc/base/run.c rename to src/cmd/isula/base/run.c index ed2a520d855ee8f8fc7e4681bb1b759043147caf..a059cdeb9a6af79cc90f517c48bb004c12411253 100644 --- a/src/cmd/lcrc/base/run.c +++ b/src/cmd/isula/base/run.c @@ -21,7 +21,7 @@ #include "arguments.h" #include "log.h" #include "utils.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "console.h" #include "error.h" @@ -81,9 +81,9 @@ static int remote_cmd_start(const struct client_arguments *args, uint32_t *exit_ { int ret = 0; bool reset_tty = false; - lcrc_connect_ops *ops = NULL; - struct lcrc_start_request request = { 0 }; - struct lcrc_start_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_start_request request = { 0 }; + struct isula_start_response *response = NULL; client_connect_config_t config = { 0 }; struct termios oldtios; @@ -103,7 +103,7 @@ static int remote_cmd_start(const struct client_arguments *args, uint32_t *exit_ request.attach_stdin = args->custom_conf.attach_stdin; request.attach_stdout = args->custom_conf.attach_stdout; request.attach_stderr = args->custom_conf.attach_stderr; - response = util_common_calloc_s(sizeof(struct lcrc_start_response)); + response = util_common_calloc_s(sizeof(struct isula_start_response)); if (response == NULL) { ERROR("Out of memory"); ret = ECOMMON; @@ -116,14 +116,14 @@ static int remote_cmd_start(const struct client_arguments *args, uint32_t *exit_ client_print_error(response->cc, response->server_errono, response->errmsg); ret = ECOMMON; if (response->server_errono || - (response->errmsg && !strcmp(response->errmsg, errno_to_error_message(LCRD_ERR_CONNECT)))) { + (response->errmsg && !strcmp(response->errmsg, errno_to_error_message(ISULAD_ERR_CONNECT)))) { ret = ESERVERERROR; } goto out; } out: - lcrc_start_response_free(response); + isula_start_response_free(response); if (reset_tty && tcsetattr(0, TCSAFLUSH, &oldtios) < 0) { ERROR("Failed to reset terminal properties"); return -1; @@ -134,9 +134,9 @@ out: static int do_resize_run_console(const struct client_arguments *args, unsigned int height, unsigned int width) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_resize_request request = { 0 }; - struct lcrc_resize_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_resize_request request = { 0 }; + struct isula_resize_response *response = NULL; client_connect_config_t config = { 0 }; ops = get_connect_client_ops(); @@ -150,7 +150,7 @@ static int do_resize_run_console(const struct client_arguments *args, unsigned i request.height = height; request.width = width; - response = util_common_calloc_s(sizeof(struct lcrc_resize_response)); + response = util_common_calloc_s(sizeof(struct isula_resize_response)); if (response == NULL) { ERROR("Out of memory"); ret = -1; @@ -165,7 +165,7 @@ static int do_resize_run_console(const struct client_arguments *args, unsigned i } out: - lcrc_resize_response_free(response); + isula_resize_response_free(response); return ret; } diff --git a/src/cmd/lcrc/base/run.h b/src/cmd/isula/base/run.h similarity index 100% rename from src/cmd/lcrc/base/run.h rename to src/cmd/isula/base/run.h diff --git a/src/cmd/lcrc/base/start.c b/src/cmd/isula/base/start.c similarity index 95% rename from src/cmd/lcrc/base/start.c rename to src/cmd/isula/base/start.c index 2389769fa795b636ad89b225ab96471cfcf12bad..fc98e8a6d5019cc2c21b2f58b35bbde6b76f37bf 100644 --- a/src/cmd/lcrc/base/start.c +++ b/src/cmd/isula/base/start.c @@ -23,7 +23,7 @@ #include "commander.h" #include "start.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "console.h" #include "utils.h" #include "commands.h" @@ -95,9 +95,9 @@ out: static int do_client_start(const struct client_arguments *args, struct command_fifo_config **console_fifos) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_start_request request = { 0 }; - struct lcrc_start_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_start_request request = { 0 }; + struct isula_start_response *response = NULL; client_connect_config_t config = { 0 }; ops = get_connect_client_ops(); @@ -117,7 +117,7 @@ static int do_client_start(const struct client_arguments *args, struct command_f request.attach_stdout = args->custom_conf.attach_stdout; request.attach_stderr = args->custom_conf.attach_stderr; - response = util_common_calloc_s(sizeof(struct lcrc_start_response)); + response = util_common_calloc_s(sizeof(struct isula_start_response)); if (response == NULL) { ERROR("Out of memory"); ret = ECOMMON; @@ -129,7 +129,7 @@ static int do_client_start(const struct client_arguments *args, struct command_f if (ret) { client_print_error(response->cc, response->server_errono, response->errmsg); if (response->server_errono || - (response->errmsg && !strcmp(response->errmsg, errno_to_error_message(LCRD_ERR_CONNECT)))) { + (response->errmsg && !strcmp(response->errmsg, errno_to_error_message(ISULAD_ERR_CONNECT)))) { ret = ESERVERERROR; util_contain_errmsg(response->errmsg, &ret); } else { @@ -139,7 +139,7 @@ static int do_client_start(const struct client_arguments *args, struct command_f } out: - lcrc_start_response_free(response); + isula_start_response_free(response); response = NULL; return ret; } diff --git a/src/cmd/lcrc/base/start.h b/src/cmd/isula/base/start.h similarity index 100% rename from src/cmd/lcrc/base/start.h rename to src/cmd/isula/base/start.h diff --git a/src/cmd/lcrc/base/stop.c b/src/cmd/isula/base/stop.c similarity index 92% rename from src/cmd/lcrc/base/stop.c rename to src/cmd/isula/base/stop.c index 56b5483399a052faf9fa0ffbd5935787a4a93777..201b012ea0e1f0c548908856759e01684fb480bc 100644 --- a/src/cmd/lcrc/base/stop.c +++ b/src/cmd/isula/base/stop.c @@ -16,7 +16,7 @@ #include "arguments.h" #include "log.h" #include "utils.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_stop_desc[] = "Stop one or more containers"; const char g_cmd_stop_usage[] = "stop [OPTIONS] CONTAINER [CONTAINER...]"; @@ -32,12 +32,12 @@ struct client_arguments g_cmd_stop_args = { static int client_stop(const struct client_arguments *args) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_stop_request request = { 0 }; - struct lcrc_stop_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_stop_request request = { 0 }; + struct isula_stop_response *response = NULL; client_connect_config_t config = { 0 }; - response = util_common_calloc_s(sizeof(struct lcrc_stop_response)); + response = util_common_calloc_s(sizeof(struct isula_stop_response)); if (response == NULL) { ERROR("Stop: Out of memory"); return -1; @@ -59,7 +59,7 @@ static int client_stop(const struct client_arguments *args) client_print_error(response->cc, response->server_errono, response->errmsg); } out: - lcrc_stop_response_free(response); + isula_stop_response_free(response); return ret; } diff --git a/src/cmd/lcrc/base/stop.h b/src/cmd/isula/base/stop.h similarity index 100% rename from src/cmd/lcrc/base/stop.h rename to src/cmd/isula/base/stop.h diff --git a/src/cmd/lcrc/commands.c b/src/cmd/isula/commands.c similarity index 98% rename from src/cmd/lcrc/commands.c rename to src/cmd/isula/commands.c index 5e4eb1046936eb385e5dbd335121317a91e5249f..d1bc433a35f579bd11f81084cf6ad159dd9254a6 100644 --- a/src/cmd/lcrc/commands.c +++ b/src/cmd/isula/commands.c @@ -85,7 +85,7 @@ free_out: static void print_version() { - printf("Version %s, commit %s\n", VERSION, LCRD_GIT_COMMIT); + printf("Version %s, commit %s\n", VERSION, ISULAD_GIT_COMMIT); } /* compare commands */ @@ -154,7 +154,7 @@ int command_default_help(const char * const program_name, struct command *comman if (command == NULL) { printf("%s: sub-command \"%s\" not found\n", program_name, argv[0]); - printf("run `lcrc --help` for a list of sub-commands\n"); + printf("run `isula --help` for a list of sub-commands\n"); return 1; } @@ -174,7 +174,7 @@ int run_command(struct command *commands, int argc, const char **argv) } if (strcmp(argv[1], "--help") == 0) { - // lcrc help command format: lcrc --help args + // isula help command format: isula --help args return command_default_help(argv[0], commands, argc - 2, (const char **)(argv + 2)); } diff --git a/src/cmd/lcrc/commands.h b/src/cmd/isula/commands.h similarity index 98% rename from src/cmd/lcrc/commands.h rename to src/cmd/isula/commands.h index a96e1b3bb0f776fefd211f9044b6ed2450994447..7ed3b979d8d6b81a0800f4c1b0f650e610ee4904 100644 --- a/src/cmd/lcrc/commands.h +++ b/src/cmd/isula/commands.h @@ -18,7 +18,7 @@ #include "arguments.h" #include -#define CLIENT_RUNDIR "/var/run/lcrc" +#define CLIENT_RUNDIR "/var/run/isula" // A command is described by: // @name: The name which should be passed as a second parameter diff --git a/src/cmd/lcrc/stream/CMakeLists.txt b/src/cmd/isula/extend/CMakeLists.txt similarity index 35% rename from src/cmd/lcrc/stream/CMakeLists.txt rename to src/cmd/isula/extend/CMakeLists.txt index 18e2eda9d15c64b8b5506582f8e6315373990aa4..9832e629b1320f7b2520e1e8948bbd2911d795a6 100644 --- a/src/cmd/lcrc/stream/CMakeLists.txt +++ b/src/cmd/isula/extend/CMakeLists.txt @@ -1,7 +1,7 @@ # get current directory sources files -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} lcrc_stream_srcs) +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} isula_extend_srcs) -set(LCRC_STREAM_SRCS - ${lcrc_stream_srcs} +set(ISULA_EXTEND_SRCS + ${isula_extend_srcs} PARENT_SCOPE ) diff --git a/src/cmd/lcrc/extend/events.c b/src/cmd/isula/extend/events.c similarity index 94% rename from src/cmd/lcrc/extend/events.c rename to src/cmd/isula/extend/events.c index e46ed9ce7ccf61ae30714e99f9d1d67cde57d8fb..f9bae5c0a75aa4563c8c6a3986bb255ceaec37d2 100644 --- a/src/cmd/lcrc/extend/events.c +++ b/src/cmd/isula/extend/events.c @@ -16,7 +16,7 @@ #include "events.h" #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_events_desc[] = "Get real time events from the server"; const char g_cmd_events_usage[] = "events [command options]"; @@ -81,12 +81,12 @@ static void print_events_callback(const container_events_format_t *event) static int client_event(struct client_arguments *args) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_events_request request = { 0 }; - struct lcrc_events_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_events_request request = { 0 }; + struct isula_events_response *response = NULL; client_connect_config_t config = { 0 }; - response = util_common_calloc_s(sizeof(struct lcrc_events_response)); + response = util_common_calloc_s(sizeof(struct isula_events_response)); if (response == NULL) { ERROR("Event: Out of memory"); return -1; @@ -122,7 +122,7 @@ static int client_event(struct client_arguments *args) } out: - lcrc_events_response_free(response); + isula_events_response_free(response); return ret; } diff --git a/src/cmd/lcrc/extend/events.h b/src/cmd/isula/extend/events.h similarity index 100% rename from src/cmd/lcrc/extend/events.h rename to src/cmd/isula/extend/events.h diff --git a/src/cmd/lcrc/extend/export.c b/src/cmd/isula/extend/export.c similarity index 93% rename from src/cmd/lcrc/extend/export.c rename to src/cmd/isula/extend/export.c index 4d8ecb40c10ae92b51e9eb79a0fdda74fe17a02e..d5765a5db8165d259a51d68bf6cc5a6432988307 100644 --- a/src/cmd/lcrc/extend/export.c +++ b/src/cmd/isula/extend/export.c @@ -17,7 +17,7 @@ #include "utils.h" #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_export_desc[] = "export container"; const char g_cmd_export_usage[] = "export [command options] [ID|NAME]"; @@ -30,13 +30,13 @@ struct client_arguments g_cmd_export_args = {}; static int client_export(const struct client_arguments *args) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_export_request request; - struct lcrc_export_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_export_request request; + struct isula_export_response *response = NULL; client_connect_config_t config = { 0 }; (void)memset(&request, 0, sizeof(request)); - response = util_common_calloc_s(sizeof(struct lcrc_export_response)); + response = util_common_calloc_s(sizeof(struct isula_export_response)); if (response == NULL) { ERROR("Resume: Out of memory"); return -1; @@ -58,7 +58,7 @@ static int client_export(const struct client_arguments *args) client_print_error(response->cc, response->server_errono, response->errmsg); } out: - lcrc_export_response_free(response); + isula_export_response_free(response); return ret; } diff --git a/src/cmd/lcrc/extend/export.h b/src/cmd/isula/extend/export.h similarity index 100% rename from src/cmd/lcrc/extend/export.h rename to src/cmd/isula/extend/export.h diff --git a/src/cmd/lcrc/extend/pause.c b/src/cmd/isula/extend/pause.c similarity index 92% rename from src/cmd/lcrc/extend/pause.c rename to src/cmd/isula/extend/pause.c index 83182eec3db1642cfdf14f4a325dd0091b52bd49..8f12d4b08506234f4f93af65d838f8e0c23c5d40 100644 --- a/src/cmd/lcrc/extend/pause.c +++ b/src/cmd/isula/extend/pause.c @@ -16,7 +16,7 @@ #include "utils.h" #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_pause_desc[] = "Pause all processes within one or more containers"; const char g_cmd_pause_usage[] = "pause [OPTIONS] CONTAINER [CONTAINER...]"; @@ -29,12 +29,12 @@ struct client_arguments g_cmd_pause_args = {}; static int client_pause(const struct client_arguments *args) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_pause_request request = { 0 }; - struct lcrc_pause_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_pause_request request = { 0 }; + struct isula_pause_response *response = NULL; client_connect_config_t config = { 0 }; - response = util_common_calloc_s(sizeof(struct lcrc_pause_response)); + response = util_common_calloc_s(sizeof(struct isula_pause_response)); if (response == NULL) { ERROR("Pause: Out of memory"); return -1; @@ -55,7 +55,7 @@ static int client_pause(const struct client_arguments *args) client_print_error(response->cc, response->server_errono, response->errmsg); } out: - lcrc_pause_response_free(response); + isula_pause_response_free(response); return ret; } diff --git a/src/cmd/lcrc/extend/pause.h b/src/cmd/isula/extend/pause.h similarity index 100% rename from src/cmd/lcrc/extend/pause.h rename to src/cmd/isula/extend/pause.h diff --git a/src/cmd/lcrc/extend/resume.c b/src/cmd/isula/extend/resume.c similarity index 92% rename from src/cmd/lcrc/extend/resume.c rename to src/cmd/isula/extend/resume.c index e2625c35b4596d77bffd10e8267592cdedcf3072..7e6bb5293f913035feba4e7ec34354c3e6e27a9b 100644 --- a/src/cmd/lcrc/extend/resume.c +++ b/src/cmd/isula/extend/resume.c @@ -16,7 +16,7 @@ #include "utils.h" #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_resume_desc[] = "Unpause all processes within one or more containers"; const char g_cmd_resume_usage[] = "unpause [OPTIONS] CONTAINER [CONTAINER...]"; @@ -29,12 +29,12 @@ struct client_arguments g_cmd_resume_args = {}; static int client_resume(const struct client_arguments *args) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_resume_request request = { 0 }; - struct lcrc_resume_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_resume_request request = { 0 }; + struct isula_resume_response *response = NULL; client_connect_config_t config = { 0 }; - response = util_common_calloc_s(sizeof(struct lcrc_resume_response)); + response = util_common_calloc_s(sizeof(struct isula_resume_response)); if (response == NULL) { ERROR("Resume: Out of memory"); return -1; @@ -54,7 +54,7 @@ static int client_resume(const struct client_arguments *args) client_print_error(response->cc, response->server_errono, response->errmsg); } out: - lcrc_resume_response_free(response); + isula_resume_response_free(response); return ret; } diff --git a/src/cmd/lcrc/extend/resume.h b/src/cmd/isula/extend/resume.h similarity index 100% rename from src/cmd/lcrc/extend/resume.h rename to src/cmd/isula/extend/resume.h diff --git a/src/cmd/lcrc/extend/stats.c b/src/cmd/isula/extend/stats.c similarity index 87% rename from src/cmd/lcrc/extend/stats.c rename to src/cmd/isula/extend/stats.c index 36de0b8e073d21092557f653db49cf5465647dfa..02131d1511ff0fceae285a541b92ffbec1b4514f 100644 --- a/src/cmd/lcrc/extend/stats.c +++ b/src/cmd/isula/extend/stats.c @@ -30,7 +30,7 @@ #include "stats.h" #include "utils.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #define ESC "\033" #define TERMCLEAR ESC "[H" ESC "[J" @@ -47,9 +47,9 @@ struct client_arguments g_cmd_stats_args = { .runtime = "lcr", }; -static struct lcrc_stats_response *g_oldstats = NULL; +static struct isula_stats_response *g_oldstats = NULL; -static void lcrc_size_humanize(unsigned long long val, char *buf, size_t bufsz) +static void isula_size_humanize(unsigned long long val, char *buf, size_t bufsz) { int ret = 0; if (val > 1024 * 1024 * 1024) { @@ -80,7 +80,7 @@ static void stats_print_header(void) printf(TERMNORM); } -static void stats_print(const struct lcrc_container_info *stats) +static void stats_print(const struct isula_container_info *stats) { #define SHORTIDLEN 12 #define PERCENT 100 @@ -94,10 +94,10 @@ static void stats_print(const struct lcrc_container_info *stats) double cpu_percent = 0.0; char *short_id = NULL; - lcrc_size_humanize(stats->blkio_read, iosb_read_str, sizeof(iosb_read_str)); - lcrc_size_humanize(stats->blkio_write, iosb_write_str, sizeof(iosb_write_str)); - lcrc_size_humanize(stats->mem_used, mem_used_str, sizeof(mem_used_str)); - lcrc_size_humanize(stats->mem_limit, mem_limit_str, sizeof(mem_limit_str)); + isula_size_humanize(stats->blkio_read, iosb_read_str, sizeof(iosb_read_str)); + isula_size_humanize(stats->blkio_write, iosb_write_str, sizeof(iosb_write_str)); + isula_size_humanize(stats->mem_used, mem_used_str, sizeof(mem_used_str)); + isula_size_humanize(stats->mem_limit, mem_limit_str, sizeof(mem_limit_str)); len = snprintf(iosb_str, sizeof(iosb_str), "%s / %s", iosb_read_str, iosb_write_str); if (len < 0 || (size_t)len >= sizeof(iosb_str)) { @@ -140,7 +140,7 @@ static void stats_print(const struct lcrc_container_info *stats) free(short_id); } -static void stats_output(const struct client_arguments *args, struct lcrc_stats_response **response) +static void stats_output(const struct client_arguments *args, struct isula_stats_response **response) { size_t i; @@ -152,15 +152,15 @@ static void stats_output(const struct client_arguments *args, struct lcrc_stats_ } fflush(stdout); - lcrc_stats_response_free(g_oldstats); + isula_stats_response_free(g_oldstats); g_oldstats = *response; *response = NULL; } -static int client_stats_mainloop(const struct client_arguments *args, const struct lcrc_stats_request *request) +static int client_stats_mainloop(const struct client_arguments *args, const struct isula_stats_request *request) { int ret = 0; - lcrc_connect_ops *ops = NULL; + isula_connect_ops *ops = NULL; client_connect_config_t config; if (args == NULL) { @@ -174,8 +174,8 @@ static int client_stats_mainloop(const struct client_arguments *args, const stru config = get_connect_config(args); while (1) { - struct lcrc_stats_response *response = NULL; - response = util_common_calloc_s(sizeof(struct lcrc_stats_response)); + struct isula_stats_response *response = NULL; + response = util_common_calloc_s(sizeof(struct isula_stats_response)); if (response == NULL) { ERROR("Out of memory"); ret = -1; @@ -186,13 +186,13 @@ static int client_stats_mainloop(const struct client_arguments *args, const stru if (ret) { ERROR("Failed to stats containers info"); client_print_error(response->cc, response->server_errono, response->errmsg); - lcrc_stats_response_free(response); + isula_stats_response_free(response); ret = -1; goto err_out; } stats_output(args, &response); - lcrc_stats_response_free(response); + isula_stats_response_free(response); if (args->nostream) { goto err_out; } @@ -201,7 +201,7 @@ static int client_stats_mainloop(const struct client_arguments *args, const stru } err_out: - lcrc_stats_response_free(g_oldstats); + isula_stats_response_free(g_oldstats); g_oldstats = NULL; return ret; } @@ -211,7 +211,7 @@ err_out: */ static int client_stats(const struct client_arguments *args) { - struct lcrc_stats_request request = { 0 }; + struct isula_stats_request request = { 0 }; request.all = args->showall; request.containers = (char **)(args->argv); diff --git a/src/cmd/lcrc/extend/stats.h b/src/cmd/isula/extend/stats.h similarity index 100% rename from src/cmd/lcrc/extend/stats.h rename to src/cmd/isula/extend/stats.h diff --git a/src/cmd/lcrc/extend/update.c b/src/cmd/isula/extend/update.c similarity index 92% rename from src/cmd/lcrc/extend/update.c rename to src/cmd/isula/extend/update.c index 069126c07058341dd9b76b2662a183a0b5459413..8e25bca7b5ddc57982805d7846a4a428eb04da72 100644 --- a/src/cmd/lcrc/extend/update.c +++ b/src/cmd/isula/extend/update.c @@ -18,7 +18,7 @@ #include "update.h" #include "utils.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_update_desc[] = "Update configuration of one or more containers"; const char g_cmd_update_usage[] = "update [OPTIONS] CONTAINER [CONTAINER...]"; @@ -27,7 +27,7 @@ struct client_arguments g_cmd_update_args = { .restart = NULL, }; -static int pack_update_request(const struct client_arguments *args, struct lcrc_update_request *request) +static int pack_update_request(const struct client_arguments *args, struct isula_update_request *request) { int ret = 0; @@ -59,14 +59,14 @@ static int pack_update_request(const struct client_arguments *args, struct lcrc_ static int client_update(const struct client_arguments *args) { int ret = 0; - lcrc_connect_ops *ops = NULL; + isula_connect_ops *ops = NULL; container_cgroup_resources_t cr = { 0 }; - lcrc_update_config_t updateconfig = { 0 }; - struct lcrc_update_request request = { 0 }; - struct lcrc_update_response *response = NULL; + isula_update_config_t updateconfig = { 0 }; + struct isula_update_request request = { 0 }; + struct isula_update_response *response = NULL; client_connect_config_t config = { 0 }; - response = util_common_calloc_s(sizeof(struct lcrc_update_response)); + response = util_common_calloc_s(sizeof(struct isula_update_response)); if (response == NULL) { ERROR("Out of memory"); return -1; @@ -97,7 +97,7 @@ static int client_update(const struct client_arguments *args) } out: - lcrc_update_response_free(response); + isula_update_response_free(response); return ret; } diff --git a/src/cmd/lcrc/extend/update.h b/src/cmd/isula/extend/update.h similarity index 100% rename from src/cmd/lcrc/extend/update.h rename to src/cmd/isula/extend/update.h diff --git a/src/cmd/lcrc/images/CMakeLists.txt b/src/cmd/isula/images/CMakeLists.txt similarity index 35% rename from src/cmd/lcrc/images/CMakeLists.txt rename to src/cmd/isula/images/CMakeLists.txt index 6bdb7cbf1804a1404d22b69ee994ae5f5388a4a8..b80c37471f6dd79c5986e24ac82fe7a827f233ff 100644 --- a/src/cmd/lcrc/images/CMakeLists.txt +++ b/src/cmd/isula/images/CMakeLists.txt @@ -1,7 +1,7 @@ # get current directory sources files -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} lcrc_images_srcs) +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} isula_images_srcs) -set(LCRC_IMAGES_SRCS - ${lcrc_images_srcs} +set(ISULA_IMAGES_SRCS + ${isula_images_srcs} PARENT_SCOPE ) diff --git a/src/cmd/lcrc/images/images.c b/src/cmd/isula/images/images.c similarity index 87% rename from src/cmd/lcrc/images/images.c rename to src/cmd/isula/images/images.c index bba14a82dfc99bfc2f3c1687aebc861779250393..fbd68dd62563462c0e1a4b5d4bbddc2695dcdfc7 100644 --- a/src/cmd/lcrc/images/images.c +++ b/src/cmd/isula/images/images.c @@ -21,7 +21,7 @@ #include "utils.h" #include "arguments.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "log.h" #define IMAGES_OPTIONS(cmdargs) \ @@ -70,9 +70,9 @@ static char *trans_time(int64_t created) } /* list print table */ -static void list_print_table(struct lcrc_image_info *images_list, const size_t size, const struct lengths *length) +static void list_print_table(struct isula_image_info *images_list, const size_t size, const struct lengths *length) { - const struct lcrc_image_info *in = NULL; + const struct isula_image_info *in = NULL; size_t i = 0; char *created = NULL; char *digest = NULL; @@ -125,7 +125,7 @@ static void list_print_table(struct lcrc_image_info *images_list, const size_t s } } -static int update_image_ref_width(const struct lcrc_image_info *in, struct lengths *l) +static int update_image_ref_width(const struct isula_image_info *in, struct lengths *l) { size_t len; char *copy_name = util_strdup_s(in->imageref); @@ -159,9 +159,9 @@ static int update_image_ref_width(const struct lcrc_image_info *in, struct lengt } /* list field width */ -static void list_field_width(const struct lcrc_image_info *images_list, const size_t size, struct lengths *l) +static void list_field_width(const struct isula_image_info *images_list, const size_t size, struct lengths *l) { - const struct lcrc_image_info *in = NULL; + const struct isula_image_info *in = NULL; size_t i = 0; char tmpbuffer[30]; @@ -198,9 +198,9 @@ static void list_field_width(const struct lcrc_image_info *images_list, const si } /* - * list all images from LCRD + * list all images from isulad */ -static void images_info_print(const struct lcrc_list_images_response *response) +static void images_info_print(const struct isula_list_images_response *response) { struct lengths max_len = { .registry_length = 30, /* registry */ @@ -215,9 +215,9 @@ static void images_info_print(const struct lcrc_list_images_response *response) } /* images info print quiet */ -static void images_info_print_quiet(const struct lcrc_list_images_response *response) +static void images_info_print_quiet(const struct isula_list_images_response *response) { - const struct lcrc_image_info *in = NULL; + const struct isula_image_info *in = NULL; size_t i = 0; for (i = 0, in = response->images_list; in != NULL && i < response->images_num; i++, in++) { @@ -231,7 +231,7 @@ static void images_info_print_quiet(const struct lcrc_list_images_response *resp /* * used by qsort function for comparing image created time */ -static inline int lcrc_image_cmp(struct lcrc_image_info *first, struct lcrc_image_info *second) +static inline int isula_image_cmp(struct isula_image_info *first, struct isula_image_info *second) { if (second->created > first->created) { return 1; @@ -247,13 +247,13 @@ static inline int lcrc_image_cmp(struct lcrc_image_info *first, struct lcrc_imag */ static int list_images(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_list_images_request request = { 0 }; - struct lcrc_list_images_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_list_images_request request = { 0 }; + struct isula_list_images_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_list_images_response)); + response = util_common_calloc_s(sizeof(struct isula_list_images_response)); if (response == NULL) { ERROR("Imagelist: Out of memory"); return -1; @@ -266,8 +266,8 @@ static int list_images(const struct client_arguments *args) goto out; } if (args->filters != NULL) { - request.filters = lcrc_filters_parse_args((const char **)args->filters, - util_array_len((const char **)(args->filters))); + request.filters = isula_filters_parse_args((const char **)args->filters, + util_array_len((const char **)(args->filters))); if (request.filters == NULL) { ERROR("Failed to parse filters args"); ret = -1; @@ -282,8 +282,8 @@ static int list_images(const struct client_arguments *args) } if (response->images_list != NULL && response->images_num > 0) { - qsort(response->images_list, (size_t)(response->images_num), sizeof(struct lcrc_image_info), - (int (*)(const void *, const void *))lcrc_image_cmp); + qsort(response->images_list, (size_t)(response->images_num), sizeof(struct isula_image_info), + (int (*)(const void *, const void *))isula_image_cmp); } if (args->dispname) { @@ -293,8 +293,8 @@ static int list_images(const struct client_arguments *args) } out: - lcrc_filters_free(request.filters); - lcrc_list_images_response_free(response); + isula_filters_free(request.filters); + isula_list_images_response_free(response); return ret; } diff --git a/src/cmd/lcrc/images/images.h b/src/cmd/isula/images/images.h similarity index 100% rename from src/cmd/lcrc/images/images.h rename to src/cmd/isula/images/images.h diff --git a/src/cmd/lcrc/images/load.c b/src/cmd/isula/images/load.c similarity index 97% rename from src/cmd/lcrc/images/load.c rename to src/cmd/isula/images/load.c index 27218a04a0776af69ef8d499640620801b70a748..1279d19abe6550c85c2dccf9a390ef3bc26c7954 100644 --- a/src/cmd/lcrc/images/load.c +++ b/src/cmd/isula/images/load.c @@ -21,7 +21,7 @@ #include "utils.h" #include "arguments.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "log.h" #ifdef ENABLE_EMBEDDED_IMAGE @@ -39,9 +39,9 @@ struct client_arguments g_cmd_load_args = { 0 }; */ static int client_load_image(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_load_request request = { 0 }; - struct lcrc_load_response response = { 0 }; + isula_connect_ops *ops = NULL; + struct isula_load_request request = { 0 }; + struct isula_load_response response = { 0 }; client_connect_config_t config = { 0 }; int ret = 0; diff --git a/src/cmd/lcrc/images/load.h b/src/cmd/isula/images/load.h similarity index 100% rename from src/cmd/lcrc/images/load.h rename to src/cmd/isula/images/load.h diff --git a/src/cmd/lcrc/images/login.c b/src/cmd/isula/images/login.c similarity index 95% rename from src/cmd/lcrc/images/login.c rename to src/cmd/isula/images/login.c index 68d851fee1b6e0fd2e0e880b4ebc4f65d0b57018..3b680591c54fdd1ba3b6ff966bd80e1ca4c8e14c 100644 --- a/src/cmd/lcrc/images/login.c +++ b/src/cmd/isula/images/login.c @@ -22,7 +22,7 @@ #include "utils.h" #include "arguments.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "log.h" const char g_cmd_login_desc[] = "Log in to a Docker registry"; @@ -35,13 +35,13 @@ struct client_arguments g_cmd_login_args = {}; */ int client_login(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_login_request request = { 0 }; - struct lcrc_login_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_login_request request = { 0 }; + struct isula_login_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_login_response)); + response = util_common_calloc_s(sizeof(struct isula_login_response)); if (response == NULL) { ERROR("Out of memory"); return ECOMMON; @@ -71,7 +71,7 @@ int client_login(const struct client_arguments *args) COMMAND_ERROR("Login Succeeded"); out: - lcrc_login_response_free(response); + isula_login_response_free(response); return ret; } diff --git a/src/cmd/lcrc/images/login.h b/src/cmd/isula/images/login.h similarity index 100% rename from src/cmd/lcrc/images/login.h rename to src/cmd/isula/images/login.h diff --git a/src/cmd/lcrc/images/logout.c b/src/cmd/isula/images/logout.c similarity index 91% rename from src/cmd/lcrc/images/logout.c rename to src/cmd/isula/images/logout.c index 5068b3a266a3ef5610ae94997fe547699e45de8d..eaab5e238548f22de368e24a01d7434ac116f5c6 100644 --- a/src/cmd/lcrc/images/logout.c +++ b/src/cmd/isula/images/logout.c @@ -21,7 +21,7 @@ #include "utils.h" #include "arguments.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "log.h" const char g_cmd_logout_desc[] = "Log out from a Docker registry"; @@ -34,13 +34,13 @@ struct client_arguments g_cmd_logout_args = {}; */ int client_logout(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_logout_request request = { 0 }; - struct lcrc_logout_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_logout_request request = { 0 }; + struct isula_logout_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_logout_response)); + response = util_common_calloc_s(sizeof(struct isula_logout_response)); if (response == NULL) { ERROR("Out of memory"); return ECOMMON; @@ -68,7 +68,7 @@ int client_logout(const struct client_arguments *args) COMMAND_ERROR("Logout Succeeded"); out: - lcrc_logout_response_free(response); + isula_logout_response_free(response); return ret; } diff --git a/src/cmd/lcrc/images/logout.h b/src/cmd/isula/images/logout.h similarity index 100% rename from src/cmd/lcrc/images/logout.h rename to src/cmd/isula/images/logout.h diff --git a/src/cmd/lcrc/images/pull.c b/src/cmd/isula/images/pull.c similarity index 92% rename from src/cmd/lcrc/images/pull.c rename to src/cmd/isula/images/pull.c index 62cf64aeaa6830edfd767f1fe7636ffe9407a26c..f9b76e3d2c58f294391058f04bfff5f875c232c4 100644 --- a/src/cmd/lcrc/images/pull.c +++ b/src/cmd/isula/images/pull.c @@ -21,7 +21,7 @@ #include "utils.h" #include "arguments.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "log.h" const char g_cmd_pull_desc[] = "Pull an image or a repository from a registry"; @@ -34,13 +34,13 @@ struct client_arguments g_cmd_pull_args = {}; */ int client_pull(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_pull_request request = { 0 }; - struct lcrc_pull_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_pull_request request = { 0 }; + struct isula_pull_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_pull_response)); + response = util_common_calloc_s(sizeof(struct isula_pull_response)); if (response == NULL) { ERROR("Out of memory"); return ECOMMON; @@ -67,7 +67,7 @@ int client_pull(const struct client_arguments *args) COMMAND_ERROR("Image \"%s\" pulled", response->image_ref); out: - lcrc_pull_response_free(response); + isula_pull_response_free(response); return ret; } diff --git a/src/cmd/lcrc/images/pull.h b/src/cmd/isula/images/pull.h similarity index 100% rename from src/cmd/lcrc/images/pull.h rename to src/cmd/isula/images/pull.h diff --git a/src/cmd/lcrc/images/rmi.c b/src/cmd/isula/images/rmi.c similarity index 93% rename from src/cmd/lcrc/images/rmi.c rename to src/cmd/isula/images/rmi.c index fc26430dcf328bbf7501900eb5ae47f088c7e1ba..98625bd185c13145dff3f6d1a96d14d7b2d9e21c 100644 --- a/src/cmd/lcrc/images/rmi.c +++ b/src/cmd/isula/images/rmi.c @@ -20,7 +20,7 @@ #include "utils.h" #include "arguments.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "log.h" const char g_cmd_rmi_desc[] = "Remove one or more images"; @@ -33,9 +33,9 @@ struct client_arguments g_cmd_rmi_args = { .force = false }; */ static int client_rmi(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_rmi_request request = { 0 }; - struct lcrc_rmi_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_rmi_request request = { 0 }; + struct isula_rmi_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; @@ -44,7 +44,7 @@ static int client_rmi(const struct client_arguments *args) return -1; } - response = util_common_calloc_s(sizeof(struct lcrc_rmi_response)); + response = util_common_calloc_s(sizeof(struct isula_rmi_response)); if (response == NULL) { ERROR("Out of memory"); return -1; @@ -69,7 +69,7 @@ static int client_rmi(const struct client_arguments *args) goto out; } out: - lcrc_rmi_response_free(response); + isula_rmi_response_free(response); return ret; } diff --git a/src/cmd/lcrc/images/rmi.h b/src/cmd/isula/images/rmi.h similarity index 100% rename from src/cmd/lcrc/images/rmi.h rename to src/cmd/isula/images/rmi.h diff --git a/src/cmd/lcrc/information/CMakeLists.txt b/src/cmd/isula/information/CMakeLists.txt similarity index 32% rename from src/cmd/lcrc/information/CMakeLists.txt rename to src/cmd/isula/information/CMakeLists.txt index 8c6cdbcdffdd49ae31c1d317a05bb3ebbced1676..b001b3dcef9d04d4862d36896297f81ee9e8f83e 100644 --- a/src/cmd/lcrc/information/CMakeLists.txt +++ b/src/cmd/isula/information/CMakeLists.txt @@ -1,7 +1,7 @@ # get current directory sources files -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} lcrc_information_srcs) +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} isula_information_srcs) -set(LCRC_INFORMATION_SRCS - ${lcrc_information_srcs} +set(ISULA_INFORMATION_SRCS + ${isula_information_srcs} PARENT_SCOPE ) diff --git a/src/cmd/lcrc/information/health.c b/src/cmd/isula/information/health.c similarity index 83% rename from src/cmd/lcrc/information/health.c rename to src/cmd/isula/information/health.c index 79f2cd54f3a49f55782059967ed0b98ac11776ca..1596526ee081b493fce93211b2c3c22d00df8d6c 100644 --- a/src/cmd/lcrc/information/health.c +++ b/src/cmd/isula/information/health.c @@ -16,9 +16,9 @@ #include "utils.h" #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" -const char g_cmd_health_check_desc[] = "LCRD health check"; +const char g_cmd_health_check_desc[] = "iSulad health check"; const char g_cmd_health_check_usage[] = "health [command options]"; struct client_arguments g_cmd_health_check_args = { @@ -30,13 +30,13 @@ struct client_arguments g_cmd_health_check_args = { */ static int client_health_check(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_health_check_request request = { 0 }; - struct lcrc_health_check_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_health_check_request request = { 0 }; + struct isula_health_check_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_health_check_response)); + response = util_common_calloc_s(sizeof(struct isula_health_check_response)); if (response == NULL) { ERROR("Health: Out of memory"); return -1; @@ -57,7 +57,7 @@ static int client_health_check(const struct client_arguments *args) ret = -1; } out: - lcrc_health_check_response_free(response); + isula_health_check_response_free(response); return ret; } @@ -93,11 +93,11 @@ int cmd_health_check_main(int argc, const char **argv) } if (client_health_check(&g_cmd_health_check_args)) { - printf("LCRD with socket name '%s' is NOT SERVING\n", g_cmd_health_check_args.socket); + printf("iSulad with socket name '%s' is NOT SERVING\n", g_cmd_health_check_args.socket); exit(ECOMMON); } - printf("LCRD with socket name '%s' is SERVING\n", g_cmd_health_check_args.socket); + printf("iSulad with socket name '%s' is SERVING\n", g_cmd_health_check_args.socket); exit(EXIT_SUCCESS); } diff --git a/src/cmd/lcrc/information/health.h b/src/cmd/isula/information/health.h similarity index 100% rename from src/cmd/lcrc/information/health.h rename to src/cmd/isula/information/health.h diff --git a/src/cmd/lcrc/information/info.c b/src/cmd/isula/information/info.c similarity index 93% rename from src/cmd/lcrc/information/info.c rename to src/cmd/isula/information/info.c index 1f1aa78dd37ab2e4c8f760cff6f23853807101c1..0e4ace82537a9020e13f561e5a791d593e8e0535 100644 --- a/src/cmd/lcrc/information/info.c +++ b/src/cmd/isula/information/info.c @@ -19,14 +19,14 @@ #include "arguments.h" #include "log.h" #include "config.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_info_desc[] = "Display system-wide information"; const char g_cmd_info_usage[] = "info"; struct client_arguments g_cmd_info_args = {}; -static void client_info_server(const struct lcrc_info_response *response) +static void client_info_server(const struct isula_info_response *response) { printf("Containers: %u\n", (unsigned int)(response->containers_num)); printf(" Running: %u\n", (unsigned int)(response->c_running)); @@ -79,13 +79,13 @@ static void client_info_server(const struct lcrc_info_response *response) static int client_info(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_info_request request = { 0 }; - struct lcrc_info_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_info_request request = { 0 }; + struct isula_info_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_info_response)); + response = util_common_calloc_s(sizeof(struct isula_info_response)); if (response == NULL) { ERROR("Info: Out of memory"); return -1; @@ -108,7 +108,7 @@ static int client_info(const struct client_arguments *args) client_info_server(response); out: - lcrc_info_response_free(response); + isula_info_response_free(response); return ret; } diff --git a/src/cmd/lcrc/information/info.h b/src/cmd/isula/information/info.h similarity index 100% rename from src/cmd/lcrc/information/info.h rename to src/cmd/isula/information/info.h diff --git a/src/cmd/lcrc/information/inspect.c b/src/cmd/isula/information/inspect.c similarity index 96% rename from src/cmd/lcrc/information/inspect.c rename to src/cmd/isula/information/inspect.c index 2be129136c52f4fc0d6d6676ca7aa65ce0c5df73..81c1144bae34b58039a830ee88d65e3da89c6099 100644 --- a/src/cmd/lcrc/information/inspect.c +++ b/src/cmd/isula/information/inspect.c @@ -16,7 +16,7 @@ #include "inspect.h" #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "console.h" #include "utils.h" #include "json_common.h" @@ -191,8 +191,9 @@ static bool inspect_filter_done(yajl_val root, const char *filter, container_tre * CONTAINER_INSPECT_ERR: have the container, but failed to inspect due to other reasons * CONTAINER_NOT_FOUND: no such container */ -static int client_inspect_container(const struct lcrc_inspect_request *request, struct lcrc_inspect_response *response, - client_connect_config_t *config, const lcrc_connect_ops *ops) +static int client_inspect_container(const struct isula_inspect_request *request, + struct isula_inspect_response *response, + client_connect_config_t *config, const isula_connect_ops *ops) { int ret = 0; @@ -211,8 +212,8 @@ static int client_inspect_container(const struct lcrc_inspect_request *request, return ret; } -static int client_inspect_image(const struct lcrc_inspect_request *request, struct lcrc_inspect_response *response, - client_connect_config_t *config, const lcrc_connect_ops *ops) +static int client_inspect_image(const struct isula_inspect_request *request, struct isula_inspect_response *response, + client_connect_config_t *config, const isula_connect_ops *ops) { int ret = 0; @@ -229,14 +230,14 @@ static int client_inspect_image(const struct lcrc_inspect_request *request, stru */ static int client_inspect(const struct client_arguments *args, const char *filter, container_tree_t *tree_array) { - lcrc_connect_ops *ops = NULL; - struct lcrc_inspect_request request = { 0 }; - struct lcrc_inspect_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_inspect_request request = { 0 }; + struct isula_inspect_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; yajl_val tree = NULL; - response = util_common_calloc_s(sizeof(struct lcrc_inspect_response)); + response = util_common_calloc_s(sizeof(struct isula_inspect_response)); if (response == NULL) { ERROR("Out of memory"); ret = -1; @@ -257,10 +258,10 @@ static int client_inspect(const struct client_arguments *args, const char *filte config = get_connect_config(args); ret = client_inspect_container(&request, response, &config, ops); if (ret == CONTAINER_NOT_FOUND) { - lcrc_inspect_response_free(response); + isula_inspect_response_free(response); response = NULL; - response = util_common_calloc_s(sizeof(struct lcrc_inspect_response)); + response = util_common_calloc_s(sizeof(struct isula_inspect_response)); if (response == NULL) { ERROR("Out of memory"); ret = -1; @@ -295,7 +296,7 @@ static int client_inspect(const struct client_arguments *args, const char *filte tree_array->tree_root = tree; out: - lcrc_inspect_response_free(response); + isula_inspect_response_free(response); return ret; } diff --git a/src/cmd/lcrc/information/inspect.h b/src/cmd/isula/information/inspect.h similarity index 100% rename from src/cmd/lcrc/information/inspect.h rename to src/cmd/isula/information/inspect.h diff --git a/src/cmd/lcrc/information/logs.c b/src/cmd/isula/information/logs.c similarity index 91% rename from src/cmd/lcrc/information/logs.c rename to src/cmd/isula/information/logs.c index 533afabf015106c3882ca92c01ba741b105c0177..a93b53b589deefbc14f9f91658e2b9fb25c37630 100644 --- a/src/cmd/lcrc/information/logs.c +++ b/src/cmd/isula/information/logs.c @@ -27,7 +27,7 @@ #include "logs.h" #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_logs_desc[] = "Fetch the logs of a container"; const char g_cmd_logs_usage[] = "logs [OPTIONS] CONTAINER"; @@ -40,18 +40,18 @@ struct client_arguments g_cmd_logs_args = { static int do_logs(const struct client_arguments *args) { #define DISABLE_ERR_MESSAGE "disable console log" - lcrc_connect_ops *ops = NULL; - struct lcrc_logs_request *request = NULL; - struct lcrc_logs_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_logs_request *request = NULL; + struct isula_logs_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_logs_response)); + response = util_common_calloc_s(sizeof(struct isula_logs_response)); if (response == NULL) { ERROR("Log: Out of memory"); return -1; } - request = util_common_calloc_s(sizeof(struct lcrc_logs_request)); + request = util_common_calloc_s(sizeof(struct isula_logs_request)); if (request == NULL) { ERROR("Out of memory"); ret = -1; @@ -84,8 +84,8 @@ static int do_logs(const struct client_arguments *args) } out: - lcrc_logs_response_free(response); - lcrc_logs_request_free(request); + isula_logs_response_free(response); + isula_logs_request_free(request); return ret; } diff --git a/src/cmd/lcrc/information/logs.h b/src/cmd/isula/information/logs.h similarity index 100% rename from src/cmd/lcrc/information/logs.h rename to src/cmd/isula/information/logs.h diff --git a/src/cmd/lcrc/information/ps.c b/src/cmd/isula/information/ps.c similarity index 92% rename from src/cmd/lcrc/information/ps.c rename to src/cmd/isula/information/ps.c index d6f40c4a7344adc0fb38067eb1d1262604cdafb9..d1ce6593bfaa9cc6de63a99c3e9a514eb0fc0fc3 100644 --- a/src/cmd/lcrc/information/ps.c +++ b/src/cmd/isula/information/ps.c @@ -23,7 +23,7 @@ #include "ps.h" #include "utils.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_list_desc[] = "List containers"; const char g_cmd_list_usage[] = "ps [command options]"; @@ -127,7 +127,7 @@ static int append_field(struct filters *ff, struct filter_field *field) return 0; } -static const char *lcrc_lcrsta2str(Container_Status sta) +static const char *isula_lcrsta2str(Container_Status sta) { if (sta >= CONTAINER_STATUS_MAX_STATE) { return NULL; @@ -135,16 +135,16 @@ static const char *lcrc_lcrsta2str(Container_Status sta) return g_containerstatusstr[sta]; } -static void list_print_quiet(struct lcrc_container_summary_info **info, const size_t size, +static void list_print_quiet(struct isula_container_summary_info **info, const size_t size, const struct lengths *length) { const char *status = NULL; size_t i = 0; for (i = 0; i < size; i++) { - const struct lcrc_container_summary_info *in = NULL; + const struct isula_container_summary_info *in = NULL; in = info[i]; - status = lcrc_lcrsta2str(in->status); + status = isula_lcrsta2str(in->status); if (status == NULL) { continue; } @@ -154,12 +154,12 @@ static void list_print_quiet(struct lcrc_container_summary_info **info, const si } } -static int mix_container_state(const struct lcrc_container_summary_info *in, char *state, size_t len) +static int mix_container_state(const struct isula_container_summary_info *in, char *state, size_t len) { int ret = 0; const char *container_status = NULL; - container_status = lcrc_lcrsta2str(in->status); + container_status = isula_lcrsta2str(in->status); if (container_status == NULL) { (void)strcpy(state, "-"); } else { @@ -169,7 +169,7 @@ static int mix_container_state(const struct lcrc_container_summary_info *in, cha return ret; } -static int handle_running_status(const char *start_at, const struct lcrc_container_summary_info *in, +static int handle_running_status(const char *start_at, const struct isula_container_summary_info *in, char *status, size_t len) { int ret = 0; @@ -195,7 +195,7 @@ out: return ret; } -static int mix_container_status(const struct lcrc_container_summary_info *in, char *status, size_t len) +static int mix_container_status(const struct isula_container_summary_info *in, char *status, size_t len) { int ret = -1; int sret = 0; @@ -359,7 +359,7 @@ static void print_created_field(int64_t created, unsigned int length) printf("%-*s", (int)length, created_duration); } -static void print_basic_container_info_item(const struct lcrc_container_summary_info *in, const char *status, +static void print_basic_container_info_item(const struct isula_container_summary_info *in, const char *status, const char *name, const struct lengths *length) { if (strcmp(name, "ID") == 0) { @@ -391,7 +391,7 @@ static void print_basic_container_info_item(const struct lcrc_container_summary_ } -static void print_extern_container_info_item(const struct lcrc_container_summary_info *in, const char *state, +static void print_extern_container_info_item(const struct isula_container_summary_info *in, const char *state, const char *name, const struct lengths *length) { if (strcmp(name, "ExitCode") == 0) { @@ -414,14 +414,14 @@ static void print_extern_container_info_item(const struct lcrc_container_summary printf("%-*s", (int)length->state_length, state); } } -static void print_container_info_item(const struct lcrc_container_summary_info *in, const char *state, +static void print_container_info_item(const struct isula_container_summary_info *in, const char *state, const char *status, const char *name, const struct lengths *length) { print_basic_container_info_item(in, status, name, length); print_extern_container_info_item(in, state, name, length); } -static void ps_print_container_info(const struct lcrc_container_summary_info *in, const char *state, +static void ps_print_container_info(const struct isula_container_summary_info *in, const char *state, const char *status, const struct lengths *length, const struct filters *ff) { size_t i = should_print_table_header(ff) ? 1 : 0; @@ -436,12 +436,12 @@ static void ps_print_container_info(const struct lcrc_container_summary_info *in printf("\n"); } -static void list_print_table(struct lcrc_container_summary_info **info, const size_t size, +static void list_print_table(struct isula_container_summary_info **info, const size_t size, struct lengths *length, const struct filters *ff) { #define MAX_STATE_LEN 32 #define MAX_STATUS_LEN 100 - const struct lcrc_container_summary_info *in = NULL; + const struct isula_container_summary_info *in = NULL; size_t i = 0; char state[MAX_STATE_LEN] = { 0 }; @@ -476,7 +476,7 @@ static void calculate_str_length(const char *str, unsigned int *length) } } -static void calculate_status_str_length(const struct lcrc_container_summary_info *in, unsigned int *length) +static void calculate_status_str_length(const struct isula_container_summary_info *in, unsigned int *length) { #define MAX_STATUS_LEN 100 size_t len; @@ -490,11 +490,11 @@ static void calculate_status_str_length(const struct lcrc_container_summary_info } } -static void calculate_state_str_length(const struct lcrc_container_summary_info *in, unsigned int *length) +static void calculate_state_str_length(const struct isula_container_summary_info *in, unsigned int *length) { const char *state = NULL; - state = lcrc_lcrsta2str(in->status); + state = isula_lcrsta2str(in->status); if (state != NULL) { size_t len; len = strlen(state); @@ -547,10 +547,10 @@ static void calculate_created_str_length(int64_t created, unsigned int *length) calculate_time_str_length(timebuffer, length); } -static void list_field_width(struct lcrc_container_summary_info **info, const size_t size, struct lengths *l) +static void list_field_width(struct isula_container_summary_info **info, const size_t size, struct lengths *l) { size_t i = 0; - const struct lcrc_container_summary_info *in = NULL; + const struct isula_container_summary_info *in = NULL; if (info == NULL || l == NULL) { return; @@ -596,8 +596,8 @@ static void list_field_width(struct lcrc_container_summary_info **info, const si /* * used by qsort function for comparing container start time */ -static inline int lcrc_container_cmp(struct lcrc_container_summary_info **first, - struct lcrc_container_summary_info **second) +static inline int isula_container_cmp(struct isula_container_summary_info **first, + struct isula_container_summary_info **second) { return strcmp((*second)->startat, (*first)->startat); } @@ -607,9 +607,9 @@ static inline int lcrc_container_cmp(struct lcrc_container_summary_info **first, */ static int client_list(const struct client_arguments *args, const struct filters *ff) { - lcrc_connect_ops *ops = NULL; - struct lcrc_list_request request = { 0 }; - struct lcrc_list_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_list_request request = { 0 }; + struct isula_list_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; struct lengths max_len = { @@ -630,7 +630,7 @@ static int client_list(const struct client_arguments *args, const struct filters .runtime_length = 7, /* RUNTIME */ }; - response = util_common_calloc_s(sizeof(struct lcrc_list_response)); + response = util_common_calloc_s(sizeof(struct isula_list_response)); if (response == NULL) { ERROR("Out of memory"); return -1; @@ -644,8 +644,8 @@ static int client_list(const struct client_arguments *args, const struct filters } if (args->filters != NULL) { - request.filters = lcrc_filters_parse_args((const char **)args->filters, - util_array_len((const char **)(args->filters))); + request.filters = isula_filters_parse_args((const char **)args->filters, + util_array_len((const char **)(args->filters))); if (request.filters == NULL) { ERROR("Failed to parse filters args"); ret = -1; @@ -662,7 +662,7 @@ static int client_list(const struct client_arguments *args, const struct filters } if (response->container_num != 0) qsort(response->container_summary, (size_t)(response->container_num), - sizeof(struct lcrc_container_summary_info *), (int (*)(const void *, const void *))lcrc_container_cmp); + sizeof(struct isula_container_summary_info *), (int (*)(const void *, const void *))isula_container_cmp); if (args->dispname) { list_print_quiet(response->container_summary, response->container_num, &max_len); @@ -672,8 +672,8 @@ static int client_list(const struct client_arguments *args, const struct filters } out: - lcrc_filters_free(request.filters); - lcrc_list_response_free(response); + isula_filters_free(request.filters); + isula_list_response_free(response); return ret; } diff --git a/src/cmd/lcrc/information/ps.h b/src/cmd/isula/information/ps.h similarity index 100% rename from src/cmd/lcrc/information/ps.h rename to src/cmd/isula/information/ps.h diff --git a/src/cmd/lcrc/information/top.c b/src/cmd/isula/information/top.c similarity index 92% rename from src/cmd/lcrc/information/top.c rename to src/cmd/isula/information/top.c index e6456fa0c0c688416bf2208113451d7f4ae3852e..5d48e485bc22a36005f4b9ee28a37790498c7b73 100644 --- a/src/cmd/lcrc/information/top.c +++ b/src/cmd/isula/information/top.c @@ -16,7 +16,7 @@ #include #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "commands.h" #include "console.h" #include "utils.h" @@ -28,7 +28,7 @@ const char g_cmd_top_desc[] = "Display the running processes of a container"; const char g_cmd_top_usage[] = "top [OPTIONS] CONTAINER [ps OPTIONS]"; struct client_arguments g_cmd_top_args = {}; -static void client_top_info_server(const struct lcrc_top_response *response) +static void client_top_info_server(const struct isula_top_response *response) { size_t i; @@ -50,14 +50,14 @@ static void client_top_info_server(const struct lcrc_top_response *response) */ static int client_top(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_top_request request = { 0 }; - struct lcrc_top_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_top_request request = { 0 }; + struct isula_top_response *response = NULL; container_inspect *inspect_data = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_top_response)); + response = util_common_calloc_s(sizeof(struct isula_top_response)); if (response == NULL) { ERROR("TOP: Out of memory"); return -1; @@ -108,7 +108,7 @@ static int client_top(const struct client_arguments *args) out: free_container_inspect(inspect_data); - lcrc_top_response_free(response); + isula_top_response_free(response); return ret; } diff --git a/src/cmd/lcrc/information/top.h b/src/cmd/isula/information/top.h similarity index 100% rename from src/cmd/lcrc/information/top.h rename to src/cmd/isula/information/top.h diff --git a/src/cmd/lcrc/information/version.c b/src/cmd/isula/information/version.c similarity index 86% rename from src/cmd/lcrc/information/version.c rename to src/cmd/isula/information/version.c index f15c3d61b3090537e32000d0fa57b6ebf893e3d5..6b42b2b8a65cedcc386a5586d950d492c34c7346 100644 --- a/src/cmd/lcrc/information/version.c +++ b/src/cmd/isula/information/version.c @@ -19,9 +19,9 @@ #include "arguments.h" #include "log.h" #include "config.h" -#include "lcrc_connect.h" +#include "isula_connect.h" -const char g_cmd_version_desc[] = "Display information about lcrc"; +const char g_cmd_version_desc[] = "Display information about isula"; const char g_cmd_version_usage[] = "version"; struct client_arguments g_cmd_version_args = {}; @@ -30,8 +30,8 @@ static void client_version_info_client() { printf("Client:\n"); printf(" Version:\t%s\n", VERSION); - printf(" Git commit:\t%s\n", LCRD_GIT_COMMIT); - printf(" Built:\t%s\n", LCRD_BUILD_TIME); + printf(" Git commit:\t%s\n", ISULAD_GIT_COMMIT); + printf(" Built:\t%s\n", ISULAD_BUILD_TIME); printf("\n"); } static void client_version_info_oci_config() @@ -41,7 +41,7 @@ static void client_version_info_oci_config() printf(" Default file:\t%s\n", OCICONFIG_PATH); printf("\n"); } -static void client_version_info_server(const struct lcrc_version_response *response) +static void client_version_info_server(const struct isula_version_response *response) { printf("Server:\n"); printf(" Version:\t%s\n", response->version ? response->version : ""); @@ -52,13 +52,13 @@ static void client_version_info_server(const struct lcrc_version_response *respo static int client_version(const struct client_arguments *args) { - lcrc_connect_ops *ops = NULL; - struct lcrc_version_request request = { 0 }; - struct lcrc_version_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_version_request request = { 0 }; + struct isula_version_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_version_response)); + response = util_common_calloc_s(sizeof(struct isula_version_response)); if (response == NULL) { ERROR("Version: Out of memory"); return -1; @@ -83,7 +83,7 @@ static int client_version(const struct client_arguments *args) client_version_info_server(response); client_version_info_oci_config(); out: - lcrc_version_response_free(response); + isula_version_response_free(response); return ret; } diff --git a/src/cmd/lcrc/information/version.h b/src/cmd/isula/information/version.h similarity index 100% rename from src/cmd/lcrc/information/version.h rename to src/cmd/isula/information/version.h diff --git a/src/cmd/lcrc/information/wait.c b/src/cmd/isula/information/wait.c similarity index 93% rename from src/cmd/lcrc/information/wait.c rename to src/cmd/isula/information/wait.c index 1286eae8eb80dba482a72554686ce3c89261bfea..e66dffa2dcb480655b7ef32dadb5f2e556faf381 100644 --- a/src/cmd/lcrc/information/wait.c +++ b/src/cmd/isula/information/wait.c @@ -16,7 +16,7 @@ #include "wait.h" #include "arguments.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" const char g_cmd_wait_desc[] = "Block until one or more containers stop, then print their exit codes"; const char g_cmd_wait_usage[] = "wait [OPTIONS] CONTAINER [CONTAINER...]"; @@ -28,13 +28,13 @@ struct client_arguments g_cmd_wait_args = {}; */ int client_wait(const struct client_arguments *args, unsigned int *exit_code) { - lcrc_connect_ops *ops = NULL; - struct lcrc_wait_request request = { 0 }; - struct lcrc_wait_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_wait_request request = { 0 }; + struct isula_wait_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_wait_response)); + response = util_common_calloc_s(sizeof(struct isula_wait_response)); if (response == NULL) { ERROR("Wait: Out of memory"); return -1; @@ -70,7 +70,7 @@ int client_wait(const struct client_arguments *args, unsigned int *exit_code) } out: - lcrc_wait_response_free(response); + isula_wait_response_free(response); return ret; } diff --git a/src/cmd/lcrc/information/wait.h b/src/cmd/isula/information/wait.h similarity index 100% rename from src/cmd/lcrc/information/wait.h rename to src/cmd/isula/information/wait.h diff --git a/src/cmd/lcrc/main.c b/src/cmd/isula/main.c similarity index 98% rename from src/cmd/lcrc/main.c rename to src/cmd/isula/main.c index 8e32e70165f5ca88add84a2c5f4b9127a434139b..a7b94ea7cb451b35c3a5e507fddacb7422f9ead0 100644 --- a/src/cmd/lcrc/main.c +++ b/src/cmd/isula/main.c @@ -10,7 +10,7 @@ * See the Mulan PSL v1 for more details. * Author: lifeng * Create: 2018-11-08 - * Description: provide init process of lcrc + * Description: provide init process of isula ******************************************************************************/ #include @@ -45,7 +45,7 @@ #include "pull.h" #include "login.h" #include "logout.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "version.h" #include "rename.h" #include "utils.h" diff --git a/src/cmd/lcrc/extend/CMakeLists.txt b/src/cmd/isula/stream/CMakeLists.txt similarity index 35% rename from src/cmd/lcrc/extend/CMakeLists.txt rename to src/cmd/isula/stream/CMakeLists.txt index d416df6b5a482689cb08d2c005ea83ee46b17372..332435bc914a2058e88791715d16921335b139ae 100644 --- a/src/cmd/lcrc/extend/CMakeLists.txt +++ b/src/cmd/isula/stream/CMakeLists.txt @@ -1,7 +1,7 @@ # get current directory sources files -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} lcrc_extend_srcs) +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} isula_stream_srcs) -set(LCRC_EXTEND_SRCS - ${lcrc_extend_srcs} +set(ISULA_STREAM_SRCS + ${isula_stream_srcs} PARENT_SCOPE ) diff --git a/src/cmd/lcrc/stream/attach.c b/src/cmd/isula/stream/attach.c similarity index 92% rename from src/cmd/lcrc/stream/attach.c rename to src/cmd/isula/stream/attach.c index 0033f85fe19a1217f331d453025b116c994f7c6e..d599d9bae41de061488d7474fc4338d3d41d59c0 100644 --- a/src/cmd/lcrc/stream/attach.c +++ b/src/cmd/isula/stream/attach.c @@ -22,7 +22,7 @@ #include "arguments.h" #include "exec.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "console.h" #include "utils.h" #include "attach.h" @@ -58,13 +58,13 @@ static int check_tty(bool tty, struct termios *oldtios, bool *reset_tty) int inspect_container(const struct client_arguments *args, container_inspect **inspect_data) { int ret = 0; - struct lcrc_inspect_request inspect_request = { 0 }; - struct lcrc_inspect_response *inspect_response = NULL; + struct isula_inspect_request inspect_request = { 0 }; + struct isula_inspect_response *inspect_response = NULL; client_connect_config_t config = { 0 }; - lcrc_connect_ops *ops = NULL; + isula_connect_ops *ops = NULL; parser_error perr = NULL; - inspect_response = util_common_calloc_s(sizeof(struct lcrc_inspect_response)); + inspect_response = util_common_calloc_s(sizeof(struct isula_inspect_response)); if (inspect_response == NULL) { COMMAND_ERROR("Out of memory"); return -1; @@ -100,7 +100,7 @@ int inspect_container(const struct client_arguments *args, container_inspect **i } out: - lcrc_inspect_response_free(inspect_response); + isula_inspect_response_free(inspect_response); free(perr); return ret; } @@ -194,9 +194,9 @@ struct wait_thread_arg { static void *container_wait_thread_main(void *thread_arg) { int ret = -1; - lcrc_connect_ops *ops = NULL; - struct lcrc_wait_request request = { 0 }; - struct lcrc_wait_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_wait_request request = { 0 }; + struct isula_wait_response *response = NULL; struct wait_thread_arg *arg = (struct wait_thread_arg *)thread_arg; client_connect_config_t config = { 0 }; @@ -208,7 +208,7 @@ static void *container_wait_thread_main(void *thread_arg) } prctl(PR_SET_NAME, "AttachWaitThread"); - response = util_common_calloc_s(sizeof(struct lcrc_wait_response)); + response = util_common_calloc_s(sizeof(struct isula_wait_response)); if (response == NULL) { ERROR("Wait: Out of memory"); goto cleanup; @@ -240,7 +240,7 @@ cleanup: if (ret == 0) { (void)sem_post(arg->sem_exited); } - lcrc_wait_response_free(response); + isula_wait_response_free(response); free(arg); return NULL; } @@ -279,9 +279,9 @@ static int container_wait_thread(struct client_arguments *args, uint32_t *exit_c static int client_attach(struct client_arguments *args, uint32_t *exit_code) { - lcrc_connect_ops *ops = NULL; - struct lcrc_attach_request request = { 0 }; - struct lcrc_attach_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_attach_request request = { 0 }; + struct isula_attach_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; struct termios oldtios = { 0 }; @@ -309,7 +309,7 @@ static int client_attach(struct client_arguments *args, uint32_t *exit_code) goto out; } - response = util_common_calloc_s(sizeof(struct lcrc_attach_response)); + response = util_common_calloc_s(sizeof(struct isula_attach_response)); if (response == NULL) { ERROR("Attach: Out of memory"); ret = ECOMMON; @@ -357,7 +357,7 @@ static int client_attach(struct client_arguments *args, uint32_t *exit_code) out: (void)sem_destroy(&sem_exited); free_container_inspect(inspect_data); - lcrc_attach_response_free(response); + isula_attach_response_free(response); if (reset_tty) { if (tcsetattr(0, TCSAFLUSH, &oldtios) < 0) { ERROR("Failed to reset terminal properties"); diff --git a/src/cmd/lcrc/stream/attach.h b/src/cmd/isula/stream/attach.h similarity index 100% rename from src/cmd/lcrc/stream/attach.h rename to src/cmd/isula/stream/attach.h diff --git a/src/cmd/lcrc/stream/cp.c b/src/cmd/isula/stream/cp.c similarity index 90% rename from src/cmd/lcrc/stream/cp.c rename to src/cmd/isula/stream/cp.c index 3f0a6e4c2430dd6c45215a24345c94f7c6c18a5f..ecccba154f6632adb7a251d7dc6d7e27b86e6c53 100644 --- a/src/cmd/lcrc/stream/cp.c +++ b/src/cmd/isula/stream/cp.c @@ -22,8 +22,8 @@ #include "arguments.h" #include "log.h" #include "path.h" -#include "lcrc_connect.h" -#include "lcrdtar.h" +#include "isula_connect.h" +#include "libtar.h" #define FromContainer 0x01u #define ToContainer 0x10u @@ -52,10 +52,10 @@ static void print_copy_from_container_error(const char *ops_err, const char *arc const struct client_arguments *args) { if (ops_err != NULL) { - if (strcmp(ops_err, errno_to_error_message(LCRD_ERR_CONNECT)) == 0) { + if (strcmp(ops_err, errno_to_error_message(ISULAD_ERR_CONNECT)) == 0) { COMMAND_ERROR("%s", ops_err); } else { - client_print_error(0, LCRD_ERR_EXEC, ops_err); + client_print_error(0, ISULAD_ERR_EXEC, ops_err); } } else if (archive_err != NULL) { COMMAND_ERROR("Failed exact archive: %s", archive_err); @@ -67,9 +67,9 @@ static void print_copy_from_container_error(const char *ops_err, const char *arc static int client_copy_from_container(const struct client_arguments *args, const char *id, const char *srcpath, const char *destpath) { - lcrc_connect_ops *ops = NULL; - struct lcrc_copy_from_container_request request = { 0 }; - struct lcrc_copy_from_container_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_copy_from_container_request request = { 0 }; + struct isula_copy_from_container_response *response = NULL; int ret = 0; int nret = 0; char *archive_err = NULL; @@ -84,7 +84,7 @@ static int client_copy_from_container(const struct client_arguments *args, const return -1; } - response = util_common_calloc_s(sizeof(struct lcrc_copy_from_container_response)); + response = util_common_calloc_s(sizeof(struct isula_copy_from_container_response)); if (response == NULL) { ERROR("Event: Out of memory"); return -1; @@ -132,14 +132,14 @@ out: free(archive_err); free(ops_err); free_archive_copy_info(srcinfo); - lcrc_copy_from_container_response_free(response); + isula_copy_from_container_response_free(response); return ret; } -static void print_copy_to_container_error(const struct lcrc_copy_to_container_response *response, +static void print_copy_to_container_error(const struct isula_copy_to_container_response *response, const char *archive_err, int ret, const struct client_arguments *args) { - if (response->cc != LCRD_SUCCESS || response->errmsg != NULL || response->server_errono != 0) { + if (response->cc != ISULAD_SUCCESS || response->errmsg != NULL || response->server_errono != 0) { client_print_error(response->cc, response->server_errono, response->errmsg); } else if (archive_err) { COMMAND_ERROR("Failed to archive: %s", archive_err); @@ -151,9 +151,9 @@ static void print_copy_to_container_error(const struct lcrc_copy_to_container_re static int client_copy_to_container(const struct client_arguments *args, const char *id, const char *srcpath, const char *destpath) { - lcrc_connect_ops *ops = NULL; - struct lcrc_copy_to_container_request request = { 0 }; - struct lcrc_copy_to_container_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_copy_to_container_request request = { 0 }; + struct isula_copy_to_container_response *response = NULL; int ret = 0; int nret = 0; char *archive_err = NULL; @@ -168,7 +168,7 @@ static int client_copy_to_container(const struct client_arguments *args, const c return -1; } - response = util_common_calloc_s(sizeof(struct lcrc_copy_to_container_response)); + response = util_common_calloc_s(sizeof(struct isula_copy_to_container_response)); if (response == NULL) { ERROR("Event: Out of memory"); return -1; @@ -219,7 +219,7 @@ out: free(resolved); free(archive_err); free_archive_copy_info(srcinfo); - lcrc_copy_to_container_response_free(response); + isula_copy_to_container_response_free(response); return ret; } diff --git a/src/cmd/lcrc/stream/cp.h b/src/cmd/isula/stream/cp.h similarity index 100% rename from src/cmd/lcrc/stream/cp.h rename to src/cmd/isula/stream/cp.h diff --git a/src/cmd/lcrc/stream/exec.c b/src/cmd/isula/stream/exec.c similarity index 94% rename from src/cmd/lcrc/stream/exec.c rename to src/cmd/isula/stream/exec.c index 2b6322caf3572a3bc13d39df79736952ad81326f..e9c78ee7529536bc792406ff41ba8b4318229cb2 100644 --- a/src/cmd/lcrc/stream/exec.c +++ b/src/cmd/isula/stream/exec.c @@ -24,7 +24,7 @@ #include "arguments.h" #include "exec.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "console.h" #include "utils.h" #include "commands.h" @@ -41,13 +41,13 @@ struct client_arguments g_cmd_exec_args = {}; static int client_exec(const struct client_arguments *args, const struct command_fifo_config *fifos, uint32_t *exit_code) { - lcrc_connect_ops *ops = NULL; - struct lcrc_exec_request request = { 0 }; - struct lcrc_exec_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_exec_request request = { 0 }; + struct isula_exec_response *response = NULL; client_connect_config_t config = { 0 }; int ret = 0; - response = util_common_calloc_s(sizeof(struct lcrc_exec_response)); + response = util_common_calloc_s(sizeof(struct isula_exec_response)); if (response == NULL) { ERROR("Out of memory"); return ECOMMON; @@ -93,7 +93,7 @@ out: *exit_code = response->exit_code; } - lcrc_exec_response_free(response); + isula_exec_response_free(response); return ret; } @@ -222,9 +222,9 @@ static int remote_cmd_exec_setup_tty(const struct client_arguments *args, bool * static int remote_cmd_exec(const struct client_arguments *args, uint32_t *exit_code) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_exec_request request = { 0 }; - struct lcrc_exec_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_exec_request request = { 0 }; + struct isula_exec_response *response = NULL; client_connect_config_t config = { 0 }; struct termios oldtios; bool reset_tty = false; @@ -236,7 +236,7 @@ static int remote_cmd_exec(const struct client_arguments *args, uint32_t *exit_c return ECOMMON; } - response = util_common_calloc_s(sizeof(struct lcrc_exec_response)); + response = util_common_calloc_s(sizeof(struct isula_exec_response)); if (response == NULL) { ERROR("Out of memory"); return ECOMMON; @@ -286,7 +286,7 @@ out: if (response->exit_code != 0) { *exit_code = response->exit_code; } - lcrc_exec_response_free(response); + isula_exec_response_free(response); return ret; } @@ -341,9 +341,9 @@ out: static int do_resize_exec_console(const struct client_arguments *args, unsigned int height, unsigned int width) { int ret = 0; - lcrc_connect_ops *ops = NULL; - struct lcrc_resize_request request = { 0 }; - struct lcrc_resize_response *response = NULL; + isula_connect_ops *ops = NULL; + struct isula_resize_request request = { 0 }; + struct isula_resize_response *response = NULL; client_connect_config_t config = { 0 }; ops = get_connect_client_ops(); @@ -358,7 +358,7 @@ static int do_resize_exec_console(const struct client_arguments *args, unsigned request.height = height; request.width = width; - response = util_common_calloc_s(sizeof(struct lcrc_resize_response)); + response = util_common_calloc_s(sizeof(struct isula_resize_response)); if (response == NULL) { ERROR("Out of memory"); ret = -1; @@ -373,7 +373,7 @@ static int do_resize_exec_console(const struct client_arguments *args, unsigned } out: - lcrc_resize_response_free(response); + isula_resize_response_free(response); return ret; } diff --git a/src/cmd/lcrc/stream/exec.h b/src/cmd/isula/stream/exec.h similarity index 100% rename from src/cmd/lcrc/stream/exec.h rename to src/cmd/isula/stream/exec.h diff --git a/src/cmd/lcrd/CMakeLists.txt b/src/cmd/isulad/CMakeLists.txt similarity index 47% rename from src/cmd/lcrd/CMakeLists.txt rename to src/cmd/isulad/CMakeLists.txt index 19e21a973834b6a961d335e2886648dc5b329612..e5eb49cd0b0645273a48721e17a5cc7cebe4768c 100644 --- a/src/cmd/lcrd/CMakeLists.txt +++ b/src/cmd/isulad/CMakeLists.txt @@ -1,5 +1,5 @@ # get current directory sources files aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} top_srcs) -set(CMD_LCRD_SRCS ${top_srcs} PARENT_SCOPE) -set(CMD_LCRD_INCS ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) +set(CMD_ISULAD_SRCS ${top_srcs} PARENT_SCOPE) +set(CMD_ISULAD_INCS ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) diff --git a/src/cmd/lcrd/arguments.c b/src/cmd/isulad/arguments.c similarity index 95% rename from src/cmd/lcrd/arguments.c rename to src/cmd/isulad/arguments.c index 4105ae4fa1a707173cd9ed7b5b26aac24a2d66d8..d4cab30144c7343877b5ac9011a0daca76177198 100644 --- a/src/cmd/lcrd/arguments.c +++ b/src/cmd/isulad/arguments.c @@ -22,9 +22,9 @@ #include "utils.h" #include "arguments.h" #include "commands.h" -#include "liblcrd.h" +#include "libisulad.h" #include "constants.h" -#include "lcrd_config.h" +#include "isulad_config.h" static int set_daemon_default_tls_options(struct service_arguments *args) { @@ -98,7 +98,7 @@ int service_arguments_init(struct service_arguments *args) args->argc = 0; args->argv = NULL; - args->progname = util_strdup_s("lcrd"); + args->progname = util_strdup_s("isulad"); args->quiet = true; args->help = false; args->version = false; @@ -108,9 +108,9 @@ int service_arguments_init(struct service_arguments *args) goto free_out; } args->json_confs->engine = util_strdup_s("lcr"); - args->json_confs->group = util_strdup_s("lcrd"); - args->json_confs->graph = util_strdup_s(LCRD_ROOT_PATH); - args->json_confs->state = util_strdup_s(LCRD_STATE_PATH); + args->json_confs->group = util_strdup_s("isulad"); + args->json_confs->graph = util_strdup_s(ISULAD_ROOT_PATH); + args->json_confs->state = util_strdup_s(ISULAD_STATE_PATH); args->json_confs->log_level = util_strdup_s("INFO"); args->json_confs->log_driver = util_strdup_s("file"); args->json_confs->log_opts = (json_map_string_string *)util_common_calloc_s(sizeof(json_map_string_string)); @@ -136,7 +136,7 @@ int service_arguments_init(struct service_arguments *args) args->max_file = 7; args->max_size = 1024 * 1024; - args->json_confs->pidfile = util_strdup_s("/var/run/lcrd.pid"); + args->json_confs->pidfile = util_strdup_s("/var/run/isulad.pid"); args->json_confs->storage_driver = util_strdup_s("overlay2"); args->json_confs->native_umask = util_strdup_s(UMASK_SECURE); args->json_confs->image_service = true; diff --git a/src/cmd/lcrd/arguments.h b/src/cmd/isulad/arguments.h similarity index 95% rename from src/cmd/lcrd/arguments.h rename to src/cmd/isulad/arguments.h index d1e37ef665addb6ec0b4f4b69b1a773314baeaad..9df04e7484990d32318ca2cdd942f3c4bc7c12a2 100644 --- a/src/cmd/lcrd/arguments.h +++ b/src/cmd/isulad/arguments.h @@ -12,8 +12,8 @@ * Create: 2017-11-22 * Description: provide container server arguments definition ******************************************************************************/ -#ifndef __LCRD_ARGUMENTS_H -#define __LCRD_ARGUMENTS_H +#ifndef __ISULAD_ARGUMENTS_H +#define __ISULAD_ARGUMENTS_H #include #include @@ -68,5 +68,5 @@ int service_arguments_init(struct service_arguments *args); void service_arguments_free(struct service_arguments *args); int server_log_opt_parser(struct service_arguments *args, const char *option); -#endif /* __LCRD_ARGUMENTS_H */ +#endif /* __ISULAD_ARGUMENTS_H */ diff --git a/src/cmd/lcrd/commands.c b/src/cmd/isulad/commands.c similarity index 94% rename from src/cmd/lcrd/commands.c rename to src/cmd/isulad/commands.c index 813a8555d208bd0ce8c84c1e12ba9959c1bcede4..6f729485b870bd3c8d67851edde4da50a9ae6a9a 100644 --- a/src/cmd/lcrd/commands.c +++ b/src/cmd/isulad/commands.c @@ -21,7 +21,7 @@ #include "config.h" #include "log.h" #include "path.h" -#include "liblcrd.h" +#include "libisulad.h" #ifdef ENABLE_OCI_IMAGE #include "driver.h" @@ -31,12 +31,12 @@ #include "constants.h" #include "isulad_daemon_configs.h" -const char lcrd_desc[] = "GLOBAL OPTIONS:"; -const char lcrd_usage[] = "[global options]"; +const char isulad_desc[] = "GLOBAL OPTIONS:"; +const char isulad_usage[] = "[global options]"; void print_version() { - printf("Version %s, commit %s\n", VERSION, LCRD_GIT_COMMIT); + printf("Version %s, commit %s\n", VERSION, ISULAD_GIT_COMMIT); } int server_callback_log_opt(command_option_t *option, const char *value) @@ -60,8 +60,9 @@ out: return ret; } -static void command_init_lcrd(command_t *self, command_option_t *options, int options_len, int argc, const char **argv, - const char *description, const char *usage) +static void command_init_isulad(command_t *self, command_option_t *options, int options_len, int argc, + const char **argv, + const char *description, const char *usage) { self->name = argv[0]; self->argc = argc - 1; @@ -70,16 +71,16 @@ static void command_init_lcrd(command_t *self, command_option_t *options, int op self->description = description; self->options = options; self->option_count = options_len; - self->type = "lcrd"; + self->type = "isulad"; } // Tries to execute a command in the command list. int parse_args(struct service_arguments *args, int argc, const char **argv) { command_t cmd = { 0 }; - struct command_option options[] = { LCRD_OPTIONS(args) }; - command_init_lcrd(&cmd, options, sizeof(options) / sizeof(options[0]), argc, (const char **)argv, lcrd_desc, - lcrd_usage); + struct command_option options[] = { ISULAD_OPTIONS(args) }; + command_init_isulad(&cmd, options, sizeof(options) / sizeof(options[0]), argc, (const char **)argv, isulad_desc, + isulad_usage); if (command_parse_args(&cmd, &args->argc, &args->argv)) { exit(EINVALIDARGS); } @@ -139,7 +140,7 @@ static int check_args_hosts_conf(const char **array, size_t size) /* validate unix/tcp socket name */ for (i = 0; i < size; i++) { if (!util_validate_socket(array[i])) { - lcrd_set_error_message("Invalid socket name: %s", array[i]); + isulad_set_error_message("Invalid socket name: %s", array[i]); ret = -1; goto out; } @@ -340,7 +341,7 @@ static int check_hosts_specified_conflict(const struct service_arguments *args) ret = -1; goto out; } - COMMAND_ERROR("unable to configure the lcrd with file %s: " + COMMAND_ERROR("unable to configure the isulad with file %s: " "the following directives are specified both as a flag and in the configuration file: hosts: " "(from flag: [%s], from file: [%s])", ISULAD_DAEMON_JSON_CONF_FILE, flag_hosts, file_hosts); @@ -523,7 +524,7 @@ static int check_conf_default_ulimit(const struct service_arguments *args) goto out; } - COMMAND_ERROR("unable to configure the lcrd with file %s: " + COMMAND_ERROR("unable to configure the isulad with file %s: " "the following directives are specified both as a flag and in the configuration file: " "default-ulimits: (from flag: %s, from file: %s)", ISULAD_DAEMON_JSON_CONF_FILE, flag_def_ulimit, file_def_ulimit); diff --git a/src/cmd/lcrd/commands.h b/src/cmd/isulad/commands.h similarity index 95% rename from src/cmd/lcrd/commands.h rename to src/cmd/isulad/commands.h index 3f99805b5f49a5cf68c171159545309789f442d2..ce1d2033157f86f9b47551b18a190f71731917e2 100644 --- a/src/cmd/lcrd/commands.h +++ b/src/cmd/isulad/commands.h @@ -12,8 +12,8 @@ * Create: 2017-11-22 * Description: provide container commands definition ******************************************************************************/ -#ifndef __LCRD_COMMAND_H -#define __LCRD_COMMAND_H +#ifndef __ISULAD_COMMAND_H +#define __ISULAD_COMMAND_H #include "arguments.h" void print_common_help(); @@ -21,14 +21,14 @@ void print_version(); // Default help command if implementation doesn't prvide one int commmand_default_help(const char * const program_name, int argc, char **argv); -int command_lcrd_valid_socket(command_option_t *option, const char *arg); +int command_isulad_valid_socket(command_option_t *option, const char *arg); int parse_args(struct service_arguments *args, int argc, const char **argv); int check_args(struct service_arguments *args); int update_hosts(struct service_arguments *args); int update_default_ulimit(struct service_arguments *args); -#define LCRD_OPTIONS(cmdargs) \ +#define ISULAD_OPTIONS(cmdargs) \ { CMD_OPT_TYPE_CALLBACK, false, "host", 'H', &(cmdargs)->hosts, \ "The socket name used to create gRPC server", command_valid_socket_append_array }, \ { CMD_OPT_TYPE_STRING_DUP, false, "pidfile", 'p', &(cmdargs)->json_confs->pidfile, \ @@ -37,7 +37,7 @@ int update_default_ulimit(struct service_arguments *args); { CMD_OPT_TYPE_STRING_DUP, false, "hook-spec", 0, &(cmdargs)->json_confs->hook_spec, \ "Default hook spec file applied to all containers", NULL }, \ { CMD_OPT_TYPE_STRING_DUP, false, "graph", 'g', &(cmdargs)->json_confs->graph, \ - "Root directory of the LCRD runtime", NULL }, \ + "Root directory of the iSulad runtime", NULL }, \ { CMD_OPT_TYPE_STRING_DUP, false, "state", 'S', &(cmdargs)->json_confs->state, \ "Root directory for execution state files", NULL }, \ { CMD_OPT_TYPE_STRING_DUP, false, "start-timeout", 0, &(cmdargs)->json_confs->start_timeout, \ @@ -52,7 +52,7 @@ int update_default_ulimit(struct service_arguments *args); server_callback_log_opt }, \ { CMD_OPT_TYPE_BOOL, false, "version", 'V', &(cmdargs)->version, "Print the version", NULL }, \ { CMD_OPT_TYPE_STRING_DUP, false, "group", 'G', &(cmdargs)->json_confs->group, \ - "Group for the unix socket(default is lcrd)", NULL }, \ + "Group for the unix socket(default is isulad)", NULL }, \ { CMD_OPT_TYPE_STRING_DUP, false, "storage-driver", 0, &(cmdargs)->json_confs->storage_driver, \ "Storage driver to use(default overlay2)", NULL }, \ { CMD_OPT_TYPE_CALLBACK, false, "storage-opt", 's', &(cmdargs)->json_confs->storage_opts, \ @@ -72,7 +72,7 @@ int update_default_ulimit(struct service_arguments *args); { CMD_OPT_TYPE_STRING_DUP, false, "image-opt-timeout", 0, &(cmdargs)->json_confs->image_opt_timeout, \ "Max timeout(default 5m) for image operation", NULL }, \ { CMD_OPT_TYPE_STRING_DUP, false, "image_server_sock_addr", 0, &(cmdargs)->json_confs->image_server_sock_addr, \ - "Set isula image remote server socket address, Default: unix:///var/run/lcrd/isula_image.sock", NULL }, \ + "Set isula image remote server socket address, Default: unix:///var/run/isulad/isula_image.sock", NULL }, \ { CMD_OPT_TYPE_STRING_DUP, false, "network-plugin", 0, &(cmdargs)->json_confs->network_plugin, \ "Set network plugin, default is null, suppport null and cni", NULL }, \ { CMD_OPT_TYPE_STRING_DUP, false, "cni-bin-dir", 0, &(cmdargs)->json_confs->cni_bin_dir, \ diff --git a/src/cmd/lcrd/main.c b/src/cmd/isulad/main.c similarity index 92% rename from src/cmd/lcrd/main.c rename to src/cmd/isulad/main.c index 25ad8a798adeec73339765640c4e8909ee308d77..2ecd6b0cb97f69648090f66c124b40627be8f1af 100644 --- a/src/cmd/lcrd/main.c +++ b/src/cmd/isulad/main.c @@ -10,7 +10,7 @@ * See the Mulan PSL v1 for more details. * Author: lifeng * Create: 2017-11-22 - * Description: provide init process of lcrd + * Description: provide init process of isulad ******************************************************************************/ #include @@ -37,13 +37,13 @@ #endif #include "constants.h" -#include "liblcrd.h" +#include "libisulad.h" #include "collector.h" #include "commands.h" #include "log.h" #include "engine.h" #include "utils.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "image.h" #include "sysinfo.h" #include "verify.h" @@ -75,7 +75,7 @@ sem_t g_daemon_shutdown_sem; static int create_client_run_path(const char *group) { int ret = 0; - const char *rundir = "/var/run/lcrc"; + const char *rundir = "/var/run/isula"; if (group == NULL) { return -1; } @@ -178,7 +178,7 @@ static void umount_daemon_mntpoint() { char *mntdir = NULL; - mntdir = conf_get_lcrd_mount_rootfs(); + mntdir = conf_get_isulad_mount_rootfs(); if (mntdir == NULL) { ERROR("Out of memory"); } else { @@ -211,9 +211,9 @@ static void clean_residual_files() free(checked_flag); /* remove pid file */ - fname = conf_get_lcrd_pidfile(); + fname = conf_get_isulad_pidfile(); if (fname == NULL) { - ERROR("Failed to get LCRD pid file path"); + ERROR("Failed to get isulad pid file path"); } else if (unlink(fname) && errno != ENOENT) { WARN("Unlink file: %s error: %s", fname, strerror(errno)); } @@ -275,7 +275,7 @@ static int ignore_signals() struct sigaction sa; /* - * Ignore SIGHUP so lcrd process still exists after + * Ignore SIGHUP so isulad process still exists after * terminal die. */ (void)memset(&sa, 0, sizeof(struct sigaction)); @@ -354,14 +354,14 @@ static int daemonize() umask(0000); - if (lcrd_server_conf_rdlock()) { + if (isulad_server_conf_rdlock()) { ret = -1; goto out; } args = conf_get_server_conf(); if (args == NULL) { - ERROR("Failed to get lcrd server config"); + ERROR("Failed to get isulad server config"); ret = -1; goto unlock_out; } @@ -380,7 +380,7 @@ static int daemonize() ret = -1; } unlock_out: - if (lcrd_server_conf_unlock()) { + if (isulad_server_conf_unlock()) { ret = -1; } out: @@ -394,7 +394,7 @@ int check_and_save_pid(const char *fn) int ret = 0; int len = 0; struct flock lk; - char pidbuf[LCRD_NUMSTRLEN64] = { 0 }; + char pidbuf[ISULAD_NUMSTRLEN64] = { 0 }; if (fn == NULL) { ERROR("Input error"); @@ -419,7 +419,7 @@ int check_and_save_pid(const char *fn) lk.l_len = 0; if (fcntl(fd, F_SETLK, &lk) != 0) { /* another daemonize instance is already running, don't start up */ - COMMAND_ERROR("Pid file found, ensure lcrd is not running or delete pid file %s" + COMMAND_ERROR("Pid file found, ensure isulad is not running or delete pid file %s" " or please specify another pid file", fn); ret = -1; goto out; @@ -451,7 +451,7 @@ out: return ret; } -int check_and_set_default_lcrd_log_file(struct service_arguments *args) +int check_and_set_default_isulad_log_file(struct service_arguments *args) { if (args == NULL) { return -1; @@ -482,7 +482,7 @@ static int set_parent_mount_dir(struct service_arguments *args) goto out; } if (strlen(args->json_confs->graph) > (SIZE_MAX - strlen("/mnt/rootfs")) - 1) { - ERROR("Root directory of the LCRD runtime is too long"); + ERROR("Root directory of the isulad runtime is too long"); goto out; } len = strlen(args->json_confs->graph) + strlen("/mnt/rootfs") + 1; @@ -547,7 +547,7 @@ static int parse_hook_spec(const char *specfile, oci_runtime_spec_hooks **phooks hooks = oci_runtime_spec_hooks_parse_file(specfile, NULL, &err); if (hooks == NULL) { ERROR("Failed to parse hook-spec file: %s", err); - lcrd_set_error_message("Invalid hook-spec file(%s) in server conf.", specfile); + isulad_set_error_message("Invalid hook-spec file(%s) in server conf.", specfile); ret = -1; goto out; } @@ -728,7 +728,7 @@ static int update_set_default_log_file(struct service_arguments *args) args->quiet = false; } - if (check_and_set_default_lcrd_log_file(args)) { + if (check_and_set_default_isulad_log_file(args)) { ret = -1; goto out; } @@ -911,16 +911,16 @@ static int init_log_gather_thread(const char *log_full_path, struct log_config * return log_gather_exitcode; } -static int lcrd_get_log_path(char **log_full_path, char **fifo_full_path) +static int isulad_get_log_path(char **log_full_path, char **fifo_full_path) { int ret = 0; - *log_full_path = conf_get_lcrd_log_file(); + *log_full_path = conf_get_isulad_log_file(); if (*log_full_path == NULL) { ret = -1; goto out; } - *fifo_full_path = conf_get_lcrd_log_gather_fifo_path(); + *fifo_full_path = conf_get_isulad_log_gather_fifo_path(); if (*fifo_full_path == NULL) { ret = -1; goto out; @@ -929,8 +929,8 @@ out: return ret; } -static int lcrd_server_init_log(const struct service_arguments *args, const char *log_full_path, - const char *fifo_full_path) +static int isulad_server_init_log(const struct service_arguments *args, const char *log_full_path, + const char *fifo_full_path) { #define FIFO_DRIVER "fifo" int ret = -1; @@ -964,8 +964,8 @@ out: return ret; } -static int lcrd_server_pre_init(const struct service_arguments *args, const char *log_full_path, - const char *fifo_full_path) +static int isulad_server_pre_init(const struct service_arguments *args, const char *log_full_path, + const char *fifo_full_path) { int ret = 0; @@ -975,7 +975,7 @@ static int lcrd_server_pre_init(const struct service_arguments *args, const char goto out; } - if (lcrd_server_init_log(args, log_full_path, fifo_full_path) != 0) { + if (isulad_server_init_log(args, log_full_path, fifo_full_path) != 0) { ret = -1; goto out; } @@ -1016,28 +1016,28 @@ out: return ret; } -static int lcrd_server_init_common() +static int isulad_server_init_common() { int ret = -1; struct service_arguments *args = NULL; char *log_full_path = NULL; char *fifo_full_path = NULL; - if (lcrd_get_log_path(&log_full_path, &fifo_full_path) != 0) { + if (isulad_get_log_path(&log_full_path, &fifo_full_path) != 0) { goto out; } - if (lcrd_server_conf_rdlock()) { + if (isulad_server_conf_rdlock()) { goto out; } args = conf_get_server_conf(); if (args == NULL) { - ERROR("Failed to get lcrd server config"); + ERROR("Failed to get isulad server config"); goto unlock_out; } - if (lcrd_server_pre_init(args, log_full_path, fifo_full_path) != 0) { + if (isulad_server_pre_init(args, log_full_path, fifo_full_path) != 0) { goto unlock_out; } @@ -1063,7 +1063,7 @@ static int lcrd_server_init_common() ret = 0; unlock_out: - if (lcrd_server_conf_unlock()) { + if (isulad_server_conf_unlock()) { ret = -1; goto out; } @@ -1153,18 +1153,18 @@ out: return ret; } -static int lcrd_server_init_service() +static int isulad_server_init_service() { int ret = -1; struct service_arguments *args = NULL; - if (lcrd_server_conf_rdlock()) { + if (isulad_server_conf_rdlock()) { goto out; } args = conf_get_server_conf(); if (args == NULL) { - ERROR("Failed to get lcrd server config"); + ERROR("Failed to get isulad server config"); goto unlock_out; } #ifdef GRPC_CONNECTOR @@ -1184,7 +1184,7 @@ static int lcrd_server_init_service() } unlock_out: - if (lcrd_server_conf_unlock()) { + if (isulad_server_conf_unlock()) { ret = -1; goto out; } @@ -1192,12 +1192,12 @@ out: return ret; } -static int lcrd_server_init_engines() +static int isulad_server_init_engines() { int ret = 0; char *engine = NULL; - engine = conf_get_lcrd_engine(); + engine = conf_get_isulad_engine(); if (engine == NULL) { ret = -1; goto out; @@ -1246,13 +1246,13 @@ static int start_monitord() msync.monitord_sem = &monitord_sem; msync.exit_code = &monitord_exitcode; if (sem_init(msync.monitord_sem, 0, 0)) { - lcrd_set_error_message("Failed to init monitor sem"); + isulad_set_error_message("Failed to init monitor sem"); ret = -1; goto out; } if (new_monitord(&msync)) { - lcrd_set_error_message("Create monitord thread failed"); + isulad_set_error_message("Create monitord thread failed"); ret = -1; sem_destroy(msync.monitord_sem); goto out; @@ -1261,7 +1261,7 @@ static int start_monitord() sem_wait(msync.monitord_sem); sem_destroy(msync.monitord_sem); if (monitord_exitcode) { - lcrd_set_error_message("Monitord start failed"); + isulad_set_error_message("Monitord start failed"); ret = -1; goto out; } @@ -1323,7 +1323,7 @@ static int start_daemon_threads(char **msg) } if (start_monitord()) { - *msg = g_lcrd_errmsg ? g_lcrd_errmsg : "Failed to init cgroups path"; + *msg = g_isulad_errmsg ? g_isulad_errmsg : "Failed to init cgroups path"; goto out; } @@ -1356,7 +1356,7 @@ static int pre_init_daemon_log() { struct log_config lconf = { 0 }; - lconf.name = "lcrd"; + lconf.name = "isulad"; lconf.quiet = true; lconf.file = NULL; lconf.priority = "ERROR"; @@ -1373,15 +1373,15 @@ static int pre_init_daemon(int argc, char **argv, char **msg) { int ret = -1; /* - * must call lcrd by root + * must call isulad by root */ if (geteuid() != 0) { - *msg = "LCRD must be called by root"; + *msg = "iSulad must be called by root"; goto out; } if (server_conf_parse_save(argc, (const char **)argv)) { - *msg = g_lcrd_errmsg ? g_lcrd_errmsg : "Failed to parse and save server conf"; + *msg = g_isulad_errmsg ? g_isulad_errmsg : "Failed to parse and save server conf"; goto out; } @@ -1391,7 +1391,7 @@ static int pre_init_daemon(int argc, char **argv, char **msg) goto out; } - if (lcrd_server_init_engines()) { + if (isulad_server_init_engines()) { *msg = "Failed to init engines"; goto out; } @@ -1418,7 +1418,7 @@ int main(int argc, char **argv) double use_time = 0; char *msg = NULL; - prctl(PR_SET_NAME, "lcrd"); + prctl(PR_SET_NAME, "isulad"); if (pre_init_daemon_log() != 0) { exit(ECOMMON); @@ -1434,12 +1434,12 @@ int main(int argc, char **argv) goto failure; } - if (lcrd_server_init_common() != 0) { + if (isulad_server_init_common() != 0) { goto failure; } if (init_cgroups_path("/lxc", 0)) { - msg = g_lcrd_errmsg ? g_lcrd_errmsg : "Failed to init cgroups path"; + msg = g_isulad_errmsg ? g_isulad_errmsg : "Failed to init cgroups path"; goto failure; } @@ -1452,7 +1452,7 @@ int main(int argc, char **argv) goto failure; } - if (lcrd_server_init_service()) { + if (isulad_server_init_service()) { msg = "Failed to init services"; goto failure; } @@ -1465,7 +1465,7 @@ int main(int argc, char **argv) clock_gettime(CLOCK_MONOTONIC, &t_end); use_time = (double)(t_end.tv_sec - t_start.tv_sec) * (double)1000000000 + (double)(t_end.tv_nsec - t_start.tv_nsec); use_time /= 1000000000; - INFO("Lcrd successfully booted in %.3f s", use_time); + INFO("iSulad successfully booted in %.3f s", use_time); #ifdef GRPC_CONNECTOR INFO("Starting grpc server..."); #else diff --git a/src/config/lcrd_config.c b/src/config/isulad_config.c similarity index 87% rename from src/config/lcrd_config.c rename to src/config/isulad_config.c index 456fb1920bed46ec4868189a5f170202707c5aa7..47cf0936c6730512f11131c7b24e69f0ffe11366 100644 --- a/src/config/lcrd_config.c +++ b/src/config/isulad_config.c @@ -27,9 +27,9 @@ #include "constants.h" #include "log.h" #include "utils.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "sysinfo.h" -#include "liblcrd.h" +#include "libisulad.h" #define ENGINE_ROOTPATH_NAME "engines" #define GRAPH_ROOTPATH_NAME "storage" @@ -38,7 +38,7 @@ #define INCREMENT_INTREVAL 2 #define BUFFER_ITEM_NUMS 10 -static struct lcrd_conf g_lcrd_conf; +static struct isulad_conf g_isulad_conf; static double g_jiffy = 0.0; /* tick to ns */ @@ -110,39 +110,39 @@ out: return ret; } -/* lcrd server conf wrlock */ -int lcrd_server_conf_wrlock() +/* isulad server conf wrlock */ +int isulad_server_conf_wrlock() { int ret = 0; - if (pthread_rwlock_wrlock(&g_lcrd_conf.lcrd_conf_rwlock)) { - ERROR("Failed to acquire lcrd conf write lock"); + if (pthread_rwlock_wrlock(&g_isulad_conf.isulad_conf_rwlock)) { + ERROR("Failed to acquire isulad conf write lock"); ret = -1; } return ret; } -/* lcrd server conf rdlock */ -int lcrd_server_conf_rdlock() +/* isulad server conf rdlock */ +int isulad_server_conf_rdlock() { int ret = 0; - if (pthread_rwlock_rdlock(&g_lcrd_conf.lcrd_conf_rwlock)) { - ERROR("Failed to acquire lcrd conf read lock"); + if (pthread_rwlock_rdlock(&g_isulad_conf.isulad_conf_rwlock)) { + ERROR("Failed to acquire isulad conf read lock"); ret = -1; } return ret; } -/* lcrd server conf unlock */ -int lcrd_server_conf_unlock() +/* isulad server conf unlock */ +int isulad_server_conf_unlock() { int ret = 0; - if (pthread_rwlock_unlock(&g_lcrd_conf.lcrd_conf_rwlock)) { - ERROR("Failed to release lcrd conf lock"); + if (pthread_rwlock_unlock(&g_isulad_conf.isulad_conf_rwlock)) { + ERROR("Failed to release isulad conf lock"); ret = -1; } @@ -151,16 +151,16 @@ int lcrd_server_conf_unlock() struct service_arguments *conf_get_server_conf() { - return g_lcrd_conf.server_conf; + return g_isulad_conf.server_conf; } -/* conf get lcrd pidfile */ -char *conf_get_lcrd_pidfile() +/* conf get isulad pidfile */ +char *conf_get_isulad_pidfile() { char *filename = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -172,7 +172,7 @@ char *conf_get_lcrd_pidfile() filename = util_strdup_s(conf->json_confs->pidfile); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return filename; } @@ -183,7 +183,7 @@ char *conf_get_engine_rootpath() char *rootpath = NULL; size_t len; - rootpath = conf_get_lcrd_rootdir(); + rootpath = conf_get_isulad_rootdir(); if (rootpath == NULL) { ERROR("Get rootpath failed"); return epath; @@ -222,7 +222,7 @@ char *conf_get_graph_rootpath() char *rootpath = NULL; size_t len; - rootpath = conf_get_lcrd_rootdir(); + rootpath = conf_get_isulad_rootdir(); if (rootpath == NULL) { ERROR("Get rootpath failed"); return epath; @@ -261,7 +261,7 @@ char *conf_get_graph_check_flag_file() char *rootpath = NULL; size_t len; - rootpath = conf_get_lcrd_rootdir(); + rootpath = conf_get_isulad_rootdir(); if (rootpath == NULL) { ERROR("Get rootpath failed"); return epath; @@ -300,7 +300,7 @@ char *conf_get_graph_run_path() char *rootpath = NULL; size_t len; - rootpath = conf_get_lcrd_statedir(); + rootpath = conf_get_isulad_statedir(); if (rootpath == NULL) { ERROR("Get rootpath failed"); return epath; @@ -344,7 +344,7 @@ char *conf_get_routine_rootdir(const char *runtime) return NULL; } - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -378,7 +378,7 @@ char *conf_get_routine_rootdir(const char *runtime) } out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return path; } @@ -393,7 +393,7 @@ char *conf_get_routine_statedir(const char *runtime) return NULL; } - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -424,17 +424,17 @@ char *conf_get_routine_statedir(const char *runtime) } out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return path; } -/* conf get lcrd rootdir */ -char *conf_get_lcrd_rootdir() +/* conf get isulad rootdir */ +char *conf_get_isulad_rootdir() { char *path = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -446,18 +446,18 @@ char *conf_get_lcrd_rootdir() path = util_strdup_s(conf->json_confs->graph); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return path; } #ifdef ENABLE_OCI_IMAGE /* conf get graph driver */ -char *conf_get_lcrd_storage_driver() +char *conf_get_isulad_storage_driver() { char *driver = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -469,17 +469,17 @@ char *conf_get_lcrd_storage_driver() driver = util_strdup_s(conf->driver->name); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return driver; } /* conf get graph driver */ -char *conf_get_lcrd_storage_driver_backing_fs() +char *conf_get_isulad_storage_driver_backing_fs() { char *fs = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -491,7 +491,7 @@ char *conf_get_lcrd_storage_driver_backing_fs() fs = util_strdup_s(conf->driver->backing_fs); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return fs; } @@ -504,7 +504,7 @@ char **conf_get_storage_opts() char *p = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -531,7 +531,7 @@ out_free: opts = NULL; } out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return opts; } #endif @@ -545,7 +545,7 @@ char **conf_get_registry_list() char *p = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -568,7 +568,7 @@ char **conf_get_registry_list() } } out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return opts; } @@ -581,7 +581,7 @@ char **conf_get_insecure_registry_list() char *p = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -604,17 +604,17 @@ char **conf_get_insecure_registry_list() } } out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return opts; } -/* conf get lcrd statedir */ -char *conf_get_lcrd_statedir() +/* conf get isulad statedir */ +char *conf_get_isulad_statedir() { char *path = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -626,17 +626,17 @@ char *conf_get_lcrd_statedir() path = util_strdup_s(conf->json_confs->state); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return path; } -/* conf get lcrd mount rootfs */ -char *conf_get_lcrd_mount_rootfs() +/* conf get isulad mount rootfs */ +char *conf_get_isulad_mount_rootfs() { char *path = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -648,17 +648,17 @@ char *conf_get_lcrd_mount_rootfs() path = util_strdup_s(conf->json_confs->rootfsmntdir); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return path; } -/* conf get lcrd umask for containers */ -char *conf_get_lcrd_native_umask() +/* conf get isulad umask for containers */ +char *conf_get_isulad_native_umask() { char *umask = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -670,17 +670,17 @@ char *conf_get_lcrd_native_umask() umask = util_strdup_s(conf->json_confs->native_umask); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return umask; } -/* conf get lcrd cgroup parent for containers */ -char *conf_get_lcrd_cgroup_parent() +/* conf get isulad cgroup parent for containers */ +char *conf_get_isulad_cgroup_parent() { char *cgroup_parent = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -692,17 +692,17 @@ char *conf_get_lcrd_cgroup_parent() cgroup_parent = util_strdup_s(conf->json_confs->cgroup_parent); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return cgroup_parent; } -/* conf get lcrd engine */ -char *conf_get_lcrd_engine() +/* conf get isulad engine */ +char *conf_get_isulad_engine() { char *engine = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -714,17 +714,17 @@ char *conf_get_lcrd_engine() engine = util_strdup_s(conf->json_confs->engine); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return engine; } -/* conf get lcrd loglevel */ -char *conf_get_lcrd_loglevel() +/* conf get isulad loglevel */ +char *conf_get_isulad_loglevel() { char *loglevel = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -736,7 +736,7 @@ char *conf_get_lcrd_loglevel() loglevel = util_strdup_s(conf->json_confs->log_level); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return loglevel; } @@ -778,24 +778,25 @@ out: return logfile; } -/* conf get lcrd log gather fifo path */ -char *conf_get_lcrd_log_gather_fifo_path() +/* conf get isulad log gather fifo path */ +char *conf_get_isulad_log_gather_fifo_path() { +#define LOG_GATHER_FIFO_NAME "/isulad_log_gather_fifo" char *logfile = NULL; char *statedir = NULL; size_t len = 0; int nret; - statedir = conf_get_lcrd_statedir(); + statedir = conf_get_isulad_statedir(); if (statedir == NULL) { - ERROR("Get lcrd statedir failed"); + ERROR("Get isulad statedir failed"); goto err_out; } - if (strlen(statedir) > (SIZE_MAX - strlen("/lcrd_log_gather_fifo")) - 1) { + if (strlen(statedir) > (SIZE_MAX - strlen(LOG_GATHER_FIFO_NAME)) - 1) { ERROR("State path is too long"); goto err_out; } - len = strlen(statedir) + strlen("/lcrd_log_gather_fifo") + 1; + len = strlen(statedir) + strlen(LOG_GATHER_FIFO_NAME) + 1; if (len > PATH_MAX) { ERROR("Too long path: %s", statedir); goto err_out; @@ -805,7 +806,7 @@ char *conf_get_lcrd_log_gather_fifo_path() ERROR("Out of memory"); goto err_out; } - nret = snprintf(logfile, len, "%s%s", statedir, "/lcrd_log_gather_fifo"); + nret = snprintf(logfile, len, "%s%s", statedir, "LOG_GATHER_FIFO_NAME"); if (nret < 0 || (size_t)nret >= len) { ERROR("Sprintf log file failed"); goto err_out; @@ -820,13 +821,13 @@ out: return logfile; } -/* conf get lcrd log file */ -char *conf_get_lcrd_log_file() +/* conf get isulad log file */ +char *conf_get_isulad_log_file() { char *logfile = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -835,10 +836,10 @@ char *conf_get_lcrd_log_file() goto out; } - logfile = get_log_file_helper(conf, "lcrd.log"); + logfile = get_log_file_helper(conf, "isulad.log"); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return logfile; } @@ -850,9 +851,9 @@ char *conf_get_engine_log_file() char *prefix = "fifo:"; size_t len = 0; - logfile = conf_get_lcrd_log_gather_fifo_path(); + logfile = conf_get_isulad_log_gather_fifo_path(); if (logfile == NULL) { - ERROR("conf_get_lcrd_log_gather_fifo_path failed"); + ERROR("conf_get_isulad_log_gather_fifo_path failed"); goto out; } len = strlen(prefix) + strlen(logfile) + 1; @@ -880,12 +881,12 @@ out: int conf_get_daemon_log_config(char **loglevel, char **logdriver, char **engine_log_path) { - *loglevel = conf_get_lcrd_loglevel(); + *loglevel = conf_get_isulad_loglevel(); if (*loglevel == NULL) { ERROR("DoStart: Failed to get log level"); return -1; } - *logdriver = conf_get_lcrd_logdriver(); + *logdriver = conf_get_isulad_logdriver(); if (*logdriver == NULL) { ERROR("DoStart: Failed to get log driver"); return -1; @@ -898,13 +899,13 @@ int conf_get_daemon_log_config(char **loglevel, char **logdriver, char **engine_ return 0; } -/* conf get lcrd logdriver */ -char *conf_get_lcrd_logdriver() +/* conf get isulad logdriver */ +char *conf_get_isulad_logdriver() { char *logdriver = NULL; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return NULL; } @@ -916,7 +917,7 @@ char *conf_get_lcrd_logdriver() logdriver = util_strdup_s(conf->json_confs->log_driver); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return logdriver; } @@ -926,7 +927,7 @@ bool conf_get_image_layer_check_flag() bool check_flag = false; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return false; } @@ -938,7 +939,7 @@ bool conf_get_image_layer_check_flag() check_flag = conf->json_confs->image_layer_check; out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return check_flag; } @@ -948,7 +949,7 @@ bool conf_get_use_decrypted_key_flag() bool check_flag = true; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return false; } @@ -960,7 +961,7 @@ bool conf_get_use_decrypted_key_flag() check_flag = *(conf->json_confs->use_decrypted_key); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return check_flag; } @@ -969,7 +970,7 @@ bool conf_get_skip_insecure_verify_flag() bool check_flag = false; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return false; } @@ -981,7 +982,7 @@ bool conf_get_skip_insecure_verify_flag() check_flag = conf->json_confs->insecure_skip_verify_enforce; out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return check_flag; } @@ -1086,13 +1087,13 @@ out: return dest; } -/* conf get lcrd hooks */ -int conf_get_lcrd_hooks(oci_runtime_spec_hooks **phooks) +/* conf get isulad hooks */ +int conf_get_isulad_hooks(oci_runtime_spec_hooks **phooks) { int ret = 0; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return -1; } @@ -1107,18 +1108,18 @@ int conf_get_lcrd_hooks(oci_runtime_spec_hooks **phooks) *phooks = NULL; } out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return ret; } -/* conf get lcrd default ulimit */ -int conf_get_lcrd_default_ulimit(host_config_ulimits_element ***ulimit) +/* conf get isulad default ulimit */ +int conf_get_isulad_default_ulimit(host_config_ulimits_element ***ulimit) { int ret = 0; size_t i, ulimit_len; struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return -1; } @@ -1137,7 +1138,7 @@ int conf_get_lcrd_default_ulimit(host_config_ulimits_element ***ulimit) } } out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return ret; } @@ -1146,7 +1147,7 @@ unsigned int conf_get_start_timeout() { struct service_arguments *conf = NULL; unsigned int ret = 0; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return 0; } @@ -1158,7 +1159,7 @@ unsigned int conf_get_start_timeout() ret = conf->start_timeout; out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return ret; } @@ -1167,7 +1168,7 @@ unsigned int conf_get_im_opt_timeout() { struct service_arguments *conf = NULL; unsigned int ret = 0; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return 0; } @@ -1179,7 +1180,7 @@ unsigned int conf_get_im_opt_timeout() ret = conf->image_opt_timeout; out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return ret; } @@ -1188,7 +1189,7 @@ char *conf_get_im_server_sock_addr() struct service_arguments *conf = NULL; char *result = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { ERROR("BUG conf_rdlock failed"); return NULL; } @@ -1201,7 +1202,7 @@ char *conf_get_im_server_sock_addr() result = util_strdup_s(conf->json_confs->image_server_sock_addr); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return result; } @@ -1214,7 +1215,7 @@ bool conf_update_im_server_sock_addr(const char *new_sock_addr) return false; } - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { ERROR("BUG conf_rdlock failed"); return false; } @@ -1229,7 +1230,7 @@ bool conf_update_im_server_sock_addr(const char *new_sock_addr) conf->json_confs->image_server_sock_addr = util_strdup_s(new_sock_addr); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return result; } @@ -1238,7 +1239,7 @@ char *conf_get_enable_plugins() struct service_arguments *conf = NULL; char *plugins = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { ERROR("BUG conf_rdlock failed"); return NULL; } @@ -1251,7 +1252,7 @@ char *conf_get_enable_plugins() plugins = util_strdup_s(conf->json_confs->enable_plugins); out: - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return plugins; } @@ -1260,27 +1261,27 @@ int save_args_to_conf(struct service_arguments *args) { int ret = 0; - ret = pthread_rwlock_init(&g_lcrd_conf.lcrd_conf_rwlock, NULL); + ret = pthread_rwlock_init(&g_isulad_conf.isulad_conf_rwlock, NULL); if (ret != 0) { - ERROR("Failed to init lcrd conf rwlock"); + ERROR("Failed to init isulad conf rwlock"); ret = -1; goto out; } - if (pthread_rwlock_wrlock(&g_lcrd_conf.lcrd_conf_rwlock) != 0) { - ERROR("Failed to acquire lcrd conf write lock"); + if (pthread_rwlock_wrlock(&g_isulad_conf.isulad_conf_rwlock) != 0) { + ERROR("Failed to acquire isulad conf write lock"); ret = -1; goto out; } - if (g_lcrd_conf.server_conf != NULL) { - service_arguments_free(g_lcrd_conf.server_conf); - free(g_lcrd_conf.server_conf); + if (g_isulad_conf.server_conf != NULL) { + service_arguments_free(g_isulad_conf.server_conf); + free(g_isulad_conf.server_conf); } - g_lcrd_conf.server_conf = args; + g_isulad_conf.server_conf = args; - if (pthread_rwlock_unlock(&g_lcrd_conf.lcrd_conf_rwlock) != 0) { - ERROR("Failed to release lcrd conf write lock"); + if (pthread_rwlock_unlock(&g_isulad_conf.isulad_conf_rwlock) != 0) { + ERROR("Failed to release isulad conf write lock"); ret = -1; goto out; } @@ -1304,10 +1305,11 @@ static int set_path_group(const char *rpath, const char *group) return -1; } } else { - if (strcmp(group, "docker") == 0 || strcmp(group, "lcrd") == 0) { + if (strcmp(group, "docker") == 0 || strcmp(group, "isulad") == 0) { DEBUG("Warning: could not change group %s to %s", rpath, group); } else { - lcrd_set_error_message("Group %s not found", group); + ERROR("Group %s not found", group); + isulad_set_error_message("Group %s not found", group); return -1; } } @@ -1334,6 +1336,7 @@ int set_unix_socket_group(const char *socket, const char *group) ret = -1; goto out; } + INFO("set socket: %s with group: %s", socket, group); nret = set_path_group(rpath, group); if (nret < 0) { ERROR("set group of the path: %s failed", rpath); @@ -1362,7 +1365,7 @@ static int maybe_create_cpu_realtime_file(bool present, int64_t value, const cha int fd = 0; ssize_t nwrite; char fpath[PATH_MAX] = { 0 }; - char buf[LCRD_NUMSTRLEN64] = { 0 }; + char buf[ISULAD_NUMSTRLEN64] = { 0 }; if (!present || value == 0) { return 0; @@ -1388,13 +1391,13 @@ static int maybe_create_cpu_realtime_file(bool present, int64_t value, const cha fd = util_open(fpath, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0700); if (fd < 0) { ERROR("Failed to open file: %s: %s", fpath, strerror(errno)); - lcrd_set_error_message("Failed to open file: %s: %s", fpath, strerror(errno)); + isulad_set_error_message("Failed to open file: %s: %s", fpath, strerror(errno)); return -1; } nwrite = util_write_nointr(fd, buf, strlen(buf)); if (nwrite < 0) { ERROR("Failed to write %s to %s: %s", buf, fpath, strerror(errno)); - lcrd_set_error_message("Failed to write '%s' to '%s': %s", buf, fpath, strerror(errno)); + isulad_set_error_message("Failed to write '%s' to '%s': %s", buf, fpath, strerror(errno)); close(fd); return -1; } @@ -1407,20 +1410,20 @@ static int get_cgroup_cpu_rt(int64_t *cpu_rt_period, int64_t *cpu_rt_runtime) { struct service_arguments *conf = NULL; - if (lcrd_server_conf_rdlock() != 0) { + if (isulad_server_conf_rdlock() != 0) { return -1; } conf = conf_get_server_conf(); if (conf == NULL) { - (void)lcrd_server_conf_unlock(); + (void)isulad_server_conf_unlock(); return -1; } *cpu_rt_period = conf->json_confs->cpu_rt_period; *cpu_rt_runtime = conf->json_confs->cpu_rt_runtime; - if (lcrd_server_conf_unlock() != 0) { + if (isulad_server_conf_unlock() != 0) { return -1; } @@ -1449,7 +1452,7 @@ static int recursively_create_cgroup(const char *path, int recursive_depth, int6 ret = find_cgroup_mountpoint_and_root("cpu", &mnt, &root); if (ret != 0 || mnt == NULL || root == NULL) { ERROR("Can not find cgroup mnt and root path for subsystem 'cpu'"); - lcrd_set_error_message("Can not find cgroup mnt and root path for subsystem 'cpu'"); + isulad_set_error_message("Can not find cgroup mnt and root path for subsystem 'cpu'"); ret = -1; goto out; } @@ -1628,7 +1631,7 @@ static int merge_hosts_conf_into_global(struct service_arguments *args, } args->json_confs->hosts_len++; if (args->json_confs->hosts_len > MAX_HOSTS) { - lcrd_set_error_message("Too many hosts, the max number is %d", MAX_HOSTS); + isulad_set_error_message("Too many hosts, the max number is %d", MAX_HOSTS); return -1; } } diff --git a/src/config/lcrd_config.h b/src/config/isulad_config.h similarity index 70% rename from src/config/lcrd_config.h rename to src/config/isulad_config.h index 3c33895b25836e67a8d5707dd5fa888dc4b654ca..492e730dd8223537c28d2c5fddd8480fb371793c 100644 --- a/src/config/lcrd_config.h +++ b/src/config/isulad_config.h @@ -12,11 +12,11 @@ * Create: 2018-11-08 * Description: provide container configure definition ******************************************************************************/ -#ifndef __LCRD_CONF_H -#define __LCRD_CONF_H +#ifndef __ISULAD_CONF_H +#define __ISULAD_CONF_H #include -#include "lcrd/arguments.h" +#include "isulad/arguments.h" #include "oci_runtime_spec.h" #include "isulad_daemon_configs.h" @@ -24,27 +24,27 @@ extern "C" { #endif -#define DEFAULT_IM_SERVER_SOCK_ADDR "unix:///var/run/lcrd/isula_image.sock" +#define DEFAULT_IM_SERVER_SOCK_ADDR "unix:///var/run/isulad/isula_image.sock" -struct lcrd_conf { - pthread_rwlock_t lcrd_conf_rwlock; +struct isulad_conf { + pthread_rwlock_t isulad_conf_rwlock; struct service_arguments *server_conf; }; -char *conf_get_lcrd_pidfile(); +char *conf_get_isulad_pidfile(); char *conf_get_engine_rootpath(); char *conf_get_routine_rootdir(const char *runtime); char *conf_get_routine_statedir(const char *runtime); -char *conf_get_lcrd_rootdir(); -char *conf_get_lcrd_statedir(); -char *conf_get_lcrd_mount_rootfs(); -char *conf_get_lcrd_engine(); -char *conf_get_lcrd_loglevel(); -char *conf_get_lcrd_logdriver(); +char *conf_get_isulad_rootdir(); +char *conf_get_isulad_statedir(); +char *conf_get_isulad_mount_rootfs(); +char *conf_get_isulad_engine(); +char *conf_get_isulad_loglevel(); +char *conf_get_isulad_logdriver(); int conf_get_daemon_log_config(char **loglevel, char **logdriver, char **engine_log_path); -char *conf_get_lcrd_log_gather_fifo_path(); +char *conf_get_isulad_log_gather_fifo_path(); -char *conf_get_lcrd_log_file(); +char *conf_get_isulad_log_file(); char *conf_get_engine_log_file(); char *conf_get_enable_plugins(); @@ -52,19 +52,19 @@ int save_args_to_conf(struct service_arguments *args); int set_unix_socket_group(const char *socket, const char *group); -int lcrd_server_conf_wrlock(); +int isulad_server_conf_wrlock(); -int lcrd_server_conf_rdlock(); +int isulad_server_conf_rdlock(); -int lcrd_server_conf_unlock(); +int isulad_server_conf_unlock(); struct service_arguments *conf_get_server_conf(); int get_system_cpu_usage(uint64_t *val); -int conf_get_lcrd_hooks(oci_runtime_spec_hooks **phooks); +int conf_get_isulad_hooks(oci_runtime_spec_hooks **phooks); -int conf_get_lcrd_default_ulimit(host_config_ulimits_element ***ulimit); +int conf_get_isulad_default_ulimit(host_config_ulimits_element ***ulimit); unsigned int conf_get_start_timeout(); @@ -74,18 +74,18 @@ char *conf_get_graph_rootpath(); char *conf_get_graph_run_path(); -char *conf_get_lcrd_storage_driver(); +char *conf_get_isulad_storage_driver(); -char *conf_get_lcrd_storage_driver_backing_fs(); +char *conf_get_isulad_storage_driver_backing_fs(); char **conf_get_storage_opts(); char **conf_get_insecure_registry_list(); char **conf_get_registry_list(); -char *conf_get_lcrd_native_umask(); +char *conf_get_isulad_native_umask(); -char *conf_get_lcrd_cgroup_parent(); +char *conf_get_isulad_cgroup_parent(); unsigned int conf_get_im_opt_timeout(); @@ -107,5 +107,5 @@ int parse_log_opts(struct service_arguments *args, const char *key, const char * } #endif -#endif /* __LCRD_CONF_H */ +#endif /* __ISULAD_CONF_H */ diff --git a/src/connect/client/CMakeLists.txt b/src/connect/client/CMakeLists.txt index 9cc25c0b3a4931e0afc7728411d5bdb8677391fa..73562f88de916c46d2b93edaf39dcefb0c4eafe5 100644 --- a/src/connect/client/CMakeLists.txt +++ b/src/connect/client/CMakeLists.txt @@ -1,5 +1,5 @@ set(client_srcs - ${CMAKE_CURRENT_SOURCE_DIR}/lcrc_connect.c + ${CMAKE_CURRENT_SOURCE_DIR}/isula_connect.c ) set(incs ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/connect/client/connect.h b/src/connect/client/connect.h index 4476adafffbd4d9ad2cb056c862ebae316426938..e2ca45191899f1b32373825d3e91ee2ad5756951 100644 --- a/src/connect/client/connect.h +++ b/src/connect/client/connect.h @@ -10,7 +10,7 @@ * See the Mulan PSL v1 for more details. * Author: liuhao * Create: 2019-07-12 -* Description: provide lcrc connect command definition +* Description: provide isula connect command definition *******************************************************************************/ #ifndef __ISULAD_CLIENT_CONNECT_H #define __ISULAD_CLIENT_CONNECT_H diff --git a/src/connect/client/grpc/client_base.h b/src/connect/client/grpc/client_base.h index 40aee719d52f00cbb5f00124126b623c19ae1cd4..487016bc8686d32dac19ce297b77dc9111fab7fd 100644 --- a/src/connect/client/grpc/client_base.h +++ b/src/connect/client/grpc/client_base.h @@ -93,10 +93,10 @@ public: status.error_code() == grpc::StatusCode::INTERNAL)) { response->errmsg = util_strdup_s(status.error_message().c_str()); } else { - response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); + response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); } - response->cc = LCRD_ERR_EXEC; + response->cc = ISULAD_ERR_EXEC; } virtual int run(const RQ *request, RP *response) @@ -127,12 +127,12 @@ public: ret = request_to_grpc(request, &req); if (ret != 0) { ERROR("Failed to translate request to grpc"); - response->cc = LCRD_ERR_INPUT; + response->cc = ISULAD_ERR_INPUT; return -1; } if (check_parameter(req)) { - response->cc = LCRD_ERR_INPUT; + response->cc = ISULAD_ERR_INPUT; return -1; } @@ -146,15 +146,15 @@ public: ret = response_from_grpc(&reply, response); if (ret != 0) { ERROR("Failed to transform grpc response"); - response->cc = LCRD_ERR_EXEC; + response->cc = ISULAD_ERR_EXEC; return -1; } - if (response->server_errono != LCRD_SUCCESS) { - response->cc = LCRD_ERR_EXEC; + if (response->server_errono != ISULAD_SUCCESS) { + response->cc = ISULAD_ERR_EXEC; } - return (response->cc == LCRD_SUCCESS) ? 0 : -1; + return (response->cc == ISULAD_SUCCESS) ? 0 : -1; } protected: diff --git a/src/connect/client/grpc/grpc_client.cc b/src/connect/client/grpc/grpc_client.cc index 6a565cde3977f480f275e4da3012972e7c7419a3..154bebff77aa292b6bac7697c6586b8da404e58b 100644 --- a/src/connect/client/grpc/grpc_client.cc +++ b/src/connect/client/grpc/grpc_client.cc @@ -17,7 +17,7 @@ #include "grpc_containers_client.h" #include "grpc_images_client.h" -int grpc_ops_init(lcrc_connect_ops *ops) +int grpc_ops_init(isula_connect_ops *ops) { if (ops == nullptr) { return -1; diff --git a/src/connect/client/grpc/grpc_client.h b/src/connect/client/grpc/grpc_client.h index c0e1c6645032800a718f093216840b4cf70eaf45..bf0ae37b809ba6382e430b19f2722c1f46ed866f 100644 --- a/src/connect/client/grpc/grpc_client.h +++ b/src/connect/client/grpc/grpc_client.h @@ -15,13 +15,13 @@ #ifndef __GRPC_CLIENT_H #define __GRPC_CLIENT_H -#include "lcrc_connect.h" +#include "isula_connect.h" #ifdef __cplusplus extern "C" { #endif -int grpc_ops_init(lcrc_connect_ops *ops); +int grpc_ops_init(isula_connect_ops *ops); #ifdef __cplusplus } diff --git a/src/connect/client/grpc/grpc_containers_client.cc b/src/connect/client/grpc/grpc_containers_client.cc index 50a108942b4792d1b6cc2e08b681b23414e73f74..0ccb7a3309d364bb459936c18e9ded815f436bcc 100644 --- a/src/connect/client/grpc/grpc_containers_client.cc +++ b/src/connect/client/grpc/grpc_containers_client.cc @@ -21,7 +21,7 @@ #include "container_copy_to_request.h" #include "container_exec_request.h" #include "utils.h" -#include "lcrdtar.h" +#include "libtar.h" #include "stoppable_thread.h" #include "container.grpc.pb.h" #include "client_base.h" @@ -38,8 +38,8 @@ using grpc::Status; using grpc::StatusCode; using google::protobuf::Timestamp; -class ContainerVersion : public ClientBase { +class ContainerVersion : public ClientBase { public: explicit ContainerVersion(void *args) : ClientBase(args) @@ -47,7 +47,7 @@ public: } ~ContainerVersion() = default; - int response_from_grpc(VersionResponse *gresponse, lcrc_version_response *response) override + int response_from_grpc(VersionResponse *gresponse, isula_version_response *response) override { if (!gresponse->version().empty()) { response->version = util_strdup_s(gresponse->version().c_str()); @@ -74,8 +74,8 @@ public: } }; -class ContainerInfo : public ClientBase { +class ContainerInfo : public ClientBase { public: explicit ContainerInfo(void *args) : ClientBase(args) @@ -83,7 +83,7 @@ public: } ~ContainerInfo() = default; - int response_from_grpc(InfoResponse *gresponse, lcrc_info_response *response) override + int response_from_grpc(InfoResponse *gresponse, isula_info_response *response) override { if (!gresponse->version().empty()) { response->version = util_strdup_s(gresponse->version().c_str()); @@ -115,7 +115,7 @@ public: } private: - void get_os_info_from_grpc(lcrc_info_response *response, InfoResponse *gresponse) + void get_os_info_from_grpc(isula_info_response *response, InfoResponse *gresponse) { if (!gresponse->kversion().empty()) { response->kversion = util_strdup_s(gresponse->kversion().c_str()); @@ -138,7 +138,7 @@ private: } } - void get_proxy_info_from_grpc(lcrc_info_response *response, InfoResponse *gresponse) + void get_proxy_info_from_grpc(isula_info_response *response, InfoResponse *gresponse) { if (!gresponse->http_proxy().empty()) { response->http_proxy = util_strdup_s(gresponse->http_proxy().c_str()); @@ -152,8 +152,8 @@ private: } }; -class ContainerCreate : public ClientBase { +class ContainerCreate : public ClientBase { public: explicit ContainerCreate(void *args) : ClientBase(args) @@ -161,7 +161,7 @@ public: } ~ContainerCreate() = default; - int request_to_grpc(const lcrc_create_request *request, CreateRequest *grequest) override + int request_to_grpc(const isula_create_request *request, CreateRequest *grequest) override { int ret = 0; char *host_json = nullptr, *config_json = nullptr; @@ -203,7 +203,7 @@ public: return 0; } - int response_from_grpc(CreateResponse *gresponse, lcrc_create_response *response) override + int response_from_grpc(CreateResponse *gresponse, isula_create_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -245,8 +245,8 @@ public: } }; -class ContainerStart : public ClientBase { +class ContainerStart : public ClientBase { public: explicit ContainerStart(void *args) : ClientBase(args) @@ -254,7 +254,7 @@ public: } ~ContainerStart() = default; - int request_to_grpc(const lcrc_start_request *request, StartRequest *grequest) override + int request_to_grpc(const isula_start_request *request, StartRequest *grequest) override { if (request == nullptr) { return -1; @@ -279,7 +279,7 @@ public: return 0; } - int response_from_grpc(StartResponse *gresponse, struct lcrc_start_response *response) override + int response_from_grpc(StartResponse *gresponse, struct isula_start_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -340,8 +340,8 @@ private: std::shared_ptr> m_stream; }; -class ContainerRemoteStart : public ClientBase { +class ContainerRemoteStart : public ClientBase { public: explicit ContainerRemoteStart(void *args) : ClientBase(args) @@ -349,7 +349,7 @@ public: } ~ContainerRemoteStart() = default; - int set_custom_header_metadata(ClientContext &context, const struct lcrc_start_request *request) + int set_custom_header_metadata(ClientContext &context, const struct isula_start_request *request) { if (request == nullptr || request->name == nullptr) { ERROR("Missing container id in the request"); @@ -372,7 +372,7 @@ public: return 0; } - void get_server_trailing_metadata(ClientContext &context, lcrc_start_response *response) + void get_server_trailing_metadata(ClientContext &context, isula_start_response *response) { auto metadata = context.GetServerTrailingMetadata(); auto cc = metadata.find("cc"); @@ -387,13 +387,13 @@ public: } } - int run(const struct lcrc_start_request *request, struct lcrc_start_response *response) override + int run(const struct isula_start_request *request, struct isula_start_response *response) override { ClientContext context; if (set_custom_header_metadata(context, request) != 0) { ERROR("Failed to translate request to grpc"); - response->cc = LCRD_ERR_INPUT; + response->cc = ISULAD_ERR_INPUT; return -1; } @@ -433,8 +433,8 @@ public: get_server_trailing_metadata(context, response); - if (response->server_errono != LCRD_SUCCESS) { - response->cc = LCRD_ERR_EXEC; + if (response->server_errono != ISULAD_SUCCESS) { + response->cc = ISULAD_ERR_EXEC; goto out; } out: @@ -444,11 +444,11 @@ out: writer.join(); } } - return (response->cc == LCRD_SUCCESS) ? 0 : -1; + return (response->cc == ISULAD_SUCCESS) ? 0 : -1; } }; -class ContainerTop : public ClientBase { +class ContainerTop : public ClientBase { public: explicit ContainerTop(void *args) : ClientBase(args) @@ -456,7 +456,7 @@ public: } ~ContainerTop() = default; - int request_to_grpc(const lcrc_top_request *request, TopRequest *grequest) override + int request_to_grpc(const isula_top_request *request, TopRequest *grequest) override { if (request == nullptr) { return -1; @@ -474,7 +474,7 @@ public: return 0; } - int response_from_grpc(TopResponse *gresponse, struct lcrc_top_response *response) override + int response_from_grpc(TopResponse *gresponse, struct isula_top_response *response) override { int i = 0; int num = gresponse->processes_size(); @@ -503,7 +503,7 @@ public: response->processes = (char **)util_common_calloc_s(num * sizeof(char *)); if (response->processes == nullptr) { ERROR("out of memory"); - response->cc = LCRD_ERR_MEMOUT; + response->cc = ISULAD_ERR_MEMOUT; return -1; } for (i = 0; i < num; i++) { @@ -529,8 +529,8 @@ public: } }; -class ContainerStop : public ClientBase { +class ContainerStop : public ClientBase { public: explicit ContainerStop(void *args) : ClientBase(args) @@ -538,7 +538,7 @@ public: } ~ContainerStop() = default; - int request_to_grpc(const lcrc_stop_request *request, StopRequest *grequest) override + int request_to_grpc(const isula_stop_request *request, StopRequest *grequest) override { if (request == nullptr) { return -1; @@ -553,7 +553,7 @@ public: return 0; } - int response_from_grpc(StopResponse *gresponse, lcrc_stop_response *response) override + int response_from_grpc(StopResponse *gresponse, isula_stop_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -579,8 +579,8 @@ public: } }; -class ContainerRename : public ClientBase { +class ContainerRename : public ClientBase { public: explicit ContainerRename(void *args) : ClientBase(args) @@ -588,7 +588,7 @@ public: } ~ContainerRename() = default; - int request_to_grpc(const lcrc_rename_request *request, RenameRequest *grequest) override + int request_to_grpc(const isula_rename_request *request, RenameRequest *grequest) override { if (request == nullptr) { return -1; @@ -605,7 +605,7 @@ public: return 0; } - int response_from_grpc(RenameResponse *gresponse, lcrc_rename_response *response) override + int response_from_grpc(RenameResponse *gresponse, isula_rename_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -636,8 +636,8 @@ public: } }; -class ContainerResize : public ClientBase { +class ContainerResize : public ClientBase { public: explicit ContainerResize(void *args) : ClientBase(args) @@ -645,7 +645,7 @@ public: } ~ContainerResize() = default; - int request_to_grpc(const lcrc_resize_request *request, ResizeRequest *grequest) override + int request_to_grpc(const isula_resize_request *request, ResizeRequest *grequest) override { if (request == nullptr) { return -1; @@ -664,7 +664,7 @@ public: return 0; } - int response_from_grpc(ResizeResponse *gresponse, lcrc_resize_response *response) override + int response_from_grpc(ResizeResponse *gresponse, isula_resize_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -691,8 +691,8 @@ public: }; -class ContainerRestart : public ClientBase { +class ContainerRestart : public ClientBase { public: explicit ContainerRestart(void *args) : ClientBase(args) @@ -700,7 +700,7 @@ public: } ~ContainerRestart() = default; - int request_to_grpc(const lcrc_restart_request *request, RestartRequest *grequest) override + int request_to_grpc(const isula_restart_request *request, RestartRequest *grequest) override { if (request == nullptr) { return -1; @@ -714,7 +714,7 @@ public: return 0; } - int response_from_grpc(RestartResponse *gresponse, lcrc_restart_response *response) override + int response_from_grpc(RestartResponse *gresponse, isula_restart_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -740,8 +740,8 @@ public: } }; -class ContainerKill : public ClientBase { +class ContainerKill : public ClientBase { public: explicit ContainerKill(void *args) : ClientBase(args) @@ -749,7 +749,7 @@ public: } ~ContainerKill() = default; - int request_to_grpc(const lcrc_kill_request *request, KillRequest *grequest) override + int request_to_grpc(const isula_kill_request *request, KillRequest *grequest) override { if (request == nullptr) { return -1; @@ -763,7 +763,7 @@ public: return 0; } - int response_from_grpc(KillResponse *gresponse, lcrc_kill_response *response) override + int response_from_grpc(KillResponse *gresponse, isula_kill_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -789,8 +789,8 @@ public: } }; -class ContainerExec : public ClientBase { +class ContainerExec : public ClientBase { public: explicit ContainerExec(void *args) : ClientBase(args) @@ -798,7 +798,7 @@ public: } ~ContainerExec() = default; - int request_to_grpc(const lcrc_exec_request *request, ExecRequest *grequest) override + int request_to_grpc(const isula_exec_request *request, ExecRequest *grequest) override { if (request == nullptr) { return -1; @@ -837,7 +837,7 @@ public: return 0; } - int response_from_grpc(ExecResponse *gresponse, lcrc_exec_response *response) override + int response_from_grpc(ExecResponse *gresponse, isula_exec_response *response) override { response->server_errono = gresponse->cc(); response->exit_code = gresponse->exit_code(); @@ -899,8 +899,8 @@ private: std::shared_ptr> m_stream; }; -class ContainerRemoteExec : public ClientBase { +class ContainerRemoteExec : public ClientBase { public: explicit ContainerRemoteExec(void *args) : ClientBase(args) @@ -908,8 +908,8 @@ public: } ~ContainerRemoteExec() = default; - int set_custom_header_metadata(ClientContext &context, const struct lcrc_exec_request *request, - struct lcrc_exec_response *response) + int set_custom_header_metadata(ClientContext &context, const struct isula_exec_request *request, + struct isula_exec_response *response) { int ret = 0; char *json = nullptr; @@ -956,7 +956,7 @@ out: free(json); return ret; } - void get_server_trailing_metadata(ClientContext &context, lcrc_exec_response *response) + void get_server_trailing_metadata(ClientContext &context, isula_exec_response *response) { auto metadata = context.GetServerTrailingMetadata(); auto cc = metadata.find("cc"); @@ -975,13 +975,13 @@ out: response->errmsg = util_strdup_s(tmpstr.c_str()); } } - int run(const struct lcrc_exec_request *request, struct lcrc_exec_response *response) override + int run(const struct isula_exec_request *request, struct isula_exec_response *response) override { ClientContext context; if (set_custom_header_metadata(context, request, response) != 0) { ERROR("Failed to translate request to grpc"); - response->cc = LCRD_ERR_INPUT; + response->cc = ISULAD_ERR_INPUT; return -1; } @@ -1010,8 +1010,8 @@ out: get_server_trailing_metadata(context, response); - if (response->server_errono != LCRD_SUCCESS) { - response->cc = LCRD_ERR_EXEC; + if (response->server_errono != ISULAD_SUCCESS) { + response->cc = ISULAD_ERR_EXEC; goto out; } out: @@ -1019,12 +1019,12 @@ out: if (writer.joinable()) { writer.join(); } - return (response->cc == LCRD_SUCCESS) ? 0 : -1; + return (response->cc == ISULAD_SUCCESS) ? 0 : -1; } }; -class ContainerInspect : public ClientBase { +class ContainerInspect : public ClientBase { public: explicit ContainerInspect(void *args) : ClientBase(args) @@ -1032,7 +1032,7 @@ public: } ~ContainerInspect() = default; - int request_to_grpc(const lcrc_inspect_request *request, InspectContainerRequest *grequest) override + int request_to_grpc(const isula_inspect_request *request, InspectContainerRequest *grequest) override { if (request == nullptr) { return -1; @@ -1047,7 +1047,7 @@ public: return 0; } - int response_from_grpc(InspectContainerResponse *gresponse, lcrc_inspect_response *response) override + int response_from_grpc(InspectContainerResponse *gresponse, isula_inspect_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->containerjson().empty()) { @@ -1077,8 +1077,8 @@ public: } }; -class ContainerDelete : public ClientBase { +class ContainerDelete : public ClientBase { public: explicit ContainerDelete(void *args) : ClientBase(args) @@ -1086,7 +1086,7 @@ public: } ~ContainerDelete() = default; - int request_to_grpc(const lcrc_delete_request *request, DeleteRequest *grequest) override + int request_to_grpc(const isula_delete_request *request, DeleteRequest *grequest) override { if (request == nullptr) { return -1; @@ -1100,7 +1100,7 @@ public: return 0; } - int response_from_grpc(DeleteResponse *gresponse, lcrc_delete_response *response) override + int response_from_grpc(DeleteResponse *gresponse, isula_delete_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->id().empty()) { @@ -1129,8 +1129,8 @@ public: } }; -class ContainerList : public ClientBase { +class ContainerList : public ClientBase { public: explicit ContainerList(void *args) : ClientBase(args) @@ -1138,7 +1138,7 @@ public: } ~ContainerList() = default; - int request_to_grpc(const lcrc_list_request *request, ListRequest *grequest) override + int request_to_grpc(const isula_list_request *request, ListRequest *grequest) override { if (request == nullptr) { return -1; @@ -1156,7 +1156,7 @@ public: return 0; } - int response_from_grpc(ListResponse *gresponse, lcrc_list_response *response) override + int response_from_grpc(ListResponse *gresponse, isula_list_response *response) override { int i = 0; int num = gresponse->containers_size(); @@ -1170,15 +1170,15 @@ public: } return 0; } - if ((size_t)num > SIZE_MAX / sizeof(lcrc_container_summary_info *)) { + if ((size_t)num > SIZE_MAX / sizeof(isula_container_summary_info *)) { ERROR("Too many summary info!"); return -1; } - response->container_summary = (struct lcrc_container_summary_info **)util_common_calloc_s( - sizeof(struct lcrc_container_summary_info *) * (size_t)num); + response->container_summary = (struct isula_container_summary_info **)util_common_calloc_s( + sizeof(struct isula_container_summary_info *) * (size_t)num); if (response->container_summary == nullptr) { ERROR("out of memory"); - response->cc = LCRD_ERR_MEMOUT; + response->cc = ISULAD_ERR_MEMOUT; return -1; } @@ -1197,13 +1197,13 @@ public: } private: - int get_container_summary_from_grpc(lcrc_list_response *response, ListResponse *gresponse, int index) + int get_container_summary_from_grpc(isula_list_response *response, ListResponse *gresponse, int index) { response->container_summary[index] = - (struct lcrc_container_summary_info *)util_common_calloc_s(sizeof(struct lcrc_container_summary_info)); + (struct isula_container_summary_info *)util_common_calloc_s(sizeof(struct isula_container_summary_info)); if (response->container_summary[index] == nullptr) { ERROR("out of memory"); - response->cc = LCRD_ERR_MEMOUT; + response->cc = ISULAD_ERR_MEMOUT; return -1; } const Container &in = gresponse->containers(index); @@ -1242,8 +1242,8 @@ private: } }; -class ContainerWait : public ClientBase { +class ContainerWait : public ClientBase { public: explicit ContainerWait(void *args) : ClientBase(args) @@ -1251,7 +1251,7 @@ public: } ~ContainerWait() = default; - int request_to_grpc(const lcrc_wait_request *request, WaitRequest *grequest) override + int request_to_grpc(const isula_wait_request *request, WaitRequest *grequest) override { if (request == nullptr) { return -1; @@ -1264,7 +1264,7 @@ public: return 0; } - int response_from_grpc(WaitResponse *gresponse, lcrc_wait_response *response) override + int response_from_grpc(WaitResponse *gresponse, isula_wait_response *response) override { response->exit_code = (int)gresponse->exit_code(); response->server_errono = gresponse->cc(); @@ -1325,8 +1325,8 @@ private: std::shared_ptr> m_stream; }; -class ContainerAttach : public ClientBase { +class ContainerAttach : public ClientBase { public: explicit ContainerAttach(void *args) : ClientBase(args) @@ -1334,7 +1334,7 @@ public: } ~ContainerAttach() = default; - int set_custom_header_metadata(ClientContext &context, const struct lcrc_attach_request *request) + int set_custom_header_metadata(ClientContext &context, const struct isula_attach_request *request) { if (request == nullptr || request->name == nullptr) { ERROR("Missing container id in the request"); @@ -1357,7 +1357,7 @@ public: return 0; } - void get_server_trailing_metadata(ClientContext &context, lcrc_attach_response *response) + void get_server_trailing_metadata(ClientContext &context, isula_attach_response *response) { auto metadata = context.GetServerTrailingMetadata(); auto cc = metadata.find("cc"); @@ -1372,13 +1372,13 @@ public: } } - int run(const struct lcrc_attach_request *request, struct lcrc_attach_response *response) override + int run(const struct isula_attach_request *request, struct isula_attach_response *response) override { ClientContext context; if (set_custom_header_metadata(context, request) != 0) { ERROR("Failed to translate request to grpc"); - response->cc = LCRD_ERR_INPUT; + response->cc = ISULAD_ERR_INPUT; return -1; } @@ -1414,8 +1414,8 @@ public: get_server_trailing_metadata(context, response); - if (response->server_errono != LCRD_SUCCESS) { - response->cc = LCRD_ERR_EXEC; + if (response->server_errono != ISULAD_SUCCESS) { + response->cc = ISULAD_ERR_EXEC; } out: @@ -1425,12 +1425,12 @@ out: writer.join(); } } - return (response->cc == LCRD_SUCCESS) ? 0 : -1; + return (response->cc == ISULAD_SUCCESS) ? 0 : -1; } }; -class ContainerPause : public ClientBase { +class ContainerPause : public ClientBase { public: explicit ContainerPause(void *args) : ClientBase(args) @@ -1438,7 +1438,7 @@ public: } ~ContainerPause() = default; - int request_to_grpc(const lcrc_pause_request *request, PauseRequest *grequest) override + int request_to_grpc(const isula_pause_request *request, PauseRequest *grequest) override { if (request == nullptr) { return -1; @@ -1451,7 +1451,7 @@ public: return 0; } - int response_from_grpc(PauseResponse *gresponse, lcrc_pause_response *response) override + int response_from_grpc(PauseResponse *gresponse, isula_pause_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -1477,8 +1477,8 @@ public: } }; -class ContainerResume : public ClientBase { +class ContainerResume : public ClientBase { public: explicit ContainerResume(void *args) : ClientBase(args) @@ -1486,7 +1486,7 @@ public: } ~ContainerResume() = default; - int request_to_grpc(const lcrc_resume_request *request, ResumeRequest *grequest) override + int request_to_grpc(const isula_resume_request *request, ResumeRequest *grequest) override { if (request == nullptr) { return -1; @@ -1499,7 +1499,7 @@ public: return 0; } - int response_from_grpc(ResumeResponse *gresponse, lcrc_resume_response *response) override + int response_from_grpc(ResumeResponse *gresponse, isula_resume_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -1525,8 +1525,8 @@ public: } }; -class ContainerExport : public ClientBase { +class ContainerExport : public ClientBase { public: explicit ContainerExport(void *args) : ClientBase(args) @@ -1534,7 +1534,7 @@ public: } ~ContainerExport() = default; - int request_to_grpc(const lcrc_export_request *request, ExportRequest *grequest) override + int request_to_grpc(const isula_export_request *request, ExportRequest *grequest) override { if (request == nullptr) { return -1; @@ -1550,7 +1550,7 @@ public: return 0; } - int response_from_grpc(ExportResponse *gresponse, lcrc_export_response *response) override + int response_from_grpc(ExportResponse *gresponse, isula_export_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -1580,8 +1580,8 @@ public: } }; -class ContainerUpdate : public ClientBase { +class ContainerUpdate : public ClientBase { public: explicit ContainerUpdate(void *args) : ClientBase(args) @@ -1589,7 +1589,7 @@ public: } ~ContainerUpdate() = default; - int request_to_grpc(const lcrc_update_request *request, UpdateRequest *grequest) override + int request_to_grpc(const isula_update_request *request, UpdateRequest *grequest) override { int ret = 0; char *json = nullptr; @@ -1598,7 +1598,7 @@ public: return -1; } - lcrc_host_config_t hostconfig; + isula_host_config_t hostconfig; (void)memset(&hostconfig, 0, sizeof(hostconfig)); if (request->updateconfig) { @@ -1622,7 +1622,7 @@ cleanup: return ret; } - int response_from_grpc(UpdateResponse *gresponse, lcrc_update_response *response) override + int response_from_grpc(UpdateResponse *gresponse, isula_update_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->errmsg().empty()) { @@ -1648,8 +1648,8 @@ cleanup: } }; -class ContainerStats : public ClientBase { +class ContainerStats : public ClientBase { public: explicit ContainerStats(void *args) : ClientBase(args) @@ -1657,7 +1657,7 @@ public: } ~ContainerStats() = default; - int request_to_grpc(const lcrc_stats_request *request, StatsRequest *grequest) override + int request_to_grpc(const isula_stats_request *request, StatsRequest *grequest) override { if (request == nullptr) { return -1; @@ -1672,12 +1672,12 @@ public: return 0; } - int response_from_grpc(StatsResponse *gresponse, lcrc_stats_response *response) override + int response_from_grpc(StatsResponse *gresponse, isula_stats_response *response) override { int size = gresponse->containers_size(); if (size > 0) { response->container_stats = - static_cast(util_common_calloc_s(size * sizeof(struct lcrc_container_info))); + static_cast(util_common_calloc_s(size * sizeof(struct isula_container_info))); if (response->container_stats == nullptr) { ERROR("Out of memory"); return -1; @@ -1718,8 +1718,8 @@ public: } }; -class ContainerEvents : public ClientBase { +class ContainerEvents : public ClientBase { public: explicit ContainerEvents(void *args) : ClientBase(args) @@ -1727,27 +1727,27 @@ public: } ~ContainerEvents() = default; - int run(const struct lcrc_events_request *request, struct lcrc_events_response *response) override + int run(const struct isula_events_request *request, struct isula_events_response *response) override { int ret; EventsRequest req; Event event; ClientContext context; Status status; - container_events_format_t lcrc_event; + container_events_format_t isula_event; ret = events_request_to_grpc(request, &req); if (ret != 0) { ERROR("Failed to translate request to grpc"); - response->server_errono = LCRD_ERR_INPUT; + response->server_errono = ISULAD_ERR_INPUT; return -1; } std::unique_ptr> reader(stub_->Events(&context, req)); while (reader->Read(&event)) { - event_from_grpc(&lcrc_event, &event); + event_from_grpc(&isula_event, &event); if (request->cb != nullptr) { - request->cb(&lcrc_event); + request->cb(&isula_event); } } status = reader->Finish(); @@ -1757,11 +1757,11 @@ public: return -1; } - if (response->server_errono != LCRD_SUCCESS) { - response->cc = LCRD_ERR_EXEC; + if (response->server_errono != ISULAD_SUCCESS) { + response->cc = ISULAD_ERR_EXEC; } - return (response->cc == LCRD_SUCCESS) ? 0 : -1; + return (response->cc == ISULAD_SUCCESS) ? 0 : -1; } private: @@ -1798,7 +1798,7 @@ private: } } - int events_request_to_grpc(const struct lcrc_events_request *request, EventsRequest *grequest) + int events_request_to_grpc(const struct isula_events_request *request, EventsRequest *grequest) { if (request == nullptr) { return -1; @@ -1862,7 +1862,7 @@ static int CopyFromContainerFinish(void *context, char **err) status.error_code() == grpc::StatusCode::INTERNAL)) { *err = util_strdup_s(status.error_message().c_str()); } else { - *err = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); + *err = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); } return -1; } @@ -1873,8 +1873,8 @@ static int CopyFromContainerFinish(void *context, char **err) } class CopyFromContainer - : public ClientBase { + : public ClientBase { public: explicit CopyFromContainer(void *args) : ClientBase(args) @@ -1882,8 +1882,8 @@ public: } ~CopyFromContainer() = default; - int run(const struct lcrc_copy_from_container_request *request, - struct lcrc_copy_from_container_response *response) override + int run(const struct isula_copy_from_container_request *request, + struct isula_copy_from_container_response *response) override { int ret; CopyFromContainerResponse res; @@ -1895,7 +1895,7 @@ public: ret = copy_from_container_request_to_grpc(request, &ctx->request); if (ret != 0) { ERROR("Failed to translate request to grpc"); - response->server_errono = LCRD_ERR_INPUT; + response->server_errono = ISULAD_ERR_INPUT; delete ctx; return -1; } @@ -1941,7 +1941,7 @@ public: } private: - int copy_from_container_request_to_grpc(const struct lcrc_copy_from_container_request *request, + int copy_from_container_request_to_grpc(const struct isula_copy_from_container_request *request, CopyFromContainerRequest *grequest) { if (request == nullptr) { @@ -2003,8 +2003,8 @@ private: }; class CopyToContainer - : public ClientBase { + : public ClientBase { public: explicit CopyToContainer(void *args) : ClientBase(args) @@ -2012,8 +2012,8 @@ public: } ~CopyToContainer() = default; - int set_custom_header_metadata(ClientContext &context, const struct lcrc_copy_to_container_request *request, - struct lcrc_copy_to_container_response *response) + int set_custom_header_metadata(ClientContext &context, const struct isula_copy_to_container_request *request, + struct isula_copy_to_container_response *response) { int ret = 0; char *json = nullptr; @@ -2056,13 +2056,13 @@ out: return ret; } - int run(const struct lcrc_copy_to_container_request *request, struct lcrc_copy_to_container_response *response) + int run(const struct isula_copy_to_container_request *request, struct isula_copy_to_container_response *response) override { ClientContext context; if (set_custom_header_metadata(context, request, response) != 0) { ERROR("Failed to translate request to grpc"); - response->cc = LCRD_ERR_INPUT; + response->cc = ISULAD_ERR_INPUT; return -1; } using StreamRSharedPtr = std::shared_ptr>; @@ -2093,8 +2093,8 @@ out: } }; -class ContainerLogs : public ClientBase { +class ContainerLogs : public ClientBase { public: explicit ContainerLogs(void *args) : ClientBase(args) @@ -2102,7 +2102,7 @@ public: } ~ContainerLogs() = default; - int run(const struct lcrc_logs_request *request, struct lcrc_logs_response *response) override + int run(const struct isula_logs_request *request, struct isula_logs_response *response) override { ClientContext context; LogsRequest grequest; @@ -2121,7 +2121,7 @@ public: if (logs_request_to_grpc(request, &grequest) != 0) { ERROR("Failed to transform container request to grpc"); - response->server_errono = LCRD_ERR_INPUT; + response->server_errono = ISULAD_ERR_INPUT; return -1; } @@ -2141,7 +2141,7 @@ public: } private: - void show_container_log(const struct lcrc_logs_request *request, const LogsResponse &gresponse) + void show_container_log(const struct isula_logs_request *request, const LogsResponse &gresponse) { static std::ostream *os = nullptr; @@ -2159,7 +2159,7 @@ private: (*os) << gresponse.data(); } - int logs_request_to_grpc(const struct lcrc_logs_request *request, LogsRequest *grequest) + int logs_request_to_grpc(const struct isula_logs_request *request, LogsRequest *grequest) { if (request == nullptr) { return -1; @@ -2184,41 +2184,41 @@ private: } }; -int grpc_containers_client_ops_init(lcrc_connect_ops *ops) +int grpc_containers_client_ops_init(isula_connect_ops *ops) { if (ops == nullptr) { return -1; } // implement following interface - ops->container.version = container_func; - ops->container.info = container_func; - ops->container.create = container_func; - ops->container.start = container_func; - ops->container.remote_start = container_func; - ops->container.stop = container_func; - ops->container.restart = container_func; - ops->container.remove = container_func; - ops->container.list = container_func; - ops->container.exec = container_func; - ops->container.remote_exec = container_func; - ops->container.attach = container_func; - ops->container.pause = container_func; - ops->container.resume = container_func; - ops->container.update = container_func; - ops->container.kill = container_func; - ops->container.stats = container_func; - ops->container.wait = container_func; - ops->container.events = container_func; - ops->container.inspect = container_func; - ops->container.export_rootfs = container_func; + ops->container.version = container_func; + ops->container.info = container_func; + ops->container.create = container_func; + ops->container.start = container_func; + ops->container.remote_start = container_func; + ops->container.stop = container_func; + ops->container.restart = container_func; + ops->container.remove = container_func; + ops->container.list = container_func; + ops->container.exec = container_func; + ops->container.remote_exec = container_func; + ops->container.attach = container_func; + ops->container.pause = container_func; + ops->container.resume = container_func; + ops->container.update = container_func; + ops->container.kill = container_func; + ops->container.stats = container_func; + ops->container.wait = container_func; + ops->container.events = container_func; + ops->container.inspect = container_func; + ops->container.export_rootfs = container_func; ops->container.copy_from_container = - container_func; + container_func; ops->container.copy_to_container = - container_func; - ops->container.top = container_func; - ops->container.rename = container_func; - ops->container.resize = container_func; - ops->container.logs = container_func; + container_func; + ops->container.top = container_func; + ops->container.rename = container_func; + ops->container.resize = container_func; + ops->container.logs = container_func; return 0; } diff --git a/src/connect/client/grpc/grpc_containers_client.h b/src/connect/client/grpc/grpc_containers_client.h index e15878ec66e15b5dcc72e77e078425b802c98e06..ee9affd1dac323d5a3e760033a383376bd131e6a 100644 --- a/src/connect/client/grpc/grpc_containers_client.h +++ b/src/connect/client/grpc/grpc_containers_client.h @@ -15,13 +15,13 @@ #ifndef __GRPC_CONTAINERS_CLIENT_H #define __GRPC_CONTAINERS_CLIENT_H -#include "lcrc_connect.h" +#include "isula_connect.h" #ifdef __cplusplus extern "C" { #endif -int grpc_containers_client_ops_init(lcrc_connect_ops *ops); +int grpc_containers_client_ops_init(isula_connect_ops *ops); #ifdef __cplusplus } diff --git a/src/connect/client/grpc/grpc_images_client.cc b/src/connect/client/grpc/grpc_images_client.cc index 6fab05c35745e73f2cef0639b5c49af6b4ed3d69..3c924edbfd7005ed85df7e7c863a27feea277f34 100644 --- a/src/connect/client/grpc/grpc_images_client.cc +++ b/src/connect/client/grpc/grpc_images_client.cc @@ -29,8 +29,8 @@ using grpc::ClientWriter; using grpc::Status; using google::protobuf::Timestamp; -class ImagesList : public ClientBase { +class ImagesList : public ClientBase { public: explicit ImagesList(void *args) : ClientBase(args) @@ -38,7 +38,7 @@ public: } ~ImagesList() = default; - int request_to_grpc(const lcrc_list_images_request *request, ListImagesRequest *grequest) override + int request_to_grpc(const isula_list_images_request *request, ListImagesRequest *grequest) override { if (request == nullptr) { return -1; @@ -53,9 +53,9 @@ public: return 0; } - int response_from_grpc(ListImagesResponse *gresponse, lcrc_list_images_response *response) override + int response_from_grpc(ListImagesResponse *gresponse, isula_list_images_response *response) override { - struct lcrc_image_info *images_list = nullptr; + struct isula_image_info *images_list = nullptr; int i; int num = gresponse->images_size(); @@ -71,15 +71,15 @@ public: response->images_num = 0; - if ((size_t)num > SIZE_MAX / sizeof(struct lcrc_image_info)) { + if ((size_t)num > SIZE_MAX / sizeof(struct isula_image_info)) { ERROR("Too many images"); - response->cc = LCRD_ERR_MEMOUT; + response->cc = ISULAD_ERR_MEMOUT; return -1; } - images_list = (struct lcrc_image_info *)util_common_calloc_s(sizeof(struct lcrc_image_info) * (size_t)num); + images_list = (struct isula_image_info *)util_common_calloc_s(sizeof(struct isula_image_info) * (size_t)num); if (images_list == nullptr) { ERROR("out of memory"); - response->cc = LCRD_ERR_MEMOUT; + response->cc = ISULAD_ERR_MEMOUT; return -1; } @@ -117,8 +117,8 @@ public: } }; -class ImagesDelete : public ClientBase { +class ImagesDelete : public ClientBase { public: explicit ImagesDelete(void *args) : ClientBase(args) @@ -126,7 +126,7 @@ public: } ~ImagesDelete() = default; - int request_to_grpc(const lcrc_rmi_request *request, DeleteImageRequest *grequest) override + int request_to_grpc(const isula_rmi_request *request, DeleteImageRequest *grequest) override { if (request == nullptr) { return -1; @@ -140,7 +140,7 @@ public: return 0; } - int response_from_grpc(DeleteImageResponse *gresponse, lcrc_rmi_response *response) override + int response_from_grpc(DeleteImageResponse *gresponse, isula_rmi_response *response) override { response->server_errono = (uint32_t)gresponse->cc(); @@ -167,8 +167,8 @@ public: } }; -class ImagesLoad : public ClientBase { +class ImagesLoad : public ClientBase { public: explicit ImagesLoad(void *args) : ClientBase(args) @@ -176,7 +176,7 @@ public: } ~ImagesLoad() = default; - int request_to_grpc(const lcrc_load_request *request, LoadImageRequest *grequest) override + int request_to_grpc(const isula_load_request *request, LoadImageRequest *grequest) override { if (request == nullptr) { return -1; @@ -195,7 +195,7 @@ public: return 0; } - int response_from_grpc(LoadImageResponse *gresponse, lcrc_load_response *response) override + int response_from_grpc(LoadImageResponse *gresponse, isula_load_response *response) override { response->server_errono = (uint32_t)gresponse->cc(); @@ -227,8 +227,8 @@ public: }; class ImagesPull : public - ClientBase { + ClientBase { public: explicit ImagesPull(void *args) : ClientBase(args) @@ -236,7 +236,7 @@ public: } ~ImagesPull() = default; - int request_to_grpc(const lcrc_pull_request *request, runtime::v1alpha2::PullImageRequest *grequest) override + int request_to_grpc(const isula_pull_request *request, runtime::v1alpha2::PullImageRequest *grequest) override { if (request == nullptr) { return -1; @@ -254,7 +254,7 @@ public: return 0; } - int response_from_grpc(runtime::v1alpha2::PullImageResponse *gresponse, lcrc_pull_response *response) override + int response_from_grpc(runtime::v1alpha2::PullImageResponse *gresponse, isula_pull_response *response) override { if (!gresponse->image_ref().empty()) { response->image_ref = util_strdup_s(gresponse->image_ref().c_str()); @@ -280,8 +280,8 @@ public: } }; -class ImageInspect : public ClientBase { +class ImageInspect : public ClientBase { public: explicit ImageInspect(void *args) : ClientBase(args) @@ -289,7 +289,7 @@ public: } ~ImageInspect() = default; - int request_to_grpc(const lcrc_inspect_request *request, InspectImageRequest *grequest) override + int request_to_grpc(const isula_inspect_request *request, InspectImageRequest *grequest) override { if (request == nullptr) { return -1; @@ -304,7 +304,7 @@ public: return 0; } - int response_from_grpc(InspectImageResponse *gresponse, lcrc_inspect_response *response) override + int response_from_grpc(InspectImageResponse *gresponse, isula_inspect_response *response) override { response->server_errono = gresponse->cc(); if (!gresponse->imagejson().empty()) { @@ -334,13 +334,13 @@ public: }; class Login : public - ClientBase { + ClientBase { public: explicit Login(void *args) : ClientBase(args) {} ~Login() = default; - int request_to_grpc(const lcrc_login_request *request, LoginRequest *grequest) override + int request_to_grpc(const isula_login_request *request, LoginRequest *grequest) override { if (request == nullptr) { return -1; @@ -362,7 +362,7 @@ public: return 0; } - int response_from_grpc(LoginResponse *gresponse, lcrc_login_response *response) override + int response_from_grpc(LoginResponse *gresponse, isula_login_response *response) override { response->server_errono = (uint32_t)gresponse->cc(); @@ -402,13 +402,13 @@ public: }; class Logout : public - ClientBase { + ClientBase { public: explicit Logout(void *args) : ClientBase(args) {} ~Logout() = default; - int request_to_grpc(const lcrc_logout_request *request, LogoutRequest *grequest) override + int request_to_grpc(const isula_logout_request *request, LogoutRequest *grequest) override { if (request == nullptr) { return -1; @@ -424,7 +424,7 @@ public: return 0; } - int response_from_grpc(LogoutResponse *gresponse, lcrc_logout_response *response) override + int response_from_grpc(LogoutResponse *gresponse, isula_logout_response *response) override { response->server_errono = (uint32_t)gresponse->cc(); @@ -455,19 +455,19 @@ public: } }; -int grpc_images_client_ops_init(lcrc_connect_ops *ops) +int grpc_images_client_ops_init(isula_connect_ops *ops) { if (ops == nullptr) { return -1; } - ops->image.list = container_func; - ops->image.remove = container_func; - ops->image.load = container_func; - ops->image.pull = container_func; - ops->image.inspect = container_func; - ops->image.login = container_func; - ops->image.logout = container_func; + ops->image.list = container_func; + ops->image.remove = container_func; + ops->image.load = container_func; + ops->image.pull = container_func; + ops->image.inspect = container_func; + ops->image.login = container_func; + ops->image.logout = container_func; return 0; } diff --git a/src/connect/client/grpc/grpc_images_client.h b/src/connect/client/grpc/grpc_images_client.h index eff36b8637a7fc3191bf47670e36599f4f536519..966fb87bf804c215be4f1f6f9d94992e824bf9b5 100644 --- a/src/connect/client/grpc/grpc_images_client.h +++ b/src/connect/client/grpc/grpc_images_client.h @@ -15,13 +15,13 @@ #ifndef __GRPC_IMAGES_CLIENT_H #define __GRPC_IMAGES_CLIENT_H -#include "lcrc_connect.h" +#include "isula_connect.h" #ifdef __cplusplus extern "C" { #endif -int grpc_images_client_ops_init(lcrc_connect_ops *ops); +int grpc_images_client_ops_init(isula_connect_ops *ops); #ifdef __cplusplus } diff --git a/src/connect/client/grpc/grpc_isula_image_client.cc b/src/connect/client/grpc/grpc_isula_image_client.cc index f94dc8becf26c32c47952a741b3d2c8efd07671b..561d1ee5a3254a3b35a0affbecedf370a106de22 100644 --- a/src/connect/client/grpc/grpc_isula_image_client.cc +++ b/src/connect/client/grpc/grpc_isula_image_client.cc @@ -10,7 +10,7 @@ * See the Mulan PSL v1 for more details. * Author: liuhao * Create: 2019-07-12 -* Description: provide lcrc connect command definition +* Description: provide isula connect command definition *******************************************************************************/ #include "grpc_isula_image_client.h" #include @@ -19,7 +19,7 @@ #include "isula_image.pb.h" #include "utils.h" #include "client_base.h" -#include "liblcrd.h" +#include "libisulad.h" namespace { int copy_image_tags_metadata(const isula::Image &gimage, struct image_metadata *metadata) @@ -656,13 +656,13 @@ public: { if (req.file().empty()) { ERROR("Load image requires input file path"); - lcrd_set_error_message("Load image requires input file path"); + isulad_set_error_message("Load image requires input file path"); return -1; } if (!req.tag().empty()) { if (util_valid_image_name(req.tag().c_str()) != true) { ERROR("Invalid tag %s", req.tag().c_str()); - lcrd_try_set_error_message("Invalid tag:%s", req.tag().c_str()); + isulad_try_set_error_message("Invalid tag:%s", req.tag().c_str()); return -1; } } @@ -686,7 +686,7 @@ public: int request_to_grpc(const isula_login_request *req, isula::LoginRequest *grequest) override { if (req == nullptr) { - lcrd_set_error_message("invalid login request"); + isulad_set_error_message("invalid login request"); return -1; } if (req->server != nullptr) { @@ -713,11 +713,11 @@ public: int check_parameter(const isula::LoginRequest &req) override { if (req.server().empty()) { - lcrd_set_error_message("Login requires server address"); + isulad_set_error_message("Login requires server address"); return -1; } if (req.username().empty() || req.password().empty()) { - lcrd_set_error_message("Missing username or password"); + isulad_set_error_message("Missing username or password"); return -1; } return 0; @@ -740,7 +740,7 @@ public: int request_to_grpc(const isula_logout_request *req, isula::LogoutRequest *grequest) override { if (req == nullptr) { - lcrd_set_error_message("invalid logout request"); + isulad_set_error_message("invalid logout request"); return -1; } if (req->server != nullptr) { @@ -761,7 +761,7 @@ public: int check_parameter(const isula::LogoutRequest &req) override { if (req.server().empty()) { - lcrd_set_error_message("Logout requires server address"); + isulad_set_error_message("Logout requires server address"); return -1; } return 0; @@ -784,7 +784,7 @@ public: int request_to_grpc(const isula_export_request *req, isula::ContainerExportRequest *grequest) override { if (req == nullptr) { - lcrd_set_error_message("unvalid export request"); + isulad_set_error_message("unvalid export request"); return -1; } if (req->name_id != nullptr) { @@ -811,11 +811,11 @@ public: int check_parameter(const isula::ContainerExportRequest &req) override { if (req.name_id().empty()) { - lcrd_set_error_message("Export rootfs requires container name"); + isulad_set_error_message("Export rootfs requires container name"); return -1; } if (req.output().empty()) { - lcrd_set_error_message("Export rootfs requires output file path"); + isulad_set_error_message("Export rootfs requires output file path"); return -1; } return 0; @@ -869,7 +869,7 @@ public: int request_to_grpc(const isula_container_fs_usage_request *req, isula::ContainerFsUsageRequest *grequest) override { if (req == nullptr) { - lcrd_set_error_message("invalid containerfsusage request"); + isulad_set_error_message("invalid containerfsusage request"); return -1; } if (req->name_id != nullptr) { @@ -894,7 +894,7 @@ public: int check_parameter(const isula::ContainerFsUsageRequest &req) override { if (req.name_id().empty()) { - lcrd_set_error_message("Required container id"); + isulad_set_error_message("Required container id"); return -1; } diff --git a/src/connect/client/grpc/grpc_isula_image_client.h b/src/connect/client/grpc/grpc_isula_image_client.h index f4c9bd0d9181d13b070b55ae03b3c0211fb4a95f..0b48f90b8eba347bdc8014ea973d2b3c1de07ad8 100644 --- a/src/connect/client/grpc/grpc_isula_image_client.h +++ b/src/connect/client/grpc/grpc_isula_image_client.h @@ -10,7 +10,7 @@ * See the Mulan PSL v1 for more details. * Author: liuhao * Create: 2019-07-12 -* Description: provide lcrc connect command definition +* Description: provide isula connect command definition *******************************************************************************/ #ifndef __GRPC_ISULA_IMAGE_CONNECT_H #define __GRPC_ISULA_IMAGE_CONNECT_H diff --git a/src/connect/client/lcrc_connect.c b/src/connect/client/isula_connect.c similarity index 87% rename from src/connect/client/lcrc_connect.c rename to src/connect/client/isula_connect.c index b5111d09fbce3a82946e3d8126cd0ef908eda2d4..90d5acd483304bf8f45e896d54d66dc42878ce7e 100644 --- a/src/connect/client/lcrc_connect.c +++ b/src/connect/client/isula_connect.c @@ -10,9 +10,9 @@ * See the Mulan PSL v1 for more details. * Author: maoweiyong * Create: 2018-11-08 - * Description: provide lcrc connect command definition + * Description: provide isula connect command definition ******************************************************************************/ -#include "lcrc_connect.h" +#include "isula_connect.h" #ifdef GRPC_CONNECTOR @@ -21,7 +21,7 @@ #include "rest_client.h" #endif -static lcrc_connect_ops g_connect_ops; +static isula_connect_ops g_connect_ops; /* connect client ops init */ int connect_client_ops_init(void) @@ -40,7 +40,7 @@ int connect_client_ops_init(void) } /* get connect client ops */ -lcrc_connect_ops *get_connect_client_ops(void) +isula_connect_ops *get_connect_client_ops(void) { return &g_connect_ops; } diff --git a/src/connect/client/isula_connect.h b/src/connect/client/isula_connect.h new file mode 100644 index 0000000000000000000000000000000000000000..67d2ba71f3dc77a91318f56de08c938f61925194 --- /dev/null +++ b/src/connect/client/isula_connect.h @@ -0,0 +1,144 @@ +/****************************************************************************** + * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved. + * iSulad licensed under the Mulan PSL v1. + * You can use this software according to the terms and conditions of the Mulan PSL v1. + * You may obtain a copy of Mulan PSL v1 at: + * http://license.coscl.org.cn/MulanPSL + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v1 for more details. + * Author: maoweiyong + * Create: 2018-11-08 + * Description: provide isula connect command definition + ******************************************************************************/ +#ifndef __ISULA_CONNECT_H +#define __ISULA_CONNECT_H + +#include "libisula.h" +#include "connect.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int(*version)(const struct isula_version_request *request, + struct isula_version_response *response, void *arg); + + int(*info)(const struct isula_info_request *request, + struct isula_info_response *response, void *arg); + + int(*create)(const struct isula_create_request *request, + struct isula_create_response *response, void *arg); + + int(*start)(const struct isula_start_request *request, + struct isula_start_response *response, void *arg); + + int(*remote_start)(const struct isula_start_request *request, + struct isula_start_response *response, void *arg); + + int(*stop)(const struct isula_stop_request *request, + struct isula_stop_response *response, void *arg); + + int(*restart)(const struct isula_restart_request *request, + struct isula_restart_response *response, void *arg); + + int(*kill)(const struct isula_kill_request *request, + struct isula_kill_response *response, void *arg); + + int(*remove)(const struct isula_delete_request *request, + struct isula_delete_response *response, void *arg); + + int(*pause)(const struct isula_pause_request *request, + struct isula_pause_response *response, void *arg); + + int(*resume)(const struct isula_resume_request *request, + struct isula_resume_response *response, void *arg); + + int(*list)(const struct isula_list_request *request, + struct isula_list_response *response, void *arg); + + int(*inspect)(const struct isula_inspect_request *request, + struct isula_inspect_response *response, void *arg); + + int(*stats)(const struct isula_stats_request *request, + struct isula_stats_response *response, void *arg); + + int(*events)(const struct isula_events_request *request, + struct isula_events_response *response, void *arg); + + int(*copy_from_container)(const struct isula_copy_from_container_request *request, + struct isula_copy_from_container_response *response, void *arg); + + int(*copy_to_container)(const struct isula_copy_to_container_request *request, + struct isula_copy_to_container_response *response, void *arg); + + int(*exec)(const struct isula_exec_request *request, + struct isula_exec_response *response, void *arg); + + int(*remote_exec)(const struct isula_exec_request *request, + struct isula_exec_response *response, void *arg); + + int(*update)(const struct isula_update_request *request, + struct isula_update_response *response, void *arg); + + int(*attach)(const struct isula_attach_request *request, + struct isula_attach_response *response, void *arg); + + int(*wait)(const struct isula_wait_request *request, + struct isula_wait_response *response, void *arg); + + int(*export_rootfs)(const struct isula_export_request *request, + struct isula_export_response *response, void *arg); + int(*top)(const struct isula_top_request *request, + struct isula_top_response *response, void *arg); + int(*rename)(const struct isula_rename_request *request, + struct isula_rename_response *response, void *arg); + int(*resize)(const struct isula_resize_request *request, + struct isula_resize_response *response, void *arg); + int(*logs)(const struct isula_logs_request *request, struct isula_logs_response *response, void *arg); +} container_ops; + +typedef struct { + int(*list)(const struct isula_list_images_request *request, + struct isula_list_images_response *response, void *arg); + + int(*remove)(const struct isula_rmi_request *request, + struct isula_rmi_response *response, void *arg); + + int(*load)(const struct isula_load_request *request, + struct isula_load_response *response, void *arg); + + int(*pull)(const struct isula_pull_request *request, + struct isula_pull_response *response, void *arg); + + int(*inspect)(const struct isula_inspect_request *request, + struct isula_inspect_response *response, void *arg); + int(*login)(const struct isula_login_request *request, + struct isula_login_response *response, void *arg); + int(*logout)(const struct isula_logout_request *request, + struct isula_logout_response *response, void *arg); +} image_ops; + +typedef struct { + int(*check)(const struct isula_health_check_request *request, + struct isula_health_check_response *response, void *arg); +} health_ops; + +typedef struct { + container_ops container; + image_ops image; + health_ops health; +} isula_connect_ops; + +int connect_client_ops_init(void); + +isula_connect_ops *get_connect_client_ops(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __ISULA_CONNECT_H */ + diff --git a/src/connect/client/lcrc_connect.h b/src/connect/client/lcrc_connect.h deleted file mode 100644 index 46635d9bf148b1e8ca9737088fb6cb41f47fde5e..0000000000000000000000000000000000000000 --- a/src/connect/client/lcrc_connect.h +++ /dev/null @@ -1,144 +0,0 @@ -/****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved. - * iSulad licensed under the Mulan PSL v1. - * You can use this software according to the terms and conditions of the Mulan PSL v1. - * You may obtain a copy of Mulan PSL v1 at: - * http://license.coscl.org.cn/MulanPSL - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v1 for more details. - * Author: maoweiyong - * Create: 2018-11-08 - * Description: provide lcrc connect command definition - ******************************************************************************/ -#ifndef __LCRC_CONNECT_H -#define __LCRC_CONNECT_H - -#include "liblcrc.h" -#include "connect.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int(*version)(const struct lcrc_version_request *request, - struct lcrc_version_response *response, void *arg); - - int(*info)(const struct lcrc_info_request *request, - struct lcrc_info_response *response, void *arg); - - int(*create)(const struct lcrc_create_request *request, - struct lcrc_create_response *response, void *arg); - - int(*start)(const struct lcrc_start_request *request, - struct lcrc_start_response *response, void *arg); - - int(*remote_start)(const struct lcrc_start_request *request, - struct lcrc_start_response *response, void *arg); - - int(*stop)(const struct lcrc_stop_request *request, - struct lcrc_stop_response *response, void *arg); - - int(*restart)(const struct lcrc_restart_request *request, - struct lcrc_restart_response *response, void *arg); - - int(*kill)(const struct lcrc_kill_request *request, - struct lcrc_kill_response *response, void *arg); - - int(*remove)(const struct lcrc_delete_request *request, - struct lcrc_delete_response *response, void *arg); - - int(*pause)(const struct lcrc_pause_request *request, - struct lcrc_pause_response *response, void *arg); - - int(*resume)(const struct lcrc_resume_request *request, - struct lcrc_resume_response *response, void *arg); - - int(*list)(const struct lcrc_list_request *request, - struct lcrc_list_response *response, void *arg); - - int(*inspect)(const struct lcrc_inspect_request *request, - struct lcrc_inspect_response *response, void *arg); - - int(*stats)(const struct lcrc_stats_request *request, - struct lcrc_stats_response *response, void *arg); - - int(*events)(const struct lcrc_events_request *request, - struct lcrc_events_response *response, void *arg); - - int(*copy_from_container)(const struct lcrc_copy_from_container_request *request, - struct lcrc_copy_from_container_response *response, void *arg); - - int(*copy_to_container)(const struct lcrc_copy_to_container_request *request, - struct lcrc_copy_to_container_response *response, void *arg); - - int(*exec)(const struct lcrc_exec_request *request, - struct lcrc_exec_response *response, void *arg); - - int(*remote_exec)(const struct lcrc_exec_request *request, - struct lcrc_exec_response *response, void *arg); - - int(*update)(const struct lcrc_update_request *request, - struct lcrc_update_response *response, void *arg); - - int(*attach)(const struct lcrc_attach_request *request, - struct lcrc_attach_response *response, void *arg); - - int(*wait)(const struct lcrc_wait_request *request, - struct lcrc_wait_response *response, void *arg); - - int(*export_rootfs)(const struct lcrc_export_request *request, - struct lcrc_export_response *response, void *arg); - int(*top)(const struct lcrc_top_request *request, - struct lcrc_top_response *response, void *arg); - int(*rename)(const struct lcrc_rename_request *request, - struct lcrc_rename_response *response, void *arg); - int(*resize)(const struct lcrc_resize_request *request, - struct lcrc_resize_response *response, void *arg); - int(*logs)(const struct lcrc_logs_request *request, struct lcrc_logs_response *response, void *arg); -} container_ops; - -typedef struct { - int(*list)(const struct lcrc_list_images_request *request, - struct lcrc_list_images_response *response, void *arg); - - int(*remove)(const struct lcrc_rmi_request *request, - struct lcrc_rmi_response *response, void *arg); - - int(*load)(const struct lcrc_load_request *request, - struct lcrc_load_response *response, void *arg); - - int(*pull)(const struct lcrc_pull_request *request, - struct lcrc_pull_response *response, void *arg); - - int(*inspect)(const struct lcrc_inspect_request *request, - struct lcrc_inspect_response *response, void *arg); - int(*login)(const struct lcrc_login_request *request, - struct lcrc_login_response *response, void *arg); - int(*logout)(const struct lcrc_logout_request *request, - struct lcrc_logout_response *response, void *arg); -} image_ops; - -typedef struct { - int(*check)(const struct lcrc_health_check_request *request, - struct lcrc_health_check_response *response, void *arg); -} health_ops; - -typedef struct { - container_ops container; - image_ops image; - health_ops health; -} lcrc_connect_ops; - -int connect_client_ops_init(void); - -lcrc_connect_ops *get_connect_client_ops(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __LCRC_CONNECT_H */ - diff --git a/src/connect/client/rest/rest_client.c b/src/connect/client/rest/rest_client.c index 8942b374f98c5b269130029524ae54f10edffb49..5bfc26fba472523881bacbb79e4f4c5488da76ac 100644 --- a/src/connect/client/rest/rest_client.c +++ b/src/connect/client/rest/rest_client.c @@ -16,7 +16,7 @@ #include "rest_containers_client.h" #include "rest_images_client.h" -int rest_ops_init(lcrc_connect_ops *ops) +int rest_ops_init(isula_connect_ops *ops) { if (ops == NULL) { return -1; diff --git a/src/connect/client/rest/rest_client.h b/src/connect/client/rest/rest_client.h index e5f2eb2b5288ed9d60c50ace6cf8429197ad751c..c87cd33cda414c7880a6250169478173b7349004 100644 --- a/src/connect/client/rest/rest_client.h +++ b/src/connect/client/rest/rest_client.h @@ -15,13 +15,13 @@ #ifndef __REST_CLIENT_H #define __REST_CLIENT_H -#include "lcrc_connect.h" +#include "isula_connect.h" #ifdef __cplusplus extern "C" { #endif -int rest_ops_init(lcrc_connect_ops *ops); +int rest_ops_init(isula_connect_ops *ops); #ifdef __cplusplus } diff --git a/src/connect/client/rest/rest_containers_client.c b/src/connect/client/rest/rest_containers_client.c index f92ead51d54c155f3b1bf5d43bdbe2713d789bd7..26d8bdb7b77aed8a8ad9c0eb13b951999c4b9773 100644 --- a/src/connect/client/rest/rest_containers_client.c +++ b/src/connect/client/rest/rest_containers_client.c @@ -16,14 +16,14 @@ #include "error.h" #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "container.rest.h" #include "pack_config.h" #include "rest_common.h" #include "rest_containers_client.h" /* create request to rest */ -static int create_request_to_rest(const struct lcrc_create_request *lc_request, char **body, size_t *body_len) +static int create_request_to_rest(const struct isula_create_request *lc_request, char **body, size_t *body_len) { container_create_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -78,7 +78,7 @@ out: } /* start request to rest */ -static int start_request_to_rest(const struct lcrc_start_request *ls_request, char **body, size_t *body_len) +static int start_request_to_rest(const struct isula_start_request *ls_request, char **body, size_t *body_len) { container_start_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -121,7 +121,7 @@ out: } /* list request to rest */ -static int list_request_to_rest(const struct lcrc_list_request *ll_request, char **body, size_t *body_len) +static int list_request_to_rest(const struct isula_list_request *ll_request, char **body, size_t *body_len) { container_list_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -203,7 +203,7 @@ out: } /* attach request to rest */ -static int attach_request_to_rest(const struct lcrc_attach_request *la_request, char **body, size_t *body_len) +static int attach_request_to_rest(const struct isula_attach_request *la_request, char **body, size_t *body_len) { container_attach_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -242,7 +242,7 @@ out: } /* resume request to rest */ -static int resume_request_to_rest(const struct lcrc_resume_request *lr_request, char **body, size_t *body_len) +static int resume_request_to_rest(const struct isula_resume_request *lr_request, char **body, size_t *body_len) { container_resume_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -272,7 +272,7 @@ out: } /* wait request to rest */ -static int wait_request_to_rest(const struct lcrc_wait_request *lw_request, char **body, size_t *body_len) +static int wait_request_to_rest(const struct isula_wait_request *lw_request, char **body, size_t *body_len) { container_wait_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -306,7 +306,7 @@ out: /* unpack create response */ static int unpack_create_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_create_response *response = arg; + struct isula_create_response *response = arg; container_create_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -329,7 +329,7 @@ static int unpack_create_response(const struct parsed_http_message *message, voi if (cresponse->id != NULL) { response->id = util_strdup_s(cresponse->id); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -343,7 +343,7 @@ out: /* unpack start response */ static int unpack_start_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_start_response *start_response = arg; + struct isula_start_response *start_response = arg; container_start_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -363,7 +363,7 @@ static int unpack_start_response(const struct parsed_http_message *message, void if (cresponse->errmsg != NULL) { start_response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -375,11 +375,11 @@ out: } static int unpack_container_info_for_list_response(container_list_response *cresponse, - struct lcrc_list_response *response) + struct isula_list_response *response) { size_t num = 0; size_t i = 0; - struct lcrc_container_summary_info **summary_info = NULL; + struct isula_container_summary_info **summary_info = NULL; if (cresponse == NULL || response == NULL) { return -1; @@ -389,12 +389,12 @@ static int unpack_container_info_for_list_response(container_list_response *cres if (num == 0) { return 0; } - if (num > SIZE_MAX / sizeof(struct lcrc_container_summary_info *)) { + if (num > SIZE_MAX / sizeof(struct isula_container_summary_info *)) { ERROR("Too many container summaries"); return -1; } - summary_info = (struct lcrc_container_summary_info **)util_common_calloc_s( - sizeof(struct lcrc_container_summary_info *) * num); + summary_info = (struct isula_container_summary_info **)util_common_calloc_s( + sizeof(struct isula_container_summary_info *) * num); if (summary_info == NULL) { ERROR("out of memory"); return -1; @@ -403,7 +403,7 @@ static int unpack_container_info_for_list_response(container_list_response *cres response->container_summary = summary_info; for (i = 0; i < num; i++) { summary_info[i] = - (struct lcrc_container_summary_info *)util_common_calloc_s(sizeof(struct lcrc_container_summary_info)); + (struct isula_container_summary_info *)util_common_calloc_s(sizeof(struct isula_container_summary_info)); if (summary_info[i] == NULL) { ERROR("Out of memory"); return -1; @@ -434,7 +434,7 @@ static int unpack_container_info_for_list_response(container_list_response *cres /* unpack list response */ static int unpack_list_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_list_response *response = arg; + struct isula_list_response *response = arg; container_list_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -454,7 +454,7 @@ static int unpack_list_response(const struct parsed_http_message *message, void if (cresponse->errmsg != NULL) { response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -472,7 +472,7 @@ out: /* unpack attach response */ static int unpack_attach_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_attach_response *attach_response = arg; + struct isula_attach_response *attach_response = arg; container_attach_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -492,7 +492,7 @@ static int unpack_attach_response(const struct parsed_http_message *message, voi if (cresponse->errmsg != NULL) { attach_response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -506,7 +506,7 @@ out: /* unpack resume response */ static int unpack_resume_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_resume_response *resume_response = arg; + struct isula_resume_response *resume_response = arg; container_resume_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -526,7 +526,7 @@ static int unpack_resume_response(const struct parsed_http_message *message, voi if (cresponse->errmsg != NULL) { resume_response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -540,7 +540,7 @@ out: /* unpack wait response */ static int unpack_wait_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_wait_response *response = arg; + struct isula_wait_response *response = arg; container_wait_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -561,7 +561,7 @@ static int unpack_wait_response(const struct parsed_http_message *message, void if (cresponse->errmsg != NULL) { response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -573,8 +573,8 @@ out: } /* rest container create */ -static int rest_container_create(const struct lcrc_create_request *lc_request, - struct lcrc_create_response *lc_response, void *arg) +static int rest_container_create(const struct isula_create_request *lc_request, + struct isula_create_response *lc_response, void *arg) { char *body = NULL; int ret = 0; @@ -585,13 +585,13 @@ static int rest_container_create(const struct lcrc_create_request *lc_request, ret = create_request_to_rest(lc_request, &body, &len); if (ret != 0) { - lc_response->cc = LCRD_ERR_INPUT; + lc_response->cc = ISULAD_ERR_INPUT; goto out; } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceCreate, body, len, &c_output); if (ret != 0) { - lc_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - lc_response->cc = LCRD_ERR_EXEC; + lc_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + lc_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(c_output, unpack_create_response, (void *)lc_response); @@ -607,7 +607,7 @@ out: } /* rest container start */ -static int rest_container_start(const struct lcrc_start_request *ls_request, struct lcrc_start_response *ls_response, +static int rest_container_start(const struct isula_start_request *ls_request, struct isula_start_response *ls_response, void *arg) { char *body = NULL; @@ -623,9 +623,9 @@ static int rest_container_start(const struct lcrc_start_request *ls_request, str } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceStart, body, len, &s_output); if (ret != 0) { - ls_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - ls_response->cc = LCRD_ERR_EXEC; - ls_response->server_errono = LCRD_ERR_EXEC; + ls_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + ls_response->cc = ISULAD_ERR_EXEC; + ls_response->server_errono = ISULAD_ERR_EXEC; goto out; } ret = get_response(s_output, unpack_start_response, (void *)ls_response); @@ -641,8 +641,8 @@ out: } /* rest container attach */ -static int rest_container_attach(const struct lcrc_attach_request *la_request, - struct lcrc_attach_response *la_response, void *arg) +static int rest_container_attach(const struct isula_attach_request *la_request, + struct isula_attach_response *la_response, void *arg) { char *body = NULL; int ret = 0; @@ -657,8 +657,8 @@ static int rest_container_attach(const struct lcrc_attach_request *la_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceAttach, body, len, &a_output); if (ret != 0) { - la_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - la_response->cc = LCRD_ERR_EXEC; + la_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + la_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(a_output, unpack_attach_response, (void *)la_response); @@ -674,8 +674,8 @@ out: } /* rest container list */ -static int rest_container_list(const struct lcrc_list_request *ll_request, - struct lcrc_list_response *ll_response, void *arg) +static int rest_container_list(const struct isula_list_request *ll_request, + struct isula_list_response *ll_response, void *arg) { char *body = NULL; int ret = 0; @@ -690,8 +690,8 @@ static int rest_container_list(const struct lcrc_list_request *ll_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceList, body, len, &l_output); if (ret != 0) { - ll_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - ll_response->cc = LCRD_ERR_EXEC; + ll_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + ll_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(l_output, unpack_list_response, (void *)ll_response); @@ -707,8 +707,8 @@ out: } /* rest container resume */ -static int rest_container_resume(const struct lcrc_resume_request *lr_request, - struct lcrc_resume_response *lr_response, void *arg) +static int rest_container_resume(const struct isula_resume_request *lr_request, + struct isula_resume_response *lr_response, void *arg) { char *body = NULL; int ret = 0; @@ -723,8 +723,8 @@ static int rest_container_resume(const struct lcrc_resume_request *lr_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceResume, body, len, &r_output); if (ret != 0) { - lr_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - lr_response->cc = LCRD_ERR_EXEC; + lr_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + lr_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(r_output, unpack_resume_response, (void *)lr_response); @@ -740,8 +740,8 @@ out: } /* rest container wait */ -static int rest_container_wait(const struct lcrc_wait_request *lw_request, - struct lcrc_wait_response *lw_response, void *arg) +static int rest_container_wait(const struct isula_wait_request *lw_request, + struct isula_wait_response *lw_response, void *arg) { char *body = NULL; int ret = 0; @@ -756,8 +756,8 @@ static int rest_container_wait(const struct lcrc_wait_request *lw_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceWait, body, len, &w_output); if (ret != 0) { - lw_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - lw_response->cc = LCRD_ERR_EXEC; + lw_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + lw_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(w_output, unpack_wait_response, (void *)lw_response); @@ -773,7 +773,7 @@ out: } /* stop request to rest */ -static int stop_request_to_rest(const struct lcrc_stop_request *ls_request, char **body, size_t *body_len) +static int stop_request_to_rest(const struct isula_stop_request *ls_request, char **body, size_t *body_len) { container_stop_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -809,7 +809,7 @@ out: /* unpack stop response */ static int unpack_stop_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_stop_response *stop_response = arg; + struct isula_stop_response *stop_response = arg; container_stop_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -829,7 +829,7 @@ static int unpack_stop_response(const struct parsed_http_message *message, void if (cresponse->errmsg != NULL) { stop_response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -841,8 +841,8 @@ out: } /* rest container stop */ -static int rest_container_stop(const struct lcrc_stop_request *ls_request, - struct lcrc_stop_response *ls_response, void *arg) +static int rest_container_stop(const struct isula_stop_request *ls_request, + struct isula_stop_response *ls_response, void *arg) { char *body = NULL; int ret = 0; @@ -857,8 +857,8 @@ static int rest_container_stop(const struct lcrc_stop_request *ls_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceStop, body, len, &output); if (ret != 0) { - ls_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - ls_response->cc = LCRD_ERR_EXEC; + ls_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + ls_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_stop_response, (void *)ls_response); @@ -874,7 +874,7 @@ out: } /* restart request to rest */ -static int restart_request_to_rest(const struct lcrc_restart_request *lr_request, char **body, size_t *body_len) +static int restart_request_to_rest(const struct isula_restart_request *lr_request, char **body, size_t *body_len) { container_restart_request *creq = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -909,7 +909,7 @@ out: /* unpack restart response */ static int unpack_restart_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_restart_response *response = arg; + struct isula_restart_response *response = arg; container_restart_response *cres = NULL; parser_error err = NULL; int ret = 0; @@ -929,7 +929,7 @@ static int unpack_restart_response(const struct parsed_http_message *message, vo if (cres->errmsg != NULL) { response->errmsg = util_strdup_s(cres->errmsg); } - ret = (cres->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cres->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -941,8 +941,8 @@ out: } /* rest container restart */ -static int rest_container_restart(const struct lcrc_restart_request *lr_request, - struct lcrc_restart_response *lr_response, void *arg) +static int rest_container_restart(const struct isula_restart_request *lr_request, + struct isula_restart_response *lr_response, void *arg) { char *body = NULL; int ret = 0; @@ -957,8 +957,8 @@ static int rest_container_restart(const struct lcrc_restart_request *lr_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceRestart, body, len, &output); if (ret != 0) { - lr_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - lr_response->cc = LCRD_ERR_EXEC; + lr_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + lr_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_restart_response, (void *)lr_response); @@ -972,10 +972,10 @@ out: } /* update request to rest */ -static int update_request_to_rest(const struct lcrc_update_request *lu_request, char **body, size_t *body_len) +static int update_request_to_rest(const struct isula_update_request *lu_request, char **body, size_t *body_len) { container_update_request *crequest = NULL; - lcrc_host_config_t srcconfig; + isula_host_config_t srcconfig; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; parser_error err = NULL; char *srcconfigjson = NULL; @@ -1022,7 +1022,7 @@ out: /* unpack update response */ static int unpack_update_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_update_response *update_response = arg; + struct isula_update_response *update_response = arg; container_update_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -1042,7 +1042,7 @@ static int unpack_update_response(const struct parsed_http_message *message, voi if (cresponse->errmsg != NULL) { update_response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -1054,8 +1054,8 @@ out: } /* rest container update */ -static int rest_container_update(const struct lcrc_update_request *lu_request, - struct lcrc_update_response *lu_response, void *arg) +static int rest_container_update(const struct isula_update_request *lu_request, + struct isula_update_response *lu_response, void *arg) { char *body = NULL; int ret = 0; @@ -1070,8 +1070,8 @@ static int rest_container_update(const struct lcrc_update_request *lu_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceUpdate, body, len, &output); if (ret != 0) { - lu_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - lu_response->cc = LCRD_ERR_EXEC; + lu_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + lu_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_update_response, (void *)lu_response); @@ -1087,7 +1087,7 @@ out: } /* version request to rest */ -static int version_request_to_rest(const struct lcrc_version_request *lv_request, char **body, size_t *body_len) +static int version_request_to_rest(const struct isula_version_request *lv_request, char **body, size_t *body_len) { container_version_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -1117,7 +1117,7 @@ out: /* unpack version response */ static int unpack_version_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_version_response *version_response = arg; + struct isula_version_response *version_response = arg; container_version_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -1149,7 +1149,7 @@ static int unpack_version_response(const struct parsed_http_message *message, vo if (cresponse->errmsg != NULL) { version_response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -1161,8 +1161,8 @@ out: } /* rest container version */ -static int rest_container_version(const struct lcrc_version_request *lv_request, - struct lcrc_version_response *lv_response, void *arg) +static int rest_container_version(const struct isula_version_request *lv_request, + struct isula_version_response *lv_response, void *arg) { char *body = NULL; int ret = 0; @@ -1177,8 +1177,8 @@ static int rest_container_version(const struct lcrc_version_request *lv_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceVersion, body, len, &output); if (ret != 0) { - lv_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - lv_response->cc = LCRD_ERR_EXEC; + lv_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + lv_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_version_response, (void *)lv_response); @@ -1194,7 +1194,7 @@ out: } /* pause request to rest */ -static int pause_request_to_rest(const struct lcrc_pause_request *lp_request, char **body, size_t *body_len) +static int pause_request_to_rest(const struct isula_pause_request *lp_request, char **body, size_t *body_len) { container_pause_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -1228,7 +1228,7 @@ out: /* unpack pause response */ static int unpack_pause_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_pause_response *pause_response = arg; + struct isula_pause_response *pause_response = arg; container_pause_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -1248,7 +1248,7 @@ static int unpack_pause_response(const struct parsed_http_message *message, void if (cresponse->errmsg != NULL) { pause_response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -1260,8 +1260,8 @@ out: } /* rest container pause */ -static int rest_container_pause(const struct lcrc_pause_request *lp_request, - struct lcrc_pause_response *lp_response, void *arg) +static int rest_container_pause(const struct isula_pause_request *lp_request, + struct isula_pause_response *lp_response, void *arg) { char *body = NULL; int ret = 0; @@ -1276,8 +1276,8 @@ static int rest_container_pause(const struct lcrc_pause_request *lp_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServicePause, body, len, &output); if (ret != 0) { - lp_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - lp_response->cc = LCRD_ERR_EXEC; + lp_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + lp_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_pause_response, (void *)lp_response); @@ -1293,7 +1293,7 @@ out: } /* kill request to rest */ -static int kill_request_to_rest(const struct lcrc_kill_request *lk_request, char **body, size_t *body_len) +static int kill_request_to_rest(const struct isula_kill_request *lk_request, char **body, size_t *body_len) { container_kill_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -1328,7 +1328,7 @@ out: /* unpack kill response */ static int unpack_kill_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_kill_response *kill_response = arg; + struct isula_kill_response *kill_response = arg; container_kill_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -1348,7 +1348,7 @@ static int unpack_kill_response(const struct parsed_http_message *message, void if (cresponse->errmsg != NULL) { kill_response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -1360,8 +1360,8 @@ out: } /* rest container kill */ -static int rest_container_kill(const struct lcrc_kill_request *lk_request, - struct lcrc_kill_response *lk_response, void *arg) +static int rest_container_kill(const struct isula_kill_request *lk_request, + struct isula_kill_response *lk_response, void *arg) { char *body = NULL; int ret = 0; @@ -1376,8 +1376,8 @@ static int rest_container_kill(const struct lcrc_kill_request *lk_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceKill, body, len, &output); if (ret != 0) { - lk_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - lk_response->cc = LCRD_ERR_EXEC; + lk_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + lk_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_kill_response, (void *)lk_response); @@ -1393,7 +1393,7 @@ out: } /* remove request to rest */ -static int remove_request_to_rest(const struct lcrc_delete_request *ld_request, char **body, size_t *body_len) +static int remove_request_to_rest(const struct isula_delete_request *ld_request, char **body, size_t *body_len) { container_delete_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -1428,7 +1428,7 @@ out: /* unpack remove response */ static int unpack_remove_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_delete_response *delete_response = arg; + struct isula_delete_response *delete_response = arg; container_delete_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -1448,7 +1448,7 @@ static int unpack_remove_response(const struct parsed_http_message *message, voi if (cresponse->errmsg != NULL) { delete_response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -1460,8 +1460,8 @@ out: } /* rest container remove */ -static int rest_container_remove(const struct lcrc_delete_request *ld_request, - struct lcrc_delete_response *ld_response, void *arg) +static int rest_container_remove(const struct isula_delete_request *ld_request, + struct isula_delete_response *ld_response, void *arg) { char *body = NULL; int ret = 0; @@ -1476,8 +1476,8 @@ static int rest_container_remove(const struct lcrc_delete_request *ld_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceRemove, body, len, &r_output); if (ret != 0) { - ld_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - ld_response->cc = LCRD_ERR_EXEC; + ld_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + ld_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(r_output, unpack_remove_response, (void *)ld_response); @@ -1493,7 +1493,7 @@ out: } /* inspect request to rest */ -static int inspect_request_to_rest(const struct lcrc_inspect_request *li_request, char **body, size_t *body_len) +static int inspect_request_to_rest(const struct isula_inspect_request *li_request, char **body, size_t *body_len) { container_inspect_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -1530,7 +1530,7 @@ out: /* unpack inspect response */ static int unpack_inspect_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_inspect_response *response = arg; + struct isula_inspect_response *response = arg; container_inspect_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -1553,7 +1553,7 @@ static int unpack_inspect_response(const struct parsed_http_message *message, vo if (cresponse->errmsg != NULL) { response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -1565,8 +1565,8 @@ out: } /* rest container inspect */ -static int rest_container_inspect(const struct lcrc_inspect_request *li_request, - struct lcrc_inspect_response *li_response, void *arg) +static int rest_container_inspect(const struct isula_inspect_request *li_request, + struct isula_inspect_response *li_response, void *arg) { char *body = NULL; int ret = 0; @@ -1581,8 +1581,8 @@ static int rest_container_inspect(const struct lcrc_inspect_request *li_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceInspect, body, len, &output); if (ret != 0) { - li_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - li_response->cc = LCRD_ERR_EXEC; + li_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + li_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_inspect_response, (void *)li_response); @@ -1598,7 +1598,7 @@ out: } /* exec request to rest */ -static int exec_request_to_rest(const struct lcrc_exec_request *le_request, char **body, size_t *body_len) +static int exec_request_to_rest(const struct isula_exec_request *le_request, char **body, size_t *body_len) { container_exec_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -1682,7 +1682,7 @@ out: /* unpack exec response */ static int unpack_exec_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_exec_response *response = arg; + struct isula_exec_response *response = arg; container_exec_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -1703,7 +1703,7 @@ static int unpack_exec_response(const struct parsed_http_message *message, void if (cresponse->errmsg != NULL) { response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -1715,8 +1715,8 @@ out: } /* rest container exec */ -static int rest_container_exec(const struct lcrc_exec_request *le_request, - struct lcrc_exec_response *le_response, void *arg) +static int rest_container_exec(const struct isula_exec_request *le_request, + struct isula_exec_response *le_response, void *arg) { char *body = NULL; int ret = 0; @@ -1731,8 +1731,8 @@ static int rest_container_exec(const struct lcrc_exec_request *le_request, } ret = rest_send_requst(socketname, RestHttpHead ContainerServiceExec, body, len, &output); if (ret != 0) { - le_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - le_response->cc = LCRD_ERR_EXEC; + le_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + le_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_exec_response, (void *)le_response); @@ -1748,7 +1748,7 @@ out: } /* rest containers client ops init */ -int rest_containers_client_ops_init(lcrc_connect_ops *ops) +int rest_containers_client_ops_init(isula_connect_ops *ops) { if (ops == NULL) { return -1; diff --git a/src/connect/client/rest/rest_containers_client.h b/src/connect/client/rest/rest_containers_client.h index a0836468f610ac96372bba64d61454d15565fdda..54d8bcf8b81f29d9be3e17f8558e02b2581613c2 100644 --- a/src/connect/client/rest/rest_containers_client.h +++ b/src/connect/client/rest/rest_containers_client.h @@ -15,13 +15,13 @@ #ifndef __REST_CONTAINERS_CLIENT_H #define __REST_CONTAINERS_CLIENT_H -#include "lcrc_connect.h" +#include "isula_connect.h" #ifdef __cplusplus extern "C" { #endif -int rest_containers_client_ops_init(lcrc_connect_ops *ops); +int rest_containers_client_ops_init(isula_connect_ops *ops); #ifdef __cplusplus } diff --git a/src/connect/client/rest/rest_images_client.c b/src/connect/client/rest/rest_images_client.c index 0a01806f6357d080058205ca82a95bd358284af8..90ca4dbff06d1af7937c2ae2b1183d0a64a8bd9b 100644 --- a/src/connect/client/rest/rest_images_client.c +++ b/src/connect/client/rest/rest_images_client.c @@ -17,13 +17,13 @@ #include #include "log.h" -#include "lcrc_connect.h" +#include "isula_connect.h" #include "image.rest.h" #include "rest_common.h" #include "rest_images_client.h" /* image load request to rest */ -static int image_load_request_to_rest(const struct lcrc_load_request *request, char **body, size_t *body_len) +static int image_load_request_to_rest(const struct isula_load_request *request, char **body, size_t *body_len) { image_load_image_request *crequest = NULL; parser_error err = NULL; @@ -55,7 +55,7 @@ out: } /* image list request to rest */ -static int image_list_request_to_rest(const struct lcrc_list_images_request *request, char **body, size_t *body_len) +static int image_list_request_to_rest(const struct isula_list_images_request *request, char **body, size_t *body_len) { image_list_images_request *crequest = NULL; parser_error err = NULL; @@ -81,7 +81,7 @@ out: } /* image delete request to rest */ -static int image_delete_request_to_rest(const struct lcrc_rmi_request *request, char **body, size_t *body_len) +static int image_delete_request_to_rest(const struct isula_rmi_request *request, char **body, size_t *body_len) { image_delete_image_request *crequest = NULL; parser_error err = NULL; @@ -112,19 +112,19 @@ out: } static int unpack_image_info_to_list_response(image_list_images_response *cresponse, - struct lcrc_list_images_response *response) + struct isula_list_images_response *response) { size_t num = 0; - struct lcrc_image_info *image_info = NULL; + struct isula_image_info *image_info = NULL; if (cresponse == NULL || response == NULL) { return -1; } num = cresponse->images_len; - if (num > 0 && (num < (SIZE_MAX / sizeof(struct lcrc_image_info)))) { + if (num > 0 && (num < (SIZE_MAX / sizeof(struct isula_image_info)))) { size_t i; - image_info = (struct lcrc_image_info *)util_common_calloc_s(sizeof(struct lcrc_image_info) * num); + image_info = (struct isula_image_info *)util_common_calloc_s(sizeof(struct isula_image_info) * num); if (image_info == NULL) { ERROR("out of memory"); return -1; @@ -153,7 +153,7 @@ static int unpack_image_info_to_list_response(image_list_images_response *crespo /* unpack image list response */ static int unpack_image_list_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_list_images_response *response = arg; + struct isula_list_images_response *response = arg; image_list_images_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -173,7 +173,7 @@ static int unpack_image_list_response(const struct parsed_http_message *message, if (cresponse->errmsg != NULL) { response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -192,7 +192,7 @@ out: /* unpack image load response */ static int unpack_image_load_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_load_response *c_load_response = arg; + struct isula_load_response *c_load_response = arg; image_load_image_response *load_response = NULL; parser_error err = NULL; int ret = 0; @@ -212,7 +212,7 @@ static int unpack_image_load_response(const struct parsed_http_message *message, if (load_response->errmsg != NULL) { c_load_response->errmsg = util_strdup_s(load_response->errmsg); } - ret = (load_response->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (load_response->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -224,7 +224,7 @@ out: } /* rest image load */ -static int rest_image_load(const struct lcrc_load_request *request, struct lcrc_load_response *response, void *arg) +static int rest_image_load(const struct isula_load_request *request, struct isula_load_response *response, void *arg) { char *body = NULL; int ret = 0; @@ -239,8 +239,8 @@ static int rest_image_load(const struct lcrc_load_request *request, struct lcrc_ } ret = rest_send_requst(socketname, RestHttpHead ImagesServiceLoad, body, len, &output); if (ret != 0) { - response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - response->cc = LCRD_ERR_EXEC; + response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_image_load_response, (void *)response); @@ -258,7 +258,7 @@ out: /* unpack image delete response */ static int unpack_image_delete_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_rmi_response *c_rmi_response = arg; + struct isula_rmi_response *c_rmi_response = arg; image_delete_image_response *delete_response = NULL; parser_error err = NULL; int ret = 0; @@ -278,7 +278,7 @@ static int unpack_image_delete_response(const struct parsed_http_message *messag if (delete_response->errmsg != NULL) { c_rmi_response->errmsg = util_strdup_s(delete_response->errmsg); } - ret = (delete_response->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (delete_response->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -290,7 +290,7 @@ out: } /* rest image list */ -static int rest_image_list(const struct lcrc_list_images_request *request, struct lcrc_list_images_response *response, +static int rest_image_list(const struct isula_list_images_request *request, struct isula_list_images_response *response, void *arg) { char *body = NULL; @@ -306,8 +306,8 @@ static int rest_image_list(const struct lcrc_list_images_request *request, struc } ret = rest_send_requst(socketname, RestHttpHead ImagesServiceList, body, len, &output); if (ret != 0) { - response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - response->cc = LCRD_ERR_EXEC; + response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_image_list_response, (void *)response); @@ -323,7 +323,7 @@ out: } /* rest image remove */ -static int rest_image_remove(const struct lcrc_rmi_request *request, struct lcrc_rmi_response *response, void *arg) +static int rest_image_remove(const struct isula_rmi_request *request, struct isula_rmi_response *response, void *arg) { char *body = NULL; int ret = 0; @@ -338,8 +338,8 @@ static int rest_image_remove(const struct lcrc_rmi_request *request, struct lcrc } ret = rest_send_requst(socketname, RestHttpHead ImagesServiceDelete, body, len, &output); if (ret != 0) { - response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - response->cc = LCRD_ERR_EXEC; + response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_image_delete_response, (void *)response); @@ -355,7 +355,7 @@ out: } /* inspect request to rest */ -static int inspect_request_to_rest(const struct lcrc_inspect_request *li_request, char **body, size_t *body_len) +static int inspect_request_to_rest(const struct isula_inspect_request *li_request, char **body, size_t *body_len) { image_inspect_request *crequest = NULL; struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; @@ -392,7 +392,7 @@ out: /* unpack inspect response */ static int unpack_inspect_response(const struct parsed_http_message *message, void *arg) { - struct lcrc_inspect_response *response = arg; + struct isula_inspect_response *response = arg; image_inspect_response *cresponse = NULL; parser_error err = NULL; int ret = 0; @@ -415,7 +415,7 @@ static int unpack_inspect_response(const struct parsed_http_message *message, vo if (cresponse->errmsg != NULL) { response->errmsg = util_strdup_s(cresponse->errmsg); } - ret = (cresponse->cc == LCRD_SUCCESS) ? 0 : -1; + ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1; if (message->status_code == EVHTP_RES_SERVERR) { ret = -1; } @@ -427,8 +427,8 @@ out: } /* rest image inspect */ -static int rest_image_inspect(const struct lcrc_inspect_request *li_request, - struct lcrc_inspect_response *li_response, void *arg) +static int rest_image_inspect(const struct isula_inspect_request *li_request, + struct isula_inspect_response *li_response, void *arg) { char *body = NULL; int ret = 0; @@ -443,8 +443,8 @@ static int rest_image_inspect(const struct lcrc_inspect_request *li_request, } ret = rest_send_requst(socketname, RestHttpHead ImagesServiceInspect, body, len, &output); if (ret != 0) { - li_response->errmsg = util_strdup_s(errno_to_error_message(LCRD_ERR_CONNECT)); - li_response->cc = LCRD_ERR_EXEC; + li_response->errmsg = util_strdup_s(errno_to_error_message(ISULAD_ERR_CONNECT)); + li_response->cc = ISULAD_ERR_EXEC; goto out; } ret = get_response(output, unpack_inspect_response, (void *)li_response); @@ -460,7 +460,7 @@ out: } /* rest images client ops init */ -int rest_images_client_ops_init(lcrc_connect_ops *ops) +int rest_images_client_ops_init(isula_connect_ops *ops) { if (ops == NULL) { return -1; diff --git a/src/connect/client/rest/rest_images_client.h b/src/connect/client/rest/rest_images_client.h index 7226d6d587b80185f8b83c8aaa72119c3da5677d..1cec7e35a680a3fbd32cb8d745386d82db5ffb70 100644 --- a/src/connect/client/rest/rest_images_client.h +++ b/src/connect/client/rest/rest_images_client.h @@ -15,13 +15,13 @@ #ifndef __REST_IMAGES_CLIENT_H #define __REST_IMAGES_CLIENT_H -#include "lcrc_connect.h" +#include "isula_connect.h" #ifdef __cplusplus extern "C" { #endif -int rest_images_client_ops_init(lcrc_connect_ops *ops); +int rest_images_client_ops_init(isula_connect_ops *ops); #ifdef __cplusplus } diff --git a/src/connect/service/grpc/grpc_containers_service.cc b/src/connect/service/grpc/grpc_containers_service.cc index 016a9598b044746c043748b8090fba350a6e321f..39c7264904fb9fd3c010caa2e1f67a7ea58ca848 100644 --- a/src/connect/service/grpc/grpc_containers_service.cc +++ b/src/connect/service/grpc/grpc_containers_service.cc @@ -41,7 +41,7 @@ void protobuf_timestamp_from_grpc(types_timestamp_t *timestamp, const Timestamp timestamp->nanos = gtimestamp.nanos(); } -void event_to_grpc(const struct lcrd_events_format *event, Event *gevent) +void event_to_grpc(const struct isulad_events_format *event, Event *gevent) { gevent->Clear(); if (event->id != nullptr) { @@ -65,7 +65,7 @@ void event_to_grpc(const struct lcrd_events_format *event, Event *gevent) } } -void copy_from_container_response_to_grpc(const struct lcrd_copy_from_container_response *copy, +void copy_from_container_response_to_grpc(const struct isulad_copy_from_container_response *copy, CopyFromContainerResponse *gcopy) { gcopy->Clear(); @@ -90,7 +90,7 @@ bool grpc_add_initial_metadata(void *context, const char *header, const char *va bool grpc_event_write_function(void *writer, void *data) { - struct lcrd_events_format *event = (struct lcrd_events_format *)data; + struct isulad_events_format *event = (struct isulad_events_format *)data; ServerWriter *gwriter = (ServerWriter *)writer; Event gevent; event_to_grpc(event, &gevent); @@ -99,14 +99,14 @@ bool grpc_event_write_function(void *writer, void *data) bool grpc_copy_from_container_write_function(void *writer, void *data) { - struct lcrd_copy_from_container_response *copy = (struct lcrd_copy_from_container_response *)data; + struct isulad_copy_from_container_response *copy = (struct isulad_copy_from_container_response *)data; ServerWriter *gwriter = (ServerWriter *)writer; CopyFromContainerResponse gcopy; copy_from_container_response_to_grpc(copy, &gcopy); return gwriter->Write(gcopy); } -static bool copy_to_container_data_from_grpc(struct lcrd_copy_to_container_data *copy, +static bool copy_to_container_data_from_grpc(struct isulad_copy_to_container_data *copy, CopyToContainerRequest *gcopy) { size_t len = (size_t)gcopy->data().length(); @@ -127,7 +127,7 @@ static bool copy_to_container_data_from_grpc(struct lcrd_copy_to_container_data bool grpc_copy_to_container_read_function(void *reader, void *data) { - struct lcrd_copy_to_container_data *copy = (struct lcrd_copy_to_container_data *)data; + struct isulad_copy_to_container_data *copy = (struct isulad_copy_to_container_data *)data; ServerReaderWriter *stream = (ServerReaderWriter *)reader; CopyToContainerRequest gcopy; @@ -156,7 +156,7 @@ Status ContainerServiceImpl::Version(ServerContext *context, const VersionReques tret = version_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -166,8 +166,8 @@ Status ContainerServiceImpl::Version(ServerContext *context, const VersionReques free_container_version_request(container_req); free_container_version_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -192,7 +192,7 @@ Status ContainerServiceImpl::Info(ServerContext *context, const InfoRequest *req tret = info_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -202,8 +202,8 @@ Status ContainerServiceImpl::Info(ServerContext *context, const InfoRequest *req free_host_info_request(container_req); free_host_info_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -228,7 +228,7 @@ Status ContainerServiceImpl::Create(ServerContext *context, const CreateRequest tret = create_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -238,8 +238,8 @@ Status ContainerServiceImpl::Create(ServerContext *context, const CreateRequest free_container_create_request(container_req); free_container_create_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -264,7 +264,7 @@ Status ContainerServiceImpl::Start(ServerContext *context, const StartRequest *r tret = start_request_from_grpc(request, &req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::CANCELLED; } @@ -274,8 +274,8 @@ Status ContainerServiceImpl::Start(ServerContext *context, const StartRequest *r free_container_start_request(req); free_container_start_response(res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -421,7 +421,7 @@ Status ContainerServiceImpl::Top(ServerContext *context, const TopRequest *reque tret = top_request_from_grpc(request, &req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::CANCELLED; } @@ -431,8 +431,8 @@ Status ContainerServiceImpl::Top(ServerContext *context, const TopRequest *reque free_container_top_request(req); free_container_top_response(res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -457,7 +457,7 @@ Status ContainerServiceImpl::Stop(ServerContext *context, const StopRequest *req tret = stop_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -467,8 +467,8 @@ Status ContainerServiceImpl::Stop(ServerContext *context, const StopRequest *req free_container_stop_request(container_req); free_container_stop_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -493,7 +493,7 @@ Status ContainerServiceImpl::Restart(ServerContext *context, const RestartReques tret = restart_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -503,8 +503,8 @@ Status ContainerServiceImpl::Restart(ServerContext *context, const RestartReques free_container_restart_request(container_req); free_container_restart_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -529,7 +529,7 @@ Status ContainerServiceImpl::Kill(ServerContext *context, const KillRequest *req tret = kill_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -539,8 +539,8 @@ Status ContainerServiceImpl::Kill(ServerContext *context, const KillRequest *req free_container_kill_request(container_req); free_container_kill_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -565,7 +565,7 @@ Status ContainerServiceImpl::Delete(ServerContext *context, const DeleteRequest tret = delete_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -575,8 +575,8 @@ Status ContainerServiceImpl::Delete(ServerContext *context, const DeleteRequest free_container_delete_request(container_req); free_container_delete_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -601,7 +601,7 @@ Status ContainerServiceImpl::Exec(ServerContext *context, const ExecRequest *req tret = exec_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::CANCELLED; } @@ -611,8 +611,8 @@ Status ContainerServiceImpl::Exec(ServerContext *context, const ExecRequest *req free_container_exec_request(container_req); free_container_exec_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -734,7 +734,7 @@ Status ContainerServiceImpl::Inspect(ServerContext *context, const InspectContai tret = inspect_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -749,8 +749,8 @@ Status ContainerServiceImpl::Inspect(ServerContext *context, const InspectContai free_container_inspect_request(container_req); free_container_inspect_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -775,7 +775,7 @@ Status ContainerServiceImpl::List(ServerContext *context, const ListRequest *req tret = list_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -785,8 +785,8 @@ Status ContainerServiceImpl::List(ServerContext *context, const ListRequest *req free_container_list_request(container_req); free_container_list_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -952,7 +952,7 @@ Status ContainerServiceImpl::Pause(ServerContext *context, const PauseRequest *r tret = pause_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -962,8 +962,8 @@ Status ContainerServiceImpl::Pause(ServerContext *context, const PauseRequest *r free_container_pause_request(container_req); free_container_pause_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -988,7 +988,7 @@ Status ContainerServiceImpl::Resume(ServerContext *context, const ResumeRequest tret = resume_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -998,8 +998,8 @@ Status ContainerServiceImpl::Resume(ServerContext *context, const ResumeRequest free_container_resume_request(container_req); free_container_resume_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -1024,7 +1024,7 @@ Status ContainerServiceImpl::Export(ServerContext *context, const ExportRequest tret = export_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -1034,8 +1034,8 @@ Status ContainerServiceImpl::Export(ServerContext *context, const ExportRequest free_container_export_request(container_req); free_container_export_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -1046,8 +1046,8 @@ Status ContainerServiceImpl::Rename(ServerContext *context, const RenameRequest { int ret, tret; service_callback_t *cb = nullptr; - struct lcrd_container_rename_request *lcrdreq = nullptr; - struct lcrd_container_rename_response *lcrdres = nullptr; + struct isulad_container_rename_request *isuladreq = nullptr; + struct isulad_container_rename_response *isuladres = nullptr; auto status = GrpcServerTlsAuth::auth(context, "container_rename"); if (!status.ok()) { @@ -1059,21 +1059,21 @@ Status ContainerServiceImpl::Rename(ServerContext *context, const RenameRequest return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback"); } - tret = container_rename_request_from_grpc(request, &lcrdreq); + tret = container_rename_request_from_grpc(request, &isuladreq); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } - ret = cb->container.rename(lcrdreq, &lcrdres); - tret = container_rename_response_to_grpc(lcrdres, reply); + ret = cb->container.rename(isuladreq, &isuladres); + tret = container_rename_response_to_grpc(isuladres, reply); - lcrd_container_rename_request_free(lcrdreq); - lcrd_container_rename_response_free(lcrdres); + isulad_container_rename_request_free(isuladreq); + isulad_container_rename_response_free(isuladres); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -1084,8 +1084,8 @@ Status ContainerServiceImpl::Resize(ServerContext *context, const ResizeRequest { int ret, tret; service_callback_t *cb = nullptr; - struct lcrd_container_resize_request *lcrdreq = nullptr; - struct lcrd_container_resize_response *lcrdres = nullptr; + struct isulad_container_resize_request *isuladreq = nullptr; + struct isulad_container_resize_response *isuladres = nullptr; auto status = GrpcServerTlsAuth::auth(context, "container_resize"); if (!status.ok()) { @@ -1097,21 +1097,21 @@ Status ContainerServiceImpl::Resize(ServerContext *context, const ResizeRequest return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback"); } - tret = container_resize_request_from_grpc(request, &lcrdreq); + tret = container_resize_request_from_grpc(request, &isuladreq); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } - ret = cb->container.resize(lcrdreq, &lcrdres); - tret = container_resize_response_to_grpc(lcrdres, reply); + ret = cb->container.resize(isuladreq, &isuladres); + tret = container_resize_response_to_grpc(isuladres, reply); - lcrd_container_resize_request_free(lcrdreq); - lcrd_container_resize_response_free(lcrdres); + isulad_container_resize_request_free(isuladreq); + isulad_container_resize_response_free(isuladres); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -1136,7 +1136,7 @@ Status ContainerServiceImpl::Update(ServerContext *context, const UpdateRequest tret = update_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -1146,8 +1146,8 @@ Status ContainerServiceImpl::Update(ServerContext *context, const UpdateRequest free_container_update_request(container_req); free_container_update_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -1172,7 +1172,7 @@ Status ContainerServiceImpl::Stats(ServerContext *context, const StatsRequest *r tret = stats_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -1182,8 +1182,8 @@ Status ContainerServiceImpl::Stats(ServerContext *context, const StatsRequest *r free_container_stats_request(container_req); free_container_stats_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -1209,7 +1209,7 @@ Status ContainerServiceImpl::Wait(ServerContext *context, const WaitRequest *req tret = wait_request_from_grpc(request, &container_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -1219,8 +1219,8 @@ Status ContainerServiceImpl::Wait(ServerContext *context, const WaitRequest *req free_container_wait_request(container_req); free_container_wait_response(container_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -1230,7 +1230,7 @@ Status ContainerServiceImpl::Events(ServerContext *context, const EventsRequest { int ret, tret; service_callback_t *cb = nullptr; - lcrd_events_request *lcrdreq = nullptr; + isulad_events_request *isuladreq = nullptr; stream_func_wrapper stream = { 0 }; auto status = GrpcServerTlsAuth::auth(context, "docker_events"); @@ -1242,7 +1242,7 @@ Status ContainerServiceImpl::Events(ServerContext *context, const EventsRequest return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback"); } - tret = events_request_from_grpc(request, &lcrdreq); + tret = events_request_from_grpc(request, &isuladreq); if (tret != 0) { ERROR("Failed to transform grpc request"); return Status(StatusCode::INTERNAL, "Failed to transform grpc request"); @@ -1253,8 +1253,8 @@ Status ContainerServiceImpl::Events(ServerContext *context, const EventsRequest stream.write_func = &grpc_event_write_function; stream.writer = (void *)writer; - ret = cb->container.events(lcrdreq, &stream); - lcrd_events_request_free(lcrdreq); + ret = cb->container.events(isuladreq, &stream); + isulad_events_request_free(isuladreq); if (ret != 0) { return Status(StatusCode::INTERNAL, "Failed to execute events callback"); } @@ -1266,7 +1266,7 @@ Status ContainerServiceImpl::CopyFromContainer(ServerContext *context, const Cop { int ret, tret; service_callback_t *cb = nullptr; - lcrd_copy_from_container_request *lcrdreq = nullptr; + isulad_copy_from_container_request *isuladreq = nullptr; auto status = GrpcServerTlsAuth::auth(context, "container_archive"); if (!status.ok()) { @@ -1277,7 +1277,7 @@ Status ContainerServiceImpl::CopyFromContainer(ServerContext *context, const Cop return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback"); } - tret = copy_from_container_request_from_grpc(request, &lcrdreq); + tret = copy_from_container_request_from_grpc(request, &isuladreq); if (tret != 0) { ERROR("Failed to transform grpc request"); return Status(StatusCode::UNKNOWN, "Failed to transform grpc request"); @@ -1291,8 +1291,8 @@ Status ContainerServiceImpl::CopyFromContainer(ServerContext *context, const Cop stream.writer = (void *)writer; char *err = nullptr; - ret = cb->container.copy_from_container(lcrdreq, &stream, &err); - lcrd_copy_from_container_request_free(lcrdreq); + ret = cb->container.copy_from_container(isuladreq, &stream, &err); + isulad_copy_from_container_request_free(isuladreq); std::string errmsg = (err != nullptr) ? err : "Failed to execute copy_from_container callback"; free(err); if (ret != 0) { @@ -1308,7 +1308,7 @@ Status ContainerServiceImpl::CopyToContainer( { int ret; service_callback_t *cb = nullptr; - container_copy_to_request *lcrdreq = nullptr; + container_copy_to_request *isuladreq = nullptr; auto status = GrpcServerTlsAuth::auth(context, "container_archive"); if (!status.ok()) { @@ -1324,8 +1324,8 @@ Status ContainerServiceImpl::CopyToContainer( if (iter != metadata.end()) { char *err = nullptr; std::string json = std::string(iter->second.data(), iter->second.length()); - lcrdreq = container_copy_to_request_parse_data(json.c_str(), nullptr, &err); - if (lcrdreq == nullptr) { + isuladreq = container_copy_to_request_parse_data(json.c_str(), nullptr, &err); + if (isuladreq == nullptr) { std::string errmsg = "Invalid copy to container json: "; errmsg += (err != nullptr) ? err : "unknown"; free(err); @@ -1341,8 +1341,8 @@ Status ContainerServiceImpl::CopyToContainer( wrapper.read_func = &grpc_copy_to_container_read_function; char *err = nullptr; - ret = cb->container.copy_to_container(lcrdreq, &wrapper, &err); - free_container_copy_to_request(lcrdreq); + ret = cb->container.copy_to_container(isuladreq, &wrapper, &err); + free_container_copy_to_request(isuladreq); std::string msg = (err != nullptr) ? err : "Failed to execute copy_to_container callback"; free(err); @@ -1372,9 +1372,9 @@ void log_to_grpc(const logger_json_file *log, LogsResponse *glog) } } -int ContainerServiceImpl::logs_request_from_grpc(const LogsRequest *grequest, struct lcrd_logs_request **request) +int ContainerServiceImpl::logs_request_from_grpc(const LogsRequest *grequest, struct isulad_logs_request **request) { - *request = (struct lcrd_logs_request *)util_common_calloc_s(sizeof(struct lcrd_logs_request)); + *request = (struct isulad_logs_request *)util_common_calloc_s(sizeof(struct isulad_logs_request)); if (*request == nullptr) { ERROR("Out of memory"); return -1; @@ -1413,8 +1413,8 @@ Status ContainerServiceImpl::Logs(ServerContext *context, const LogsRequest* req { int ret = 0; service_callback_t *cb = nullptr; - struct lcrd_logs_request *lcrd_request = nullptr; - struct lcrd_logs_response *lcrd_response = nullptr; + struct isulad_logs_request *isulad_request = nullptr; + struct isulad_logs_response *isulad_response = nullptr; stream_func_wrapper stream = { 0 }; auto status = GrpcServerTlsAuth::auth(context, "container_logs"); @@ -1427,7 +1427,7 @@ Status ContainerServiceImpl::Logs(ServerContext *context, const LogsRequest* req return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback"); } - ret = logs_request_from_grpc(request, &lcrd_request); + ret = logs_request_from_grpc(request, &isulad_request); if (ret != 0) { ERROR("Failed to transform grpc request"); return Status(StatusCode::UNKNOWN, "Failed to transform grpc request"); @@ -1438,14 +1438,14 @@ Status ContainerServiceImpl::Logs(ServerContext *context, const LogsRequest* req stream.write_func = &grpc_logs_write_function; stream.writer = (void *)writer; - ret = cb->container.logs(lcrd_request, &stream, &lcrd_response); - lcrd_logs_request_free(lcrd_request); + ret = cb->container.logs(isulad_request, &stream, &isulad_response); + isulad_logs_request_free(isulad_request); std::string errmsg = "Failed to execute logs"; - if (lcrd_response == nullptr) { + if (isulad_response == nullptr) { return Status(StatusCode::UNKNOWN, errmsg); } - errmsg = (lcrd_response->errmsg != nullptr) ? lcrd_response->errmsg : "Failed to execute logs"; - lcrd_logs_response_free(lcrd_response); + errmsg = (isulad_response->errmsg != nullptr) ? isulad_response->errmsg : "Failed to execute logs"; + isulad_logs_response_free(isulad_response); if (ret != 0) { return Status(StatusCode::UNKNOWN, errmsg); } diff --git a/src/connect/service/grpc/grpc_containers_service.h b/src/connect/service/grpc/grpc_containers_service.h index 9dee9b116aab2702d3d2bfcb7bca61a3d7263846..21fbf279b559c288c8d2e65f0cd6e20005ecbf8a 100644 --- a/src/connect/service/grpc/grpc_containers_service.h +++ b/src/connect/service/grpc/grpc_containers_service.h @@ -110,7 +110,7 @@ private: int response_to_grpc(const T1 *response, T2 *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } gresponse->set_cc(response->cc); @@ -165,15 +165,15 @@ private: int resume_request_from_grpc(const ResumeRequest *grequest, container_resume_request **request); int container_rename_request_from_grpc(const RenameRequest *grequest, - struct lcrd_container_rename_request **request); + struct isulad_container_rename_request **request); - int container_rename_response_to_grpc(const struct lcrd_container_rename_response *response, + int container_rename_response_to_grpc(const struct isulad_container_rename_response *response, RenameResponse *gresponse); int container_resize_request_from_grpc(const ResizeRequest *grequest, - struct lcrd_container_resize_request **request); + struct isulad_container_resize_request **request); - int container_resize_response_to_grpc(const struct lcrd_container_resize_response *response, + int container_resize_response_to_grpc(const struct isulad_container_resize_response *response, ResizeResponse *gresponse); int update_request_from_grpc(const UpdateRequest *grequest, container_update_request **request); @@ -188,10 +188,10 @@ private: int wait_response_to_grpc(const container_wait_response *response, WaitResponse *gresponse); - int events_request_from_grpc(const EventsRequest *grequest, struct lcrd_events_request **request); + int events_request_from_grpc(const EventsRequest *grequest, struct isulad_events_request **request); int copy_from_container_request_from_grpc(const CopyFromContainerRequest *grequest, - struct lcrd_copy_from_container_request **request); + struct isulad_copy_from_container_request **request); int remote_exec_request_from_stream(ServerContext *context, container_exec_request **request, std::string &errmsg); @@ -218,7 +218,7 @@ private: int pack_proxy_info_to_grpc(const host_info_response *response, InfoResponse *gresponse); - int logs_request_from_grpc(const LogsRequest *grequest, struct lcrd_logs_request **request); + int logs_request_from_grpc(const LogsRequest *grequest, struct isulad_logs_request **request); }; #endif /* _GRPC_CONTAINER_SERVICE_H_ */ diff --git a/src/connect/service/grpc/grpc_containers_service_private.cc b/src/connect/service/grpc/grpc_containers_service_private.cc index a573f7b2f19a8e4569ad24916f2d29eb53490fab..b7ceafc0e59a74308e1fa2aa82cc6fa87fa39e14 100644 --- a/src/connect/service/grpc/grpc_containers_service_private.cc +++ b/src/connect/service/grpc/grpc_containers_service_private.cc @@ -34,7 +34,7 @@ int ContainerServiceImpl::version_response_to_grpc(const container_version_respo VersionResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } gresponse->set_cc(response->cc); @@ -71,7 +71,7 @@ int ContainerServiceImpl::info_request_from_grpc(const InfoRequest *grequest, ho int ContainerServiceImpl::info_response_to_grpc(const host_info_response *response, InfoResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -150,7 +150,7 @@ int ContainerServiceImpl::create_request_from_grpc(const CreateRequest *grequest int ContainerServiceImpl::create_response_to_grpc(const container_create_response *response, CreateResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } gresponse->set_cc(response->cc); @@ -233,7 +233,7 @@ int ContainerServiceImpl::top_request_from_grpc(const TopRequest *grequest, cont int ContainerServiceImpl::top_response_to_grpc(const container_top_response *response, TopResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } gresponse->set_cc(response->cc); @@ -327,7 +327,7 @@ int ContainerServiceImpl::delete_request_from_grpc(const DeleteRequest *grequest int ContainerServiceImpl::delete_response_to_grpc(const container_delete_response *response, DeleteResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } gresponse->set_cc(response->cc); @@ -417,7 +417,7 @@ int ContainerServiceImpl::exec_request_from_grpc(const ExecRequest *grequest, co int ContainerServiceImpl::exec_response_to_grpc(const container_exec_response *response, ExecResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -454,7 +454,7 @@ int ContainerServiceImpl::inspect_response_to_grpc(const container_inspect_respo InspectContainerResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -533,7 +533,7 @@ cleanup: int ContainerServiceImpl::list_response_to_grpc(const container_list_response *response, ListResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -612,10 +612,10 @@ int ContainerServiceImpl::resume_request_from_grpc(const ResumeRequest *grequest } int ContainerServiceImpl::container_rename_request_from_grpc(const RenameRequest *grequest, - struct lcrd_container_rename_request **request) + struct isulad_container_rename_request **request) { - struct lcrd_container_rename_request *tmpreq = (struct lcrd_container_rename_request *)util_common_calloc_s( - sizeof(struct lcrd_container_rename_request)); + struct isulad_container_rename_request *tmpreq = (struct isulad_container_rename_request *)util_common_calloc_s( + sizeof(struct isulad_container_rename_request)); if (tmpreq == nullptr) { ERROR("Out of memory"); return -1; @@ -633,11 +633,11 @@ int ContainerServiceImpl::container_rename_request_from_grpc(const RenameRequest return 0; } -int ContainerServiceImpl::container_rename_response_to_grpc(const struct lcrd_container_rename_response *response, +int ContainerServiceImpl::container_rename_response_to_grpc(const struct isulad_container_rename_response *response, RenameResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -653,10 +653,10 @@ int ContainerServiceImpl::container_rename_response_to_grpc(const struct lcrd_co } int ContainerServiceImpl::container_resize_request_from_grpc(const ResizeRequest *grequest, - struct lcrd_container_resize_request **request) + struct isulad_container_resize_request **request) { - struct lcrd_container_resize_request *tmpreq = (struct lcrd_container_resize_request *)util_common_calloc_s( - sizeof(struct lcrd_container_resize_request)); + struct isulad_container_resize_request *tmpreq = (struct isulad_container_resize_request *)util_common_calloc_s( + sizeof(struct isulad_container_resize_request)); if (tmpreq == nullptr) { ERROR("Out of memory"); return -1; @@ -678,11 +678,11 @@ int ContainerServiceImpl::container_resize_request_from_grpc(const ResizeRequest return 0; } -int ContainerServiceImpl::container_resize_response_to_grpc(const struct lcrd_container_resize_response *response, +int ContainerServiceImpl::container_resize_response_to_grpc(const struct isulad_container_resize_response *response, ResizeResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -721,7 +721,7 @@ int ContainerServiceImpl::update_request_from_grpc(const UpdateRequest *grequest int ContainerServiceImpl::update_response_to_grpc(const container_update_response *response, UpdateResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -765,7 +765,7 @@ int ContainerServiceImpl::stats_request_from_grpc(const StatsRequest *grequest, int ContainerServiceImpl::stats_response_to_grpc(const container_stats_response *response, StatsResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -815,7 +815,7 @@ int ContainerServiceImpl::wait_request_from_grpc(const WaitRequest *grequest, co int ContainerServiceImpl::wait_response_to_grpc(const container_wait_response *response, WaitResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -827,10 +827,11 @@ int ContainerServiceImpl::wait_response_to_grpc(const container_wait_response *r return 0; } -int ContainerServiceImpl::events_request_from_grpc(const EventsRequest *grequest, struct lcrd_events_request **request) +int ContainerServiceImpl::events_request_from_grpc(const EventsRequest *grequest, + struct isulad_events_request **request) { - struct lcrd_events_request *tmpreq = (struct lcrd_events_request *)util_common_calloc_s( - sizeof(struct lcrd_events_request)); + struct isulad_events_request *tmpreq = (struct isulad_events_request *)util_common_calloc_s( + sizeof(struct isulad_events_request)); if (tmpreq == nullptr) { ERROR("Out of memory"); return -1; @@ -855,10 +856,10 @@ int ContainerServiceImpl::events_request_from_grpc(const EventsRequest *grequest } int ContainerServiceImpl::copy_from_container_request_from_grpc( - const CopyFromContainerRequest *grequest, struct lcrd_copy_from_container_request **request) + const CopyFromContainerRequest *grequest, struct isulad_copy_from_container_request **request) { - struct lcrd_copy_from_container_request *tmpreq = (struct lcrd_copy_from_container_request *)util_common_calloc_s( - sizeof(lcrd_copy_from_container_request)); + struct isulad_copy_from_container_request *tmpreq = (struct isulad_copy_from_container_request *)util_common_calloc_s( + sizeof(isulad_copy_from_container_request)); if (tmpreq == nullptr) { ERROR("Out of memory"); return -1; @@ -905,7 +906,7 @@ int ContainerServiceImpl::remote_exec_request_from_stream(ServerContext *context void ContainerServiceImpl::add_exec_trailing_metadata(ServerContext *context, container_exec_response *response) { if (response == nullptr) { - context->AddTrailingMetadata("cc", std::to_string((int)LCRD_ERR_MEMOUT)); + context->AddTrailingMetadata("cc", std::to_string((int)ISULAD_ERR_MEMOUT)); return; } context->AddTrailingMetadata("cc", std::to_string(response->cc)); @@ -961,7 +962,7 @@ cleanup: void ContainerServiceImpl::add_attach_trailing_metadata(ServerContext *context, container_attach_response *response) { if (response == nullptr) { - context->AddTrailingMetadata("cc", std::to_string((int)LCRD_ERR_MEMOUT)); + context->AddTrailingMetadata("cc", std::to_string((int)ISULAD_ERR_MEMOUT)); return; } context->AddTrailingMetadata("cc", std::to_string(response->cc)); @@ -1015,7 +1016,7 @@ cleanup: void ContainerServiceImpl::add_start_trailing_metadata(ServerContext *context, container_start_response *response) { if (response == nullptr) { - context->AddTrailingMetadata("cc", std::to_string((int)LCRD_ERR_MEMOUT)); + context->AddTrailingMetadata("cc", std::to_string((int)ISULAD_ERR_MEMOUT)); return; } context->AddTrailingMetadata("cc", std::to_string(response->cc)); @@ -1049,7 +1050,7 @@ int ContainerServiceImpl::export_request_from_grpc(const ExportRequest *grequest int ContainerServiceImpl::pack_os_info_to_grpc(const host_info_response *response, InfoResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -1089,7 +1090,7 @@ int ContainerServiceImpl::pack_os_info_to_grpc(const host_info_response *respons int ContainerServiceImpl::pack_proxy_info_to_grpc(const host_info_response *response, InfoResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } diff --git a/src/connect/service/grpc/grpc_images_service.cc b/src/connect/service/grpc/grpc_images_service.cc index a540b3ba5d208dd8edc6a8277bb77e0bd1c06d18..3eef061d929dd2f61ee100d68fa3d3b716564f45 100644 --- a/src/connect/service/grpc/grpc_images_service.cc +++ b/src/connect/service/grpc/grpc_images_service.cc @@ -91,7 +91,7 @@ cleanup: int ImagesServiceImpl::image_list_response_to_grpc(image_list_images_response *response, ListImagesResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -199,7 +199,7 @@ int ImagesServiceImpl::inspect_response_to_grpc(const image_inspect_response *re InspectImageResponse *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } @@ -228,7 +228,7 @@ Status ImagesServiceImpl::List(ServerContext *context, const ListImagesRequest * int tret = image_list_request_from_grpc(request, &image_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -239,8 +239,8 @@ Status ImagesServiceImpl::List(ServerContext *context, const ListImagesRequest * free_image_list_images_request(image_req); free_image_list_images_response(image_res); if (tret != 0) { - reply->set_errmsg(util_strdup_s(errno_to_error_message(LCRD_ERR_INTERNAL))); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_errmsg(util_strdup_s(errno_to_error_message(ISULAD_ERR_INTERNAL))); + reply->set_cc(ISULAD_ERR_INPUT); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -261,7 +261,7 @@ Status ImagesServiceImpl::Delete(ServerContext *context, const DeleteImageReques int tret = image_remove_request_from_grpc(request, &image_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -272,8 +272,8 @@ Status ImagesServiceImpl::Delete(ServerContext *context, const DeleteImageReques free_image_delete_image_request(image_req); free_image_delete_image_response(image_res); if (tret != 0) { - reply->set_errmsg(util_strdup_s(errno_to_error_message(LCRD_ERR_INTERNAL))); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_errmsg(util_strdup_s(errno_to_error_message(ISULAD_ERR_INTERNAL))); + reply->set_cc(ISULAD_ERR_INPUT); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -294,7 +294,7 @@ Status ImagesServiceImpl::Load(ServerContext *context, const LoadImageRequest *r int tret = image_load_request_from_grpc(request, &image_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -305,8 +305,8 @@ Status ImagesServiceImpl::Load(ServerContext *context, const LoadImageRequest *r free_image_load_image_request(image_req); free_image_load_image_response(image_res); if (tret != 0) { - reply->set_errmsg(util_strdup_s(errno_to_error_message(LCRD_ERR_INTERNAL))); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_errmsg(util_strdup_s(errno_to_error_message(ISULAD_ERR_INTERNAL))); + reply->set_cc(ISULAD_ERR_INPUT); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } @@ -334,7 +334,7 @@ Status ImagesServiceImpl::Inspect(ServerContext *context, const InspectImageRequ tret = inspect_request_from_grpc(request, &image_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -344,8 +344,8 @@ Status ImagesServiceImpl::Inspect(ServerContext *context, const InspectImageRequ free_image_inspect_request(image_req); free_image_inspect_response(image_res); if (tret != 0) { - reply->set_errmsg(errno_to_error_message(LCRD_ERR_INTERNAL)); - reply->set_cc(LCRD_ERR_INTERNAL); + reply->set_errmsg(errno_to_error_message(ISULAD_ERR_INTERNAL)); + reply->set_cc(ISULAD_ERR_INTERNAL); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } return Status::OK; @@ -414,7 +414,7 @@ Status ImagesServiceImpl::Login(ServerContext *context, const LoginRequest *requ int tret = image_login_request_from_grpc(request, &image_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -425,8 +425,8 @@ Status ImagesServiceImpl::Login(ServerContext *context, const LoginRequest *requ free_image_login_request(image_req); free_image_login_response(image_res); if (tret != 0) { - reply->set_errmsg(util_strdup_s(errno_to_error_message(LCRD_ERR_INTERNAL))); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_errmsg(util_strdup_s(errno_to_error_message(ISULAD_ERR_INTERNAL))); + reply->set_cc(ISULAD_ERR_INPUT); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } @@ -448,7 +448,7 @@ Status ImagesServiceImpl::Logout(ServerContext *context, const LogoutRequest *re int tret = image_logout_request_from_grpc(request, &image_req); if (tret != 0) { ERROR("Failed to transform grpc request"); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_cc(ISULAD_ERR_INPUT); return Status::OK; } @@ -459,8 +459,8 @@ Status ImagesServiceImpl::Logout(ServerContext *context, const LogoutRequest *re free_image_logout_request(image_req); free_image_logout_response(image_res); if (tret != 0) { - reply->set_errmsg(util_strdup_s(errno_to_error_message(LCRD_ERR_INTERNAL))); - reply->set_cc(LCRD_ERR_INPUT); + reply->set_errmsg(util_strdup_s(errno_to_error_message(ISULAD_ERR_INTERNAL))); + reply->set_cc(ISULAD_ERR_INPUT); ERROR("Failed to translate response to grpc, operation is %s", ret ? "failed" : "success"); } diff --git a/src/connect/service/grpc/grpc_images_service.h b/src/connect/service/grpc/grpc_images_service.h index e0950d949ce97455c5677b521c05d47e918c4882..881bd6b53d701024a3c69061e0f542d7403d3aea 100644 --- a/src/connect/service/grpc/grpc_images_service.h +++ b/src/connect/service/grpc/grpc_images_service.h @@ -62,7 +62,7 @@ private: int response_to_grpc(const T1 *response, T2 *gresponse) { if (response == nullptr) { - gresponse->set_cc(LCRD_ERR_MEMOUT); + gresponse->set_cc(ISULAD_ERR_MEMOUT); return 0; } gresponse->set_cc(response->cc); diff --git a/src/connect/service/grpc/grpc_service.cc b/src/connect/service/grpc/grpc_service.cc index af39ecef9d19a98444ed9a205623b5c076cbf013..3e0edb0992225d113e4691423e7bf2e7a4ef05f3 100644 --- a/src/connect/service/grpc/grpc_service.cc +++ b/src/connect/service/grpc/grpc_service.cc @@ -40,7 +40,7 @@ public: int Init(const struct service_arguments *args) { if (args == nullptr || args->hosts == nullptr) { - ERROR("lcrd config socket address is empty"); + ERROR("isulad config socket address is empty"); return -1; } diff --git a/src/connect/service/service_common.h b/src/connect/service/service_common.h index ee472ed5072cc1f6f5460a1984d9cb0d83228dd8..bd25479dd0329164b4dbd49ba4f656ce629c1af8 100644 --- a/src/connect/service/service_common.h +++ b/src/connect/service/service_common.h @@ -16,7 +16,7 @@ #define __SERVICE_COMMON_H #include "arguments.h" -#include "liblcrd.h" +#include "libisulad.h" #ifdef __cplusplus extern "C" { diff --git a/src/constants.h b/src/constants.h index 243abdfb7deb637de123527c60588c0cf66ff8d2..624c1f9d1290ba618749d373fc3157876c2dd64a 100644 --- a/src/constants.h +++ b/src/constants.h @@ -13,8 +13,8 @@ * Description: provide macro definition ******************************************************************************/ -#ifndef _LCRD_CONSTANTS_H -#define _LCRD_CONSTANTS_H +#ifndef _ISULAD_CONSTANTS_H +#define _ISULAD_CONSTANTS_H /* mode of file and directory */ diff --git a/src/container_def.h b/src/container_def.h index b167ada92928036922b386f1537091ccb559cb8c..c18c2a8dafc29a733a8df1ef438038e210e7a3b0 100644 --- a/src/container_def.h +++ b/src/container_def.h @@ -25,16 +25,16 @@ extern "C" { #endif #ifndef DEFAULT_UNIX_SOCKET -#define DEFAULT_UNIX_SOCKET "unix:///var/run/lcrd.sock" +#define DEFAULT_UNIX_SOCKET "unix:///var/run/isulad.sock" #endif #ifndef DEFAULT_ROOTFS_PATH #define DEFAULT_ROOTFS_PATH "/dev/ram0" #endif #ifndef OCICONFIG_PATH -#define OCICONFIG_PATH "/etc/default/lcrd/config.json" +#define OCICONFIG_PATH "/etc/default/isulad/config.json" #endif #ifndef OCI_SYSTEM_CONTAINER_CONFIG_PATH -#define OCI_SYSTEM_CONTAINER_CONFIG_PATH "/etc/default/lcrd/systemcontainer_config.json" +#define OCI_SYSTEM_CONTAINER_CONFIG_PATH "/etc/default/isulad/systemcontainer_config.json" #endif #ifndef SECCOMP_DEFAULT_PATH #define SECCOMP_DEFAULT_PATH "/etc/isulad/seccomp_default.json" diff --git a/src/contrib/config/daemon.json b/src/contrib/config/daemon.json index 44a416ce10b7fe344d53c2e079591cce0fb02fbf..7baea20d4dc41d0f354cb9ea9727ee20b2f12f1b 100644 --- a/src/contrib/config/daemon.json +++ b/src/contrib/config/daemon.json @@ -1,18 +1,18 @@ { - "group": "lcrd", - "graph": "/var/lib/lcrd", - "state": "/var/run/lcrd", + "group": "isulad", + "graph": "/var/lib/isulad", + "state": "/var/run/isulad", "engine": "lcr", "log-level": "ERROR", - "pidfile": "/var/run/lcrd.pid", + "pidfile": "/var/run/isulad.pid", "log-opts": { "log-file-mode": "0600", - "log-path": "/var/lib/lcrd", + "log-path": "/var/lib/isulad", "max-file": "1", "max-size": "30KB" }, "log-driver": "stdout", - "hook-spec": "/etc/default/lcrd/hooks/default.json", + "hook-spec": "/etc/default/isulad/hooks/default.json", "start-timeout": "2m", "storage-driver": "overlay2", "storage-opts": [ @@ -24,7 +24,7 @@ ], "pod-sandbox-image": "", "image-opt-timeout": "5m", - "image-server-sock-addr": "unix:///var/run/lcrd/isula_image.sock", + "image-server-sock-addr": "unix:///var/run/isulad/isula_image.sock", "native.umask": "secure", "network-plugin": "", "cni-bin-dir": "", diff --git a/src/contrib/config/iSulad.sysconfig b/src/contrib/config/iSulad.sysconfig index c25da0be035f8f8ef1c4ea4865ee471687511a48..580d6de00772bfaadec799ec864a3d18e188dce2 100644 --- a/src/contrib/config/iSulad.sysconfig +++ b/src/contrib/config/iSulad.sysconfig @@ -3,7 +3,7 @@ # the iSulad daemon socket configuration # # Modify these options if you want to change the way the iSulad daemon runs -# OPTIONS='-H unix:///var/run/lcrd.sock' +# OPTIONS='-H unix:///var/run/isulad.sock' # OPTIONS='-H tcp://0.0.0.0:2375' # OPTIONS='-H tcp://0.0.0.0:2375 --tlsverify --tlscacert=/root/.iSulad/ca.pem --tlscert=/root/.iSulad/server-cert.pem --tlskey=/root/.iSulad/server-key.pem' @@ -11,12 +11,12 @@ # # 'DOCKER_CERT_PATH' contains the location of the client configuration files used for TLS verification. #ISULAD_CERT_PATH=/etc/iSulad -# 'DOCKER_HOST' specifies the daemon socket to connect to. The default is a local socket(unix:///var/run/lcrd.sock). +# 'DOCKER_HOST' specifies the daemon socket to connect to. The default is a local socket(unix:///var/run/isulad.sock). #ISULAD_HOST=tcp://127.0.0.1:2375 # 'DOCKER_TLS_VERIFY' enables Transport Layer Security (TLS) for the local Docker client #ISULAD_TLS_VERIFY=1 # Modify 'SYSMONITOR_OPTIONS' if you want to change the way the iSulad daemon runs,because client need to adapt daemon -#SYSMONITOR_OPTIONS='-H unix:///var/run/lcrd.sock' +#SYSMONITOR_OPTIONS='-H unix:///var/run/isulad.sock' #SYSMONITOR_OPTIONS='-H tcp://127.0.0.1:2375' #SYSMONITOR_OPTIONS='-H tcp://127.0.0.1:2375 --tlsverify --tlscacert=/root/.iSulad/ca.pem --tlscert=/root/.iSulad/cert.pem --tlskey=/root/.iSulad/key.pem' diff --git a/src/contrib/docker b/src/contrib/docker index f759effb9c79b42f679567169d0b35fb3c990587..7ede4c6ee2c61a5ad55c9f55644ed6238f1cf519 100755 --- a/src/contrib/docker +++ b/src/contrib/docker @@ -16,11 +16,11 @@ #set -x LWC_PATH=/usr DEFAULT_ROOTFS_PATH=/dev/ram0 -LCRC_COMMON_OPTION= +ISULA_COMMON_OPTION= SOCKET_PATH=unix:///var/run/docker.sock SPACE_REPLACE_MAGIC="[#)" export IMAGE_NONE_PATH=$DEFAULT_ROOTFS_PATH -info_lcrc_command_help() +info_isula_command_help() { echo "See 'docker $1 --help'." 1>&2 } @@ -28,13 +28,13 @@ info_lcrc_command_help() error_invalid_flag() { echo "flag provided but not defined: $2" 1>&2 - info_lcrc_command_help $1 + info_isula_command_help $1 } INFO_DOCKER_COMMAND_NO_ARGUMENT() { echo "\"docker $1\" requires at least 1 argument(s)." 1>&2 - info_lcrc_command_help $1 + info_isula_command_help $1 } LOG_ERROR() @@ -57,7 +57,7 @@ Options: --device=[] Add a host device to the container -e, --env=[] Set environment variables --entrypoint Entrypoint to run when starting the container - --external-rootfs=PATH Specify the custom rootfs that is not managed by LCRD for the container, directory or block device + --external-rootfs=PATH Specify the custom rootfs that is not managed by isulad for the container, directory or block device --help Print usage --hook-spec File containing hook definition(prestart, poststart, poststop) -h, --hostname Container host name @@ -90,7 +90,7 @@ command_run() exit 0 fi done - exec $LWC_PATH/bin/lcrc run $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula run $ISULA_COMMON_OPTION "$@" } STOP_USAGE=" @@ -119,7 +119,7 @@ command_stop() fi done - exec $LWC_PATH/bin/lcrc stop $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula stop $ISULA_COMMON_OPTION "$@" } KILL_USAGE=" @@ -145,7 +145,7 @@ command_kill() exit 0 fi done - exec $LWC_PATH/bin/lcrc kill $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula kill $ISULA_COMMON_OPTION "$@" } PS_USAGE=" @@ -169,10 +169,10 @@ command_ps() fi done RET=0 - $LWC_PATH/bin/lcrc ps $LCRC_COMMON_OPTION "$@" + $LWC_PATH/bin/isula ps $ISULA_COMMON_OPTION "$@" let "RET=$?" if [ $RET == 1 -o $RET == 125 ]; then - info_lcrc_command_help ps + info_isula_command_help ps fi exit $RET } @@ -210,7 +210,7 @@ command_pull() command_version() { - exec $LWC_PATH/bin/lcrc version $LCRC_COMMON_OPTION + exec $LWC_PATH/bin/isula version $ISULA_COMMON_OPTION } INSPECT_USAGE=" @@ -256,9 +256,9 @@ command_inspect() fi if [ -z "$FORMAT" ] ; then - exec $LWC_PATH/bin/lcrc inspect $LCRC_COMMON_OPTION $LCRC_INSPECT_OPTION "$@" + exec $LWC_PATH/bin/isula inspect $ISULA_COMMON_OPTION $ISULA_INSPECT_OPTION "$@" else - exec $LWC_PATH/bin/lcrc inspect $LCRC_COMMON_OPTION $LCRC_INSPECT_OPTION -f "$FORMAT" "$@" + exec $LWC_PATH/bin/isula inspect $ISULA_COMMON_OPTION $ISULA_INSPECT_OPTION -f "$FORMAT" "$@" fi } @@ -286,7 +286,7 @@ command_exec() fi done - exec $LWC_PATH/bin/lcrc exec $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula exec $ISULA_COMMON_OPTION "$@" } RM_USAGE=" @@ -313,7 +313,7 @@ command_rm() exit 0 fi done - exec $LWC_PATH/bin/lcrc rm $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula rm $ISULA_COMMON_OPTION "$@" } RMI_USAGE=" @@ -339,7 +339,7 @@ command_rmi() exit 0 fi done - exec $LWC_PATH/bin/lcrc rmi $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula rmi $ISULA_COMMON_OPTION "$@" } LOAD_USAGE=" @@ -362,7 +362,7 @@ command_load() exit 0 fi done - exec $LWC_PATH/bin/lcrc load $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula load $ISULA_COMMON_OPTION "$@" } IMAGES_USAGE=" @@ -384,7 +384,7 @@ command_images() exit 0 fi done - exec $LWC_PATH/bin/lcrc images $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula images $ISULA_COMMON_OPTION "$@" } RESTART_USAGE=" @@ -410,7 +410,7 @@ command_restart() exit 0 fi done - exec $LWC_PATH/bin/lcrc restart $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula restart $ISULA_COMMON_OPTION "$@" } WAIT_USAGE=" @@ -435,7 +435,7 @@ command_wait() exit 0 fi done - exec $LWC_PATH/bin/lcrc wait $LCRC_COMMON_OPTION "$@" + exec $LWC_PATH/bin/isula wait $ISULA_COMMON_OPTION "$@" } LOGS_USAGE=" @@ -465,10 +465,10 @@ command_logs() done RET=0 - $LWC_PATH/bin/lcrc logs $LCRC_COMMON_OPTION "$@" + $LWC_PATH/bin/isula logs $ISULA_COMMON_OPTION "$@" let "RET=$?" if [ $RET == 1 ]; then - info_lcrc_command_help logs + info_isula_command_help logs fi exit $RET } @@ -567,6 +567,6 @@ while true ; do esac done -LCRC_COMMON_OPTION="$LCRC_COMMON_OPTION -H $SOCKET_PATH" +ISULA_COMMON_OPTION="$ISULA_COMMON_OPTION -H $SOCKET_PATH" command_docker "$@"; diff --git a/src/contrib/init/isulad.init b/src/contrib/init/isulad.init new file mode 100644 index 0000000000000000000000000000000000000000..7a391acc5e5a7aa44f13f4789cae1d892b25c524 --- /dev/null +++ b/src/contrib/init/isulad.init @@ -0,0 +1,119 @@ +#! /bin/sh + +# Provides: isulad +# Short-Description: light-weighted container runtime daemon +# Description: isulad is a light-weighted container runtime daemon + +set -e + +# /etc/init.d/isulad: start and stop the isulad daemon + +DAEMON=/usr/bin/isulad +ISULAD_ENABLE=true +ISULAD_OPTS='-s test' +ISULAD_DEFAULTS_FILE=/etc/default/isulad +ISULAD_CONFIG_FILE=/etc/isulad/daemon.json +ISULAD_PID_FILE=/var/run/isulad.pid + +test -x $DAEMON || exit 0 + +. /lib/lsb/init-functions + +if [ -s $ISULAD_DEFAULTS_FILE ]; then + . $ISULAD_DEFAULTS_FILE + case "x$ISULAD_ENABLE" in + xtrue|xfalse) ;; + xinetd) exit 0 + ;; + *) log_failure_msg "Value of ISULAD_ENABLE in $ISULAD_DEFAULTS_FILE must be either 'true' or 'false';" + log_failure_msg "not starting isulad daemon." + exit 1 + ;; + esac +fi + +export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/local/bin" + +isulad_start() { + if [ ! -s "$ISULAD_CONFIG_FILE" ]; then + log_failure_msg "missing or empty config file $ISULAD_CONFIG_FILE" + log_end_msg 1 + exit 0 + fi + if /usr/bin/nohup $DARMON --pidfile $ISULAD_PID_FILE $ISULAD_OPTS & + then + rc=0 + sleep 1 + if ! kill -0 $(cat $ISULAD_PID_FILE) >/dev/null 2>&1; then + log_failure_msg "isulad daemon failed to start" + rc=1 + fi + else + rc=1 + fi + if [ $rc -eq 0 ]; then + log_end_msg 0 + else + log_end_msg 1 + rm -f $ISULAD_PID_FILE + fi +} # isulad_start + + +case "$1" in + start) + if "$ISULAD_ENABLE"; then + log_daemon_msg "Starting isulad daemon" "isulad" + if [ -s $ISULAD_PID_FILE ] && kill -0 $(cat $ISULAD_PID_FILE) >/dev/null 2>&1; then + log_progress_msg "apparently already running" + log_end_msg 0 + exit 0 + fi + isulad_start + else + if [ -s "$ISULAD_CONFIG_FILE" ]; then + [ "$VERBOSE" != no ] && log_warning_msg "isulad daemon not enabled in $ISULAD_DEFAULTS_FILE, not starting..." + fi + fi + ;; + stop) + log_daemon_msg "Stopping isulad daemon" "isulad" + kill -INT $(cat $ISULAD_PID_FILE) + log_end_msg $? + rm -f $ISULAD_PID_FILE + ;; + + reload|force-reload) + log_warning_msg "Reloading isulad daemon: not needed, as the daemon" + log_warning_msg "re-reads the config file whenever a client connects." + ;; + + restart) + set +e + if $ISULAD_ENABLE; then + log_daemon_msg "Restarting isulad daemon" "isulad" + if [ -s $ISULAD_PID_FILE ] && kill -0 $(cat $ISULAD_PID_FILE) >/dev/null 2>&1; then + kill -INT $(cat $ISULAD_PID_FILE) + sleep 1 + else + log_warning_msg "isulad daemon not running, attempting to start." + rm -f $ISULAD_PID_FILE + fi + isulad_start + else + if [ -s "$ISULAD_CONFIG_FILE" ]; then + [ "$VERBOSE" != no ] && log_warning_msg "isulad daemon not enabled in $ISULAD_DEFAULTS_FILE, not starting..." + fi + fi + ;; + + status) + status_of_proc -p $ISULAD_PID_FILE "$DAEMON" isulad + exit $? # notreached due to set -e + ;; + *) + echo "Usage: /etc/init.d/isulad {start|stop|reload|force-reload|restart|status}" + exit 1 +esac + +exit 0 diff --git a/src/contrib/init/lcrd.service b/src/contrib/init/isulad.service similarity index 91% rename from src/contrib/init/lcrd.service rename to src/contrib/init/isulad.service index 051c965d7b51541da811473d815aa3ba727d5acc..8344fe6d5caeeebff6413a3a32f3169ac15a4461 100644 --- a/src/contrib/init/lcrd.service +++ b/src/contrib/init/isulad.service @@ -5,7 +5,7 @@ After=network.target [Service] Type=notify EnvironmentFile=-/etc/sysconfig/iSulad -ExecStart=/usr/bin/lcrd $OPTIONS +ExecStart=/usr/bin/isulad $OPTIONS ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=1048576 LimitNPROC=infinity diff --git a/src/contrib/init/lcrd.init b/src/contrib/init/lcrd.init deleted file mode 100644 index 9daa0282ce7c85f0315567cd30ef767184484db0..0000000000000000000000000000000000000000 --- a/src/contrib/init/lcrd.init +++ /dev/null @@ -1,119 +0,0 @@ -#! /bin/sh - -# Provides: lcrd -# Short-Description: light-weighted container runtime daemon -# Description: lcrd is a light-weighted container runtime daemon - -set -e - -# /etc/init.d/lcrd: start and stop the lcrd daemon - -DAEMON=/usr/bin/lcrd -LCRD_ENABLE=true -LCRD_OPTS='-s test' -LCRD_DEFAULTS_FILE=/etc/default/lcrd -LCRD_CONFIG_FILE=/etc/isulad/daemon.json -LCRD_PID_FILE=/var/run/lcrd.pid - -test -x $DAEMON || exit 0 - -. /lib/lsb/init-functions - -if [ -s $LCRD_DEFAULTS_FILE ]; then - . $LCRD_DEFAULTS_FILE - case "x$LCRD_ENABLE" in - xtrue|xfalse) ;; - xinetd) exit 0 - ;; - *) log_failure_msg "Value of LCRD_ENABLE in $LCRD_DEFAULTS_FILE must be either 'true' or 'false';" - log_failure_msg "not starting lcrd daemon." - exit 1 - ;; - esac -fi - -export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/local/bin" - -lcrd_start() { - if [ ! -s "$LCRD_CONFIG_FILE" ]; then - log_failure_msg "missing or empty config file $LCRD_CONFIG_FILE" - log_end_msg 1 - exit 0 - fi - if /usr/bin/nohup $DARMON --pidfile $LCRD_PID_FILE $LCRD_OPTS & - then - rc=0 - sleep 1 - if ! kill -0 $(cat $LCRD_PID_FILE) >/dev/null 2>&1; then - log_failure_msg "lcrd daemon failed to start" - rc=1 - fi - else - rc=1 - fi - if [ $rc -eq 0 ]; then - log_end_msg 0 - else - log_end_msg 1 - rm -f $LCRD_PID_FILE - fi -} # lcrd_start - - -case "$1" in - start) - if "$LCRD_ENABLE"; then - log_daemon_msg "Starting lcrd daemon" "lcrd" - if [ -s $LCRD_PID_FILE ] && kill -0 $(cat $LCRD_PID_FILE) >/dev/null 2>&1; then - log_progress_msg "apparently already running" - log_end_msg 0 - exit 0 - fi - lcrd_start - else - if [ -s "$LCRD_CONFIG_FILE" ]; then - [ "$VERBOSE" != no ] && log_warning_msg "lcrd daemon not enabled in $LCRD_DEFAULTS_FILE, not starting..." - fi - fi - ;; - stop) - log_daemon_msg "Stopping lcrd daemon" "lcrd" - kill -INT $(cat $LCRD_PID_FILE) - log_end_msg $? - rm -f $LCRD_PID_FILE - ;; - - reload|force-reload) - log_warning_msg "Reloading lcrd daemon: not needed, as the daemon" - log_warning_msg "re-reads the config file whenever a client connects." - ;; - - restart) - set +e - if $LCRD_ENABLE; then - log_daemon_msg "Restarting lcrd daemon" "lcrd" - if [ -s $LCRD_PID_FILE ] && kill -0 $(cat $LCRD_PID_FILE) >/dev/null 2>&1; then - kill -INT $(cat $LCRD_PID_FILE) - sleep 1 - else - log_warning_msg "lcrd daemon not running, attempting to start." - rm -f $LCRD_PID_FILE - fi - lcrd_start - else - if [ -s "$LCRD_CONFIG_FILE" ]; then - [ "$VERBOSE" != no ] && log_warning_msg "lcrd daemon not enabled in $LCRD_DEFAULTS_FILE, not starting..." - fi - fi - ;; - - status) - status_of_proc -p $LCRD_PID_FILE "$DAEMON" lcrd - exit $? # notreached due to set -e - ;; - *) - echo "Usage: /etc/init.d/lcrd {start|stop|reload|force-reload|restart|status}" - exit 1 -esac - -exit 0 diff --git a/src/contrib/sysmonitor/isulad-check.sh b/src/contrib/sysmonitor/isulad-check.sh index d980fdd836e788aac4426cbe04295b16efc90810..d0df9fe19b01d1bb3875ba12362669edf7ad6762 100755 --- a/src/contrib/sysmonitor/isulad-check.sh +++ b/src/contrib/sysmonitor/isulad-check.sh @@ -16,8 +16,8 @@ source /etc/sysconfig/iSulad #健康检查文件 -healthcheck_file="/var/run/lcrd/isulad_healcheck_status" -createfile_time="/var/run/lcrd/isulad_healcheck_ctime" +healthcheck_file="/var/run/isulad/isulad_healcheck_status" +createfile_time="/var/run/isulad/isulad_healcheck_ctime" #健康检查超时时间 declare -i timeout_time=900 @@ -29,13 +29,13 @@ declare -i status_change_time=930 function status_check() { pid=$1 if [ $? -ne 0 ];then - echo "cat /var/run/lcrd.pid failed!" + echo "cat /var/run/isulad.pid failed!" return 1 fi cat /proc/${pid}/status >> /dev/null 2>&1 if [ $? -ne 0 ];then - echo "/var/run/lcrd.pid exitst while process not exists!" + echo "/var/run/isulad.pid exitst while process not exists!" return 1 fi @@ -57,7 +57,7 @@ function basic_check() sleep 2 date_start=$(date +%s) - tmp_id=`cat /var/run/lcrd.pid` + tmp_id=`cat /var/run/isulad.pid` status_check $tmp_id check_daemon=$? @@ -109,7 +109,7 @@ function health_check() { while [ $i -lt ${timeout_time} ] do - timeout -s 9 1 lcrc version $SYSMONITOR_OPTIONS + timeout -s 9 1 isula version $SYSMONITOR_OPTIONS ret=$? if [ $ret -eq 0 ];then echo "success">${healthcheck_file} diff --git a/src/contrib/sysmonitor/isulad-monit b/src/contrib/sysmonitor/isulad-monit index c13b0d174a7628194d4ad709ed5bf005a43ff3bd..6041f1e2b265c2fd62367ef265b0628e5b011d8f 100644 --- a/src/contrib/sysmonitor/isulad-monit +++ b/src/contrib/sysmonitor/isulad-monit @@ -1,4 +1,4 @@ -NAME=lcrd -RECOVER_COMMAND=systemctl restart lcrd -MONITOR_COMMAND=/etc/default/lcrd/isulad-check.sh -STOP_COMMAND=systemctl stop lcrd +NAME=isulad +RECOVER_COMMAND=systemctl restart isulad +MONITOR_COMMAND=/etc/default/isulad/isulad-check.sh +STOP_COMMAND=systemctl stop isulad diff --git a/src/cutils/utils.h b/src/cutils/utils.h index ea594a0fa2cab88b5558e7bc376f75bb2d182d0f..73d6a792959587b089a6c329ddfab82a98a2f90c 100644 --- a/src/cutils/utils.h +++ b/src/cutils/utils.h @@ -72,8 +72,8 @@ extern "C" { #define MAX_PATH_DEPTH 1024 #define MAX_BUFFER_SIZE 4096 -#define LCRD_NUMSTRLEN64 21 -#define LCRD_NUMSTRLEN32 11 +#define ISULAD_NUMSTRLEN64 21 +#define ISULAD_NUMSTRLEN32 11 #define MAXLINE 4096 #define MAX_HOST_NAME_LEN 64 #define MAX_IMAGE_NAME_LEN 255 @@ -113,7 +113,7 @@ extern "C" { #define Time_Minute (60LL * Time_Second) #define Time_Hour (60LL * Time_Minute) -/* Max regular file size for LCRC\LCRD to open as same as docker */ +/* Max regular file size for isula\isulad to open as same as docker */ #define REGULAR_FILE_SIZE (10 * SIZE_MB) #define rFC339Local "2006-01-02T15:04:05" diff --git a/src/cutils/utils_file.c b/src/cutils/utils_file.c index ff3886d7c60c0694f225150b636065e26beacf0c..3bac06876aac796cc0871ce0487595af4194d43f 100644 --- a/src/cutils/utils_file.c +++ b/src/cutils/utils_file.c @@ -405,7 +405,7 @@ char *util_human_size(uint64_t val) index++; } - len = LCRD_NUMSTRLEN64 + 2 + 1; + len = ISULAD_NUMSTRLEN64 + 2 + 1; out = util_common_calloc_s(len); if (out == NULL) { ERROR("Memory out"); diff --git a/src/engines/engine.c b/src/engines/engine.c index a7bc13221d2a0415be83ab4979a9d752fb257302..2d08a2766e98dd7144eee37d7c39cd5bd4b20276 100644 --- a/src/engines/engine.c +++ b/src/engines/engine.c @@ -22,18 +22,18 @@ #include "constants.h" #include "linked_list.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "log.h" #include "utils.h" #include "lcr_engine.h" -#include "liblcrd.h" +#include "libisulad.h" -struct lcrd_engine_operation_lists { - pthread_rwlock_t lcrd_engines_op_rwlock; - struct linked_list lcrd_engines_op_list; +struct isulad_engine_operation_lists { + pthread_rwlock_t isulad_engines_op_rwlock; + struct linked_list isulad_engines_op_list; }; -static struct lcrd_engine_operation_lists g_lcrd_engines_lists; +static struct isulad_engine_operation_lists g_isulad_engines_lists; typedef int (*engine_init_func_t)(struct engine_operation *ops); @@ -42,17 +42,17 @@ int engines_global_init() { int ret = 0; - (void)memset(&g_lcrd_engines_lists, 0, sizeof(struct lcrd_engine_operation_lists)); - /* init lcrd_engines_op_rwlock */ + (void)memset(&g_isulad_engines_lists, 0, sizeof(struct isulad_engine_operation_lists)); + /* init isulad_engines_op_rwlock */ - ret = pthread_rwlock_init(&g_lcrd_engines_lists.lcrd_engines_op_rwlock, NULL); + ret = pthread_rwlock_init(&g_isulad_engines_lists.isulad_engines_op_rwlock, NULL); if (ret != 0) { - ERROR("Failed to init lcrd conf rwlock"); + ERROR("Failed to init isulad conf rwlock"); ret = -1; goto out; } - linked_list_init(&g_lcrd_engines_lists.lcrd_engines_op_list); + linked_list_init(&g_isulad_engines_lists.isulad_engines_op_list); out: return ret; @@ -72,14 +72,14 @@ static int engine_routine_log_init(const struct engine_operation *eop) } engine_log_path = conf_get_engine_log_file(); - if (lcrd_server_conf_rdlock()) { + if (isulad_server_conf_rdlock()) { ret = -1; goto out; } args = conf_get_server_conf(); if (args == NULL) { - ERROR("Failed to get lcrd server config"); + ERROR("Failed to get isulad server config"); ret = -1; goto unlock_out; } @@ -97,7 +97,7 @@ static int engine_routine_log_init(const struct engine_operation *eop) } unlock_out: - if (lcrd_server_conf_unlock()) { + if (isulad_server_conf_unlock()) { ret = -1; goto out; } @@ -143,7 +143,7 @@ static struct engine_operation *query_engine_locked(const char *name) struct linked_list *it = NULL; struct linked_list *next = NULL; - linked_list_for_each_safe(it, &g_lcrd_engines_lists.lcrd_engines_op_list, next) { + linked_list_for_each_safe(it, &g_isulad_engines_lists.isulad_engines_op_list, next) { engine_op = (struct engine_operation *)it->elem; if (engine_op == NULL) { DEBUG("Invalid engine list elem"); @@ -172,7 +172,7 @@ static struct engine_operation *new_engine_locked(const char *name) if (engine_op == NULL) { ERROR("Failed to initialize engine or runtime: %s", name); - lcrd_set_error_message("Failed to initialize engine or runtime: %s", name); + isulad_set_error_message("Failed to initialize engine or runtime: %s", name); return NULL; } @@ -215,8 +215,8 @@ int engines_discovery(const char *name) return -1; } - if (pthread_rwlock_wrlock(&g_lcrd_engines_lists.lcrd_engines_op_rwlock)) { - ERROR("Failed to acquire lcrd engines list write lock"); + if (pthread_rwlock_wrlock(&g_isulad_engines_lists.isulad_engines_op_rwlock)) { + ERROR("Failed to acquire isulad engines list write lock"); return -1; } @@ -242,11 +242,11 @@ int engines_discovery(const char *name) } linked_list_add_elem(newnode, engine_op); - linked_list_add_tail(&g_lcrd_engines_lists.lcrd_engines_op_list, newnode); + linked_list_add_tail(&g_isulad_engines_lists.isulad_engines_op_list, newnode); unlock_out: - if (pthread_rwlock_unlock(&g_lcrd_engines_lists.lcrd_engines_op_rwlock)) { - ERROR("Failed to release lcrd engines list write lock"); + if (pthread_rwlock_unlock(&g_isulad_engines_lists.isulad_engines_op_rwlock)) { + ERROR("Failed to release isulad engines list write lock"); ret = -1; } @@ -264,13 +264,13 @@ static struct engine_operation *engines_check_handler_exist(const char *name) goto out; } - if (pthread_rwlock_rdlock(&g_lcrd_engines_lists.lcrd_engines_op_rwlock)) { - ERROR("Failed to acquire lcrd engines list read lock"); + if (pthread_rwlock_rdlock(&g_isulad_engines_lists.isulad_engines_op_rwlock)) { + ERROR("Failed to acquire isulad engines list read lock"); engine_op = NULL; goto out; } - linked_list_for_each_safe(it, &g_lcrd_engines_lists.lcrd_engines_op_list, next) { + linked_list_for_each_safe(it, &g_isulad_engines_lists.isulad_engines_op_list, next) { engine_op = (struct engine_operation *)it->elem; if (engine_op == NULL) { DEBUG("Invalid engine list elem"); @@ -284,8 +284,8 @@ static struct engine_operation *engines_check_handler_exist(const char *name) engine_op = NULL; } - if (pthread_rwlock_unlock(&g_lcrd_engines_lists.lcrd_engines_op_rwlock)) { - CRIT("Failed to release lcrd engines list read lock"); + if (pthread_rwlock_unlock(&g_isulad_engines_lists.isulad_engines_op_rwlock)) { + CRIT("Failed to release isulad engines list read lock"); engine_op = NULL; goto out; } diff --git a/src/engines/engine.h b/src/engines/engine.h index f50545f3efaf88a5363543a2a4b99b809388294b..69303e2f5f4705a7c13bae4a420df23c2529fafb 100644 --- a/src/engines/engine.h +++ b/src/engines/engine.h @@ -12,8 +12,8 @@ * Create: 2018-11-08 * Description: provide container engine definition ******************************************************************************/ -#ifndef __LCRD_ENGINE_H -#define __LCRD_ENGINE_H +#ifndef __ISULAD_ENGINE_H +#define __ISULAD_ENGINE_H #include #include diff --git a/src/engines/lcr/lcr_engine.c b/src/engines/lcr/lcr_engine.c index 922a016fc27f84464173f3f1e90795b0dc6814b7..644c742cb6248ccdda9723c3f4caff0bdc8d8738 100644 --- a/src/engines/lcr/lcr_engine.c +++ b/src/engines/lcr/lcr_engine.c @@ -25,7 +25,7 @@ #include "error.h" #include "engine.h" #include "log.h" -#include "lcrd_config.h" +#include "isulad_config.h" typedef bool(*lcr_state_op_t)(const char *name, const char *lcrpath, struct lcr_container_state *lcs); typedef void(*lcr_container_state_free_t)(struct lcr_container_state *lcs); diff --git a/src/engines/lcr/lcr_engine.h b/src/engines/lcr/lcr_engine.h index ba8b54ce46034794a0cb30815e61d0dc8dd1082d..af317fdd264572721ca31d866e06d4d1e21da979 100644 --- a/src/engines/lcr/lcr_engine.h +++ b/src/engines/lcr/lcr_engine.h @@ -12,8 +12,8 @@ * Create: 2018-11-08 * Description: provide container lcr engine definition ******************************************************************************/ -#ifndef __LCRD_LCR_ENGINE_H -#define __LCRD_LCR_ENGINE_H +#ifndef __ISULAD_LCR_ENGINE_H +#define __ISULAD_LCR_ENGINE_H #include "engine.h" diff --git a/src/error.c b/src/error.c index 387dfc0aad8a9cbda81ad451f676ded4f9a2d72e..214980c6824b2ffc21c6ff9ce8d0f22325f4d8a3 100644 --- a/src/error.c +++ b/src/error.c @@ -15,22 +15,22 @@ #include "error.h" #include "utils.h" -#define LCRD_ERRMSG_GEN(n, s) { LCRD_##n, s }, -struct lcrd_strerror_tab_t { - lcrd_errno_t errcode; +#define ISULAD_ERRMSG_GEN(n, s) { ISULAD_##n, s }, +struct isulad_strerror_tab_t { + isulad_errno_t errcode; const char *errmsg; }; -static const struct lcrd_strerror_tab_t g_lcrd_strerror_tab[] = { - LCRD_ERRNO_MAP(LCRD_ERRMSG_GEN) +static const struct isulad_strerror_tab_t g_isulad_strerror_tab[] = { + ISULAD_ERRNO_MAP(ISULAD_ERRMSG_GEN) }; -#undef LCRD_ERRMSG_GEN +#undef ISULAD_ERRMSG_GEN /* errno to error message */ -const char *errno_to_error_message(lcrd_errno_t err) +const char *errno_to_error_message(isulad_errno_t err) { - if ((size_t)err >= sizeof(g_lcrd_strerror_tab) / sizeof(g_lcrd_strerror_tab[0])) { - return g_lcrd_strerror_tab[LCRD_ERR_UNKNOWN].errmsg; + if ((size_t)err >= sizeof(g_isulad_strerror_tab) / sizeof(g_isulad_strerror_tab[0])) { + return g_isulad_strerror_tab[ISULAD_ERR_UNKNOWN].errmsg; } - return g_lcrd_strerror_tab[err].errmsg; + return g_isulad_strerror_tab[err].errmsg; } diff --git a/src/error.h b/src/error.h index 0802a45890d04cf889a86300d3117a60af4fe15f..d447b8b07ab04857e4bbecbafe3bda3db4a73251 100644 --- a/src/error.h +++ b/src/error.h @@ -12,8 +12,8 @@ * Create: 2018-11-08 * Description: provide container error definition ******************************************************************************/ -#ifndef __LCRD_ERROR_H_ -#define __LCRD_ERROR_H_ +#ifndef __ISULAD_ERROR_H_ +#define __ISULAD_ERROR_H_ #include #include @@ -26,7 +26,7 @@ extern "C" { #define DEF_SUCCESS_STR "Success" #define DEF_ERR_RUNTIME_STR "Runtime error" -#define LCRD_ERRNO_MAP(XX) \ +#define ISULAD_ERRNO_MAP(XX) \ XX(SUCCESS, DEF_SUCCESS_STR) \ \ /* err in posix api call */ \ @@ -46,11 +46,11 @@ extern "C" { /* err max */ \ XX(ERR_UNKNOWN, "Unknown error") -#define LCRD_ERRNO_GEN(n, s) LCRD_##n, -typedef enum { LCRD_ERRNO_MAP(LCRD_ERRNO_GEN) } lcrd_errno_t; -#undef LCRD_ERRNO_GEN +#define ISULAD_ERRNO_GEN(n, s) ISULAD_##n, +typedef enum { ISULAD_ERRNO_MAP(ISULAD_ERRNO_GEN) } isulad_errno_t; +#undef ISULAD_ERRNO_GEN -const char *errno_to_error_message(lcrd_errno_t err); +const char *errno_to_error_message(isulad_errno_t err); static inline void format_errorf(char **err, const char *format, ...) { diff --git a/src/http/buffer.h b/src/http/buffer.h index 4bd8a9247578f22d446dad081982b50244520d92..2a00e7a5366c71a7cb386b2b1b28aa22b0b345c2 100644 --- a/src/http/buffer.h +++ b/src/http/buffer.h @@ -12,8 +12,8 @@ * Create: 2018-11-08 * Description: provide container buffer definition ******************************************************************************/ -#ifndef LCRD_BUFFER_H -#define LCRD_BUFFER_H +#ifndef ISULAD_BUFFER_H +#define ISULAD_BUFFER_H #include #include diff --git a/src/http/http.h b/src/http/http.h index a5ac51ad307a29c1fb1ca3c2bab056776e6c6ae4..d447ec247fd17bce906f08515f050da3d248f38b 100644 --- a/src/http/http.h +++ b/src/http/http.h @@ -12,8 +12,8 @@ * Create: 2018-11-08 * Description: provide container http function definition ******************************************************************************/ -#ifndef LCRD_HTTP_H -#define LCRD_HTTP_H +#ifndef ISULAD_HTTP_H +#define ISULAD_HTTP_H #ifdef __cplusplus extern "C" { diff --git a/src/http/parser.c b/src/http/parser.c index c388c6a031851c067d472777ee84d4688d4d3f47..92f8de0f110b565eeb269207e2cd291bbf16b1fb 100644 --- a/src/http/parser.c +++ b/src/http/parser.c @@ -12,6 +12,31 @@ * Create: 2018-11-08 * Description: provide container parser functions ******************************************************************************/ +/* + * Since some of this code is derived from http-parser, their copyright + * is retained here.... + * + * Copyright Joyent, Inc. and other Node contributors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + #include #include #include diff --git a/src/http/parser.h b/src/http/parser.h index c7506088ad031110e7fe8ae3954b1ab4c6a77b9c..537293224cf88fe15027d76293db3c1929fb05d2 100644 --- a/src/http/parser.h +++ b/src/http/parser.h @@ -12,6 +12,31 @@ * Create: 2018-11-08 * Description: provide container parser definition ******************************************************************************/ +/* + * Since some of this code is derived from http-parser, their copyright + * is retained here.... + * + * Copyright Joyent, Inc. and other Node contributors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + #ifndef _PARSER_H #define _PARSER_H diff --git a/src/image/embedded/embedded_config_merge.c b/src/image/embedded/embedded_config_merge.c index dcf7037d5c7b3f5d1752fad08130dfd55f10954c..befb2544c35e7e8867cdf9e88f79f30c36026030 100644 --- a/src/image/embedded/embedded_config_merge.c +++ b/src/image/embedded/embedded_config_merge.c @@ -21,7 +21,7 @@ #include "utils.h" #include "log.h" -#include "liblcrd.h" +#include "libisulad.h" #include "oci_runtime_spec.h" #include "embedded_manifest.h" #include "specs_extend.h" diff --git a/src/image/embedded/embedded_image.c b/src/image/embedded/embedded_image.c index 28c9f0887a2502290dea8f8b8f36972fc005f97e..3ae0be5d2a523aab1114511c1ce06e33cccf7745 100644 --- a/src/image/embedded/embedded_image.c +++ b/src/image/embedded/embedded_image.c @@ -53,7 +53,7 @@ bool embedded_detect(const char *image_name) { if (image_name == NULL && !util_valid_embedded_image_name(image_name)) { WARN("invalid image name %s", image_name); - lcrd_set_error_message("Invalid image name '%s'", image_name); + isulad_set_error_message("Invalid image name '%s'", image_name); return false; } @@ -193,7 +193,7 @@ static int embedded_images_to_imagetool_images(struct db_all_images *all_images, if (images_num >= (SIZE_MAX / sizeof(imagetool_image *))) { ERROR("Too many images, out of memory"); ret = -1; - lcrd_try_set_error_message("Get too many images info, out of memory"); + isulad_try_set_error_message("Get too many images info, out of memory"); goto out; } list->images = util_common_calloc_s(sizeof(imagetool_image *) * images_num); @@ -280,7 +280,7 @@ int embedded_list_images(const im_list_request *request, imagetool_images_list * } else if (ret != 0 || all_images == NULL || all_images->imagesnum == 0) { ERROR("Get image info failed"); ret = -1; - lcrd_try_set_error_message("Get image info failed"); + isulad_try_set_error_message("Get image info failed"); goto out; } @@ -288,7 +288,7 @@ int embedded_list_images(const im_list_request *request, imagetool_images_list * if (ret != 0) { ERROR("Failed to translate embedded images to imagetool images"); ret = -1; - lcrd_try_set_error_message("Failed to translate embedded images to imagetool images"); + isulad_try_set_error_message("Failed to translate embedded images to imagetool images"); goto out; } @@ -335,7 +335,7 @@ int embedded_remove_image(const im_remove_request *request) if (strcmp(conts[i]->common_config->image, image_ref) == 0) { ERROR("unable to remove image %s, container %s is using it", image_ref, conts[i]->common_config->id); - lcrd_set_error_message("Image is in use"); + isulad_set_error_message("Image is in use"); ret = EIMAGEBUSY; goto unref_continue; } diff --git a/src/image/embedded/lim.c b/src/image/embedded/lim.c index 47dd41cea01434c97c2b806ec82ad674edbf7614..d93aa2fd8a790d0300532353d3838efe13608d22 100644 --- a/src/image/embedded/lim.c +++ b/src/image/embedded/lim.c @@ -19,7 +19,7 @@ #include "error.h" #include "log.h" #include "lim.h" -#include "liblcrd.h" +#include "libisulad.h" #include "mediatype.h" #include "snapshot.h" #include "snapshot_def.h" @@ -165,7 +165,7 @@ static bool validate_layer_path_in_container(size_t layer_index, char *path) if (layer_index == 0) { if (path != NULL && path[0] != 0) { ERROR("first layer's path in container must be empty, got %s", path); - lcrd_try_set_error_message("Invalid content in manifest: first layer path in container must be empty"); + isulad_try_set_error_message("Invalid content in manifest: first layer path in container must be empty"); return false; } return true; @@ -174,8 +174,8 @@ static bool validate_layer_path_in_container(size_t layer_index, char *path) if (!valid_absolute_path(path)) { ERROR("path in container %s should be absolute path, layer %llu", path, (unsigned long long)layer_index); - lcrd_try_set_error_message("Invalid content in manifest:" - " layer path in container(except first layer) must be absolute path"); + isulad_try_set_error_message("Invalid content in manifest:" + " layer path in container(except first layer) must be absolute path"); return false; } return true; @@ -188,7 +188,7 @@ static bool validate_layer_path_in_host_real(size_t layer_index, if (!util_file_exists(real_path)) { ERROR("file not exist, path in host %s, real path is %s", path_in_host, real_path); - lcrd_try_set_error_message("Invalid content in manifest: layer not exists"); + isulad_try_set_error_message("Invalid content in manifest: layer not exists"); return false; } @@ -196,11 +196,11 @@ static bool validate_layer_path_in_host_real(size_t layer_index, ERROR("invalid path in host %s, real path is %s, layer %u", path_in_host, real_path, layer_index); if (fmod == (uint32_t)S_IFREG) { - lcrd_try_set_error_message("Invalid content in manifest: layer(except first layer) is not a regular file"); + isulad_try_set_error_message("Invalid content in manifest: layer(except first layer) is not a regular file"); } else if ((int)fmod == S_IFDIR) { - lcrd_try_set_error_message("Invalid content in manifest: layer(except first layer) is not a directory"); + isulad_try_set_error_message("Invalid content in manifest: layer(except first layer) is not a directory"); } else if ((int)fmod == S_IFBLK) { - lcrd_try_set_error_message("Invalid content in manifest: layer is not block device"); + isulad_try_set_error_message("Invalid content in manifest: layer is not block device"); } return false; } @@ -217,14 +217,14 @@ static bool validate_layer_path_in_host(size_t layer_index, const char *location if (!valid_absolute_path(path_in_host)) { ERROR("path in host %s not a absolute path, layer %u", path_in_host, layer_index); - lcrd_try_set_error_message("Invalid content in manifest: first layer path in host must be absolute path"); + isulad_try_set_error_message("Invalid content in manifest: first layer path in host must be absolute path"); return false; } if ((int)fmod == S_IFDIR && strcmp(path_in_host, "/") != 0) { ERROR("expected / as root, got %s, layer %u", path_in_host, layer_index); - lcrd_try_set_error_message("Invalid content in manifest: first layer path in host must be /"); + isulad_try_set_error_message("Invalid content in manifest: first layer path in host must be /"); return false; } abs_path = util_strdup_s(path_in_host); @@ -235,15 +235,15 @@ static bool validate_layer_path_in_host(size_t layer_index, const char *location int sret = 0; if (!valid_relative_path(path_in_host)) { ERROR("path in host %s not a relative path, layer %u", path_in_host, layer_index); - lcrd_try_set_error_message("Invalid content in manifest:" - " layer path in host(except first layer) must be relative path"); + isulad_try_set_error_message("Invalid content in manifest:" + " layer path in host(except first layer) must be relative path"); return false; } abs_path = util_add_path(location, path_in_host); sret = snprintf(parent_location, sizeof(parent_location), "%s/..", location); if (sret < 0 || (size_t)sret >= sizeof(parent_location)) { ERROR("Failed to sprintf parent_location"); - lcrd_try_set_error_message("Failed to sprintf parent_location"); + isulad_try_set_error_message("Failed to sprintf parent_location"); UTIL_FREE_AND_SET_NULL(abs_path); UTIL_FREE_AND_SET_NULL(tmp_path); return false; @@ -251,7 +251,7 @@ static bool validate_layer_path_in_host(size_t layer_index, const char *location tmp_path = follow_symlink_in_scope(abs_path, parent_location); if (tmp_path == NULL || !strncmp(tmp_path, "..", 2)) { ERROR("invalid layer path %s", path_in_host); - lcrd_try_set_error_message("Invalid content in manifest: layer not exists"); + isulad_try_set_error_message("Invalid content in manifest: layer not exists"); UTIL_FREE_AND_SET_NULL(abs_path); UTIL_FREE_AND_SET_NULL(tmp_path); return false; @@ -261,7 +261,7 @@ static bool validate_layer_path_in_host(size_t layer_index, const char *location if (strlen(abs_path) > PATH_MAX || realpath(abs_path, real_path) == NULL) { ERROR("invalid layer path %s", abs_path); - lcrd_try_set_error_message("Invalid content in manifest: layer not exists"); + isulad_try_set_error_message("Invalid content in manifest: layer not exists"); UTIL_FREE_AND_SET_NULL(abs_path); return false; } @@ -285,8 +285,8 @@ static bool validate_layer_media_type(size_t layer_index, char *media_type, } } - lcrd_try_set_error_message("Invalid content in manifest: layer's media type must be" - " application/squashfs.image.rootfs.diff.img or application/bind.image.rootfs.diff.dir"); + isulad_try_set_error_message("Invalid content in manifest: layer's media type must be" + " application/squashfs.image.rootfs.diff.img or application/bind.image.rootfs.diff.dir"); ERROR("invalid layer media type %s", media_type); return false; } @@ -305,7 +305,7 @@ static bool validate_layer_digest(size_t layer_index, char *path, uint32_t fmod, // first layer's digest must be empty if (layer_index == 0) { - lcrd_try_set_error_message("Invalid content in manifest: first layer's digest must be empty"); + isulad_try_set_error_message("Invalid content in manifest: first layer's digest must be empty"); ERROR("first layer's digest must be empty, got %s", digest); } @@ -313,21 +313,21 @@ static bool validate_layer_digest(size_t layer_index, char *path, uint32_t fmod, if ((int)fmod == S_IFDIR) { ERROR("Invalid digest %s, digest must be empty if media type is %s", digest, MediaTypeEmbeddedLayerDir); - lcrd_try_set_error_message("Invalid content in mainfest: layer digest must be empty if mediaType is %s", - MediaTypeEmbeddedLayerDir); + isulad_try_set_error_message("Invalid content in mainfest: layer digest must be empty if mediaType is %s", + MediaTypeEmbeddedLayerDir); return false; } /* check if digest format is valid */ if (!util_valid_digest(digest)) { ERROR("invalid digest %s for layer", digest); - lcrd_try_set_error_message("Invalid content in mainfest: layer(except first layer) has invalid digest"); + isulad_try_set_error_message("Invalid content in mainfest: layer(except first layer) has invalid digest"); return false; } /* calc and check digest */ if (!util_valid_digest_file(path, digest)) { - lcrd_try_set_error_message("Invalid content in mainfest: layer(except first layer) has invalid digest"); + isulad_try_set_error_message("Invalid content in mainfest: layer(except first layer) has invalid digest"); return false; } @@ -367,7 +367,7 @@ static bool validate_layer_size(size_t layer_index, if (layer->size < 0) { ERROR("invalid layer size %lld, layer %llu", (long long)layer->size, (unsigned long long)layer_index); - lcrd_try_set_error_message("Invalid content in manifest: layer's size must not be negative number"); + isulad_try_set_error_message("Invalid content in manifest: layer's size must not be negative number"); return false; } return true; @@ -378,14 +378,14 @@ static bool validate_create_time(char *created) { if (!util_valid_time_tz(created)) { ERROR("invalid created time %s, invalid format", created); - lcrd_try_set_error_message("Invalid content in manifest: invalid created time"); + isulad_try_set_error_message("Invalid content in manifest: invalid created time"); return false; } /* ensure time can be processed by us */ if (time_tz_to_seconds_nanos(created, NULL, NULL)) { ERROR("invalid created time %s, invalid time value", created); - lcrd_try_set_error_message("Invalid content in manifest: invalid created time"); + isulad_try_set_error_message("Invalid content in manifest: invalid created time"); return false; } return true; @@ -396,20 +396,20 @@ static bool validate_image_name(char *image_name) { if (image_name == NULL) { ERROR("image name not exist"); - lcrd_try_set_error_message("Invalid content in manfiest: image name not exist"); + isulad_try_set_error_message("Invalid content in manfiest: image name not exist"); return false; } if (strcmp(image_name, "none") == 0 || strcmp(image_name, "none:latest") == 0) { ERROR("image name %s must not be none or none:latest", image_name); - lcrd_try_set_error_message("Image name 'none' or 'none:latest' in manifest is reserved, please use other name"); + isulad_try_set_error_message("Image name 'none' or 'none:latest' in manifest is reserved, please use other name"); return false; } if (!util_valid_embedded_image_name(image_name)) { ERROR("invalid image name %s", image_name); - lcrd_try_set_error_message("Invalid content in manfiest: invalid image name"); + isulad_try_set_error_message("Invalid content in manfiest: invalid image name"); return false; } return true; @@ -420,7 +420,7 @@ static bool validate_image_layers_number(size_t layers_len) { if (layers_len > LAYER_NUM_MAX || layers_len < 1) { ERROR("invalid layers number %d maxium is %d", layers_len, LAYER_NUM_MAX); - lcrd_try_set_error_message("Invalid content in mainfest: layer empty or max depth exceeded"); + isulad_try_set_error_message("Invalid content in mainfest: layer empty or max depth exceeded"); return false; } return true; @@ -442,14 +442,14 @@ static bool valid_embedded_manifest(embedded_manifest *manifest, const char *pat if (manifest->schema_version != 1) { ERROR("invalid schema version %u", manifest->schema_version); - lcrd_try_set_error_message("Invalid content in manifest: schema version must be 1"); + isulad_try_set_error_message("Invalid content in manifest: schema version must be 1"); return false; } if (manifest->media_type == NULL || strcmp(manifest->media_type, MediaTypeEmbeddedImageManifest) != 0) { ERROR("invalid manifest media type %s", manifest->media_type); - lcrd_try_set_error_message("Invalid content in manifest:" - " manifest's media type must be application/embedded.manifest+json"); + isulad_try_set_error_message("Invalid content in manifest:" + " manifest's media type must be application/embedded.manifest+json"); return false; } @@ -499,20 +499,20 @@ static bool valid_manifest_and_get_size(embedded_manifest *manifest, const char } if (strlen(abs_path) > PATH_MAX || !realpath(abs_path, real_path)) { ERROR("invalid file path %s", abs_path); - lcrd_try_set_error_message("Invalid content in manifest: layer not exists"); + isulad_try_set_error_message("Invalid content in manifest: layer not exists"); goto out; } UTIL_FREE_AND_SET_NULL(abs_path); size = util_file_size(real_path); if (size < 0) { - lcrd_try_set_error_message("Calculate layer size failed"); + isulad_try_set_error_message("Calculate layer size failed"); goto out; } if (INT64_MAX - size < *image_size) { ERROR("The layer size is too large!"); - lcrd_try_set_error_message("The layer size is too large!"); + isulad_try_set_error_message("The layer size is too large!"); goto out; } *image_size += size; @@ -541,7 +541,7 @@ int lim_add_manifest(struct image_creator *ic, char *path, char *digest, bool mv } if (strcmp(ic->type, IMAGE_TYPE_EMBEDDED) != 0) { ERROR("invalid image type %s", ic->type); - lcrd_try_set_error_message("Invalid image type: image type must be embedded"); + isulad_try_set_error_message("Invalid image type: image type must be embedded"); return EINVALIDARGS; } @@ -549,7 +549,7 @@ int lim_add_manifest(struct image_creator *ic, char *path, char *digest, bool mv manifest_digest = util_full_file_digest(path); if (manifest_digest == NULL) { ERROR("calc full digest of %s failed", path); - lcrd_try_set_error_message("Invalid manifest: invalid digest"); + isulad_try_set_error_message("Invalid manifest: invalid digest"); return -1; } @@ -557,7 +557,7 @@ int lim_add_manifest(struct image_creator *ic, char *path, char *digest, bool mv if (strcmp(manifest_digest, digest) != 0) { ERROR("file %s digest %s not match %s", path, manifest_digest, digest); ret = EINVALIDARGS; - lcrd_try_set_error_message("Invalid manifest: invalid digest"); + isulad_try_set_error_message("Invalid manifest: invalid digest"); goto out; } } @@ -566,7 +566,7 @@ int lim_add_manifest(struct image_creator *ic, char *path, char *digest, bool mv if (manifest == NULL) { ERROR("parse embedded manifest file %s failed", path); ret = EINVALIDARGS; - lcrd_try_set_error_message("Invalid content in manifest: parse manifest as a json file failed"); + isulad_try_set_error_message("Invalid content in manifest: parse manifest as a json file failed"); goto out; } @@ -600,7 +600,7 @@ int lim_add_manifest(struct image_creator *ic, char *path, char *digest, bool mv if (ret != 0) { ERROR("Failed to save the image to DB, ret is %d", ret); if (ret == DB_NAME_CONFLICT) { - lcrd_try_set_error_message("Image name is conflicted in the database"); + isulad_try_set_error_message("Image name is conflicted in the database"); ret = ENAMECONFLICT; } else { ret = -1; @@ -669,7 +669,7 @@ int lim_delete_image(char *name, bool force) ret = db_read_image(name, &imginfo); if (ret != 0) { ERROR("can't find image %s in database", name); - lcrd_try_set_error_message("No such image:%s", name); + isulad_try_set_error_message("No such image:%s", name); ret = EIMAGENOTFOUND; goto out; } @@ -686,12 +686,12 @@ int lim_delete_image(char *name, bool force) goto out; } else if (ret == DB_INUSE) { ERROR("image %s is in use", name); - lcrd_try_set_error_message("Image is in use"); + isulad_try_set_error_message("Image is in use"); ret = EIMAGEBUSY; goto out; } else if (ret == DB_NOT_EXIST) { ERROR("image %s not exist", name); - lcrd_try_set_error_message("No such image:%s", name); + isulad_try_set_error_message("No such image:%s", name); ret = EIMAGENOTFOUND; goto out; @@ -745,7 +745,7 @@ int lim_create_rw_layer(char *name, const char *id, char **options, ret = db_read_image(name, &imginfo); if (ret != 0) { ERROR("can't find image %s in database", name); - lcrd_try_set_error_message("No such image:%s", name); + isulad_try_set_error_message("No such image:%s", name); ret = EIMAGENOTFOUND; goto out; } @@ -796,7 +796,7 @@ int lim_query_image_data(const char *name, const char *type, if (ret != 0 || imginfo == NULL) { ERROR("can't find image %s in database", name); ret = -1; - lcrd_try_set_error_message("No such image:%s", name); + isulad_try_set_error_message("No such image:%s", name); goto out; } diff --git a/src/image/embedded/load.c b/src/image/embedded/load.c index 2f65c3f2a7b4eee35a28c9e3a72434639c1af9c9..c9be5e1e2f574456b020e9d9187cc5482010cb22 100644 --- a/src/image/embedded/load.c +++ b/src/image/embedded/load.c @@ -16,7 +16,7 @@ #include #include "error.h" -#include "liblcrd.h" +#include "libisulad.h" #include "embedded_image.h" #include "lim.h" #include "limits.h" @@ -97,26 +97,26 @@ static char *get_digest(const char *file) if (strlen(sgn_file) > PATH_MAX || realpath(sgn_file, real_path) == NULL) { ERROR("get real path of %s failed", sgn_file); - lcrd_try_set_error_message("Manifest's signature file not exist"); + isulad_try_set_error_message("Manifest's signature file not exist"); goto out; } if (!util_file_exists(real_path)) { - lcrd_try_set_error_message("Manifest's signature file not exist"); + isulad_try_set_error_message("Manifest's signature file not exist"); goto out; } digest = util_read_text_file(real_path); if (digest == NULL) { ERROR("read digest from file %s failed", real_path); - lcrd_try_set_error_message("Invalid manifest: invalid digest"); + isulad_try_set_error_message("Invalid manifest: invalid digest"); goto out; } if (strnlen(digest, digest_len + 1) != digest_len) { DEBUG("digest %s too short", digest); UTIL_FREE_AND_SET_NULL(digest); - lcrd_try_set_error_message("Invalid manifest: invalid digest"); + isulad_try_set_error_message("Invalid manifest: invalid digest"); goto out; } @@ -145,19 +145,19 @@ static int load_image(char *file) if (strlen(file) > PATH_MAX || !realpath(file, real_path)) { ERROR("invalid file path %s", file); - lcrd_try_set_error_message("Invalid manifest: manifest not found"); + isulad_try_set_error_message("Invalid manifest: manifest not found"); return EINVALIDARGS; } if (!util_file_exists(real_path)) { ERROR("file %s not exist", file); - lcrd_try_set_error_message("Invalid manifest: manifest not found"); + isulad_try_set_error_message("Invalid manifest: manifest not found"); return EINVALIDARGS; } if (!util_valid_file(real_path, S_IFREG)) { ERROR("manifest file %s is not a regular file", real_path); - lcrd_try_set_error_message("Invalid manifest: manifest is not a regular file"); + isulad_try_set_error_message("Invalid manifest: manifest is not a regular file"); return EINVALIDARGS; } diff --git a/src/image/external/ext_image.c b/src/image/external/ext_image.c index 7eb07abb1c9a2d11f71e3143c89f3a02f9856f0e..38a77c8eda61fb9202314890f90af39ca3da763d 100644 --- a/src/image/external/ext_image.c +++ b/src/image/external/ext_image.c @@ -64,12 +64,12 @@ int ext_prepare_rf(const im_prepare_request *request, char **real_rootfs) char real_path[PATH_MAX] = { 0 }; if (request->image_name[0] != '/') { ERROR("Rootfs should be absolutely path"); - lcrd_set_error_message("Rootfs should be absolutely path"); + isulad_set_error_message("Rootfs should be absolutely path"); return -1; } if (realpath(request->image_name, real_path) == NULL) { ERROR("Failed to clean rootfs path '%s': %s", request->image_name, strerror(errno)); - lcrd_set_error_message("Failed to clean rootfs path '%s': %s", request->image_name, strerror(errno)); + isulad_set_error_message("Failed to clean rootfs path '%s': %s", request->image_name, strerror(errno)); return -1; } *real_rootfs = util_strdup_s(real_path); diff --git a/src/image/image.c b/src/image/image.c index 8e76b172d537cc410906278199205bb49d602e56..c7d7ae6c752bbd8485ebc62c73758c6768f60426 100644 --- a/src/image/image.c +++ b/src/image/image.c @@ -22,7 +22,7 @@ #include #include "image.h" -#include "liblcrd.h" +#include "libisulad.h" #include "log.h" #include "utils.h" @@ -165,7 +165,7 @@ static const struct bim_type *bim_query(const char *image_name) } temp = g_bims[i].ops->resolve_image_name(image_name); if (temp == NULL) { - lcrd_append_error_message("Failed to resovle image name%s", image_name); + isulad_append_error_message("Failed to resovle image name%s", image_name); return NULL; } int r = g_bims[i].ops->detect(temp); @@ -239,7 +239,7 @@ static struct bim *bim_get(const char *image_type, const char *image_name, const if (image_name != NULL) { bim->image_name = bim->ops->resolve_image_name(image_name); if (bim->image_name == NULL) { - lcrd_append_error_message("Failed to resovle image name%s", image_name); + isulad_append_error_message("Failed to resovle image name%s", image_name); bim_put(bim); return NULL; } @@ -640,7 +640,7 @@ char *im_get_image_type(const char *image, const char *external_rootfs) bim_type = bim_query(image_name); if (bim_type == NULL) { ERROR("Failed to query type of image %s", image_name); - lcrd_set_error_message("No such image:%s", image_name); + isulad_set_error_message("No such image:%s", image_name); return NULL; } @@ -654,7 +654,7 @@ bool im_config_image_exist(const char *image_name) bim_type = bim_query(image_name); if (bim_type == NULL) { ERROR("Config image %s not exist", image_name); - lcrd_set_error_message("Image %s not exist", image_name); + isulad_set_error_message("Image %s not exist", image_name); return false; } @@ -844,8 +844,8 @@ int im_list_images(const im_list_request *ctx, im_list_response **response) EVENT("Event: {Object: list images, Type: listed}"); - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); } return 0; @@ -885,7 +885,7 @@ static bool check_im_pull_args(const im_pull_request *req, im_pull_response * co } if (req->image == NULL) { ERROR("Empty image required"); - lcrd_set_error_message("Empty image required"); + isulad_set_error_message("Empty image required"); return false; } return true; @@ -979,13 +979,13 @@ int im_load_image(const im_load_request *request, im_load_response **response) if (request->file == NULL) { ERROR("Load image requires image tarball file path"); - lcrd_set_error_message("Load image requires image tarball file path"); + isulad_set_error_message("Load image requires image tarball file path"); goto pack_response; } if (request->type == NULL) { ERROR("Missing image type"); - lcrd_set_error_message("Missing image type"); + isulad_set_error_message("Missing image type"); goto pack_response; } @@ -1011,8 +1011,8 @@ int im_load_image(const im_load_request *request, im_load_response **response) EVENT("Event: {Object: %s, Type: loaded}", request->file); pack_response: - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); } bim_put(bim); @@ -1067,19 +1067,19 @@ int im_login(const im_login_request *request, im_login_response **response) if (request->server == NULL) { ERROR("Login requires server address"); - lcrd_set_error_message("Login requires server address"); + isulad_set_error_message("Login requires server address"); goto pack_response; } if (request->type == NULL) { ERROR("Login requires image type"); - lcrd_set_error_message("Login requires image type"); + isulad_set_error_message("Login requires image type"); goto pack_response; } if (request->username == NULL || request->password == NULL) { ERROR("Missing username or password"); - lcrd_set_error_message("Missing username or password"); + isulad_set_error_message("Missing username or password"); goto pack_response; } @@ -1101,8 +1101,8 @@ int im_login(const im_login_request *request, im_login_response **response) EVENT("Event: {Object: %s, Type: logined}", request->server); pack_response: - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); } bim_put(bim); @@ -1160,13 +1160,13 @@ int im_logout(const im_logout_request *request, im_logout_response **response) if (request->server == NULL) { ERROR("Logout requires server address"); - lcrd_set_error_message("Logout requires server address"); + isulad_set_error_message("Logout requires server address"); goto pack_response; } if (request->type == NULL) { ERROR("Logout requires image type"); - lcrd_set_error_message("Logout requires image type"); + isulad_set_error_message("Logout requires image type"); goto pack_response; } @@ -1188,8 +1188,8 @@ int im_logout(const im_logout_request *request, im_logout_response **response) EVENT("Event: {Object: %s, Type: logouted}", request->server); pack_response: - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); } bim_put(bim); @@ -1243,7 +1243,7 @@ int im_image_status(im_status_request *request, im_status_response **response) if (request->image.image == NULL) { ERROR("get image status requires image ref"); - lcrd_set_error_message("get image status requires image ref"); + isulad_set_error_message("get image status requires image ref"); goto pack_response; } @@ -1252,7 +1252,7 @@ int im_image_status(im_status_request *request, im_status_response **response) bim_type = bim_query(image_ref); if (bim_type == NULL) { ERROR("No such image:%s", image_ref); - lcrd_set_error_message("No such image:%s", image_ref); + isulad_set_error_message("No such image:%s", image_ref); goto pack_response; } @@ -1273,9 +1273,9 @@ int im_image_status(im_status_request *request, im_status_response **response) } pack_response: - if (g_lcrd_errmsg != NULL) { + if (g_isulad_errmsg != NULL) { free((*response)->errmsg); - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); } free(image_ref); bim_put(bim); @@ -1302,7 +1302,7 @@ int im_rm_image(const im_remove_request *request, im_remove_response **response) if (request->image.image == NULL) { ERROR("remove image requires image ref"); - lcrd_set_error_message("remove image requires image ref"); + isulad_set_error_message("remove image requires image ref"); goto pack_response; } @@ -1313,7 +1313,7 @@ int im_rm_image(const im_remove_request *request, im_remove_response **response) bim_type = bim_query(image_ref); if (bim_type == NULL) { ERROR("No such image:%s", image_ref); - lcrd_set_error_message("No such image:%s", image_ref); + isulad_set_error_message("No such image:%s", image_ref); goto pack_response; } @@ -1337,8 +1337,8 @@ int im_rm_image(const im_remove_request *request, im_remove_response **response) EVENT("Event: {Object: %s, Type: image removed}", image_ref); pack_response: - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); } free(image_ref); bim_put(bim); @@ -1419,7 +1419,7 @@ int im_inspect_image(const im_inspect_request *request, im_inspect_response **re if (request->image.image == NULL) { ERROR("inspect image requires image ref"); - lcrd_set_error_message("inspect image requires image ref"); + isulad_set_error_message("inspect image requires image ref"); ret = -1; goto pack_response; } @@ -1431,7 +1431,7 @@ int im_inspect_image(const im_inspect_request *request, im_inspect_response **re bim_type = bim_query(image_ref); if (bim_type == NULL) { ERROR("No such image:%s", image_ref); - lcrd_set_error_message("No such image:%s", image_ref); + isulad_set_error_message("No such image:%s", image_ref); ret = -1; goto pack_response; } @@ -1451,8 +1451,8 @@ int im_inspect_image(const im_inspect_request *request, im_inspect_response **re EVENT("Event: {Object: %s, Type: image inspected}", image_ref); pack_response: - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); } if (inspected_json != NULL) { (*response)->im_inspect_json = util_strdup_s(inspected_json); diff --git a/src/image/image.h b/src/image/image.h index 05d0ed954c913aada3bbbeebcb16eee79ef4a684..2c4b32f8ce67a2369b02bc028a63b6ade932c667 100644 --- a/src/image/image.h +++ b/src/image/image.h @@ -23,7 +23,7 @@ #include "oci_runtime_spec.h" #include "container_custom_config.h" #include "host_config.h" -#include "liblcrd.h" +#include "libisulad.h" #ifdef ENABLE_OCI_IMAGE #include "oci_image_type.h" diff --git a/src/image/oci/global_config.c b/src/image/oci/global_config.c index 65e817e8f813ace516aef54d8899258870e3d361..70b1838aa66975833d2432d7ca515e47d310bd24 100644 --- a/src/image/oci/global_config.c +++ b/src/image/oci/global_config.c @@ -16,7 +16,7 @@ #include -#include "lcrd_config.h" +#include "isulad_config.h" #include "log.h" #ifdef ENABLE_OCI_IMAGE #include "driver.h" @@ -33,7 +33,7 @@ static int pack_global_graph_driver(const char * const *options, bool ignore_sto i = *count; - graph_driver = conf_get_lcrd_storage_driver(); + graph_driver = conf_get_isulad_storage_driver(); if (graph_driver == NULL) { COMMAND_ERROR("Failed to get graph driver"); goto out; @@ -41,7 +41,7 @@ static int pack_global_graph_driver(const char * const *options, bool ignore_sto driver = graphdriver_get(graph_driver); if (strcmp(graph_driver, "overlay2") == 0) { // Treating overlay2 as overlay cause image was downloaded always - // in '/var/lib/lcrd/storage/overlay' directory. + // in '/var/lib/isulad/storage/overlay' directory. // See iSulad-kit/vendor/github.com/containers/storage/drivers/overlay/overlay.go, // Driver is inited by name "overlay". graph_driver[strlen(graph_driver) - 1] = '\0'; @@ -121,7 +121,7 @@ static char *adapt_log_level() char *isulad_level = NULL; char *adapted_level = NULL; - isulad_level = conf_get_lcrd_loglevel(); + isulad_level = conf_get_isulad_loglevel(); if (isulad_level == NULL) { goto out; } diff --git a/src/image/oci/isula_container_export.c b/src/image/oci/isula_container_export.c index c81b346a226722e9484ef75a65b1d8d00697a2f2..124eb655e629fe348fe6c98e99d994fe5ac49123 100644 --- a/src/image/oci/isula_container_export.c +++ b/src/image/oci/isula_container_export.c @@ -18,7 +18,7 @@ #include "isula_helper.h" #include "connect.h" #include "utils.h" -#include "liblcrd.h" +#include "libisulad.h" #include "log.h" static struct isula_export_request *generate_isula_export_request(const char *name_id, const char *out_file, @@ -44,11 +44,11 @@ static struct isula_export_request *generate_isula_export_request(const char *na static int is_valid_arguments(const char *name_id, const char *out_file) { if (name_id == NULL) { - lcrd_set_error_message("Export rootfs requires container name"); + isulad_set_error_message("Export rootfs requires container name"); return -1; } if (out_file == NULL) { - lcrd_set_error_message("Export rootfs requires output file path"); + isulad_set_error_message("Export rootfs requires output file path"); return -1; } return 0; @@ -97,7 +97,7 @@ int isula_container_export(const char *name_id, const char *out_file, uint32_t u ret = im_ops->container_export(ireq, iresp, &conf); if (ret != 0) { ERROR("Failed to export rootfs : %s", iresp->errmsg); - lcrd_set_error_message("Failed to export rootfs with error: %s", iresp->errmsg); + isulad_set_error_message("Failed to export rootfs with error: %s", iresp->errmsg); } out: diff --git a/src/image/oci/isula_container_fs_usage.c b/src/image/oci/isula_container_fs_usage.c index 2b3da73d1716cfb6a9257b1346957c63f6210b28..7740dba987a2481b6074fca6c46c9153ba0088d8 100644 --- a/src/image/oci/isula_container_fs_usage.c +++ b/src/image/oci/isula_container_fs_usage.c @@ -18,7 +18,7 @@ #include "isula_helper.h" #include "connect.h" #include "utils.h" -#include "liblcrd.h" +#include "libisulad.h" #include "log.h" static int generate_isula_container_fs_usage_request(const char *name_id, @@ -94,7 +94,7 @@ int isula_container_fs_usage(const char *name_id, char **usages) ret = im_ops->container_fs_usage(ireq, iresp, &conf); if (ret != 0) { ERROR("Get container %s fs usage failed: %s", name_id, iresp->errmsg); - lcrd_set_error_message("Failed to container fs info with error: %s", iresp->errmsg); + isulad_set_error_message("Failed to container fs info with error: %s", iresp->errmsg); goto out; } *usages = iresp->usage; diff --git a/src/image/oci/isula_helper.c b/src/image/oci/isula_helper.c index 581385a3d0c541d32dcddb238579ef88684cff25..6a55833670715be7750591499b857b0e2aa76efd 100644 --- a/src/image/oci/isula_helper.c +++ b/src/image/oci/isula_helper.c @@ -16,7 +16,7 @@ #include "utils.h" #include "log.h" -#include "lcrd_config.h" +#include "isulad_config.h" int get_isula_image_connect_config(client_connect_config_t *conf) { diff --git a/src/image/oci/isula_image.c b/src/image/oci/isula_image.c index f231f5dd040d98a69404126195a535c76e20f33a..cdd5c4c03c47fda2a35188b733d2f32b27075000 100644 --- a/src/image/oci/isula_image.c +++ b/src/image/oci/isula_image.c @@ -40,7 +40,7 @@ #include "containers_store.h" #include "oci_images_store.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "utils.h" #define IMAGE_NOT_KNOWN_ERR "image not known" @@ -244,7 +244,7 @@ int isula_rmi(const im_remove_request *request) ret = 0; goto clean_memory; } - lcrd_set_error_message("Failed to remove image with error: %s", errmsg); + isulad_set_error_message("Failed to remove image with error: %s", errmsg); ERROR("Failed to remove image '%s' with error: %s", real_image_name, errmsg); goto unlock; } @@ -283,7 +283,7 @@ int isula_container_filesystem_usage(const im_container_fs_usage_request *reques *fs_usage = imagetool_fs_info_parse_data(output, NULL, &err); if (*fs_usage == NULL) { ERROR("Failed to parse output json: %s", err); - lcrd_set_error_message("Failed to parse output json:%s", err); + isulad_set_error_message("Failed to parse output json:%s", err); ret = -1; } diff --git a/src/image/oci/isula_image_fs_info.c b/src/image/oci/isula_image_fs_info.c index f11182d03f5b09e136b9b1242275426cadc559b7..6710433b20fb8e0f747ed112a8820fe8f8ad8f9e 100644 --- a/src/image/oci/isula_image_fs_info.c +++ b/src/image/oci/isula_image_fs_info.c @@ -138,7 +138,7 @@ int isula_image_fs_info(im_fs_info_response *resp) ret = im_ops->image_fs_info(&ireq, iresp, &conf); if (ret != 0) { ERROR("Failed to get image fs info with error: %s", iresp->errmsg); - lcrd_set_error_message("Failed to get image fs info with error: %s", iresp->errmsg); + isulad_set_error_message("Failed to get image fs info with error: %s", iresp->errmsg); goto out; } ret = pack_im_response(iresp, resp); diff --git a/src/image/oci/isula_image_load.c b/src/image/oci/isula_image_load.c index c481df29ddcfc8249f9ec4cf3ed5235d39cb30a0..e73420abc061abea3ae8502d6431aaa4dd0e8e9a 100644 --- a/src/image/oci/isula_image_load.c +++ b/src/image/oci/isula_image_load.c @@ -18,7 +18,7 @@ #include "isula_helper.h" #include "connect.h" #include "utils.h" -#include "liblcrd.h" +#include "libisulad.h" #include "utils_verify.h" #include "log.h" @@ -81,13 +81,13 @@ static char **get_refs_from_output(const char *output) if (output == NULL) { ERROR("Failed to load image because can not get output"); - lcrd_set_error_message("Failed to load image because can not get output"); + isulad_set_error_message("Failed to load image because can not get output"); return NULL; } if (strnlen(output, (size_t)(g_output_max_size + 1)) > (size_t)g_output_max_size) { ERROR("Failed to load image because stdoutput exceeded max size"); - lcrd_set_error_message("Failed to load image because stdoutput exceeded max size"); + isulad_set_error_message("Failed to load image because stdoutput exceeded max size"); return NULL; } @@ -98,7 +98,7 @@ static char **get_refs_from_output(const char *output) if (refs == NULL) { ERROR("Failed to load image because cann't get image reference from output." "stdout buffer is [%s]", output); - lcrd_set_error_message("Failed to load image because cann't get image reference from output"); + isulad_set_error_message("Failed to load image because cann't get image reference from output"); goto out; } @@ -127,11 +127,11 @@ static int generate_isula_load_request(const char *file, const char *tag, struct static int is_valid_arguments(const char *file, const char *tag, char ***refs) { if (file == NULL) { - lcrd_set_error_message("Load image requires input file path"); + isulad_set_error_message("Load image requires input file path"); return -1; } if (tag != NULL && !util_valid_image_name(tag)) { - lcrd_try_set_error_message("Invalid tag:%s", tag); + isulad_try_set_error_message("Invalid tag:%s", tag); return -1; } @@ -184,7 +184,7 @@ int isula_image_load(const char *file, const char *tag, char ***refs) ret = im_ops->load(ireq, iresp, &conf); if (ret != 0) { ERROR("Load image %s failed: %s", file, iresp->errmsg); - lcrd_set_error_message("Load image %s failed: %s", file, iresp->errmsg); + isulad_set_error_message("Load image %s failed: %s", file, iresp->errmsg); goto out; } *refs = get_refs_from_output(iresp->outmsg); diff --git a/src/image/oci/isula_login.c b/src/image/oci/isula_login.c index f022d28b90e2621c7acd38004ec4b188943f8e71..89d9328ed903a4050e752e295f02b217bbc7191c 100644 --- a/src/image/oci/isula_login.c +++ b/src/image/oci/isula_login.c @@ -18,18 +18,18 @@ #include "isula_helper.h" #include "connect.h" #include "utils.h" -#include "liblcrd.h" +#include "libisulad.h" #include "log.h" static int is_valid_arguments(const char *server, const char *username, const char *password) { if (server == NULL) { - lcrd_set_error_message("Login requires server address"); + isulad_set_error_message("Login requires server address"); return -1; } if (username == NULL || password == NULL) { - lcrd_set_error_message("Missing username or password"); + isulad_set_error_message("Missing username or password"); return -1; } @@ -97,7 +97,7 @@ int isula_do_login(const char *server, const char *username, const char *passwor ret = im_ops->login(ireq, iresp, &conf); if (ret != 0) { ERROR("Failed to login with error: %s", iresp->errmsg); - lcrd_set_error_message("Failed to login with error: %s", iresp->errmsg); + isulad_set_error_message("Failed to login with error: %s", iresp->errmsg); } out: diff --git a/src/image/oci/isula_logout.c b/src/image/oci/isula_logout.c index 16fbc84c5f91c3963d5358623ed822bce1e89480..43d4907014fdc95163fd80a3bc3916e9f7398f2e 100644 --- a/src/image/oci/isula_logout.c +++ b/src/image/oci/isula_logout.c @@ -18,7 +18,7 @@ #include "isula_helper.h" #include "connect.h" #include "utils.h" -#include "liblcrd.h" +#include "libisulad.h" #include "log.h" static int generate_isula_logout_request(const char *server, struct isula_logout_request **ireq) @@ -40,7 +40,7 @@ static int generate_isula_logout_request(const char *server, struct isula_logout static inline int is_valid_arguments(const char *server) { if (server == NULL) { - lcrd_set_error_message("Logout requires server address"); + isulad_set_error_message("Logout requires server address"); return -1; } return 0; @@ -89,7 +89,7 @@ int isula_do_logout(const char *server) ret = im_ops->logout(ireq, iresp, &conf); if (ret != 0) { ERROR("Failed to logout with error: %s", iresp->errmsg); - lcrd_set_error_message("Failed to logout with error: %s", iresp->errmsg); + isulad_set_error_message("Failed to logout with error: %s", iresp->errmsg); } out: diff --git a/src/image/oci/isula_rootfs_prepare.c b/src/image/oci/isula_rootfs_prepare.c index 65ff6702595da254d9b0198c39d72b14cf1fb534..50e9baa6b206b8c88318171891189bf5a28257a4 100644 --- a/src/image/oci/isula_rootfs_prepare.c +++ b/src/image/oci/isula_rootfs_prepare.c @@ -16,7 +16,7 @@ #include "isula_image_connect.h" #include "isula_helper.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "utils.h" #include "log.h" @@ -62,7 +62,7 @@ static int parse_image_conf_from_json_str(const char *image_conf_str, oci_image_ *spec = oci_image_spec_parse_data(image_conf_str, NULL, &err); if (*spec == NULL) { ERROR("Failed to parse image conf: %s", err); - lcrd_set_error_message("Failed to parse image conf"); + isulad_set_error_message("Failed to parse image conf"); ret = -1; } @@ -77,10 +77,10 @@ static int dealwith_result(int result, struct isula_prepare_response *iresp, cha if (result != 0) { if (iresp->errmsg != NULL) { ERROR("Failed to prepare rootfs with error: %s", iresp->errmsg); - lcrd_set_error_message("Failed to prepare rootfs with error: %s", iresp->errmsg); + isulad_set_error_message("Failed to prepare rootfs with error: %s", iresp->errmsg); } else { ERROR("Failed to prepare rootfs"); - lcrd_set_error_message("Failed to prepare rootfs"); + isulad_set_error_message("Failed to prepare rootfs"); } } else { *real_rootfs = iresp->mount_point; diff --git a/src/image/oci/isula_storage_status.c b/src/image/oci/isula_storage_status.c index 28be9af972c7b5861bd92f52a9d199fc0fef7c10..9a2e7f551639ce94ad90192777861d08687d775f 100644 --- a/src/image/oci/isula_storage_status.c +++ b/src/image/oci/isula_storage_status.c @@ -67,7 +67,7 @@ int isula_do_storage_status(im_storage_status_response *resp) nret = im_ops->storage_status(&ireq, iresp, &conf); if (nret != 0) { ERROR("Failed to get storage status with error: %s", iresp->errmsg); - lcrd_set_error_message("Failed to get storage status with error: %s", iresp->errmsg); + isulad_set_error_message("Failed to get storage status with error: %s", iresp->errmsg); ret = -1; goto out; } diff --git a/src/image/oci/oci_common_operators.c b/src/image/oci/oci_common_operators.c index 730682d030c61fd12459933e5a152bae85cae897..cb31b062b400a9475190093d5a2f32496fc466ce 100644 --- a/src/image/oci/oci_common_operators.c +++ b/src/image/oci/oci_common_operators.c @@ -702,7 +702,7 @@ int oci_status_image(im_status_request *request, im_status_response **response) image_ref = request->image.image; if (image_ref == NULL) { ERROR("Inspect image requires image ref"); - lcrd_set_error_message("Inspect image requires image ref"); + isulad_set_error_message("Inspect image requires image ref"); ret = -1; goto pack_response; } @@ -710,7 +710,7 @@ int oci_status_image(im_status_request *request, im_status_response **response) resolved_name = oci_resolve_image_name(image_ref); if (resolved_name == NULL) { ERROR("Failed to reslove image name %s", image_ref); - lcrd_set_error_message("Failed to reslove image name %s", image_ref); + isulad_set_error_message("Failed to reslove image name %s", image_ref); ret = -1; goto pack_response; } @@ -720,7 +720,7 @@ int oci_status_image(im_status_request *request, im_status_response **response) image_info = oci_images_store_get(resolved_name); if (image_info == NULL) { ERROR("No such image:%s", resolved_name); - lcrd_set_error_message("No such image:%s", resolved_name); + isulad_set_error_message("No such image:%s", resolved_name); ret = -1; goto pack_response; } @@ -729,7 +729,7 @@ int oci_status_image(im_status_request *request, im_status_response **response) oci_image_unref(image_info); if (ret != 0) { ERROR("Failed to dup image info:%s", resolved_name); - lcrd_set_error_message("Failed to dup image info:%s", resolved_name); + isulad_set_error_message("Failed to dup image info:%s", resolved_name); ret = -1; goto pack_response; } diff --git a/src/image/oci/oci_config_merge.c b/src/image/oci/oci_config_merge.c index 53392f5cc5e49c585240badf8fca312c25cebf5a..5e003328de2a84c90143f82fe6470d29af29eca3 100644 --- a/src/image/oci/oci_config_merge.c +++ b/src/image/oci/oci_config_merge.c @@ -21,7 +21,7 @@ #include #include "utils.h" #include "log.h" -#include "liblcrd.h" +#include "libisulad.h" #include "specs_mount.h" #include "specs_extend.h" diff --git a/src/image/oci/oci_image_unix.h b/src/image/oci/oci_image_unix.h index b5591c32abab52e93b8c5f824a585f58fcc0ce69..12ff7c9ad2a9b016d0385e6650bbca75da6941e6 100644 --- a/src/image/oci/oci_image_unix.h +++ b/src/image/oci/oci_image_unix.h @@ -17,7 +17,7 @@ #include -#include "liblcrd.h" +#include "libisulad.h" #include "util_atomic.h" #include "imagetool_image_status.h" diff --git a/src/image/oci/oci_images_store.c b/src/image/oci/oci_images_store.c index 7ddae667323c2f1bd0c9d7c41091bebc7289e075..fef1678d8c3e491f6604128f8ef3f12ad61f9793 100644 --- a/src/image/oci/oci_images_store.c +++ b/src/image/oci/oci_images_store.c @@ -19,7 +19,7 @@ #include "log.h" #include "utils.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "constants.h" #include "oci_common_operators.h" diff --git a/src/image/oci/oci_images_store.h b/src/image/oci/oci_images_store.h index 954f9e9fe62f0ae866c5e80311eda170e0f3869a..cce5841024b8517e25eb81f2da1af868526467de 100644 --- a/src/image/oci/oci_images_store.h +++ b/src/image/oci/oci_images_store.h @@ -44,5 +44,5 @@ int oci_image_store_init(); } #endif -#endif /* __LCRD_MEMORY_STORE_H__ */ +#endif /* __ISULAD_MEMORY_STORE_H__ */ diff --git a/src/image/oci/run_image_server.c b/src/image/oci/run_image_server.c index 01945ca94524677295526534f5d4ff3d3b038401..bab6f5050e1db4aeb677e13b611ef674e406bafd 100644 --- a/src/image/oci/run_image_server.c +++ b/src/image/oci/run_image_server.c @@ -28,7 +28,7 @@ #include "isula_image.h" #include "isula_health_check.h" #include "global_config.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "log.h" #include "utils_file.h" #include "utils.h" diff --git a/src/json/schema/src/common_c.py b/src/json/schema/src/common_c.py index ca259eed3aadb3970ea4efda6600f7d2d8e22edf..4ccf16b28e1c6924a971e195b7ce46c106152ab1 100644 --- a/src/json/schema/src/common_c.py +++ b/src/json/schema/src/common_c.py @@ -4,19 +4,24 @@ Description: commom source file Interface: None History: 2019-06-17 ''' -# - Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. -# - iSulad licensed under the Mulan PSL v1. -# - You can use this software according to the terms and conditions of the Mulan PSL v1. -# - You may obtain a copy of Mulan PSL v1 at: -# - http://license.coscl.org.cn/MulanPSL -# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# - PURPOSE. -# - See the Mulan PSL v1 for more details. -# - Description: generate json -# - Author: tanyifeng -# - Create: 2018-04-25 -#!/usr/bin/python -Es +# +# libocispec - a C library for parsing OCI spec files. +# +# Copyright (C) 2017, 2019 Giuseppe Scrivano +# Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. +# +# libocispec is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# libocispec is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with libocispec. If not, see . CODE = '''// Auto generated file. Do not edit! # define _GNU_SOURCE diff --git a/src/json/schema/src/common_h.py b/src/json/schema/src/common_h.py index d828e19293d362fba061bdd4bc1b425ac04e746e..c1a8a8bd21a37fb83d7c72ace9d4d16487672849 100644 --- a/src/json/schema/src/common_h.py +++ b/src/json/schema/src/common_h.py @@ -4,18 +4,25 @@ Description: commom header file Interface: None History: 2019-06-17 ''' -# - Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. -# - iSulad licensed under the Mulan PSL v1. -# - You can use this software according to the terms and conditions of the Mulan PSL v1. -# - You may obtain a copy of Mulan PSL v1 at: -# - http://license.coscl.org.cn/MulanPSL -# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# - PURPOSE. -# - See the Mulan PSL v1 for more details. -# - Description: generate json -# - Author: tanyifeng -# - Create: 2018-04-25 +# +# libocispec - a C library for parsing OCI spec files. +# +# Copyright (C) 2017, 2019 Giuseppe Scrivano +# Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. +# +# libocispec is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# libocispec is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with libocispec. If not, see . +# #!/usr/bin/python -Es """ diff --git a/src/json/schema/src/generate.py b/src/json/schema/src/generate.py index 221570cc88c3c31cf37574cc323921b3e11941d5..534e07e8cfb9e01d8939716dde970dda816983f6 100644 --- a/src/json/schema/src/generate.py +++ b/src/json/schema/src/generate.py @@ -4,19 +4,24 @@ Description: header class and functions Interface: None History: 2019-06-17 ''' -# - Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. -# - iSulad licensed under the Mulan PSL v1. -# - You can use this software according to the terms and conditions of the Mulan PSL v1. -# - You may obtain a copy of Mulan PSL v1 at: -# - http://license.coscl.org.cn/MulanPSL -# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# - PURPOSE. -# - See the Mulan PSL v1 for more details. -# - Description: generate json -# - Author: tanyifeng -# - Create: 2018-04-25 -#!/usr/bin/python -Es + +# libocispec - a C library for parsing OCI spec files. +# +# Copyright (C) 2017, 2019 Giuseppe Scrivano +# Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. +# +# libocispec is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# libocispec is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with libocispec. If not, see . import traceback import os diff --git a/src/json/schema/src/headers.py b/src/json/schema/src/headers.py index a2cff897bb38d94f4da1dca91f5a747a9aed273c..98116a60d6dba75640523669119851d06b4222b6 100644 --- a/src/json/schema/src/headers.py +++ b/src/json/schema/src/headers.py @@ -4,18 +4,25 @@ Description: header class and functions Interface: None History: 2019-06-17 ''' -# - Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. -# - iSulad licensed under the Mulan PSL v1. -# - You can use this software according to the terms and conditions of the Mulan PSL v1. -# - You may obtain a copy of Mulan PSL v1 at: -# - http://license.coscl.org.cn/MulanPSL -# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# - PURPOSE. -# - See the Mulan PSL v1 for more details. -# - Description: generate json -# - Author: tanyifeng -# - Create: 2018-04-25 +# +# libocispec - a C library for parsing OCI spec files. +# +# Copyright (C) 2017, 2019 Giuseppe Scrivano +# Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. +# +# libocispec is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# libocispec is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with libocispec. If not, see . +# #!/usr/bin/python -Es import helpers diff --git a/src/json/schema/src/helpers.py b/src/json/schema/src/helpers.py index ca4e5aaf56d0b6ec77d8588fe163700fa96fa69d..92a96c9ddff8d7a5e7a67635a1e1414e24e8f2e9 100644 --- a/src/json/schema/src/helpers.py +++ b/src/json/schema/src/helpers.py @@ -4,18 +4,25 @@ Description: helper class and functions Interface: None History: 2019-06-17 ''' -# - Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. -# - iSulad licensed under the Mulan PSL v1. -# - You can use this software according to the terms and conditions of the Mulan PSL v1. -# - You may obtain a copy of Mulan PSL v1 at: -# - http://license.coscl.org.cn/MulanPSL -# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# - PURPOSE. -# - See the Mulan PSL v1 for more details. -# - Description: generate json -# - Author: tanyifeng -# - Create: 2018-04-25 +# +# libocispec - a C library for parsing OCI spec files. +# +# Copyright (C) 2017, 2019 Giuseppe Scrivano +# Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. +# +# libocispec is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# libocispec is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with libocispec. If not, see . +# #!/usr/bin/python -Es import os import sys diff --git a/src/json/schema/src/read_file.c b/src/json/schema/src/read_file.c index ee3604a923f9780a2b169127b6587158c6ddc182..bbfff73a711daec6d8241c670ecd1912132669b4 100644 --- a/src/json/schema/src/read_file.c +++ b/src/json/schema/src/read_file.c @@ -1,17 +1,17 @@ -/****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved. - * iSulad licensed under the Mulan PSL v1. - * You can use this software according to the terms and conditions of the Mulan PSL v1. - * You may obtain a copy of Mulan PSL v1 at: - * http://license.coscl.org.cn/MulanPSL - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v1 for more details. - * Author: tanyifeng - * Create: 2018-11-1 - * Description: provide file read functions - ********************************************************************************/ +/* + Copyright 2017 Giuseppe Scrivano + Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ #include #include #include diff --git a/src/json/schema/src/read_file.h b/src/json/schema/src/read_file.h index cc14940a579b32a7c1bc09f493bbde06b10e176e..0bf6a2548e14d13f631512ee23befc69d6d98d5d 100644 --- a/src/json/schema/src/read_file.h +++ b/src/json/schema/src/read_file.h @@ -1,17 +1,17 @@ -/***************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved. - * iSulad licensed under the Mulan PSL v1. - * You can use this software according to the terms and conditions of the Mulan PSL v1. - * You may obtain a copy of Mulan PSL v1 at: - * http://license.coscl.org.cn/MulanPSL - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v1 for more details. - * Author: tanyifeng - * Create: 2018-11-08 - * Description: provide container read file definition - ****************************************************************************/ +/* + Copyright 2017 Giuseppe Scrivano + Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ #ifndef __JSON_READ_FILE_H_ #define __JSON_READ_FILE_H_ diff --git a/src/json/schema/src/sources.py b/src/json/schema/src/sources.py index 7d7b7d5762a0645547bbefd8cbb38b21791de311..d4b53932c41b527b946014728eae54c1ee7a0910 100644 --- a/src/json/schema/src/sources.py +++ b/src/json/schema/src/sources.py @@ -1,21 +1,24 @@ # -*- coding: utf-8 -*- -""" -Copyright (C) Huawei Technologies., Ltd. 2017-2019. All rights reserved. -# - iSulad licensed under the Mulan PSL v1. -# - You can use this software according to the terms and conditions of the Mulan PSL v1. -# - You may obtain a copy of Mulan PSL v1 at: -# - http://license.coscl.org.cn/MulanPSL -# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# - PURPOSE. -# - See the Mulan PSL v1 for more details. -Description: generate json -Author: tanyifeng -Interface: None -History: 2018-04-25 created -2019-06-17 Code specification -""" #!/usr/bin/python -Es +# +# libocispec - a C library for parsing OCI spec files. +# +# Copyright (C) 2017, 2019 Giuseppe Scrivano +# Copyright (C) Huawei Technologies., Ltd. 2018-2019. All rights reserved. +# +# libocispec is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# libocispec is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with libocispec. If not, see . +# import helpers diff --git a/src/liblcrc.c b/src/libisula.c similarity index 74% rename from src/liblcrc.c rename to src/libisula.c index 9c32de75f936b0c17601f6661065c4a10a372f74..58b1ee0a7b9e2c113452e87145a6fbb8de23db31 100644 --- a/src/liblcrc.c +++ b/src/libisula.c @@ -10,20 +10,20 @@ * See the Mulan PSL v1 for more details. * Author: tanyifeng * Create: 2018-11-08 - * Description: provide container lcrc library functions + * Description: provide container isula library functions ******************************************************************************/ #include #include #include #include -#include "liblcrc.h" +#include "libisula.h" #include "log.h" #include "pack_config.h" #include "utils.h" -/* lcrc filters free */ -void lcrc_filters_free(struct lcrc_filters *filters) +/* isula filters free */ +void isula_filters_free(struct isula_filters *filters) { size_t i; if (filters == NULL) { @@ -42,9 +42,9 @@ void lcrc_filters_free(struct lcrc_filters *filters) free(filters); } -struct lcrc_filters *lcrc_filters_parse_args(const char **array, size_t len) +struct isula_filters *isula_filters_parse_args(const char **array, size_t len) { - struct lcrc_filters *filters = NULL; + struct isula_filters *filters = NULL; size_t i; if (len == 0 || array == NULL) { @@ -104,12 +104,12 @@ struct lcrc_filters *lcrc_filters_parse_args(const char **array, size_t len) } return filters; cleanup: - lcrc_filters_free(filters); + isula_filters_free(filters); return NULL; } -/* lcrc container info free */ -void lcrc_container_info_free(struct lcrc_container_info *info) +/* isula container info free */ +void isula_container_info_free(struct isula_container_info *info) { if (info == NULL) { return; @@ -120,8 +120,8 @@ void lcrc_container_info_free(struct lcrc_container_info *info) free(info); } -/* lcrc version request free */ -void lcrc_version_request_free(struct lcrc_version_request *request) +/* isula version request free */ +void isula_version_request_free(struct isula_version_request *request) { if (request == NULL) { return; @@ -129,8 +129,8 @@ void lcrc_version_request_free(struct lcrc_version_request *request) free(request); } -/* lcrc version response free */ -void lcrc_version_response_free(struct lcrc_version_response *response) +/* isula version response free */ +void isula_version_response_free(struct isula_version_response *response) { if (response == NULL) { return; @@ -154,8 +154,8 @@ void lcrc_version_response_free(struct lcrc_version_response *response) free(response); } -/* lcrc info request free */ -void lcrc_info_request_free(struct lcrc_info_request *request) +/* isula info request free */ +void isula_info_request_free(struct isula_info_request *request) { if (request == NULL) { return; @@ -163,8 +163,8 @@ void lcrc_info_request_free(struct lcrc_info_request *request) free(request); } -/* lcrc info response free */ -void lcrc_info_response_free(struct lcrc_info_response *response) +/* isula info response free */ +void isula_info_response_free(struct isula_info_response *response) { if (response == NULL) { return; @@ -214,7 +214,7 @@ void lcrc_info_response_free(struct lcrc_info_response *response) free(response); } -void lcrc_ns_change_files_free(lcrc_host_config_t *hostconfig) +void isula_ns_change_files_free(isula_host_config_t *hostconfig) { if (hostconfig == NULL) { return; @@ -225,7 +225,7 @@ void lcrc_ns_change_files_free(lcrc_host_config_t *hostconfig) hostconfig->ns_change_files_len = 0; } -void lcrc_host_config_storage_opts_free(lcrc_host_config_t *hostconfig) +void isula_host_config_storage_opts_free(isula_host_config_t *hostconfig) { if (hostconfig == NULL) { return; @@ -235,7 +235,7 @@ void lcrc_host_config_storage_opts_free(lcrc_host_config_t *hostconfig) hostconfig->storage_opts = NULL; } -void lcrc_host_config_sysctl_free(lcrc_host_config_t *hostconfig) +void isula_host_config_sysctl_free(isula_host_config_t *hostconfig) { if (hostconfig == NULL) { return; @@ -245,8 +245,8 @@ void lcrc_host_config_sysctl_free(lcrc_host_config_t *hostconfig) hostconfig->sysctls = NULL; } -/* lcrc host config free */ -void lcrc_host_config_free(lcrc_host_config_t *hostconfig) +/* isula host config free */ +void isula_host_config_free(isula_host_config_t *hostconfig) { if (hostconfig == NULL) { return; @@ -325,8 +325,8 @@ void lcrc_host_config_free(lcrc_host_config_t *hostconfig) free(hostconfig); } -/* lcrc container config free */ -void lcrc_container_config_free(lcrc_container_config_t *config) +/* isula container config free */ +void isula_container_config_free(isula_container_config_t *config) { if (config == NULL) { return; @@ -368,8 +368,8 @@ void lcrc_container_config_free(lcrc_container_config_t *config) free(config); } -/* lcrc create request free */ -void lcrc_create_request_free(struct lcrc_create_request *request) +/* isula create request free */ +void isula_create_request_free(struct isula_create_request *request) { if (request == NULL) { return; @@ -387,16 +387,16 @@ void lcrc_create_request_free(struct lcrc_create_request *request) free(request->runtime); request->runtime = NULL; - lcrc_host_config_free(request->hostconfig); + isula_host_config_free(request->hostconfig); request->hostconfig = NULL; - lcrc_container_config_free(request->config); + isula_container_config_free(request->config); request->config = NULL; free(request); } -/* lcrc create response free */ -void lcrc_create_response_free(struct lcrc_create_response *response) +/* isula create response free */ +void isula_create_response_free(struct isula_create_response *response) { if (response == NULL) { return; @@ -411,8 +411,8 @@ void lcrc_create_response_free(struct lcrc_create_response *response) free(response); } -/* lcrc start request free */ -void lcrc_start_request_free(struct lcrc_start_request *request) +/* isula start request free */ +void isula_start_request_free(struct isula_start_request *request) { if (request == NULL) { return; @@ -433,8 +433,8 @@ void lcrc_start_request_free(struct lcrc_start_request *request) free(request); } -/* lcrc start response free */ -void lcrc_start_response_free(struct lcrc_start_response *response) +/* isula start response free */ +void isula_start_response_free(struct isula_start_response *response) { if (response == NULL) { return; @@ -446,8 +446,8 @@ void lcrc_start_response_free(struct lcrc_start_response *response) free(response); } -/* lcrc_top_request_free */ -void lcrc_top_request_free(struct lcrc_top_request *request) +/* isula_top_request_free */ +void isula_top_request_free(struct isula_top_request *request) { if (request == NULL) { return; @@ -469,8 +469,8 @@ void lcrc_top_request_free(struct lcrc_top_request *request) free(request); } -/* lcrc_top_response_free */ -void lcrc_top_response_free(struct lcrc_top_response *response) +/* isula_top_response_free */ +void isula_top_response_free(struct isula_top_response *response) { if (response == NULL) { return; @@ -493,8 +493,8 @@ void lcrc_top_response_free(struct lcrc_top_response *response) free(response); } -/* lcrc stop request free */ -void lcrc_stop_request_free(struct lcrc_stop_request *request) +/* isula stop request free */ +void isula_stop_request_free(struct isula_stop_request *request) { if (request == NULL) { return; @@ -506,8 +506,8 @@ void lcrc_stop_request_free(struct lcrc_stop_request *request) free(request); } -/* lcrc stop response free */ -void lcrc_stop_response_free(struct lcrc_stop_response *response) +/* isula stop response free */ +void isula_stop_response_free(struct isula_stop_response *response) { if (response == NULL) { return; @@ -519,8 +519,8 @@ void lcrc_stop_response_free(struct lcrc_stop_response *response) free(response); } -/* lcrc restart request free */ -void lcrc_restart_request_free(struct lcrc_restart_request *request) +/* isula restart request free */ +void isula_restart_request_free(struct isula_restart_request *request) { if (request == NULL) { return; @@ -532,8 +532,8 @@ void lcrc_restart_request_free(struct lcrc_restart_request *request) free(request); } -/* lcrc restart response free */ -void lcrc_restart_response_free(struct lcrc_restart_response *response) +/* isula restart response free */ +void isula_restart_response_free(struct isula_restart_response *response) { if (response == NULL) { return; @@ -545,8 +545,8 @@ void lcrc_restart_response_free(struct lcrc_restart_response *response) free(response); } -/* lcrc delete request free */ -void lcrc_delete_request_free(struct lcrc_delete_request *request) +/* isula delete request free */ +void isula_delete_request_free(struct isula_delete_request *request) { if (request == NULL) { return; @@ -558,8 +558,8 @@ void lcrc_delete_request_free(struct lcrc_delete_request *request) free(request); } -/* lcrc delete response free */ -void lcrc_delete_response_free(struct lcrc_delete_response *response) +/* isula delete response free */ +void isula_delete_response_free(struct isula_delete_response *response) { if (response == NULL) { return; @@ -574,8 +574,8 @@ void lcrc_delete_response_free(struct lcrc_delete_response *response) free(response); } -/* lcrc list request free */ -void lcrc_list_request_free(struct lcrc_list_request *request) +/* isula list request free */ +void isula_list_request_free(struct isula_list_request *request) { if (request == NULL) { return; @@ -584,8 +584,8 @@ void lcrc_list_request_free(struct lcrc_list_request *request) free(request); } -/* lcrc list response free */ -void lcrc_list_response_free(struct lcrc_list_response *response) +/* isula list response free */ +void isula_list_response_free(struct isula_list_response *response) { if (response == NULL) { return; @@ -638,8 +638,8 @@ void lcrc_list_response_free(struct lcrc_list_response *response) free(response); } -/* lcrc exec request free */ -void lcrc_exec_request_free(struct lcrc_exec_request *request) +/* isula exec request free */ +void isula_exec_request_free(struct isula_exec_request *request) { if (request == NULL) { return; @@ -683,8 +683,8 @@ void lcrc_exec_request_free(struct lcrc_exec_request *request) free(request); } -/* lcrc exec response free */ -void lcrc_exec_response_free(struct lcrc_exec_response *response) +/* isula exec response free */ +void isula_exec_response_free(struct isula_exec_response *response) { if (response == NULL) { return; @@ -696,8 +696,8 @@ void lcrc_exec_response_free(struct lcrc_exec_response *response) free(response); } -/* lcrc attach request free */ -void lcrc_attach_request_free(struct lcrc_attach_request *request) +/* isula attach request free */ +void isula_attach_request_free(struct isula_attach_request *request) { if (request == NULL) { return; @@ -718,8 +718,8 @@ void lcrc_attach_request_free(struct lcrc_attach_request *request) free(request); } -/* lcrc attach response free */ -void lcrc_attach_response_free(struct lcrc_attach_response *response) +/* isula attach response free */ +void isula_attach_response_free(struct isula_attach_response *response) { if (response == NULL) { return; @@ -731,8 +731,8 @@ void lcrc_attach_response_free(struct lcrc_attach_response *response) free(response); } -/* lcrc pause request free */ -void lcrc_pause_request_free(struct lcrc_pause_request *request) +/* isula pause request free */ +void isula_pause_request_free(struct isula_pause_request *request) { if (request == NULL) { return; @@ -743,8 +743,8 @@ void lcrc_pause_request_free(struct lcrc_pause_request *request) free(request); } -/* lcrc pause response free */ -void lcrc_pause_response_free(struct lcrc_pause_response *response) +/* isula pause response free */ +void isula_pause_response_free(struct isula_pause_response *response) { if (response == NULL) { return; @@ -756,8 +756,8 @@ void lcrc_pause_response_free(struct lcrc_pause_response *response) free(response); } -/* lcrc resume request free */ -void lcrc_resume_request_free(struct lcrc_resume_request *request) +/* isula resume request free */ +void isula_resume_request_free(struct isula_resume_request *request) { if (request == NULL) { return; @@ -768,8 +768,8 @@ void lcrc_resume_request_free(struct lcrc_resume_request *request) free(request); } -/* lcrc resume response free */ -void lcrc_resume_response_free(struct lcrc_resume_response *response) +/* isula resume response free */ +void isula_resume_response_free(struct isula_resume_response *response) { if (response == NULL) { return; @@ -781,8 +781,8 @@ void lcrc_resume_response_free(struct lcrc_resume_response *response) free(response); } -/* lcrc kill request free */ -void lcrc_kill_request_free(struct lcrc_kill_request *request) +/* isula kill request free */ +void isula_kill_request_free(struct isula_kill_request *request) { if (request == NULL) { return; @@ -793,8 +793,8 @@ void lcrc_kill_request_free(struct lcrc_kill_request *request) free(request); } -/* lcrc kill response free */ -void lcrc_kill_response_free(struct lcrc_kill_response *response) +/* isula kill response free */ +void isula_kill_response_free(struct isula_kill_response *response) { if (response == NULL) { return; @@ -805,8 +805,8 @@ void lcrc_kill_response_free(struct lcrc_kill_response *response) free(response); } -/* lcrc update config free */ -void lcrc_update_config_free(lcrc_update_config_t *config) +/* isula update config free */ +void isula_update_config_free(isula_update_config_t *config) { if (config == NULL) { return; @@ -821,8 +821,8 @@ void lcrc_update_config_free(lcrc_update_config_t *config) free(config); } -/* lcrc update request free */ -void lcrc_update_request_free(struct lcrc_update_request *request) +/* isula update request free */ +void isula_update_request_free(struct isula_update_request *request) { if (request == NULL) { return; @@ -831,14 +831,14 @@ void lcrc_update_request_free(struct lcrc_update_request *request) free(request->name); request->name = NULL; - lcrc_update_config_free(request->updateconfig); + isula_update_config_free(request->updateconfig); request->updateconfig = NULL; free(request); } -/* lcrc update response free */ -void lcrc_update_response_free(struct lcrc_update_response *response) +/* isula update response free */ +void isula_update_response_free(struct isula_update_response *response) { if (response == NULL) { return; @@ -850,8 +850,8 @@ void lcrc_update_response_free(struct lcrc_update_response *response) free(response); } -/* lcrc stats request free */ -void lcrc_stats_request_free(struct lcrc_stats_request *request) +/* isula stats request free */ +void isula_stats_request_free(struct isula_stats_request *request) { size_t i = 0; @@ -870,8 +870,8 @@ void lcrc_stats_request_free(struct lcrc_stats_request *request) free(request); } -/* lcrc stats response free */ -void lcrc_stats_response_free(struct lcrc_stats_response *response) +/* isula stats response free */ +void isula_stats_response_free(struct isula_stats_response *response) { if (response == NULL) { return; @@ -892,8 +892,8 @@ void lcrc_stats_response_free(struct lcrc_stats_response *response) free(response); } -/* lcrc events request free */ -void lcrc_events_request_free(struct lcrc_events_request *request) +/* isula events request free */ +void isula_events_request_free(struct isula_events_request *request) { if (request == NULL) { return; @@ -905,8 +905,8 @@ void lcrc_events_request_free(struct lcrc_events_request *request) free(request); } -/* lcrc events response free */ -void lcrc_events_response_free(struct lcrc_events_response *response) +/* isula events response free */ +void isula_events_response_free(struct isula_events_response *response) { if (response == NULL) { return; @@ -918,7 +918,7 @@ void lcrc_events_response_free(struct lcrc_events_response *response) free(response); } -void lcrc_copy_from_container_request_free(struct lcrc_copy_from_container_request *request) +void isula_copy_from_container_request_free(struct isula_copy_from_container_request *request) { if (request == NULL) { return; @@ -934,7 +934,7 @@ void lcrc_copy_from_container_request_free(struct lcrc_copy_from_container_reque free(request); } -void lcrc_copy_from_container_response_free(struct lcrc_copy_from_container_response *response) +void isula_copy_from_container_response_free(struct isula_copy_from_container_response *response) { if (response == NULL) { return; @@ -947,7 +947,7 @@ void lcrc_copy_from_container_response_free(struct lcrc_copy_from_container_resp free(response); } -void lcrc_copy_to_container_request_free(struct lcrc_copy_to_container_request *request) +void isula_copy_to_container_request_free(struct isula_copy_to_container_request *request) { if (request == NULL) { return; @@ -967,7 +967,7 @@ void lcrc_copy_to_container_request_free(struct lcrc_copy_to_container_request * free(request); } -void lcrc_copy_to_container_response_free(struct lcrc_copy_to_container_response *response) +void isula_copy_to_container_response_free(struct isula_copy_to_container_response *response) { if (response == NULL) { return; @@ -979,8 +979,8 @@ void lcrc_copy_to_container_response_free(struct lcrc_copy_to_container_response free(response); } -/* lcrc inspect request free */ -void lcrc_inspect_request_free(struct lcrc_inspect_request *request) +/* isula inspect request free */ +void isula_inspect_request_free(struct isula_inspect_request *request) { if (request == NULL) { return; @@ -992,8 +992,8 @@ void lcrc_inspect_request_free(struct lcrc_inspect_request *request) free(request); } -/* lcrc inspect response free */ -void lcrc_inspect_response_free(struct lcrc_inspect_response *response) +/* isula inspect response free */ +void isula_inspect_response_free(struct isula_inspect_response *response) { if (response == NULL) { return; @@ -1008,8 +1008,8 @@ void lcrc_inspect_response_free(struct lcrc_inspect_response *response) free(response); } -/* lcrc wait request free */ -void lcrc_wait_request_free(struct lcrc_wait_request *request) +/* isula wait request free */ +void isula_wait_request_free(struct isula_wait_request *request) { if (request == NULL) { return; @@ -1020,8 +1020,8 @@ void lcrc_wait_request_free(struct lcrc_wait_request *request) free(request); } -/* lcrc wait response free */ -void lcrc_wait_response_free(struct lcrc_wait_response *response) +/* isula wait response free */ +void isula_wait_response_free(struct isula_wait_response *response) { if (response == NULL) { return; @@ -1033,8 +1033,8 @@ void lcrc_wait_response_free(struct lcrc_wait_response *response) free(response); } -/* lcrc health check request free */ -void lcrc_health_check_request_free(struct lcrc_health_check_request *request) +/* isula health check request free */ +void isula_health_check_request_free(struct isula_health_check_request *request) { if (request == NULL) { return; @@ -1046,8 +1046,8 @@ void lcrc_health_check_request_free(struct lcrc_health_check_request *request) free(request); } -/* lcrc health check response free */ -void lcrc_health_check_response_free(struct lcrc_health_check_response *response) +/* isula health check response free */ +void isula_health_check_response_free(struct isula_health_check_response *response) { if (response == NULL) { return; @@ -1059,8 +1059,8 @@ void lcrc_health_check_response_free(struct lcrc_health_check_response *response free(response); } -/* lcrc create image request free */ -void lcrc_create_image_request_free(struct lcrc_create_image_request *request) +/* isula create image request free */ +void isula_create_image_request_free(struct isula_create_image_request *request) { if (request == NULL) { return; @@ -1079,8 +1079,8 @@ void lcrc_create_image_request_free(struct lcrc_create_image_request *request) return; } -/* lcrc create image response free */ -void lcrc_create_image_response_free(struct lcrc_create_image_response *response) +/* isula create image response free */ +void isula_create_image_response_free(struct isula_create_image_response *response) { if (response == NULL) { return; @@ -1102,11 +1102,11 @@ void lcrc_create_image_response_free(struct lcrc_create_image_response *response return; } -/* lcrc images list free */ -void lcrc_images_list_free(size_t images_num, struct lcrc_image_info *images_list) +/* isula images list free */ +void isula_images_list_free(size_t images_num, struct isula_image_info *images_list) { int i = 0; - struct lcrc_image_info *in = NULL; + struct isula_image_info *in = NULL; if (images_num == 0 || images_list == NULL) { return; @@ -1122,8 +1122,8 @@ void lcrc_images_list_free(size_t images_num, struct lcrc_image_info *images_lis return; } -/* lcrc list images request free */ -void lcrc_list_images_request_free(struct lcrc_list_images_request *request) +/* isula list images request free */ +void isula_list_images_request_free(struct isula_list_images_request *request) { if (request == NULL) { return; @@ -1133,8 +1133,8 @@ void lcrc_list_images_request_free(struct lcrc_list_images_request *request) return; } -/* lcrc list images response free */ -void lcrc_list_images_response_free(struct lcrc_list_images_response *response) +/* isula list images response free */ +void isula_list_images_response_free(struct isula_list_images_response *response) { if (response == NULL) { return; @@ -1143,14 +1143,14 @@ void lcrc_list_images_response_free(struct lcrc_list_images_response *response) free(response->errmsg); response->errmsg = NULL; - lcrc_images_list_free(response->images_num, response->images_list); + isula_images_list_free(response->images_num, response->images_list); response->images_num = 0; response->images_list = NULL; free(response); } -/* lcrc rmi request free */ -void lcrc_rmi_request_free(struct lcrc_rmi_request *request) +/* isula rmi request free */ +void isula_rmi_request_free(struct isula_rmi_request *request) { if (request == NULL) { return; @@ -1163,8 +1163,8 @@ void lcrc_rmi_request_free(struct lcrc_rmi_request *request) return; } -/* lcrc rmi response free */ -void lcrc_rmi_response_free(struct lcrc_rmi_response *response) +/* isula rmi response free */ +void isula_rmi_response_free(struct isula_rmi_response *response) { if (response == NULL) { return; @@ -1177,8 +1177,8 @@ void lcrc_rmi_response_free(struct lcrc_rmi_response *response) return; } -/* lcrc pull response free */ -void lcrc_pull_request_free(struct lcrc_pull_request *request) +/* isula pull response free */ +void isula_pull_request_free(struct isula_pull_request *request) { if (request == NULL) { return; @@ -1191,8 +1191,8 @@ void lcrc_pull_request_free(struct lcrc_pull_request *request) return; } -/* lcrc pull response free */ -void lcrc_pull_response_free(struct lcrc_pull_response *response) +/* isula pull response free */ +void isula_pull_response_free(struct isula_pull_response *response) { if (response == NULL) { return; @@ -1207,8 +1207,8 @@ void lcrc_pull_response_free(struct lcrc_pull_response *response) return; } -/* lcrc load request free */ -void lcrc_load_request_free(struct lcrc_load_request *request) +/* isula load request free */ +void isula_load_request_free(struct isula_load_request *request) { if (request == NULL) { return; @@ -1227,8 +1227,8 @@ void lcrc_load_request_free(struct lcrc_load_request *request) return; } -/* lcrc load response free */ -void lcrc_load_response_free(struct lcrc_load_response *response) +/* isula load response free */ +void isula_load_response_free(struct isula_load_response *response) { if (response == NULL) { return; @@ -1241,8 +1241,8 @@ void lcrc_load_response_free(struct lcrc_load_response *response) return; } -/* lcrc login response free */ -void lcrc_login_response_free(struct lcrc_login_response *response) +/* isula login response free */ +void isula_login_response_free(struct isula_login_response *response) { if (response == NULL) { return; @@ -1255,8 +1255,8 @@ void lcrc_login_response_free(struct lcrc_login_response *response) return; } -/* lcrc logout response free */ -void lcrc_logout_response_free(struct lcrc_logout_response *response) +/* isula logout response free */ +void isula_logout_response_free(struct isula_logout_response *response) { if (response == NULL) { return; @@ -1269,8 +1269,8 @@ void lcrc_logout_response_free(struct lcrc_logout_response *response) return; } -/* lcrc export request free */ -void lcrc_export_request_free(struct lcrc_export_request *request) +/* isula export request free */ +void isula_export_request_free(struct isula_export_request *request) { if (request == NULL) { return; @@ -1285,8 +1285,8 @@ void lcrc_export_request_free(struct lcrc_export_request *request) free(request); } -/* lcrc export response free */ -void lcrc_export_response_free(struct lcrc_export_response *response) +/* isula export response free */ +void isula_export_response_free(struct isula_export_response *response) { if (response == NULL) { return; @@ -1298,8 +1298,8 @@ void lcrc_export_response_free(struct lcrc_export_response *response) free(response); } -/* lcrc rename request free */ -void lcrc_rename_request_free(struct lcrc_rename_request *request) +/* isula rename request free */ +void isula_rename_request_free(struct isula_rename_request *request) { if (request == NULL) { return; @@ -1314,8 +1314,8 @@ void lcrc_rename_request_free(struct lcrc_rename_request *request) free(request); } -/* lcrc rename response free */ -void lcrc_rename_response_free(struct lcrc_rename_response *response) +/* isula rename response free */ +void isula_rename_response_free(struct isula_rename_response *response) { if (response == NULL) { return; @@ -1327,8 +1327,8 @@ void lcrc_rename_response_free(struct lcrc_rename_response *response) free(response); } -/* lcrc resize request free */ -void lcrc_resize_request_free(struct lcrc_resize_request *request) +/* isula resize request free */ +void isula_resize_request_free(struct isula_resize_request *request) { if (request == NULL) { return; @@ -1343,8 +1343,8 @@ void lcrc_resize_request_free(struct lcrc_resize_request *request) free(request); } -/* lcrc resize response free */ -void lcrc_resize_response_free(struct lcrc_resize_response *response) +/* isula resize response free */ +void isula_resize_response_free(struct isula_resize_response *response) { if (response == NULL) { return; @@ -1357,8 +1357,8 @@ void lcrc_resize_response_free(struct lcrc_resize_response *response) } -/* lcrc logs request free */ -void lcrc_logs_request_free(struct lcrc_logs_request *request) +/* isula logs request free */ +void isula_logs_request_free(struct isula_logs_request *request) { if (request == NULL) { return; @@ -1376,8 +1376,8 @@ void lcrc_logs_request_free(struct lcrc_logs_request *request) free(request); } -/* lcrc logs response free */ -void lcrc_logs_response_free(struct lcrc_logs_response *response) +/* isula logs response free */ +void isula_logs_response_free(struct isula_logs_response *response) { if (response == NULL) { return; diff --git a/src/liblcrc.h b/src/libisula.h similarity index 54% rename from src/liblcrc.h rename to src/libisula.h index 423f7fc97aeebfe388d6a12d4ed2254b9d718ce4..ef9caef6d25afba968213c97cb68ce2a05c70892 100644 --- a/src/liblcrc.h +++ b/src/libisula.h @@ -10,10 +10,10 @@ * See the Mulan PSL v1 for more details. * Author: tanyifeng * Create: 2018-11-08 - * Description: provide container lcrc library definition + * Description: provide container isula library definition ******************************************************************************/ -#ifndef __LIB_LCRC_H -#define __LIB_LCRC_H +#ifndef __LIB_ISULA_H +#define __LIB_ISULA_H #include #include @@ -27,13 +27,13 @@ extern "C" { #endif -struct lcrc_filters { +struct isula_filters { char **keys; char **values; size_t len; }; -typedef struct lcrc_container_config { +typedef struct isula_container_config { char **env; size_t env_len; @@ -92,9 +92,9 @@ typedef struct lcrc_container_config { char **accel; size_t accel_len; -} lcrc_container_config_t; +} isula_container_config_t; -typedef struct lcrc_host_config { +typedef struct isula_host_config { char **devices; size_t devices_len; @@ -179,25 +179,25 @@ typedef struct lcrc_host_config { char **security; size_t security_len; -} lcrc_host_config_t; +} isula_host_config_t; -struct lcrc_create_request { +struct isula_create_request { char *name; char *rootfs; char *image; char *runtime; - lcrc_host_config_t *hostconfig; - lcrc_container_config_t *config; + isula_host_config_t *hostconfig; + isula_container_config_t *config; }; -struct lcrc_create_response { +struct isula_create_response { char *id; uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_start_request { +struct isula_start_request { char *name; char *stdin; bool attach_stdin; @@ -207,19 +207,19 @@ struct lcrc_start_request { bool attach_stderr; }; -struct lcrc_start_response { +struct isula_start_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_top_request { +struct isula_top_request { char *name; int ps_argc; char **ps_args; }; -struct lcrc_top_response { +struct isula_top_response { uint32_t cc; uint32_t server_errono; char *errmsg; @@ -228,73 +228,73 @@ struct lcrc_top_response { size_t processes_len; }; -struct lcrc_stop_request { +struct isula_stop_request { char *name; bool force; int timeout; }; -struct lcrc_stop_response { +struct isula_stop_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_restart_request { +struct isula_restart_request { char *name; unsigned int timeout; }; -struct lcrc_restart_response { +struct isula_restart_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_kill_request { +struct isula_kill_request { char *name; uint32_t signal; }; -struct lcrc_kill_response { +struct isula_kill_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_delete_request { +struct isula_delete_request { char *name; bool force; }; -struct lcrc_delete_response { +struct isula_delete_response { char *name; uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_pause_request { +struct isula_pause_request { char *name; }; -struct lcrc_pause_response { +struct isula_pause_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_resume_request { +struct isula_resume_request { char *name; }; -struct lcrc_resume_response { +struct isula_resume_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_container_info { +struct isula_container_info { char *id; uint64_t pids_current; // CPU usage @@ -312,25 +312,25 @@ struct lcrc_container_info { uint64_t kmem_limit; }; -struct lcrc_inspect_request { +struct isula_inspect_request { char *name; bool bformat; int timeout; }; -struct lcrc_inspect_response { +struct isula_inspect_response { uint32_t cc; uint32_t server_errono; char *json; char *errmsg; }; -struct lcrc_list_request { - struct lcrc_filters *filters; +struct isula_list_request { + struct isula_filters *filters; bool all; }; -struct lcrc_container_summary_info { +struct isula_container_summary_info { char *id; char *image; char *command; @@ -347,29 +347,29 @@ struct lcrc_container_summary_info { int64_t created; }; -struct lcrc_list_response { +struct isula_list_response { uint32_t cc; uint32_t server_errono; size_t container_num; - struct lcrc_container_summary_info **container_summary; + struct isula_container_summary_info **container_summary; char *errmsg; }; -struct lcrc_stats_request { +struct isula_stats_request { char **containers; size_t containers_len; bool all; }; -struct lcrc_stats_response { +struct isula_stats_response { uint32_t cc; uint32_t server_errono; size_t container_num; - struct lcrc_container_info *container_stats; + struct isula_container_info *container_stats; char *errmsg; }; -struct lcrc_events_request { +struct isula_events_request { container_events_callback_t cb; bool storeonly; char *id; @@ -377,19 +377,19 @@ struct lcrc_events_request { types_timestamp_t until; }; -struct lcrc_events_response { +struct isula_events_response { uint32_t server_errono; uint32_t cc; char *errmsg; }; -struct lcrc_copy_from_container_request { +struct isula_copy_from_container_request { char *id; char *runtime; char *srcpath; }; -struct lcrc_copy_from_container_response { +struct isula_copy_from_container_response { uint32_t server_errono; uint32_t cc; char *errmsg; @@ -397,7 +397,7 @@ struct lcrc_copy_from_container_response { struct io_read_wrapper reader; }; -struct lcrc_copy_to_container_request { +struct isula_copy_to_container_request { char *id; char *runtime; char *srcpath; @@ -407,13 +407,13 @@ struct lcrc_copy_to_container_request { struct io_read_wrapper reader; }; -struct lcrc_copy_to_container_response { +struct isula_copy_to_container_response { uint32_t server_errono; uint32_t cc; char *errmsg; }; -struct lcrc_logs_request { +struct isula_logs_request { char *id; char *runtime; @@ -425,25 +425,25 @@ struct lcrc_logs_request { bool details; }; -struct lcrc_logs_response { +struct isula_logs_response { uint32_t server_errono; uint32_t cc; char *errmsg; }; -struct lcrc_wait_request { +struct isula_wait_request { char *id; uint32_t condition; }; -struct lcrc_wait_response { +struct isula_wait_response { int exit_code; uint32_t server_errono; uint32_t cc; char *errmsg; }; -struct lcrc_exec_request { +struct isula_exec_request { char *name; char *suffix; bool tty; @@ -462,14 +462,14 @@ struct lcrc_exec_request { char *user; }; -struct lcrc_exec_response { +struct isula_exec_response { uint32_t cc; uint32_t server_errono; uint32_t exit_code; char *errmsg; }; -struct lcrc_attach_request { +struct isula_attach_request { char *name; char *stdin; char *stdout; @@ -479,27 +479,27 @@ struct lcrc_attach_request { bool attach_stderr; }; -struct lcrc_attach_response { +struct isula_attach_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_health_check_request { +struct isula_health_check_request { char *service; }; -struct lcrc_health_check_response { +struct isula_health_check_response { Health_Serving_Status health_status; uint32_t cc; char *errmsg; }; -struct lcrc_version_request { +struct isula_version_request { char unuseful; }; -struct lcrc_version_response { +struct isula_version_response { uint32_t cc; uint32_t server_errono; char *version; @@ -509,11 +509,11 @@ struct lcrc_version_response { char *errmsg; }; -struct lcrc_info_request { +struct isula_info_request { char unuseful; }; -struct lcrc_info_response { +struct isula_info_response { uint32_t cc; uint32_t server_errono; char *version; @@ -539,23 +539,23 @@ struct lcrc_info_response { char *errmsg; }; -typedef struct lcrc_update_config { +typedef struct isula_update_config { char *restart_policy; container_cgroup_resources_t *cr; -} lcrc_update_config_t; +} isula_update_config_t; -struct lcrc_update_request { +struct isula_update_request { char *name; - lcrc_update_config_t *updateconfig; + isula_update_config_t *updateconfig; }; -struct lcrc_update_response { +struct isula_update_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_image_info { +struct isula_image_info { char *imageref; char *type; char *digest; @@ -564,67 +564,67 @@ struct lcrc_image_info { int64_t size; /* Bytes */ }; -struct lcrc_create_image_request { - struct lcrc_image_info image_info; +struct isula_create_image_request { + struct isula_image_info image_info; }; -struct lcrc_create_image_response { +struct isula_create_image_response { uint32_t cc; uint32_t server_errono; - struct lcrc_image_info image_info; + struct isula_image_info image_info; char *errmsg; }; -struct lcrc_list_images_request { - struct lcrc_filters *filters; +struct isula_list_images_request { + struct isula_filters *filters; // unuseful definition to avoid generate empty struct which will get 0 if we call sizeof char unuseful; }; -struct lcrc_list_images_response { +struct isula_list_images_response { uint32_t cc; uint32_t server_errono; size_t images_num; - struct lcrc_image_info *images_list; + struct isula_image_info *images_list; char *errmsg; }; -struct lcrc_rmi_request { +struct isula_rmi_request { char *image_name; bool force; }; -struct lcrc_rmi_response { +struct isula_rmi_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_pull_request { +struct isula_pull_request { char *image_name; }; -struct lcrc_pull_response { +struct isula_pull_response { char *image_ref; uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_load_request { +struct isula_load_request { char *socketname; char *file; char *type; char *tag; }; -struct lcrc_load_response { +struct isula_load_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_login_request { +struct isula_login_request { char *socketname; char *username; char *password; @@ -632,206 +632,206 @@ struct lcrc_login_request { char *type; }; -struct lcrc_login_response { +struct isula_login_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_logout_request { +struct isula_logout_request { char *socketname; char *server; char *type; }; -struct lcrc_logout_response { +struct isula_logout_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_export_request { +struct isula_export_request { char *name; char *file; }; -struct lcrc_export_response { +struct isula_export_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_rename_request { +struct isula_rename_request { char *old_name; char *new_name; }; -struct lcrc_rename_response { +struct isula_rename_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -struct lcrc_resize_request { +struct isula_resize_request { char *id; char *suffix; uint32_t height; uint32_t width; }; -struct lcrc_resize_response { +struct isula_resize_response { uint32_t cc; uint32_t server_errono; char *errmsg; }; -Container_Status lcrcstastr2sta(const char *state); +Container_Status isulastastr2sta(const char *state); -struct lcrc_filters *lcrc_filters_parse_args(const char **array, size_t len); +struct isula_filters *isula_filters_parse_args(const char **array, size_t len); -void lcrc_filters_free(struct lcrc_filters *filters); +void isula_filters_free(struct isula_filters *filters); -void lcrc_container_info_free(struct lcrc_container_info *info); +void isula_container_info_free(struct isula_container_info *info); -void lcrc_version_request_free(struct lcrc_version_request *request); +void isula_version_request_free(struct isula_version_request *request); -void lcrc_version_response_free(struct lcrc_version_response *response); +void isula_version_response_free(struct isula_version_response *response); -void lcrc_info_request_free(struct lcrc_info_request *request); +void isula_info_request_free(struct isula_info_request *request); -void lcrc_info_response_free(struct lcrc_info_response *response); +void isula_info_response_free(struct isula_info_response *response); -void lcrc_ns_change_files_free(lcrc_host_config_t *hostconfig); +void isula_ns_change_files_free(isula_host_config_t *hostconfig); -void lcrc_host_config_storage_opts_free(lcrc_host_config_t *hostconfig); +void isula_host_config_storage_opts_free(isula_host_config_t *hostconfig); -void lcrc_host_config_sysctl_free(lcrc_host_config_t *hostconfig); +void isula_host_config_sysctl_free(isula_host_config_t *hostconfig); -void lcrc_host_config_free(lcrc_host_config_t *hostconfig); +void isula_host_config_free(isula_host_config_t *hostconfig); -void lcrc_container_config_free(lcrc_container_config_t *config); +void isula_container_config_free(isula_container_config_t *config); -void lcrc_create_request_free(struct lcrc_create_request *request); +void isula_create_request_free(struct isula_create_request *request); -void lcrc_create_response_free(struct lcrc_create_response *response); +void isula_create_response_free(struct isula_create_response *response); -void lcrc_start_request_free(struct lcrc_start_request *request); +void isula_start_request_free(struct isula_start_request *request); -void lcrc_start_response_free(struct lcrc_start_response *response); +void isula_start_response_free(struct isula_start_response *response); -void lcrc_top_request_free(struct lcrc_top_request *request); +void isula_top_request_free(struct isula_top_request *request); -void lcrc_top_response_free(struct lcrc_top_response *response); +void isula_top_response_free(struct isula_top_response *response); -void lcrc_stop_request_free(struct lcrc_stop_request *request); +void isula_stop_request_free(struct isula_stop_request *request); -void lcrc_stop_response_free(struct lcrc_stop_response *response); +void isula_stop_response_free(struct isula_stop_response *response); -void lcrc_restart_request_free(struct lcrc_restart_request *request); +void isula_restart_request_free(struct isula_restart_request *request); -void lcrc_restart_response_free(struct lcrc_restart_response *response); +void isula_restart_response_free(struct isula_restart_response *response); -void lcrc_delete_request_free(struct lcrc_delete_request *request); +void isula_delete_request_free(struct isula_delete_request *request); -void lcrc_delete_response_free(struct lcrc_delete_response *response); +void isula_delete_response_free(struct isula_delete_response *response); -void lcrc_list_request_free(struct lcrc_list_request *request); +void isula_list_request_free(struct isula_list_request *request); -void lcrc_list_response_free(struct lcrc_list_response *response); +void isula_list_response_free(struct isula_list_response *response); -void lcrc_exec_request_free(struct lcrc_exec_request *request); +void isula_exec_request_free(struct isula_exec_request *request); -void lcrc_exec_response_free(struct lcrc_exec_response *response); +void isula_exec_response_free(struct isula_exec_response *response); -void lcrc_attach_request_free(struct lcrc_attach_request *request); +void isula_attach_request_free(struct isula_attach_request *request); -void lcrc_attach_response_free(struct lcrc_attach_response *response); +void isula_attach_response_free(struct isula_attach_response *response); -void lcrc_pause_request_free(struct lcrc_pause_request *request); +void isula_pause_request_free(struct isula_pause_request *request); -void lcrc_pause_response_free(struct lcrc_pause_response *response); +void isula_pause_response_free(struct isula_pause_response *response); -void lcrc_resume_request_free(struct lcrc_resume_request *request); +void isula_resume_request_free(struct isula_resume_request *request); -void lcrc_resume_response_free(struct lcrc_resume_response *response); +void isula_resume_response_free(struct isula_resume_response *response); -void lcrc_kill_request_free(struct lcrc_kill_request *request); +void isula_kill_request_free(struct isula_kill_request *request); -void lcrc_kill_response_free(struct lcrc_kill_response *response); +void isula_kill_response_free(struct isula_kill_response *response); -void lcrc_update_config_free(lcrc_update_config_t *config); +void isula_update_config_free(isula_update_config_t *config); -void lcrc_update_request_free(struct lcrc_update_request *request); +void isula_update_request_free(struct isula_update_request *request); -void lcrc_update_response_free(struct lcrc_update_response *response); +void isula_update_response_free(struct isula_update_response *response); -void lcrc_stats_request_free(struct lcrc_stats_request *request); +void isula_stats_request_free(struct isula_stats_request *request); -void lcrc_stats_response_free(struct lcrc_stats_response *response); +void isula_stats_response_free(struct isula_stats_response *response); -void lcrc_events_request_free(struct lcrc_events_request *request); +void isula_events_request_free(struct isula_events_request *request); -void lcrc_events_response_free(struct lcrc_events_response *response); +void isula_events_response_free(struct isula_events_response *response); -void lcrc_copy_from_container_request_free(struct lcrc_copy_from_container_request *request); +void isula_copy_from_container_request_free(struct isula_copy_from_container_request *request); -void lcrc_copy_from_container_response_free(struct lcrc_copy_from_container_response *response); +void isula_copy_from_container_response_free(struct isula_copy_from_container_response *response); -void lcrc_copy_to_container_request_free(struct lcrc_copy_to_container_request *request); +void isula_copy_to_container_request_free(struct isula_copy_to_container_request *request); -void lcrc_copy_to_container_response_free(struct lcrc_copy_to_container_response *response); +void isula_copy_to_container_response_free(struct isula_copy_to_container_response *response); -void lcrc_inspect_request_free(struct lcrc_inspect_request *request); +void isula_inspect_request_free(struct isula_inspect_request *request); -void lcrc_inspect_response_free(struct lcrc_inspect_response *response); +void isula_inspect_response_free(struct isula_inspect_response *response); -void lcrc_wait_request_free(struct lcrc_wait_request *request); +void isula_wait_request_free(struct isula_wait_request *request); -void lcrc_wait_response_free(struct lcrc_wait_response *response); +void isula_wait_response_free(struct isula_wait_response *response); -void lcrc_health_check_request_free(struct lcrc_health_check_request *request); +void isula_health_check_request_free(struct isula_health_check_request *request); -void lcrc_health_check_response_free(struct lcrc_health_check_response *response); +void isula_health_check_response_free(struct isula_health_check_response *response); -void lcrc_create_image_request_free(struct lcrc_create_image_request *request); +void isula_create_image_request_free(struct isula_create_image_request *request); -void lcrc_create_image_response_free(struct lcrc_create_image_response *response); +void isula_create_image_response_free(struct isula_create_image_response *response); -void lcrc_images_list_free(size_t images_num, struct lcrc_image_info *images_list); +void isula_images_list_free(size_t images_num, struct isula_image_info *images_list); -void lcrc_list_images_request_free(struct lcrc_list_images_request *request); +void isula_list_images_request_free(struct isula_list_images_request *request); -void lcrc_list_images_response_free(struct lcrc_list_images_response *response); +void isula_list_images_response_free(struct isula_list_images_response *response); -void lcrc_rmi_request_free(struct lcrc_rmi_request *request); +void isula_rmi_request_free(struct isula_rmi_request *request); -void lcrc_rmi_response_free(struct lcrc_rmi_response *response); +void isula_rmi_response_free(struct isula_rmi_response *response); -void lcrc_load_request_free(struct lcrc_load_request *request); +void isula_load_request_free(struct isula_load_request *request); -void lcrc_load_response_free(struct lcrc_load_response *response); +void isula_load_response_free(struct isula_load_response *response); -void lcrc_login_response_free(struct lcrc_login_response *response); +void isula_login_response_free(struct isula_login_response *response); -void lcrc_logout_response_free(struct lcrc_logout_response *response); +void isula_logout_response_free(struct isula_logout_response *response); -void lcrc_pull_request_free(struct lcrc_pull_request *request); -void lcrc_pull_response_free(struct lcrc_pull_response *response); +void isula_pull_request_free(struct isula_pull_request *request); +void isula_pull_response_free(struct isula_pull_response *response); -void lcrc_export_request_free(struct lcrc_export_request *request); +void isula_export_request_free(struct isula_export_request *request); -void lcrc_export_response_free(struct lcrc_export_response *response); +void isula_export_response_free(struct isula_export_response *response); -void lcrc_rename_request_free(struct lcrc_rename_request *request); +void isula_rename_request_free(struct isula_rename_request *request); -void lcrc_rename_response_free(struct lcrc_rename_response *response); +void isula_rename_response_free(struct isula_rename_response *response); -void lcrc_resize_request_free(struct lcrc_resize_request *request); +void isula_resize_request_free(struct isula_resize_request *request); -void lcrc_resize_response_free(struct lcrc_resize_response *response); +void isula_resize_response_free(struct isula_resize_response *response); -void lcrc_logs_request_free(struct lcrc_logs_request *request); -void lcrc_logs_response_free(struct lcrc_logs_response *response); +void isula_logs_request_free(struct isula_logs_request *request); +void isula_logs_response_free(struct isula_logs_response *response); #ifdef __cplusplus } diff --git a/src/liblcrd.c b/src/libisulad.c similarity index 69% rename from src/liblcrd.c rename to src/libisulad.c index 2fdb820796a929f2d1494ccfe2c7940837a0c9da..2c35ef6dae9366b1110f99fc57213d326174a0e4 100644 --- a/src/liblcrd.c +++ b/src/libisulad.c @@ -10,7 +10,7 @@ * See the Mulan PSL v1 for more details. * Author: tanyifeng * Create: 2018-11-08 - * Description: provide container lcrd functions + * Description: provide container isulad functions ******************************************************************************/ #include #include @@ -18,16 +18,16 @@ #include #include -#include "liblcrd.h" +#include "libisulad.h" #include "log.h" #include "pack_config.h" #include "utils.h" // record the errno -__thread char *g_lcrd_errmsg = NULL; +__thread char *g_isulad_errmsg = NULL; -/* lcrd events request free */ -void lcrd_events_request_free(struct lcrd_events_request *request) +/* isulad events request free */ +void isulad_events_request_free(struct isulad_events_request *request) { if (request == NULL) { return; @@ -39,7 +39,7 @@ void lcrd_events_request_free(struct lcrd_events_request *request) free(request); } -void lcrd_copy_from_container_request_free(struct lcrd_copy_from_container_request *request) +void isulad_copy_from_container_request_free(struct isulad_copy_from_container_request *request) { if (request == NULL) { return; @@ -54,7 +54,7 @@ void lcrd_copy_from_container_request_free(struct lcrd_copy_from_container_reque free(request); } -void lcrd_copy_from_container_response_free(struct lcrd_copy_from_container_response *response) +void isulad_copy_from_container_response_free(struct isulad_copy_from_container_response *response) { if (response == NULL) { return; @@ -67,8 +67,8 @@ void lcrd_copy_from_container_response_free(struct lcrd_copy_from_container_resp free(response); } -/* lcrd set error message */ -void lcrd_set_error_message(const char *format, ...) +/* isulad set error message */ +void isulad_set_error_message(const char *format, ...) { int ret = 0; char errbuf[BUFSIZ + 1] = { 0 }; @@ -83,15 +83,15 @@ void lcrd_set_error_message(const char *format, ...) return; } - g_lcrd_errmsg = util_strdup_s(errbuf); + g_isulad_errmsg = util_strdup_s(errbuf); } -/* lcrd try set error message */ -void lcrd_try_set_error_message(const char *format, ...) +/* isulad try set error message */ +void isulad_try_set_error_message(const char *format, ...) { int ret = 0; - if (g_lcrd_errmsg != NULL) { + if (g_isulad_errmsg != NULL) { return; } char errbuf[BUFSIZ + 1] = { 0 }; @@ -105,11 +105,11 @@ void lcrd_try_set_error_message(const char *format, ...) return; } - g_lcrd_errmsg = util_strdup_s(errbuf); + g_isulad_errmsg = util_strdup_s(errbuf); } -/* lcrd append error message */ -void lcrd_append_error_message(const char *format, ...) +/* isulad append error message */ +void isulad_append_error_message(const char *format, ...) { int ret = 0; char errbuf[BUFSIZ + 1] = { 0 }; @@ -123,18 +123,18 @@ void lcrd_append_error_message(const char *format, ...) if (ret < 0 || ret >= BUFSIZ) { return; } - result = util_string_append(g_lcrd_errmsg, errbuf); + result = util_string_append(g_isulad_errmsg, errbuf); if (result == NULL) { return; } - if (g_lcrd_errmsg != NULL) { - free(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + free(g_isulad_errmsg); } - g_lcrd_errmsg = result; + g_isulad_errmsg = result; } -/* lcrd container rename request free */ -void lcrd_container_rename_request_free(struct lcrd_container_rename_request *request) +/* isulad container rename request free */ +void isulad_container_rename_request_free(struct isulad_container_rename_request *request) { if (request == NULL) { return; @@ -148,8 +148,8 @@ void lcrd_container_rename_request_free(struct lcrd_container_rename_request *re free(request); } -/* lcrd container rename response free */ -void lcrd_container_rename_response_free(struct lcrd_container_rename_response *response) +/* isulad container rename response free */ +void isulad_container_rename_response_free(struct isulad_container_rename_response *response) { if (response == NULL) { return; @@ -163,8 +163,8 @@ void lcrd_container_rename_response_free(struct lcrd_container_rename_response * free(response); } -/* lcrd container rename request free */ -void lcrd_container_resize_request_free(struct lcrd_container_resize_request *request) +/* isulad container rename request free */ +void isulad_container_resize_request_free(struct isulad_container_resize_request *request) { if (request == NULL) { return; @@ -179,8 +179,8 @@ void lcrd_container_resize_request_free(struct lcrd_container_resize_request *re free(request); } -/* lcrd container rename response free */ -void lcrd_container_resize_response_free(struct lcrd_container_resize_response *response) +/* isulad container rename response free */ +void isulad_container_resize_response_free(struct isulad_container_resize_response *response) { if (response == NULL) { return; @@ -195,7 +195,7 @@ void lcrd_container_resize_response_free(struct lcrd_container_resize_response * } -void lcrd_logs_request_free(struct lcrd_logs_request *request) +void isulad_logs_request_free(struct isulad_logs_request *request) { if (request == NULL) { return; @@ -212,7 +212,7 @@ void lcrd_logs_request_free(struct lcrd_logs_request *request) free(request); } -void lcrd_logs_response_free(struct lcrd_logs_response *response) +void isulad_logs_response_free(struct isulad_logs_response *response) { if (response == NULL) { return; diff --git a/src/liblcrd.h b/src/libisulad.h similarity index 67% rename from src/liblcrd.h rename to src/libisulad.h index 9e31e5fa1df314e7960280caadd1bc4efc1b896b..183166dff0ff91c0a5ed21d6bbe02fc21cffe782 100644 --- a/src/liblcrd.h +++ b/src/libisulad.h @@ -10,10 +10,10 @@ * See the Mulan PSL v1 for more details. * Author: tanyifeng * Create: 2018-11-08 - * Description: provide container lcrd definition + * Description: provide container isulad definition ******************************************************************************/ -#ifndef __LIB_LCRD_H -#define __LIB_LCRD_H +#ifndef __LIB_ISULAD_H +#define __LIB_ISULAD_H #include #include @@ -24,8 +24,8 @@ extern "C" { #endif -/* record the lcrd errmsg */ -extern __thread char *g_lcrd_errmsg; +/* record the isulad errmsg */ +extern __thread char *g_isulad_errmsg; #define CONTAINER_LOG_CONFIG_KEY_FILE "log.console.file" #define CONTAINER_LOG_CONFIG_KEY_ROTATE "log.console.filerotate" @@ -38,20 +38,20 @@ extern __thread char *g_lcrd_errmsg; #define AUTH_PLUGIN "authz-broker" -#define LCRD_ISULA_ADAPTER "isula-adapter" -#define LCRD_ISULA_ACCEL_ARGS "isulad.accel.args" -#define LCRD_ISULA_ACCEL_ARGS_SEPERATOR ";" -#define LCRD_ENABLE_PLUGINS "LCRD_ENABLE_PLUGINS" -#define LCRD_ENABLE_PLUGINS_SEPERATOR "," -#define LCRD_ENABLE_PLUGINS_SEPERATOR_CHAR ',' +#define ISULAD_ISULA_ADAPTER "isula-adapter" +#define ISULAD_ISULA_ACCEL_ARGS "isulad.accel.args" +#define ISULAD_ISULA_ACCEL_ARGS_SEPERATOR ";" +#define ISULAD_ENABLE_PLUGINS "ISULAD_ENABLE_PLUGINS" +#define ISULAD_ENABLE_PLUGINS_SEPERATOR "," +#define ISULAD_ENABLE_PLUGINS_SEPERATOR_CHAR ',' #define MAX_HOSTS 10 -/* clear the g_lcrd_errmsg */ +/* clear the g_isulad_errmsg */ #define DAEMON_CLEAR_ERRMSG() do { \ - if (g_lcrd_errmsg != NULL) { \ - free(g_lcrd_errmsg); \ - g_lcrd_errmsg = NULL; \ + if (g_isulad_errmsg != NULL) { \ + free(g_isulad_errmsg); \ + g_isulad_errmsg = NULL; \ } \ } while (0) @@ -63,7 +63,7 @@ typedef enum { REQUIRE_AND_VERIFY_CLIENT_CERT } client_auth_type_t; -struct lcrd_client_cgroup_resources { +struct isulad_client_cgroup_resources { uint16_t blkio_weight; int64_t cpu_shares; int64_t cpu_period; @@ -86,7 +86,7 @@ struct create_custom_config { char **env; /* cgroup resources */ - struct lcrd_client_cgroup_resources cr; + struct isulad_client_cgroup_resources cr; /* hugepage limits */ int hugepage_limits_len; @@ -158,7 +158,7 @@ struct create_custom_config { char *share_ns[NAMESPACE_MAX]; }; -struct lcrd_events_format { +struct isulad_events_format { char *id; uint32_t has_type; container_events_type_t type; @@ -169,7 +169,7 @@ struct lcrd_events_format { types_timestamp_t timestamp; }; -typedef void (handle_events_callback_t)(struct lcrd_events_format *event); +typedef void (handle_events_callback_t)(struct isulad_events_format *event); typedef bool (*stream_check_call_cancelled)(void *context); typedef bool (*stream_write_fun_t)(void *writer, void *data); @@ -186,7 +186,7 @@ typedef struct { stream_read_fun_t read_func; } stream_func_wrapper; -struct lcrd_events_request { +struct isulad_events_request { handle_events_callback_t *cb; bool storeonly; char *id; @@ -194,29 +194,29 @@ struct lcrd_events_request { types_timestamp_t until; }; -struct lcrd_events_response { +struct isulad_events_response { uint32_t server_errono; uint32_t cc; char *errmsg; }; -struct lcrd_copy_from_container_request { +struct isulad_copy_from_container_request { char *id; char *runtime; char *srcpath; }; -struct lcrd_copy_from_container_response { +struct isulad_copy_from_container_response { char *data; size_t data_len; }; -struct lcrd_copy_to_container_data { +struct isulad_copy_to_container_data { char *data; size_t data_len; }; -struct lcrd_logs_request { +struct isulad_logs_request { char *id; char *runtime; @@ -228,47 +228,47 @@ struct lcrd_logs_request { bool details; }; -struct lcrd_logs_response { +struct isulad_logs_response { uint32_t cc; char *errmsg; }; -struct lcrd_health_check_request { +struct isulad_health_check_request { char *service; }; -struct lcrd_health_check_response { +struct isulad_health_check_response { Health_Serving_Status health_status; uint32_t cc; char *errmsg; }; -struct lcrd_container_rename_request { +struct isulad_container_rename_request { char *old_name; char *new_name; }; -struct lcrd_container_rename_response { +struct isulad_container_rename_response { char *id; uint32_t cc; char *errmsg; }; -struct lcrd_container_resize_request { +struct isulad_container_resize_request { char *id; char *suffix; uint32_t height; uint32_t width; }; -struct lcrd_container_resize_response { +struct isulad_container_resize_response { char *id; uint32_t cc; char *errmsg; }; -struct lcrd_image_info { +struct isulad_image_info { char *imageref; char *type; char *digest; @@ -277,14 +277,14 @@ struct lcrd_image_info { int64_t size; /* Bytes */ }; -struct lcrd_create_image_request { - struct lcrd_image_info image_info; +struct isulad_create_image_request { + struct isulad_image_info image_info; }; -struct lcrd_create_image_response { +struct isulad_create_image_response { uint32_t cc; uint32_t server_errono; - struct lcrd_image_info image_info; + struct isulad_image_info image_info; char *errmsg; }; @@ -295,28 +295,28 @@ struct container_log_config { }; void container_log_config_free(struct container_log_config *conf); -void lcrd_events_request_free(struct lcrd_events_request *request); +void isulad_events_request_free(struct isulad_events_request *request); -void lcrd_copy_from_container_request_free(struct lcrd_copy_from_container_request *request); +void isulad_copy_from_container_request_free(struct isulad_copy_from_container_request *request); -void lcrd_copy_from_container_response_free(struct lcrd_copy_from_container_response *response); +void isulad_copy_from_container_response_free(struct isulad_copy_from_container_response *response); -void lcrd_set_error_message(const char *format, ...); +void isulad_set_error_message(const char *format, ...); -void lcrd_try_set_error_message(const char *format, ...); +void isulad_try_set_error_message(const char *format, ...); -void lcrd_append_error_message(const char *format, ...); +void isulad_append_error_message(const char *format, ...); -void lcrd_container_rename_request_free(struct lcrd_container_rename_request *request); +void isulad_container_rename_request_free(struct isulad_container_rename_request *request); -void lcrd_container_rename_response_free(struct lcrd_container_rename_response *response); +void isulad_container_rename_response_free(struct isulad_container_rename_response *response); -void lcrd_container_resize_request_free(struct lcrd_container_resize_request *request); +void isulad_container_resize_request_free(struct isulad_container_resize_request *request); -void lcrd_container_resize_response_free(struct lcrd_container_resize_response *response); +void isulad_container_resize_response_free(struct isulad_container_resize_response *response); -void lcrd_logs_request_free(struct lcrd_logs_request *request); -void lcrd_logs_response_free(struct lcrd_logs_response *response); +void isulad_logs_request_free(struct isulad_logs_request *request); +void isulad_logs_response_free(struct isulad_logs_response *response); #ifdef __cplusplus } #endif diff --git a/src/log.c b/src/log.c index 4b4a36910a81ad49c856a0c8a05f91abc69dd2e5..86fc8d8a0d0e159871437bb9414e4805099fc916 100644 --- a/src/log.c +++ b/src/log.c @@ -32,29 +32,16 @@ const char * const g_log_prio_name[] = { "FATAL", "ALERT", "CRIT", "ERROR", "WARN", "NOTICE", "INFO", "DEBUG", "TRACE" }; -/* predefined priorities. */ -enum log_priority { - LOG_PRIORITY_FATAL = LOG_EMERG, - LOG_PRIORITY_ALERT = LOG_ALERT, - LOG_PRIORITY_CRIT = LOG_CRIT, - LOG_PRIORITY_ERROR = LOG_ERR, - LOG_PRIORITY_WARN = LOG_WARNING, - LOG_PRIORITY_NOTICE = LOG_NOTICE, - LOG_PRIORITY_INFO = LOG_INFO, - LOG_PRIORITY_DEBUG = LOG_DEBUG, - LOG_PRIORITY_TRACE, - LOG_PRIORITY_MAX -}; - #define MAX_MSG_LENGTH 4096 +#define MAX_LOG_PREFIX_LENGTH 15 static __thread char *g_log_prefix = NULL; -static char *g_log_vmname = NULL; static bool g_log_quiet = false; -static int g_log_level = LOG_PRIORITY_DEBUG; +static char *g_log_module = NULL; +static int g_log_level = ISULA_LOG_DEBUG; static int g_log_driver = LOG_DRIVER_STDOUT; -int g_lcrd_log_fd = -1; +int g_isulad_log_fd = -1; /* set log prefix */ void set_log_prefix(const char *prefix) @@ -70,8 +57,8 @@ void set_log_prefix(const char *prefix) void set_default_command_log_config(const char *name, struct log_config *log) { - log->name = name; log->quiet = true; + log->name = name; log->file = NULL; log->priority = "DEBUG"; log->driver = "stdout"; @@ -86,8 +73,7 @@ void free_log_prefix() g_log_prefix = NULL; } -/* write nointr */ -static ssize_t write_nointr(int fd, const void *buf, size_t count) +static ssize_t isulad_save_log(int fd, const void *buf, size_t count) { ssize_t nret = 0; @@ -102,10 +88,8 @@ static ssize_t write_nointr(int fd, const void *buf, size_t count) return nret; } -void log_append_logfile(const struct log_event *event, const char *timestamp, const char *msg); -void log_append_stderr(const struct log_event *event, const char *timestamp, const char *msg); - -int lcrd_unix_trans_to_utc(char *buf, size_t bufsize, const struct timespec *time); +void do_fifo_log(const struct log_object_metadata *meta, const char *timestamp, const char *msg); +void do_stderr_log(const struct log_object_metadata *meta, const char *timestamp, const char *msg); /* change str logdriver to enum */ int change_str_logdriver_to_enum(const char *driver) @@ -164,14 +148,14 @@ static int log_init_checker(const struct log_config *log) return -1; } - for (i = LOG_PRIORITY_FATAL; i < LOG_PRIORITY_MAX; i++) { + for (i = ISULA_LOG_FATAL; i < ISULA_LOG_MAX; i++) { if (strcasecmp(g_log_prio_name[i], log->priority) == 0) { g_log_level = i; break; } } - if (i == LOG_PRIORITY_MAX) { + if (i == ISULA_LOG_MAX) { fprintf(stderr, "Unable to parse logging level:%s\n", log->priority); return -1; } @@ -191,8 +175,8 @@ int log_init(struct log_config *log) int nret = 0; char *full_path = NULL; - if (g_lcrd_log_fd != -1) { - fprintf(stderr, "lcrd log_init called with log already initialized\n"); + if (g_isulad_log_fd != -1) { + fprintf(stderr, "isulad log_init called with log already initialized\n"); return 0; } @@ -200,12 +184,11 @@ int log_init(struct log_config *log) return -1; } - free(g_log_vmname); - g_log_vmname = util_strdup_s(log->name); - + free(g_log_module); + g_log_module = util_strdup_s(log->name); g_log_quiet = log->quiet; - if (log->file == NULL || strcmp(log->file, "none") == 0) { + if (log->file == NULL) { if (g_log_driver == LOG_DRIVER_FIFO) { fprintf(stderr, "Must set log file if driver is %s\n", log->driver); nret = -1; @@ -219,9 +202,9 @@ int log_init(struct log_config *log) nret = -1; goto out; } - g_lcrd_log_fd = open_fifo(full_path); + g_isulad_log_fd = open_fifo(full_path); - if (g_lcrd_log_fd == -1) { + if (g_isulad_log_fd == -1) { nret = -1; } out: @@ -233,83 +216,116 @@ out: return nret; } -/* log append */ -int log_append(const struct log_event *event, const char *format, ...) +static char *parse_timespec_to_human() { - int rc = 0; - va_list args; - char msg[MAX_MSG_LENGTH] = { 0 }; - char date_time[LCRD_LOG_TIME_SIZE] = { 0 }; struct timespec timestamp; + struct tm ptm = {0}; + char date_time[ISULAD_LOG_TIME_MAX_LEN] = { 0 }; + int nret; +#define SEC_TO_NSEC 1000000 +#define FIRST_YEAR_OF_GMT 1900 - va_start(args, format); - rc = vsnprintf(msg, MAX_MSG_LENGTH, format, args); - va_end(args); - if (rc < 0) { - rc = snprintf(msg, MAX_MSG_LENGTH, "%s", "Failed to truncate print error log"); - if (rc < 0 || (size_t)rc >= MAX_MSG_LENGTH) { - return 0; - } + if (clock_gettime(CLOCK_REALTIME, ×tamp) == -1) { + COMMAND_ERROR("Failed to get real time"); + return 0; } - if (clock_gettime(CLOCK_REALTIME, ×tamp) == -1) { - fprintf(stderr, "Failed to get real time"); - return -1; + if (localtime_r(&(timestamp.tv_sec), &ptm) == NULL) { + SYSERROR("Transfer timespec failed"); + return NULL; } - if (lcrd_unix_trans_to_utc(date_time, LCRD_LOG_TIME_SIZE, ×tamp) < 0) { - return 0; + + nret = snprintf(date_time, ISULAD_LOG_TIME_MAX_LEN, "%04d%02d%02d%02d%02d%02d.%03ld", + ptm.tm_year + FIRST_YEAR_OF_GMT, ptm.tm_mon + 1, ptm.tm_mday, ptm.tm_hour, ptm.tm_min, ptm.tm_sec, + timestamp.tv_nsec / SEC_TO_NSEC); + + if (nret < 0 || nret >= ISULAD_LOG_TIME_MAX_LEN) { + COMMAND_ERROR("Sprintf failed"); + return NULL; } + return util_strdup_s(date_time); +} + +static int do_log_by_driver(const struct log_object_metadata *meta, const char *msg, const char *date_time) +{ switch (g_log_driver) { case LOG_DRIVER_STDOUT: if (g_log_quiet) { break; } - log_append_stderr(event, date_time, msg); + do_stderr_log(meta, date_time, msg); break; case LOG_DRIVER_FIFO: - if (g_lcrd_log_fd == -1) { + if (g_isulad_log_fd == -1) { fprintf(stderr, "Do not set log file\n"); return -1; } - log_append_logfile(event, date_time, msg); + do_fifo_log(meta, date_time, msg); break; case LOG_DRIVER_NOSET: break; default: - fprintf(stderr, "Invalid log driver\n"); + COMMAND_ERROR("Invalid log driver"); return -1; } - return 0; } -/* log append logfile */ -void log_append_logfile(const struct log_event *event, const char *timestamp, const char *msg) +int new_log(const struct log_object_metadata *meta, const char *format, ...) +{ + int rc = 0; + int ret = 0; + va_list args; + char msg[MAX_MSG_LENGTH] = { 0 }; + char *date_time = NULL; + + va_start(args, format); + rc = vsnprintf(msg, MAX_MSG_LENGTH, format, args); + va_end(args); + if (rc < 0) { + rc = snprintf(msg, MAX_MSG_LENGTH, "%s", "Failed to truncate print error log"); + if (rc < 0 || (size_t)rc >= MAX_MSG_LENGTH) { + return 0; + } + } + + date_time = parse_timespec_to_human(); + if (date_time == NULL) { + goto out; + } + + ret = do_log_by_driver(meta, msg, date_time); + +out: + free(date_time); + return ret; +} + +void do_fifo_log(const struct log_object_metadata *meta, const char *timestamp, const char *msg) { int log_fd = -1; int nret = 0; size_t size = 0; char *tmp_prefix = NULL; - char log_buffer[LCRD_LOG_BUFFER_SIZE] = { 0 }; + char log_buffer[ISULAD_LOG_BUFFER_SIZE] = { 0 }; - if (event == NULL || event->priority > g_log_level) { + if (meta == NULL || meta->level > g_log_level) { return; } - log_fd = g_lcrd_log_fd; + log_fd = g_isulad_log_fd; if (log_fd == -1) { return; } - tmp_prefix = g_log_prefix != NULL ? g_log_prefix : g_log_vmname; - if (tmp_prefix != NULL && strlen(tmp_prefix) > 15) { - tmp_prefix = tmp_prefix + (strlen(tmp_prefix) - 15); + tmp_prefix = g_log_prefix != NULL ? g_log_prefix : g_log_module; + if (tmp_prefix != NULL && strlen(tmp_prefix) > MAX_LOG_PREFIX_LENGTH) { + tmp_prefix = tmp_prefix + (strlen(tmp_prefix) - MAX_LOG_PREFIX_LENGTH); } - if (event->locinfo != NULL) { - nret = snprintf(log_buffer, sizeof(log_buffer), "%15s %s %-8s %s - %s:%s:%d - %s", - tmp_prefix ? tmp_prefix : "", timestamp, g_log_prio_name[event->priority], - g_log_vmname ? g_log_vmname : "lcrd", event->locinfo->file, event->locinfo->func, - event->locinfo->line, msg); + if (meta->file != NULL) { + nret = snprintf(log_buffer, sizeof(log_buffer), "%15s %s %-8s %s:%s:%d - %s", + tmp_prefix ? tmp_prefix : "", timestamp, g_log_prio_name[meta->level], + meta->file, meta->func, meta->line, msg); } else { nret = snprintf(log_buffer, sizeof(log_buffer), "%s %s", timestamp, msg); } @@ -325,121 +341,34 @@ void log_append_logfile(const struct log_event *event, const char *timestamp, co log_buffer[size] = '\n'; - if (write_nointr(log_fd, log_buffer, (size + 1)) == -1) { - fprintf(stderr, "write log into logfile failed"); + if (isulad_save_log(log_fd, log_buffer, (size + 1)) == -1) { + COMMAND_ERROR("Write log into logfile failed"); } } /* log append stderr */ -void log_append_stderr(const struct log_event *event, const char *timestamp, const char *msg) +void do_stderr_log(const struct log_object_metadata *meta, const char *timestamp, const char *msg) { char *tmp_prefix = NULL; - if (event == NULL || event->priority > g_log_level) { + if (meta == NULL || meta->level > g_log_level) { return; } - tmp_prefix = g_log_prefix ? g_log_prefix : g_log_vmname; - if (tmp_prefix != NULL && strlen(tmp_prefix) > 15) { - tmp_prefix = tmp_prefix + (strlen(tmp_prefix) - 15); + tmp_prefix = g_log_prefix ? g_log_prefix : g_log_module; + if (tmp_prefix != NULL && strlen(tmp_prefix) > MAX_LOG_PREFIX_LENGTH) { + tmp_prefix = tmp_prefix + (strlen(tmp_prefix) - MAX_LOG_PREFIX_LENGTH); } - if (event->locinfo != NULL) { + if (meta->file != NULL) { fprintf(stderr, "%15s ", tmp_prefix ? tmp_prefix : ""); } fprintf(stderr, "%s ", timestamp); - if (event->locinfo != NULL) { - fprintf(stderr, "%-8s ", g_log_prio_name[event->priority]); - fprintf(stderr, "%s - ", g_log_vmname ? g_log_vmname : "lcrd"); - fprintf(stderr, "%s:%s:%d - ", event->locinfo->file, event->locinfo->func, event->locinfo->line); + if (meta->file != NULL) { + fprintf(stderr, "%-8s ", g_log_prio_name[meta->level]); + fprintf(stderr, "%s:%s:%d - ", meta->file, meta->func, meta->line); } fprintf(stderr, "%s", msg); fprintf(stderr, "\n"); } -/* lcrd unix trans to utc */ -int lcrd_unix_trans_to_utc(char *buf, size_t bufsize, const struct timespec *time) -{ - int ret = 0; - int64_t trans_to_days = 0; - int64_t all_days = 0; - int64_t age = 0; - int64_t doa = 0; - int64_t yoa = 0; - int64_t real_year = 0; - int64_t doy = 0; - int64_t nom = 0; - int64_t real_day = 0; - int64_t real_month = 0; - int64_t trans_to_sec = 0; - int64_t real_hours = 0; - int64_t hours_to_sec = 0; - int64_t real_minutes = 0; - int64_t real_seconds = 0; - char ns[LCRD_NUMSTRLEN64] = { 0 }; - - /* Transtate seconds to number of days. */ - trans_to_days = time->tv_sec / 86400; - - /* Calculate days from 0000-03-01 to 1970-01-01.Days base it */ - all_days = trans_to_days + 719468; - - /* compute the age.One age means 400 years(146097 days) */ - age = (all_days >= 0 ? all_days : all_days - 146096) / 146097; - - /* The day-of-age (doa) can then be found by subtracting the genumber */ - doa = (all_days - age * 146097); - - /* Calculate year-of-age (yoa, range [0, 399]) */ - yoa = ((doa - (doa / 1460)) + (doa / 36524) - (doa / 146096)) / 365; - - /* Compute the year this moment */ - real_year = yoa + age * 400; - - /* Calculate the day-of-year */ - doy = doa - (365 * yoa + yoa / 4 - yoa / 100); - - /* Compute the month number. */ - nom = (5 * doy + 2) / 153; - - /* Compute the real_day. */ - real_day = (doy - ((153 * nom + 2) / 5)) + 1; - - /* Compute the correct month. */ - real_month = nom + (nom < 10 ? 3 : -9); - - /* Add one year before March */ - if (real_month < 3) { - real_year++; - } - - /* Translate days in the age to seconds. */ - trans_to_sec = trans_to_days * 86400; - - /* Compute the real_hours */ - real_hours = (time->tv_sec - trans_to_sec) / 3600; - - /* Translate the real hours to seconds. */ - hours_to_sec = real_hours * 3600; - - /* Calculate the real minutes */ - real_minutes = ((time->tv_sec - trans_to_sec) - hours_to_sec) / 60; - - /* Calculate the real seconds */ - real_seconds = (((time->tv_sec - trans_to_sec) - hours_to_sec) - (real_minutes * 60)); - - ret = snprintf(ns, LCRD_NUMSTRLEN64, "%ld", time->tv_nsec); - if (ret < 0 || (size_t)ret >= LCRD_NUMSTRLEN64) { - return -1; - } - - /* Create the final timestamp */ - ret = snprintf(buf, bufsize, "%" PRId64 "%02" PRId64 "%02" PRId64 "%02" PRId64 "%02" PRId64 "%02" PRId64 ".%.3s", - real_year, real_month, real_day, real_hours, real_minutes, real_seconds, ns); - if (ret < 0 || (size_t)ret >= bufsize) { - return -1; - } - - return 0; -} - diff --git a/src/log.h b/src/log.h index 29cae6564a31ce94640e3d053b5191519d117a03..ce324aa75a061d93a9be0b856807e9668d71968f 100644 --- a/src/log.h +++ b/src/log.h @@ -12,14 +12,12 @@ * Create: 2018-11-08 * Description: provide container log function definition ******************************************************************************/ -#ifndef __LCRD_LOG_H -#define __LCRD_LOG_H +#ifndef __ISULAD_LOG_H +#define __ISULAD_LOG_H -#include #include +#include #include -#include -#include #ifdef __cplusplus extern "C" { @@ -29,46 +27,48 @@ extern "C" { #define O_CLOEXEC 02000000 #endif -#ifndef F_DUPFD_CLOEXEC -#define F_DUPFD_CLOEXEC 1030 -#endif +#define ISULAD_LOG_BUFFER_SIZE 4096 -#define LCRD_LOG_BUFFER_SIZE 4096 +#define ISULAD_LOG_TIME_MAX_LEN 21 -/* We're logging in seconds and nanoseconds. Assuming that the underlying - * datatype is currently at maximum a 64bit integer, we have a date string that - * is of maximum length (2^64 - 1) * 2 = (21 + 21) = 42. - * */ -#define LCRD_LOG_TIME_SIZE 42 +enum g_log_driver { + LOG_DRIVER_STDOUT, + LOG_DRIVER_FIFO, + LOG_DRIVER_NOSET, +}; -enum g_log_driver { LOG_DRIVER_STDOUT, LOG_DRIVER_FIFO, LOG_DRIVER_SYSLOG, LOG_DRIVER_NOSET }; +enum isula_log_level { + ISULA_LOG_FATAL = 0, + ISULA_LOG_ALERT, + ISULA_LOG_CRIT, + ISULA_LOG_ERROR, + ISULA_LOG_WARN, + ISULA_LOG_NOTICE, + ISULA_LOG_INFO, + ISULA_LOG_DEBUG, + ISULA_LOG_TRACE, + ISULA_LOG_MAX +}; struct log_config { + bool quiet; const char *name; const char *file; const char *priority; const char *prefix; const char *driver; - bool quiet; }; -/* location information of the logging event */ -struct log_locinfo { +/* brief logging event object */ +struct log_object_metadata { + /* location information of the logging item */ const char *file; const char *func; int line; -}; - -#define LOG_LOCINFO_INIT \ - { \ - .file = __FILE__, .func = __func__, .line = __LINE__, \ - } -/* brief logging event object */ -struct log_event { - int priority; - struct log_locinfo *locinfo; + int level; }; + int log_init(struct log_config *log); void set_default_command_log_config(const char *name, struct log_config *log); @@ -79,87 +79,47 @@ void free_log_prefix(); int change_str_logdriver_to_enum(const char *driver); -int log_append(const struct log_event *event, const char *format, ...); +int new_log(const struct log_object_metadata *meta, const char *format, ...); -#define DEBUG(format, ...) \ - do { \ - struct log_locinfo locinfo = LOG_LOCINFO_INIT; \ - struct log_event append_log_event; \ - append_log_event.locinfo = &locinfo; \ - append_log_event.priority = LOG_DEBUG; \ - (void)log_append(&append_log_event, format, ##__VA_ARGS__); \ +#define COMMON_LOG(loglevel, format, ...) \ + do { \ + struct log_object_metadata meta = { \ + .file = __FILENAME__, .func = __func__, .line = __LINE__, .level = loglevel, \ + }; \ + (void)new_log(&meta, format, ##__VA_ARGS__); \ } while (0) +#define DEBUG(format, ...) \ + COMMON_LOG(ISULA_LOG_DEBUG, format, ##__VA_ARGS__) + #define INFO(format, ...) \ - do { \ - struct log_locinfo locinfo = LOG_LOCINFO_INIT; \ - struct log_event append_log_event; \ - append_log_event.locinfo = &locinfo; \ - append_log_event.priority = LOG_INFO; \ - (void)log_append(&append_log_event, format, ##__VA_ARGS__); \ - } while (0) + COMMON_LOG(ISULA_LOG_INFO, format, ##__VA_ARGS__) #define NOTICE(format, ...) \ - do { \ - struct log_locinfo locinfo = LOG_LOCINFO_INIT; \ - struct log_event append_log_event; \ - append_log_event.locinfo = &locinfo; \ - append_log_event.priority = LOG_NOTICE; \ - (void)log_append(&append_log_event, format, ##__VA_ARGS__); \ - } while (0) + COMMON_LOG(ISULA_LOG_NOTICE, format, ##__VA_ARGS__) #define WARN(format, ...) \ - do { \ - struct log_locinfo locinfo = LOG_LOCINFO_INIT; \ - struct log_event append_log_event; \ - append_log_event.locinfo = &locinfo; \ - append_log_event.priority = LOG_WARNING; \ - (void)log_append(&append_log_event, format, ##__VA_ARGS__); \ - } while (0) + COMMON_LOG(ISULA_LOG_WARN, format, ##__VA_ARGS__) #define ERROR(format, ...) \ - do { \ - struct log_locinfo locinfo = LOG_LOCINFO_INIT; \ - struct log_event append_log_event; \ - append_log_event.locinfo = &locinfo; \ - append_log_event.priority = LOG_ERR; \ - (void)log_append(&append_log_event, format, ##__VA_ARGS__); \ - } while (0) - -#define EVENT(format, ...) \ - do { \ - struct log_event append_log_event; \ - append_log_event.locinfo = NULL; \ - append_log_event.priority = LOG_ERR; \ - log_append(&append_log_event, format, ##__VA_ARGS__); \ + COMMON_LOG(ISULA_LOG_ERROR, format, ##__VA_ARGS__) + +#define EVENT(format, ...) \ + do { \ + struct log_object_metadata meta = { \ + .file = NULL, .func = NULL, .line = 0, .level = ISULA_LOG_ERROR, \ + }; \ + (void)new_log(&meta, format, ##__VA_ARGS__); \ } while (0) #define CRIT(format, ...) \ - do { \ - struct log_locinfo locinfo = LOG_LOCINFO_INIT; \ - struct log_event append_log_event; \ - append_log_event.locinfo = &locinfo; \ - append_log_event.priority = LOG_CRIT; \ - (void)log_append(&append_log_event, format, ##__VA_ARGS__); \ - } while (0) + COMMON_LOG(ISULA_LOG_CRIT, format, ##__VA_ARGS__) #define ALERT(format, ...) \ - do { \ - struct log_locinfo locinfo = LOG_LOCINFO_INIT; \ - struct log_event append_log_event; \ - append_log_event.locinfo = &locinfo; \ - append_log_event.priority = LOG_ALERT; \ - (void)log_append(&append_log_event, format, ##__VA_ARGS__); \ - } while (0) + COMMON_LOG(ISULA_LOG_ALERT, format, ##__VA_ARGS__) #define FATAL(format, ...) \ - do { \ - struct log_locinfo locinfo = LOG_LOCINFO_INIT; \ - struct log_event append_log_event; \ - append_log_event.locinfo = &locinfo; \ - append_log_event.priority = LOG_EMERG; \ - (void)log_append(&append_log_event, format, ##__VA_ARGS__); \ - } while (0) + COMMON_LOG(ISULA_LOG_FATAL, format, ##__VA_ARGS__) #define SYSERROR(format, ...) \ do { \ @@ -168,12 +128,12 @@ int log_append(const struct log_event *event, const char *format, ...); #define COMMAND_ERROR(fmt, args...) \ do { \ - fprintf(stderr, fmt "\n", ##args); \ + (void)fprintf(stderr, fmt "\n", ##args); \ } while (0) #ifdef __cplusplus } #endif -#endif /* __LCRD_LOG_H */ +#endif /* __ISULAD_LOG_H */ diff --git a/src/map/map.h b/src/map/map.h index d6f7ebeb2ab75dcebd4747f9e18d1e5150b6cabd..79b95b01c354e6b3c46a291afa7cec937bcb95c0 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -12,8 +12,8 @@ * Create: 2018-11-08 * Description: provide container map definition ******************************************************************************/ -#ifndef __LCRD_MAP_H__ -#define __LCRD_MAP_H__ +#ifndef __ISULAD_MAP_H__ +#define __ISULAD_MAP_H__ #include "rb_tree.h" @@ -103,5 +103,5 @@ void map_clear(map_t *map); } #endif -#endif /* __LCRD_MAP_H__ */ +#endif /* __ISULAD_MAP_H__ */ diff --git a/src/pack_config.c b/src/pack_config.c index 102c44fb642baaad42195023ecfb45e55bf33225..8eb44a497c423a3470cfdbb4d48cf53ec3c1e302 100644 --- a/src/pack_config.c +++ b/src/pack_config.c @@ -71,7 +71,7 @@ cleanup: return ret; } -static int pack_host_config_ns_change_files(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_config_ns_change_files(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -101,7 +101,7 @@ out: return ret; } -static int pack_host_config_cap_add(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_config_cap_add(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -140,7 +140,7 @@ out: return ret; } -static int pack_host_config_cap_drop(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_config_cap_drop(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -180,7 +180,7 @@ out: return ret; } -static int pack_host_config_caps(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_config_caps(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; @@ -200,7 +200,7 @@ out: return ret; } -static int pack_host_network_extra_hosts(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_network_extra_hosts(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -226,7 +226,7 @@ out: return ret; } -static int pack_host_network_dns(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_network_dns(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -253,7 +253,7 @@ out: return ret; } -static int pack_host_network_dns_options(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_network_dns_options(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -280,7 +280,7 @@ out: return ret; } -static int pack_host_network_dns_search(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_network_dns_search(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -307,7 +307,7 @@ out: return ret; } -static int pack_host_config_network(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_config_network(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; @@ -585,7 +585,7 @@ out: return ulimit; } -static void pack_cgroup_resources_cpu(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static void pack_cgroup_resources_cpu(host_config *dstconfig, const isula_host_config_t *srcconfig) { /* cgroup blkio weight */ if (srcconfig->cr->blkio_weight) { @@ -626,7 +626,7 @@ static void pack_cgroup_resources_cpu(host_config *dstconfig, const lcrc_host_co } } -static void pack_cgroup_resources_mem(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static void pack_cgroup_resources_mem(host_config *dstconfig, const isula_host_config_t *srcconfig) { /* memory limit */ if (srcconfig->cr->memory) { @@ -649,7 +649,7 @@ static void pack_cgroup_resources_mem(host_config *dstconfig, const lcrc_host_co } } -static void pack_cgroup_resources(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static void pack_cgroup_resources(host_config *dstconfig, const isula_host_config_t *srcconfig) { pack_cgroup_resources_cpu(dstconfig, srcconfig); @@ -663,7 +663,7 @@ static void pack_cgroup_resources(host_config *dstconfig, const lcrc_host_config dstconfig->oom_score_adj = (int)srcconfig->cr->oom_score_adj; } -static int pack_hostconfig_ulimits(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_hostconfig_ulimits(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i; @@ -712,7 +712,7 @@ out: return ret; } -static int pack_hostconfig_cgroup(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_hostconfig_cgroup(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; @@ -1163,7 +1163,7 @@ erro_out: return NULL; } -static int parse_seccomp(const lcrc_host_config_t *srcconfig, host_config *dstconfig) +static int parse_seccomp(const isula_host_config_t *srcconfig, host_config *dstconfig) { int ret = 0; int nret = 0; @@ -1241,7 +1241,7 @@ out: return ret; } -static int parse_no_new_privileges(const lcrc_host_config_t *srcconfig, host_config *dstconfig) +static int parse_no_new_privileges(const isula_host_config_t *srcconfig, host_config *dstconfig) { int ret = 0; size_t i = 0; @@ -1272,7 +1272,7 @@ static int parse_no_new_privileges(const lcrc_host_config_t *srcconfig, host_con return ret; } -int generate_storage_opts(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +int generate_storage_opts(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t j; @@ -1301,7 +1301,7 @@ out: return ret; } -static int generate_sysctls(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +static int generate_sysctls(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t j; @@ -1326,7 +1326,7 @@ out: return ret; } -int generate_devices(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +int generate_devices(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -1359,7 +1359,7 @@ out: return ret; } -static int generate_blkio_weight_device(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +static int generate_blkio_weight_device(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -1395,7 +1395,7 @@ out: return ret; } -static int generate_blkio_throttle_read_bps_device(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +static int generate_blkio_throttle_read_bps_device(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -1437,7 +1437,7 @@ out: return ret; } -static int generate_blkio_throttle_write_bps_device(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +static int generate_blkio_throttle_write_bps_device(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -1479,7 +1479,7 @@ out: return ret; } -static int generate_blkio(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +static int generate_blkio(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret; @@ -1504,7 +1504,7 @@ out: return ret; } -int generate_hugetlb_limits(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +int generate_hugetlb_limits(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -1538,7 +1538,7 @@ out: return ret; } -int generate_binds(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +int generate_binds(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -1567,7 +1567,7 @@ out: return ret; } -int generate_groups(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +int generate_groups(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; size_t i = 0; @@ -1595,7 +1595,7 @@ out: return ret; } -int generate_security(host_config **dstconfig, const lcrc_host_config_t *srcconfig) +int generate_security(host_config **dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; @@ -1636,7 +1636,7 @@ static inline void check_and_strdup_s(char **dst_item, const char *src_item) } } -static int pack_host_config_common(host_config *dstconfig, const lcrc_host_config_t *srcconfig) +static int pack_host_config_common(host_config *dstconfig, const isula_host_config_t *srcconfig) { int ret = 0; @@ -1709,7 +1709,7 @@ out: return ret; } -int generate_hostconfig(const lcrc_host_config_t *srcconfig, char **hostconfigstr) +int generate_hostconfig(const isula_host_config_t *srcconfig, char **hostconfigstr) { int ret = 0; parser_error err = NULL; @@ -1776,7 +1776,7 @@ out: } static int pack_container_custom_config_log(container_custom_config *custom_spec, - const lcrc_container_config_t *custom_conf) + const isula_container_config_t *custom_conf) { int ret = 0; @@ -1802,7 +1802,7 @@ out: } static int pack_container_custom_config_args(container_custom_config *custom_spec, - const lcrc_container_config_t *custom_conf) + const isula_container_config_t *custom_conf) { int ret = 0; int i; @@ -1841,7 +1841,7 @@ out: } static int pack_container_custom_config_mounts(container_custom_config *custom_spec, - const lcrc_container_config_t *custom_conf) + const isula_container_config_t *custom_conf) { int ret = 0; int i = 0; @@ -1868,7 +1868,7 @@ out: } static int pack_container_custom_config_array(container_custom_config *custom_spec, - const lcrc_container_config_t *custom_conf) + const isula_container_config_t *custom_conf) { int ret = 0; int i = 0; @@ -1894,7 +1894,7 @@ out: return ret; } -static bool have_health_check(const lcrc_container_config_t *custom_conf) +static bool have_health_check(const isula_container_config_t *custom_conf) { bool have_health_settings = false; @@ -1930,7 +1930,7 @@ out: } static int pack_custom_with_health_check(container_custom_config *custom_spec, - const lcrc_container_config_t *custom_conf, bool have_health_settings, + const isula_container_config_t *custom_conf, bool have_health_settings, defs_health_check *health_config) { int ret = 0; @@ -1963,7 +1963,7 @@ out: } static int pack_container_custom_config_health(container_custom_config *custom_spec, - const lcrc_container_config_t *custom_conf) + const isula_container_config_t *custom_conf) { int ret = 0; bool have_health_settings = false; @@ -2003,7 +2003,7 @@ out: } static int pack_container_custom_config_annotation(container_custom_config *custom_spec, - const lcrc_container_config_t *custom_conf) + const isula_container_config_t *custom_conf) { int ret = 0; size_t j; @@ -2029,7 +2029,7 @@ out: } static int pack_container_custom_config_pre(container_custom_config *custom_spec, - const lcrc_container_config_t *custom_conf) + const isula_container_config_t *custom_conf) { int ret = 0; @@ -2063,7 +2063,7 @@ out: /* translate create_custom_config to container_custom_config */ static int pack_container_custom_config(container_custom_config *custom_spec, - const lcrc_container_config_t *custom_conf) + const isula_container_config_t *custom_conf) { int ret = -1; @@ -2114,7 +2114,7 @@ out: return ret; } -int generate_container_config(const lcrc_container_config_t *custom_conf, char **custom_config_str) +int generate_container_config(const isula_container_config_t *custom_conf, char **custom_config_str) { int ret = 0; container_custom_config *custom_spec = NULL; diff --git a/src/pack_config.h b/src/pack_config.h index b6386f2f7914877dfafeadc6b0f8ae11e89bef73..2c48f1abd497bf86710b2e5492f07d069fbaf35d 100644 --- a/src/pack_config.h +++ b/src/pack_config.h @@ -15,15 +15,15 @@ #ifndef __PACK_CONFIG_H__ #define __PACK_CONFIG_H__ -#include "liblcrc.h" +#include "libisula.h" #ifdef __cplusplus extern "C" { #endif -int generate_hostconfig(const lcrc_host_config_t *srcconfig, char **hostconfigstr); +int generate_hostconfig(const isula_host_config_t *srcconfig, char **hostconfigstr); -int generate_container_config(const lcrc_container_config_t *custom_conf, +int generate_container_config(const isula_container_config_t *custom_conf, char **custom_config_str); #ifdef __cplusplus diff --git a/src/path.h b/src/path.h index 988d31e6a4a5c08cbabfaf5be5634f28c1b81558..75156674e02b5d6a0d981b5198d13f0222074e88 100644 --- a/src/path.h +++ b/src/path.h @@ -12,8 +12,8 @@ * Create: 2018-11-08 * Description: provide container path function definition ******************************************************************************/ -#ifndef __LCRD_PATH_H_ -#define __LCRD_PATH_H_ +#ifndef __ISULAD_PATH_H_ +#define __ISULAD_PATH_H_ #ifdef __cplusplus extern "C" { diff --git a/src/plugin/plugin.c b/src/plugin/plugin.c index c0de76a291e6037256ca30badca57f30b094d29d..1f98a71c76adbe7e9d8bd0561adfa66502c72c54 100644 --- a/src/plugin/plugin.c +++ b/src/plugin/plugin.c @@ -27,7 +27,7 @@ #include "utils.h" #include "parser.h" #include "buffer.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "specs.h" #include "specs_extend.h" #include "rest_common.h" @@ -47,7 +47,7 @@ #include "plugin_event_post_remove_request.h" #include "plugin_event_post_remove_response.h" -#define plugin_socket_path "/run/lcrd/plugins" +#define plugin_socket_path "/run/isulad/plugins" #define plugin_socket_file_regex ".*.sock$" // suffix is '.sock' @@ -120,9 +120,9 @@ static char *join_enable_plugins(const char *plugins) return util_strdup_s(plugins); } - tmp = util_string_append(LCRD_ENABLE_PLUGINS_SEPERATOR, default_plugins); + tmp = util_string_append(ISULAD_ENABLE_PLUGINS_SEPERATOR, default_plugins); if (tmp == NULL) { - ERROR("string append failed %s -> %s", LCRD_ENABLE_PLUGINS_SEPERATOR, default_plugins); + ERROR("string append failed %s -> %s", ISULAD_ENABLE_PLUGINS_SEPERATOR, default_plugins); goto out; } @@ -150,14 +150,14 @@ static char *get_uniq_enable_plugins(const oci_runtime_spec *oci) goto failed; } - names = oci_container_get_env(oci, LCRD_ENABLE_PLUGINS); + names = oci_container_get_env(oci, ISULAD_ENABLE_PLUGINS); full = join_enable_plugins(names); if (full == NULL) { INFO("no plugins enabled"); goto failed; } - raw = util_string_split(full, LCRD_ENABLE_PLUGINS_SEPERATOR_CHAR); + raw = util_string_split(full, ISULAD_ENABLE_PLUGINS_SEPERATOR_CHAR); if (raw == NULL) { ERROR("split plugin name failed"); goto failed; @@ -175,13 +175,13 @@ static char *get_uniq_enable_plugins(const oci_runtime_spec *oci) } } - names = util_string_join(LCRD_ENABLE_PLUGINS_SEPERATOR, (const char **)arr, util_array_len((const char **)arr)); + names = util_string_join(ISULAD_ENABLE_PLUGINS_SEPERATOR, (const char **)arr, util_array_len((const char **)arr)); if (names == NULL) { ERROR("join uniq plugin name failed"); goto failed; } - full = util_string_append(names, LCRD_ENABLE_PLUGINS "="); + full = util_string_append(names, ISULAD_ENABLE_PLUGINS "="); if (full == NULL) { ERROR("init uniq enable plugins env failed"); goto failed; @@ -223,7 +223,7 @@ static int set_env_enable_plugins(oci_runtime_spec *oci) goto failed; } - if (util_env_insert(&oci->process->env, &oci->process->env_len, LCRD_ENABLE_PLUGINS, strlen(LCRD_ENABLE_PLUGINS), + if (util_env_insert(&oci->process->env, &oci->process->env_len, ISULAD_ENABLE_PLUGINS, strlen(ISULAD_ENABLE_PLUGINS), uniq)) { WARN("set env %s failed", uniq); } @@ -247,7 +247,7 @@ static char **get_enable_plugins(const char *plugins) return dst; } - arr = util_string_split(plugins, LCRD_ENABLE_PLUGINS_SEPERATOR_CHAR); + arr = util_string_split(plugins, ISULAD_ENABLE_PLUGINS_SEPERATOR_CHAR); if (arr == NULL) { ERROR("Out of memory"); goto out; @@ -297,7 +297,7 @@ static int get_plugin_dir(char *plugin_dir) return -1; } - statedir = conf_get_lcrd_statedir(); + statedir = conf_get_isulad_statedir(); if (statedir == NULL) { ERROR("failed get statedir"); return -1; @@ -951,7 +951,7 @@ static bool plugin_useby_container(const plugin_t *plugin, const container_t *co return ok; } - plugin_names = container_get_env_nolock(cont, LCRD_ENABLE_PLUGINS); + plugin_names = container_get_env_nolock(cont, ISULAD_ENABLE_PLUGINS); pnames = get_enable_plugins(plugin_names); for (i = 0; i < util_array_len((const char **)pnames); i++) { @@ -987,7 +987,7 @@ static int unpack_init_response(const struct parsed_http_message *message, void ret = check_err(resp->err_code, resp->err_message); if (ret != 0) { - lcrd_set_error_message(resp->err_message); + isulad_set_error_message(resp->err_message); ERROR("init response error massge (%d)%s", resp->err_code, resp->err_message); goto out; } @@ -1380,7 +1380,7 @@ static int plugin_event_handle_dispath(const container_t *cont, uint64_t pe) return 0; } - plugins = container_get_env_nolock(cont, LCRD_ENABLE_PLUGINS); + plugins = container_get_env_nolock(cont, ISULAD_ENABLE_PLUGINS); ret = plugin_event_handle_dispath_impl(cid, plugins, pe); free(cid); free(plugins); @@ -1410,7 +1410,7 @@ static int unpack_event_pre_create_response(const struct parsed_http_message *me ret = check_err(resp->err_code, resp->err_message); if (ret) { - lcrd_set_error_message(resp->err_message); + isulad_set_error_message(resp->err_message); ret = -1; ERROR("pre-create response error massge (%d)%s", resp->err_code, resp->err_message); goto out; @@ -1533,7 +1533,7 @@ int plugin_event_container_pre_create(const char *cid, oci_runtime_spec *ocic) } set_env_enable_plugins(ocic); - plugin_names = oci_container_get_env(ocic, LCRD_ENABLE_PLUGINS); + plugin_names = oci_container_get_env(ocic, ISULAD_ENABLE_PLUGINS); pnames = get_enable_plugins(plugin_names); if (pnames == NULL) { goto out; @@ -1602,7 +1602,7 @@ static int unpack_event_pre_start_response(const struct parsed_http_message *mes ret = check_err(resp->err_code, resp->err_message); if (ret != 0) { - lcrd_set_error_message(resp->err_message); + isulad_set_error_message(resp->err_message); ERROR("pre-start response error massge (%d)%s", resp->err_code, resp->err_message); goto out; } @@ -1699,7 +1699,7 @@ static int unpack_event_post_stop_response(const struct parsed_http_message *mes ret = check_err(resp->err_code, resp->err_message); if (ret != 0) { - lcrd_set_error_message(resp->err_message); + isulad_set_error_message(resp->err_message); ERROR("post-stop response error massge (%d)%s", resp->err_code, resp->err_message); goto out; } @@ -1797,7 +1797,7 @@ static int unpack_event_post_remove_response(const struct parsed_http_message *m ret = check_err(resp->err_code, resp->err_message); if (ret != 0) { - lcrd_set_error_message(resp->err_message); + isulad_set_error_message(resp->err_message); ERROR("post-remove response error massge (%d)%s", resp->err_code, resp->err_message); goto out; } @@ -1895,7 +1895,7 @@ int plugin_event_container_post_remove2(const char *cid, const oci_runtime_spec return 0; } - plugins = oci_container_get_env(oci, LCRD_ENABLE_PLUGINS); + plugins = oci_container_get_env(oci, ISULAD_ENABLE_PLUGINS); cidx = util_strdup_s(cid); if (cidx == NULL) { ERROR("out of memory"); diff --git a/src/plugin/plugin.h b/src/plugin/plugin.h index aae99f57ce9d0e1bf78822e8fdb3f579b2428c16..50a84cf107f2a0f1d03504070f2e94cbf3d83c6c 100644 --- a/src/plugin/plugin.h +++ b/src/plugin/plugin.h @@ -81,12 +81,12 @@ typedef struct plugin_manager { plugin_manager_t *g_plugin_manager; /* - * init at lcrd start, scan and init/sync all plugins + * init at isulad start, scan and init/sync all plugins */ int pm_init(void); int pm_scan(void); /* - * destroy at lcrd exit + * destroy at isulad exit */ int pm_destroy(); /* diff --git a/src/runtime/lcr/lcr_rt_ops.c b/src/runtime/lcr/lcr_rt_ops.c index e66a8aeaae638777a53ae732da745b069afce14f..72a6fa8a0ccfd78f0c97a64b66cf6a9450790f4e 100644 --- a/src/runtime/lcr/lcr_rt_ops.c +++ b/src/runtime/lcr/lcr_rt_ops.c @@ -22,7 +22,7 @@ #include "engine.h" #include "callback.h" #include "error.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "runtime.h" bool rt_lcr_detect(const char *runtime) @@ -59,9 +59,9 @@ int rt_lcr_create(const char *name, const char *runtime, const rt_create_params_ ERROR("Failed to create container"); const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Create container error: %s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Create container error: %s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg + : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -135,9 +135,9 @@ int rt_lcr_start(const char *name, const char *runtime, const rt_start_params_t if (!engine_ops->engine_start_op(&request)) { const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Start container error: %s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Start container error: %s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg + : DEF_ERR_RUNTIME_STR); ERROR("Start container error: %s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; @@ -176,9 +176,9 @@ int rt_lcr_clean_resource(const char *name, const char *runtime, const rt_clean_ if (!engine_ops->engine_clean_op(name, params->rootpath, params->logpath, params->loglevel, params->pid)) { const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_try_set_error_message("Clean resource container error;%s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + isulad_try_set_error_message("Clean resource container error;%s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg + : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -205,7 +205,7 @@ static int remove_container_rootpath(const char *id, const char *root_path) if (ret != 0) { const char *tmp_err = (errno != 0) ? strerror(errno) : "error"; ERROR("Failed to delete container's root directory %s: %s", cont_root_path, tmp_err); - lcrd_set_error_message("Failed to delete container's root directory %s: %s", cont_root_path, tmp_err); + isulad_set_error_message("Failed to delete container's root directory %s: %s", cont_root_path, tmp_err); ret = -1; goto out; } @@ -229,8 +229,8 @@ int rt_lcr_rm(const char *name, const char *runtime, const rt_rm_params_t *param if (!engine_ops->engine_delete_op(name, params->rootpath)) { ret = -1; const char *tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Runtime delete container error: %s", - (tmpmsg != NULL && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Runtime delete container error: %s", + (tmpmsg != NULL && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ERROR("Runtime delete container error: %s", (tmpmsg != NULL && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); if (tmpmsg != NULL && strstr(tmpmsg, "No such container") != NULL) { @@ -335,9 +335,9 @@ int rt_lcr_exec(const char *id, const char *runtime, const rt_exec_params_t *par if (!engine_ops->engine_exec_op(&request, exit_code)) { const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Exec container error;%s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? - tmpmsg : DEF_ERR_RUNTIME_STR); - util_contain_errmsg(g_lcrd_errmsg, exit_code); + isulad_set_error_message("Exec container error;%s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? + tmpmsg : DEF_ERR_RUNTIME_STR); + util_contain_errmsg(g_isulad_errmsg, exit_code); engine_ops->engine_clear_errmsg_op(); ret = -1; goto out; @@ -366,8 +366,8 @@ int rt_lcr_pause(const char *name, const char *runtime, const rt_pause_params_t DEBUG("Pause container %s failed", name); const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Pause container error;%s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? - tmpmsg : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Pause container error;%s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? + tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -394,9 +394,9 @@ int rt_lcr_resume(const char *name, const char *runtime, const rt_resume_params_ DEBUG("Resume container %s failed", name); const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Resume container error;%s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Resume container error;%s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg + : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -424,8 +424,8 @@ int rt_lcr_attach(const char *name, const char *runtime, const rt_attach_params_ ERROR("attach failed"); const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Attach container error;%s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? - tmpmsg : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Attach container error;%s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? + tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -473,8 +473,8 @@ int rt_lcr_update(const char *id, const char *runtime, const rt_update_params_t DEBUG("Update container %s failed", id); const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Cannot update container %s: %s", id, (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? - tmpmsg : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Cannot update container %s: %s", id, (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? + tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -501,8 +501,8 @@ int rt_lcr_listpids(const char *name, const char *runtime, const rt_listpids_par DEBUG("Top container %s failed", name); const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Runtime top container error: %s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Runtime top container error: %s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -529,9 +529,9 @@ int rt_lcr_resize(const char *id, const char *runtime, const rt_resize_params_t DEBUG("resize container %s failed", id); const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Resize container error;%s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Resize container error;%s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg + : DEF_ERR_RUNTIME_STR); ret = -1; goto out; @@ -559,9 +559,9 @@ int rt_lcr_exec_resize(const char *id, const char *runtime, const rt_exec_resize DEBUG("exec resize container %s failed", id); const char *tmpmsg = NULL; tmpmsg = engine_ops->engine_get_errmsg_op(); - lcrd_set_error_message("Resize container error;%s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Resize container error;%s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg + : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } diff --git a/src/services/callback.h b/src/services/callback.h index 129ecbafdf98e11316b6977a38155f46d58665be..4fcdc02a23177d28e92f2359a9e2222673328534 100644 --- a/src/services/callback.h +++ b/src/services/callback.h @@ -15,7 +15,7 @@ #ifndef __SERVICE_CALLBACK_H_ #define __SERVICE_CALLBACK_H_ -#include "liblcrd.h" +#include "libisulad.h" #include "console.h" #include "container_get_id_request.h" #include "container_get_id_response.h" @@ -78,9 +78,9 @@ extern "C" { typedef struct { int(*subscribe)(char *name, types_timestamp_t *since, - types_timestamp_t *until, struct lcrd_events_format ***events); + types_timestamp_t *until, struct isulad_events_format ***events); - int(*wait)(struct lcrd_events_request *request, stream_func_wrapper *stream); + int(*wait)(struct isulad_events_request *request, stream_func_wrapper *stream); } service_container_events_callback_t; typedef struct { @@ -125,21 +125,21 @@ typedef struct { int(*wait)(const container_wait_request *request, container_wait_response **response); - int(*events)(const struct lcrd_events_request *request, const stream_func_wrapper *stream); + int(*events)(const struct isulad_events_request *request, const stream_func_wrapper *stream); int(*export_rootfs)(const container_export_request *request, container_export_response **response); - int(*copy_from_container)(const struct lcrd_copy_from_container_request *request, const stream_func_wrapper *stream, + int(*copy_from_container)(const struct isulad_copy_from_container_request *request, const stream_func_wrapper *stream, char **err); int(*copy_to_container)(const container_copy_to_request *request, stream_func_wrapper *stream, char **err); - int(*rename)(const struct lcrd_container_rename_request *request, struct lcrd_container_rename_response **response); + int(*rename)(const struct isulad_container_rename_request *request, struct isulad_container_rename_response **response); - int(*logs)(const struct lcrd_logs_request *request, - stream_func_wrapper *stream, struct lcrd_logs_response **response); + int(*logs)(const struct isulad_logs_request *request, + stream_func_wrapper *stream, struct isulad_logs_response **response); - int(*resize)(const struct lcrd_container_resize_request *request, struct lcrd_container_resize_response **response); + int(*resize)(const struct isulad_container_resize_request *request, struct isulad_container_resize_response **response); } service_container_callback_t; typedef struct { @@ -157,7 +157,7 @@ typedef struct { } service_image_callback_t; typedef struct { - int(*check)(const struct lcrd_health_check_request *request, struct lcrd_health_check_response *response); + int(*check)(const struct isulad_health_check_request *request, struct isulad_health_check_response *response); } service_health_callback_t; typedef struct { diff --git a/src/services/cri/network_plugin.h b/src/services/cri/network_plugin.h index 7c37addab684ca7f1357c8bfbbd2753f6d219921..ba90fc27b49595376cba0c9a9387f540babe8004 100644 --- a/src/services/cri/network_plugin.h +++ b/src/services/cri/network_plugin.h @@ -32,7 +32,7 @@ const std::string POD_DISABLE_DEFAULT_NET_ANNOTATION_KEY = "network.alpha.kubern class NetworkPluginConf { public: /* settings for net plugin */ - NetworkPluginConf(const std::string &dockershimRootDirectory = "/var/lib/lcrd/shim", + NetworkPluginConf(const std::string &dockershimRootDirectory = "/var/lib/isulad/shim", const std::string &pluginConfDir = "/etc/cni/net.d/", const std::string &pluginBinDir = "/opt/cni/bin", const std::string &pluginName = "", const std::string &hairpinMode = "hairpin-veth", const std::string &nonMasqueradeCIDR = "", diff --git a/src/services/execution/events/collector.c b/src/services/execution/events/collector.c index 1e197a884a74b80fd8d13dee86b8f6fc7eabfe1b..bbb2d373988ce4c289cde1d051da49e1a54256fd 100644 --- a/src/services/execution/events/collector.c +++ b/src/services/execution/events/collector.c @@ -29,8 +29,8 @@ #include "log.h" #include #include "collector.h" -#include "lcrd_config.h" -#include "liblcrd.h" +#include "isulad_config.h" +#include "libisulad.h" #include "containers_store.h" static struct context_lists g_context_lists; @@ -127,7 +127,7 @@ static container_events_type_t lcrsta2Evetype(int value) } /* format_msg */ -static bool format_msg(struct lcrd_events_format *r, struct monitord_msg *msg) +static bool format_msg(struct isulad_events_format *r, struct monitord_msg *msg) { bool ret = false; int err = 0; @@ -176,28 +176,28 @@ static bool format_msg(struct lcrd_events_format *r, struct monitord_msg *msg) return ret; } -static const char * const g_lcrd_event_strtype[] = { +static const char * const g_isulad_event_strtype[] = { "EXIT", "STOPPED", "STARTING", "RUNNING", "STOPPING", "ABORTING", "FREEZING", "FROZEN", "THAWED", "OOM", "CREATE", "START", "EXEC_ADDED", "PAUSED1", }; -/* lcrd event sta2str */ -static const char *lcrd_event_sta2str(container_events_type_t sta) +/* isulad event sta2str */ +static const char *isulad_event_sta2str(container_events_type_t sta) { if (sta > EVENTS_TYPE_PAUSED1) { return NULL; } - return g_lcrd_event_strtype[sta]; + return g_isulad_event_strtype[sta]; } -/* lcrd monitor fifo send */ -static void lcrd_monitor_fifo_send(const struct monitord_msg *msg, const char *statedir) +/* isulad monitor fifo send */ +static void isulad_monitor_fifo_send(const struct monitord_msg *msg, const char *statedir) { int fd = -1; ssize_t ret = 0; char *fifo_path = NULL; - fifo_path = lcrd_monitor_fifo_name(statedir); + fifo_path = isulad_monitor_fifo_name(statedir); if (fifo_path == NULL) { return; } @@ -231,8 +231,8 @@ out: } } -/* lcrd monitor send event */ -int lcrd_monitor_send_event(const char *name, runtime_state_t state, int pid, int exit_code) +/* isulad monitor send event */ +int isulad_monitor_send_event(const char *name, runtime_state_t state, int pid, int exit_code) { int ret = 0; char *statedir = NULL; @@ -249,9 +249,9 @@ int lcrd_monitor_send_event(const char *name, runtime_state_t state, int pid, in goto out; } - statedir = conf_get_lcrd_statedir(); + statedir = conf_get_isulad_statedir(); if (statedir == NULL) { - CRIT("Can not get lcrd root path"); + CRIT("Can not get isulad root path"); ret = -1; goto out; } @@ -265,7 +265,7 @@ int lcrd_monitor_send_event(const char *name, runtime_state_t state, int pid, in msg.exit_code = exit_code; } - lcrd_monitor_fifo_send(&msg, statedir); + isulad_monitor_fifo_send(&msg, statedir); out: free(statedir); @@ -273,7 +273,7 @@ out: } /* write events log */ -static int write_events_log(const struct lcrd_events_format *events) +static int write_events_log(const struct isulad_events_format *events) { #define PID_PREFIX ", Pid: " #define EXIT_CODE_PREFIX ", ExitCode: " @@ -306,7 +306,7 @@ static int write_events_log(const struct lcrd_events_format *events) } EVENT("Event: {Object: %s, Type: %s%s%s}", events->id, - (events->has_type ? lcrd_event_sta2str((container_events_type_t)events->type) : "-"), + (events->has_type ? isulad_event_sta2str((container_events_type_t)events->type) : "-"), (events->has_pid ? pid_str : ""), (events->has_exit_status ? exit_status_str : "")); out: @@ -316,7 +316,7 @@ out: } /* events copy */ -static void event_copy(const struct lcrd_events_format *src, struct lcrd_events_format *dest) +static void event_copy(const struct isulad_events_format *src, struct isulad_events_format *dest) { if (src == NULL || dest == NULL) { return; @@ -337,9 +337,9 @@ static void event_copy(const struct lcrd_events_format *src, struct lcrd_events_ } /* events append */ -static void events_append(const struct lcrd_events_format *event) +static void events_append(const struct isulad_events_format *event) { - struct lcrd_events_format *tmpevent = NULL; + struct isulad_events_format *tmpevent = NULL; struct linked_list *newnode = NULL; struct linked_list *firstnode = NULL; @@ -355,7 +355,7 @@ static void events_append(const struct lcrd_events_format *event) goto unlock; } - tmpevent = util_common_calloc_s(sizeof(struct lcrd_events_format)); + tmpevent = util_common_calloc_s(sizeof(struct isulad_events_format)); if (tmpevent == NULL) { CRIT("Memory allocation error."); free(newnode); @@ -372,7 +372,7 @@ static void events_append(const struct lcrd_events_format *event) if (firstnode != NULL) { linked_list_del(firstnode); - tmpevent = (struct lcrd_events_format *)firstnode->elem; + tmpevent = (struct isulad_events_format *)firstnode->elem; event_copy(event, tmpevent); linked_list_add_tail(&g_events_buffer.event_list, firstnode); @@ -386,7 +386,7 @@ unlock: } } -static int do_write_events(const stream_func_wrapper *stream, struct lcrd_events_format *event) +static int do_write_events(const stream_func_wrapper *stream, struct isulad_events_format *event) { int ret = 0; @@ -404,7 +404,7 @@ out: return ret; } -static int check_since_time(const types_timestamp_t *since, const struct lcrd_events_format *event) +static int check_since_time(const types_timestamp_t *since, const struct isulad_events_format *event) { if (since != NULL && (since->has_seconds || since->has_nanos)) { if (types_timestamp_cmp(&event->timestamp, since) < 0) { @@ -414,7 +414,7 @@ static int check_since_time(const types_timestamp_t *since, const struct lcrd_ev return 0; } -static int check_util_time(const types_timestamp_t *until, const struct lcrd_events_format *event) +static int check_util_time(const types_timestamp_t *until, const struct isulad_events_format *event) { if (until != NULL && (until->has_seconds || until->has_nanos)) { if (types_timestamp_cmp(&event->timestamp, until) > 0) { @@ -433,7 +433,7 @@ static int do_subscribe(const char *name, const types_timestamp_t *since, const regmatch_t regmatch = { 0 }; struct linked_list *it = NULL; struct linked_list *next = NULL; - struct lcrd_events_format *c_event = NULL; + struct isulad_events_format *c_event = NULL; if (pthread_mutex_lock(&g_events_buffer.event_mutex)) { WARN("Failed to lock"); @@ -441,7 +441,7 @@ static int do_subscribe(const char *name, const types_timestamp_t *since, const } linked_list_for_each_safe(it, &g_events_buffer.event_list, next) { - c_event = (struct lcrd_events_format *)it->elem; + c_event = (struct isulad_events_format *)it->elem; if (check_since_time(since, c_event) != 0) { continue; @@ -503,7 +503,7 @@ int events_subscribe(const char *name, const types_timestamp_t *since, const typ } /* events forward */ -static void events_forward(struct lcrd_events_format *r) +static void events_forward(struct isulad_events_format *r) { struct linked_list *it = NULL; struct linked_list *next = NULL; @@ -634,7 +634,7 @@ error: } /* post event to events hander */ -static int post_event_to_events_hander(const struct lcrd_events_format *events) +static int post_event_to_events_hander(const struct isulad_events_format *events) { int ret = 0; container_t *cont = NULL; @@ -668,7 +668,7 @@ out: /* events handler */ void events_handler(struct monitord_msg *msg) { - struct lcrd_events_format events = { 0 }; + struct isulad_events_format events = { 0 }; if (msg == NULL) { ERROR("Invalid input arguments"); @@ -688,20 +688,20 @@ void events_handler(struct monitord_msg *msg) /* forward events to grpc clients */ events_forward(&events); - /* log event into lcrd.log */ + /* log event into isulad.log */ (void)write_events_log(&events); } /* dup event */ -struct lcrd_events_format *dup_event(const struct lcrd_events_format *event) +struct isulad_events_format *dup_event(const struct isulad_events_format *event) { - struct lcrd_events_format *out = NULL; + struct isulad_events_format *out = NULL; if (event == NULL || event->id == NULL) { return NULL; } - out = util_common_calloc_s(sizeof(struct lcrd_events_format)); + out = util_common_calloc_s(sizeof(struct isulad_events_format)); if (out == NULL) { return NULL; } @@ -712,7 +712,7 @@ struct lcrd_events_format *dup_event(const struct lcrd_events_format *event) } /* free event */ -void free_event(struct lcrd_events_format *event) +void free_event(struct isulad_events_format *event) { if (event == NULL) { return; diff --git a/src/services/execution/events/collector.h b/src/services/execution/events/collector.h index 642e5149fd244e99f103ccade3f2a1926bfda32e..c806e0eb86f319caa8fe59707c73753e0e85ddbe 100644 --- a/src/services/execution/events/collector.h +++ b/src/services/execution/events/collector.h @@ -18,7 +18,7 @@ #include #include #include "linked_list.h" -#include "liblcrd.h" +#include "libisulad.h" #include "monitord.h" struct context_lists { @@ -36,11 +36,11 @@ int add_monitor_client(char *name, const types_timestamp_t *since, const types_t int events_subscribe(const char *name, const types_timestamp_t *since, const types_timestamp_t *until, const stream_func_wrapper *stream); -struct lcrd_events_format *dup_event(const struct lcrd_events_format *event); +struct isulad_events_format *dup_event(const struct isulad_events_format *event); -void free_event(struct lcrd_events_format *event); +void free_event(struct isulad_events_format *event); -int lcrd_monitor_send_event(const char *name, runtime_state_t state, int pid, int exit_code); +int isulad_monitor_send_event(const char *name, runtime_state_t state, int pid, int exit_code); #endif /* __COLLECTOR_H */ diff --git a/src/services/execution/events/events_handler.c b/src/services/execution/events/events_handler.c index 9c544bb96280edcf851c331a140ba353fd548224..3599b4464f40958d10b57a5e2bf3d438dae8f825 100644 --- a/src/services/execution/events/events_handler.c +++ b/src/services/execution/events/events_handler.c @@ -23,7 +23,7 @@ #include "error.h" #include "log.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "collector.h" #include "events_handler.h" #include "utils.h" @@ -50,7 +50,7 @@ static void events_handler_unlock(events_handler_t *handler) /* events handler free */ void events_handler_free(events_handler_t *handler) { - struct lcrd_events_format *event = NULL; + struct isulad_events_format *event = NULL; struct linked_list *it = NULL; struct linked_list *next = NULL; @@ -59,7 +59,7 @@ void events_handler_free(events_handler_t *handler) } linked_list_for_each_safe(it, &(handler->events_list), next) { - event = (struct lcrd_events_format *)it->elem; + event = (struct isulad_events_format *)it->elem; linked_list_del(it); free_event(event); free(it); @@ -101,7 +101,7 @@ cleanup: } /* container state changed */ -static int container_state_changed(container_t *cont, const struct lcrd_events_format *events) +static int container_state_changed(container_t *cont, const struct isulad_events_format *events) { int ret = 0; int pid = 0; @@ -209,7 +209,7 @@ out: static int handle_one(container_t *cont, events_handler_t *handler) { struct linked_list *it = NULL; - struct lcrd_events_format *events = NULL; + struct isulad_events_format *events = NULL; events_handler_lock(handler); @@ -224,7 +224,7 @@ static int handle_one(container_t *cont, events_handler_t *handler) events_handler_unlock(handler); - events = (struct lcrd_events_format *)it->elem; + events = (struct isulad_events_format *)it->elem; INFO("Received event %s with pid %d", events->id, events->pid); if (container_state_changed(cont, events)) { @@ -279,12 +279,12 @@ out: /* events handler post events */ int events_handler_post_events(events_handler_t *handler, - const struct lcrd_events_format *event) + const struct isulad_events_format *event) { int ret = 0; char *name = NULL; pthread_t td; - struct lcrd_events_format *post_event = NULL; + struct isulad_events_format *post_event = NULL; struct linked_list *it = NULL; if (handler == NULL || event == NULL) { diff --git a/src/services/execution/events/events_handler.h b/src/services/execution/events/events_handler.h index 48eee1678fedc944c2743e77ebe402cd6d9dfdf4..22d33d0e78711ffdc9f61dd6d6d6afac9fb73d7c 100644 --- a/src/services/execution/events/events_handler.h +++ b/src/services/execution/events/events_handler.h @@ -19,7 +19,7 @@ #include #include "linked_list.h" -#include "liblcrd.h" +#include "libisulad.h" typedef struct _events_handler_t { pthread_mutex_t mutex; @@ -33,7 +33,7 @@ events_handler_t *events_handler_new(); void events_handler_free(events_handler_t *handler); -int events_handler_post_events(events_handler_t *handler, const struct lcrd_events_format *event); +int events_handler_post_events(events_handler_t *handler, const struct isulad_events_format *event); #endif /* __EVENTS_HANDLER_H */ diff --git a/src/services/execution/execute/execution.c b/src/services/execution/execute/execution.c index bbe292eb9ffd864cd0983a964bc14ca323a9ab49..667bfaa8870f6b007ab1a378ca7a1b7d3d0303a9 100644 --- a/src/services/execution/execute/execution.c +++ b/src/services/execution/execute/execution.c @@ -32,7 +32,7 @@ #include "log.h" #include "engine.h" #include "console.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "config.h" #include "image.h" #include "execution.h" @@ -53,6 +53,7 @@ #include "utils.h" #include "error.h" + static int filter_by_label(const container_t *cont, const container_get_id_request *request) { int ret = 0; @@ -68,14 +69,14 @@ static int filter_by_label(const container_t *cont, const container_get_id_reque if (cont->common_config->config == NULL || cont->common_config->config->labels == NULL || \ cont->common_config->config->labels->len == 0) { ERROR("No such container: %s", request->id_or_name); - lcrd_set_error_message("No such container: %s", request->id_or_name); + isulad_set_error_message("No such container: %s", request->id_or_name); ret = -1; goto out; } p_equal = strchr(request->label, '='); if (p_equal == NULL) { ERROR("Invalid label: %s", request->label); - lcrd_set_error_message("Invalid label: %s", request->label); + isulad_set_error_message("Invalid label: %s", request->label); ret = -1; goto out; } @@ -91,7 +92,7 @@ static int filter_by_label(const container_t *cont, const container_get_id_reque } ret = -1; ERROR("No such container: %s", request->id_or_name); - lcrd_set_error_message("No such container: %s", request->id_or_name); + isulad_set_error_message("No such container: %s", request->id_or_name); out: return ret; @@ -104,8 +105,8 @@ static void pack_get_id_response(container_get_id_response *response, const char } response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } if (id != NULL) { @@ -119,7 +120,7 @@ static void pack_get_id_response(container_get_id_response *response, const char static int container_get_id_cb(const container_get_id_request *request, container_get_id_response **response) { char *id = NULL; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; container_t *cont = NULL; DAEMON_CLEAR_ERRMSG(); @@ -131,27 +132,27 @@ static int container_get_id_cb(const container_get_id_request *request, containe *response = util_common_calloc_s(sizeof(container_get_id_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } if (!util_valid_container_id_or_name(request->id_or_name)) { ERROR("Invalid container name: %s", request->id_or_name ? request->id_or_name : ""); - lcrd_set_error_message("Invalid container name: %s", request->id_or_name ? request->id_or_name : ""); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name: %s", request->id_or_name ? request->id_or_name : ""); + cc = ISULAD_ERR_EXEC; goto pack_response; } cont = containers_store_get(request->id_or_name); if (cont == NULL) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; ERROR("No such container: %s", request->id_or_name); - lcrd_set_error_message("No such container: %s", request->id_or_name); + isulad_set_error_message("No such container: %s", request->id_or_name); goto pack_response; } if (filter_by_label(cont, request) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -161,7 +162,7 @@ pack_response: pack_get_id_response(*response, id, cc); container_unref(cont); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int send_signal_to_process(pid_t pid, unsigned long long start_time, uint32_t signal) @@ -289,7 +290,7 @@ static int start_request_check(const container_start_request *h) if (!util_valid_container_id_or_name(h->id)) { ERROR("Invalid container name %s", h->id); - lcrd_set_error_message("Invalid container name %s", h->id); + isulad_set_error_message("Invalid container name %s", h->id); ret = -1; goto out; } @@ -379,7 +380,7 @@ static int chmod_runtime_bundle_permission(const char *runtime) goto error_out; } - root_dir = conf_get_lcrd_rootdir(); + root_dir = conf_get_isulad_rootdir(); if (root_dir == NULL) { ret = -1; goto error_out; @@ -713,7 +714,7 @@ static int do_start_container(container_t *cont, const char *console_fifos[], bo if (reset_rm && !reset_restart_manager(cont, true)) { ERROR("Failed to reset restart manager"); - lcrd_set_error_message("Failed to reset restart manager"); + isulad_set_error_message("Failed to reset restart manager"); ret = -1; goto out; } @@ -843,20 +844,20 @@ int start_container(container_t *cont, const char *console_fifos[], bool reset_r if (is_paused(cont->state)) { ERROR("Cannot start a paused container, try unpause instead"); - lcrd_set_error_message("Cannot start a paused container, try unpause instead."); + isulad_set_error_message("Cannot start a paused container, try unpause instead."); ret = -1; goto out; } if (is_removal_in_progress(cont->state) || is_dead(cont->state)) { ERROR("Container is marked for removal and cannot be started."); - lcrd_set_error_message("Container is marked for removal and cannot be started."); + isulad_set_error_message("Container is marked for removal and cannot be started."); ret = -1; goto out; } if (gc_is_gc_progress(cont->common_config->id)) { - lcrd_set_error_message("You cannot start container %s in garbage collector progress.", cont->common_config->id); + isulad_set_error_message("You cannot start container %s in garbage collector progress.", cont->common_config->id); ERROR("You cannot start container %s in garbage collector progress.", cont->common_config->id); ret = -1; goto out; @@ -881,8 +882,8 @@ int start_container(container_t *cont, const char *console_fifos[], bool reset_r } set_stopped: - container_state_set_error(cont->state, (const char *)g_lcrd_errmsg); - util_contain_errmsg(g_lcrd_errmsg, &exit_code); + container_state_set_error(cont->state, (const char *)g_isulad_errmsg); + util_contain_errmsg(g_isulad_errmsg, &exit_code); state_set_stopped(cont->state, exit_code); container_wait_stop_cond_broadcast(cont); if (!save_after_auto_remove(cont)) { @@ -935,8 +936,8 @@ static void pack_start_response(container_start_response *response, uint32_t cc, } response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } if (id != NULL) { @@ -953,7 +954,7 @@ static int container_start_prepare(container_t *cont, const container_start_requ if (container_to_disk_locking(cont)) { ERROR("Failed to save container \"%s\" to disk", id); - lcrd_set_error_message("Failed to save container \"%s\" to disk", id); + isulad_set_error_message("Failed to save container \"%s\" to disk", id); return -1; } @@ -968,7 +969,7 @@ static int container_start_cb(const container_start_request *request, container_ int stdinfd, struct io_write_wrapper *stdout_handler, struct io_write_wrapper *stderr_handler) { - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *id = NULL; char *fifos[3] = { NULL, NULL, NULL }; char *fifopath = NULL; @@ -984,20 +985,20 @@ static int container_start_cb(const container_start_request *request, container_ *response = util_common_calloc_s(sizeof(container_start_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } if (start_request_check(request)) { - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } cont = containers_store_get(request->id); if (cont == NULL) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; ERROR("No such container:%s", request->id); - lcrd_set_error_message("No such container:%s", request->id); + isulad_set_error_message("No such container:%s", request->id); goto pack_response; } @@ -1014,12 +1015,12 @@ static int container_start_cb(const container_start_request *request, container_ } if (container_start_prepare(cont, request, stdinfd, stdout_handler, stderr_handler, &fifopath, fifos) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (start_container(cont, (const char **)fifos, true) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1038,7 +1039,7 @@ pack_response: } free_log_prefix(); malloc_trim(0); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int kill_with_signal(container_t *cont, uint32_t signal) @@ -1102,8 +1103,8 @@ static int force_kill(container_t *cont) if (ret != 0) { ERROR("Container stuck for 90 seconds and failed to kill the monitor of container, " "please check the config"); - lcrd_set_error_message("Container stuck for 90 seconds " - "and failed to kill the monitor of container, please check configuration files"); + isulad_set_error_message("Container stuck for 90 seconds " + "and failed to kill the monitor of container, please check configuration files"); goto out; } ret = container_wait_stop(cont, -1); @@ -1128,7 +1129,7 @@ int stop_container(container_t *cont, int timeout, bool force, bool restart) if (is_paused(cont->state)) { ERROR("Container %s is paused. Unpause the container before stopping or killing", id); - lcrd_set_error_message("Container %s is paused. Unpause the container before stopping or killing", id); + isulad_set_error_message("Container %s is paused. Unpause the container before stopping or killing", id); ret = -1; goto out; } @@ -1181,7 +1182,7 @@ static int restart_container(container_t *cont) if (is_removal_in_progress(cont->state) || is_dead(cont->state)) { ERROR("Container is marked for removal and cannot be started."); - lcrd_set_error_message("Container is marked for removal and cannot be started."); + isulad_set_error_message("Container is marked for removal and cannot be started."); goto out; } @@ -1211,14 +1212,14 @@ out: static uint32_t stop_and_start(container_t *cont, int timeout) { int ret = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; const char *console_fifos[3] = { NULL, NULL, NULL }; const char *id = cont->common_config->id; ret = stop_container(cont, timeout, false, true); if (ret != 0) { - cc = LCRD_ERR_EXEC; - container_state_set_error(cont->state, (const char *)g_lcrd_errmsg); + cc = ISULAD_ERR_EXEC; + container_state_set_error(cont->state, (const char *)g_isulad_errmsg); goto out; } @@ -1226,13 +1227,13 @@ static uint32_t stop_and_start(container_t *cont, int timeout) state_set_starting(cont->state); if (container_to_disk_locking(cont)) { ERROR("Failed to save container \"%s\" to disk", id); - cc = LCRD_ERR_EXEC; - lcrd_set_error_message("Failed to save container \"%s\" to disk", id); + cc = ISULAD_ERR_EXEC; + isulad_set_error_message("Failed to save container \"%s\" to disk", id); goto out; } if (verify_container_settings_start(cont->root_path, id)) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto out; } if (is_running(cont->state)) { @@ -1241,7 +1242,7 @@ static uint32_t stop_and_start(container_t *cont, int timeout) } if (start_container(cont, console_fifos, true) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto out; } out: @@ -1255,8 +1256,8 @@ static void pack_restart_response(container_restart_response *response, uint32_t return; } response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } if (id != NULL) { @@ -1270,21 +1271,21 @@ static uint32_t do_restart_container(container_t *cont, int timeout) ret = restart_container(cont); if (ret == -1) { - container_state_set_error(cont->state, (const char *)g_lcrd_errmsg); - return LCRD_ERR_EXEC; + container_state_set_error(cont->state, (const char *)g_isulad_errmsg); + return ISULAD_ERR_EXEC; } else if (ret == -2) { /* runtime don't implement restart, use stop and start */ return stop_and_start(cont, timeout); } - return LCRD_SUCCESS; + return ISULAD_SUCCESS; } static int container_restart_cb(const container_restart_request *request, container_restart_response **response) { int timeout = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *name = NULL; char *id = NULL; container_t *cont = NULL; @@ -1299,7 +1300,7 @@ static int container_restart_cb(const container_restart_request *request, *response = util_common_calloc_s(sizeof(container_restart_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } @@ -1307,17 +1308,17 @@ static int container_restart_cb(const container_restart_request *request, timeout = request->timeout; if (!util_valid_container_id_or_name(name)) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); + isulad_set_error_message("Invalid container name %s", name); goto pack_response; } cont = containers_store_get(name); if (cont == NULL) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; ERROR("No such container: %s", name); - lcrd_set_error_message("No such container:%s", name); + isulad_set_error_message("No such container:%s", name); goto pack_response; } @@ -1328,14 +1329,14 @@ static int container_restart_cb(const container_restart_request *request, EVENT("Event: {Object: %s, Type: restarting}", id); if (gc_is_gc_progress(id)) { - lcrd_set_error_message("You cannot restart container %s in garbage collector progress.", id); + isulad_set_error_message("You cannot restart container %s in garbage collector progress.", id); ERROR("You cannot restart container %s in garbage collector progress.", id); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } cc = do_restart_container(cont, timeout); - if (cc != LCRD_SUCCESS) { + if (cc != ISULAD_SUCCESS) { goto pack_response; } @@ -1344,7 +1345,7 @@ pack_response: pack_restart_response(*response, cc, id); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static void pack_stop_response(container_stop_response *response, uint32_t cc, const char *id) @@ -1353,8 +1354,8 @@ static void pack_stop_response(container_stop_response *response, uint32_t cc, c return; } response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } if (id != NULL) { @@ -1369,7 +1370,7 @@ static int container_stop_cb(const container_stop_request *request, bool force = false; char *name = NULL; char *id = NULL; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; container_t *cont = NULL; DAEMON_CLEAR_ERRMSG(); @@ -1381,7 +1382,7 @@ static int container_stop_cb(const container_stop_request *request, *response = util_common_calloc_s(sizeof(container_stop_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } @@ -1391,22 +1392,22 @@ static int container_stop_cb(const container_stop_request *request, if (name == NULL) { ERROR("Stop: receive NULL id"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name %s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } cont = containers_store_get(name); if (cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1416,15 +1417,15 @@ static int container_stop_cb(const container_stop_request *request, EVENT("Event: {Object: %s, Type: Stopping}", id); if (gc_is_gc_progress(id)) { - lcrd_set_error_message("You cannot stop container %s in garbage collector progress.", id); + isulad_set_error_message("You cannot stop container %s in garbage collector progress.", id); ERROR("You cannot stop container %s in garbage collector progress.", id); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (stop_container(cont, timeout, force, false)) { - cc = LCRD_ERR_EXEC; - container_state_set_error(cont->state, (const char *)g_lcrd_errmsg); + cc = ISULAD_ERR_EXEC; + container_state_set_error(cont->state, (const char *)g_isulad_errmsg); goto pack_response; } @@ -1434,7 +1435,7 @@ pack_response: pack_stop_response(*response, cc, id); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int kill_container(container_t *cont, uint32_t signal) @@ -1448,7 +1449,7 @@ static int kill_container(container_t *cont, uint32_t signal) if (!is_running(cont->state)) { ERROR("Cannot kill container: Container %s is not running", id); - lcrd_set_error_message("Cannot kill container: Container %s is not running", id); + isulad_set_error_message("Cannot kill container: Container %s is not running", id); ret = -1; goto out; } @@ -1475,8 +1476,8 @@ static void pack_kill_response(container_kill_response *response, uint32_t cc, c return; } response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } if (id != NULL) { @@ -1491,7 +1492,7 @@ static int container_kill_cb(const container_kill_request *request, char *name = NULL; char *id = NULL; uint32_t signal = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; container_t *cont = NULL; DAEMON_CLEAR_ERRMSG(); @@ -1504,7 +1505,7 @@ static int container_kill_cb(const container_kill_request *request, *response = util_common_calloc_s(sizeof(container_kill_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } @@ -1513,29 +1514,29 @@ static int container_kill_cb(const container_kill_request *request, if (name == NULL) { ERROR("Kill: receive NULL id"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } if (!util_valid_container_id_or_name(name)) { - lcrd_set_error_message("Invalid container name %s", name); + isulad_set_error_message("Invalid container name %s", name); ERROR("Invalid container name %s", name); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (!util_check_signal_valid((int)signal)) { - lcrd_set_error_message("Not supported signal %d", signal); + isulad_set_error_message("Not supported signal %d", signal); ERROR("Not supported signal %d", signal); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } cont = containers_store_get(name); if (cont == NULL) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); + isulad_set_error_message("No such container:%s", name); goto pack_response; } @@ -1546,16 +1547,16 @@ static int container_kill_cb(const container_kill_request *request, if (gc_is_gc_progress(id)) { - lcrd_set_error_message("You cannot kill container %s in garbage collector progress.", id); + isulad_set_error_message("You cannot kill container %s in garbage collector progress.", id); ERROR("You cannot kill container %s in garbage collector progress.", id); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } ret = kill_container(cont, signal); if (ret != 0) { - cc = LCRD_ERR_EXEC; - container_state_set_error(cont->state, (const char *)g_lcrd_errmsg); + cc = ISULAD_ERR_EXEC; + container_state_set_error(cont->state, (const char *)g_isulad_errmsg); goto pack_response; } @@ -1565,7 +1566,7 @@ pack_response: pack_kill_response(*response, cc, id); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int do_runtime_rm_helper(const char *id, const char *runtime, const char *rootpath) @@ -1615,7 +1616,7 @@ static int do_cleanup_container_resources(container_t *cont) (void)container_to_disk(cont); if (gc_is_gc_progress(id)) { - lcrd_set_error_message("You cannot remove container %s in garbage collector progress.", id); + isulad_set_error_message("You cannot remove container %s in garbage collector progress.", id); ERROR("You cannot remove container %s in garbage collector progress.", id); ret = -1; goto out; @@ -1681,7 +1682,7 @@ int set_container_to_removal(const container_t *cont) bool removal_progress = state_set_removal_in_progress(cont->state); if (removal_progress) { - lcrd_set_error_message("Container:%s was already in removal progress", id); + isulad_set_error_message("Container:%s was already in removal progress", id); ERROR("Container:%s was already in removal progress", id); ret = -1; goto out; @@ -1706,14 +1707,14 @@ int cleanup_container(container_t *cont, bool force) if (is_running(cont->state)) { if (!force) { if (is_paused(cont->state)) { - lcrd_set_error_message("You cannot remove a paused container %s. " - "Unpause and then stop the container before " - "attempting removal or force remove", id); + isulad_set_error_message("You cannot remove a paused container %s. " + "Unpause and then stop the container before " + "attempting removal or force remove", id); ERROR("You cannot remove a paused container %s. Unpause and then stop the container before " "attempting removal or force remove", id); } else { - lcrd_set_error_message("You cannot remove a running container %s. " - "Stop the container before attempting removal or use -f", id); + isulad_set_error_message("You cannot remove a running container %s. " + "Stop the container before attempting removal or use -f", id); ERROR("You cannot remove a running container %s." " Stop the container before attempting removal or use -f", id); } @@ -1722,7 +1723,7 @@ int cleanup_container(container_t *cont, bool force) } ret = stop_container(cont, 3, force, false); if (ret != 0) { - lcrd_append_error_message("Could not stop running container %s, cannot remove. ", id); + isulad_append_error_message("Could not stop running container %s, cannot remove. ", id); ERROR("Could not stop running container %s, cannot remove", id); ret = -1; goto reset_removal_progress; @@ -1750,8 +1751,8 @@ static void pack_delete_response(container_delete_response *response, uint32_t c return; } response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } if (id != NULL) { @@ -1763,7 +1764,7 @@ static int container_delete_cb(const container_delete_request *request, container_delete_response **response) { bool force = false; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *name = NULL; char *id = NULL; container_t *cont = NULL; @@ -1777,7 +1778,7 @@ static int container_delete_cb(const container_delete_request *request, *response = util_common_calloc_s(sizeof(container_delete_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } @@ -1786,16 +1787,16 @@ static int container_delete_cb(const container_delete_request *request, if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); - cc = LCRD_ERR_INPUT; + isulad_set_error_message("Invalid container name %s", name); + cc = ISULAD_ERR_INPUT; goto pack_response; } cont = containers_store_get(name); if (cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1809,12 +1810,12 @@ static int container_delete_cb(const container_delete_request *request, container_unlock(cont); if (nret != 0) { ERROR("Failed to set container %s state to removal", id); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (cleanup_container(cont, force)) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1824,7 +1825,7 @@ pack_response: pack_delete_response(*response, cc, id); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } void container_callback_init(service_container_callback_t *cb) diff --git a/src/services/execution/execute/execution_create.c b/src/services/execution/execute/execution_create.c index 8cce2ad1933ba3cd1a089f448133bdf752ea998b..1e94fcc46a86d80097ac166fba4d4e99af7e21d7 100644 --- a/src/services/execution/execute/execution_create.c +++ b/src/services/execution/execute/execution_create.c @@ -31,7 +31,7 @@ #include "log.h" #include "engine.h" #include "console.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "config.h" #include "specs.h" #include "verify.h" @@ -63,7 +63,7 @@ static int create_request_check(const container_create_request *request) if (request->image != NULL && !util_valid_image_name(request->image)) { ERROR("invalid image name %s", request->image); - lcrd_set_error_message("Invalid image name '%s'", request->image); + isulad_set_error_message("Invalid image name '%s'", request->image); ret = -1; goto out; } @@ -76,8 +76,8 @@ static int create_request_check(const container_create_request *request) if (!util_valid_runtime_name(request->runtime)) { ERROR("Invalid runtime name:%s", request->runtime); - lcrd_set_error_message("Invalid runtime name (%s), only \"lcr\" supported.", - request->runtime); + isulad_set_error_message("Invalid runtime name (%s), only \"lcr\" supported.", + request->runtime); ret = -1; goto out; } @@ -447,7 +447,7 @@ static int maintain_container_id(const container_create_request *request, char * id = try_generate_id(); if (id == NULL) { ERROR("Failed to generate container ID"); - lcrd_set_error_message("Failed to generate container ID"); + isulad_set_error_message("Failed to generate container ID"); ret = -1; goto out; } @@ -462,7 +462,7 @@ static int maintain_container_id(const container_create_request *request, char * if (!util_valid_container_name(name)) { ERROR("Invalid container name (%s), only [a-zA-Z0-9][a-zA-Z0-9_.-]+$ are allowed.", name); - lcrd_set_error_message("Invalid container name (%s), only [a-zA-Z0-9][a-zA-Z0-9_.-]+$ are allowed.", name); + isulad_set_error_message("Invalid container name (%s), only [a-zA-Z0-9][a-zA-Z0-9_.-]+$ are allowed.", name); ret = -1; goto out; } @@ -471,9 +471,9 @@ static int maintain_container_id(const container_create_request *request, char * if (!name_index_add(name, id)) { ERROR("Name %s is in use", name); - lcrd_set_error_message("Conflict. The name \"%s\" is already in use by container %s. " - "You have to remove (or rename) that container to be able to reuse that name.", - name, name); + isulad_set_error_message("Conflict. The name \"%s\" is already in use by container %s. " + "You have to remove (or rename) that container to be able to reuse that name.", + name, name); ret = -1; goto out; } @@ -492,8 +492,8 @@ static char *get_runtime_from_request(const container_create_request *request) static void pack_create_response(container_create_response *response, const char *id, uint32_t cc) { response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } if (id != NULL) { @@ -568,7 +568,7 @@ static int generate_merged_oci_config_json(const char *id, oci_runtime_spec *oci if (*oci_config_data == NULL) { ERROR("Failed to generate runtime spec json,erro:%s", err); free(err); - lcrd_set_error_message("Failed to generate runtime spec json"); + isulad_set_error_message("Failed to generate runtime spec json"); return -1; } free(err); @@ -773,12 +773,12 @@ static int get_request_container_info(const container_create_request *request, c { if (create_request_check(request) != 0) { ERROR("Invalid create container request"); - *cc = LCRD_ERR_INPUT; + *cc = ISULAD_ERR_INPUT; return -1; } if (maintain_container_id(request, id, name) != 0) { - *cc = LCRD_ERR_EXEC; + *cc = ISULAD_ERR_EXEC; return -1; } @@ -818,18 +818,18 @@ static int preparate_runtime_environment(const container_create_request *request { *runtime = get_runtime_from_request(request); if (*runtime == NULL) { - *cc = LCRD_ERR_INPUT; + *cc = ISULAD_ERR_INPUT; return -1; } *runtime_root = conf_get_routine_rootdir(*runtime); if (*runtime_root == NULL) { - *cc = LCRD_ERR_EXEC; + *cc = ISULAD_ERR_EXEC; return -1; } if (create_container_root_dir(id, *runtime_root) != 0) { - *cc = LCRD_ERR_EXEC; + *cc = ISULAD_ERR_EXEC; return -1; } @@ -909,7 +909,7 @@ static int generate_oci_config_json(const char *id, const container_create_reque int container_create_cb(const container_create_request *request, container_create_response **response) { - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *real_rootfs = NULL; char *image_type = NULL; char *runtime_root = NULL; @@ -938,7 +938,7 @@ int container_create_cb(const container_create_request *request, } if (get_request_image_info(request, &image_type, &ext_config_image, &image_name) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto clean_nameindex; } @@ -947,41 +947,41 @@ int container_create_cb(const container_create_request *request, } if (get_basic_spec(request, id, runtime_root, &host_spec, &custom_spec) != 0) { - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto clean_container_root_dir; } if (get_v2_spec(request, id, name, runtime_root, host_spec, image_type, &v2_spec) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto clean_container_root_dir; } if (save_container_config_before_create(id, runtime_root, host_spec, v2_spec) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto clean_container_root_dir; } host_channel = dup_host_channel(host_spec->host_channel); if (prepare_host_channel(host_channel, host_spec->user_remap)) { ERROR("Failed to prepare host channel with '%s'", host_spec->host_channel); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto clean_container_root_dir; } oci_spec = merge_config(id, image_type, image_name, ext_config_image, host_spec, custom_spec, v2_spec, &real_rootfs); if (oci_spec == NULL) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto clean_rootfs; } if (real_rootfs == NULL) { ERROR("Can not found rootfs"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto clean_rootfs; } if (generate_oci_config_json(id, request, host_spec, custom_spec, oci_spec, &oci_config_data) != 0) { - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto clean_rootfs; } @@ -990,18 +990,18 @@ int container_create_cb(const container_create_request *request, if (runtime_create(id, runtime, &create_params) != 0) { ERROR("Runtime create container failed"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto clean_rootfs; } if (v2_spec_merge_config(custom_spec, oci_spec, v2_spec) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto clean_on_error; } if (register_new_container(id, runtime, &host_spec, &v2_spec)) { ERROR("Failed to register new container"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto clean_on_error; } @@ -1038,6 +1038,6 @@ pack_response: free_host_config_host_channel(host_channel); free_log_prefix(); malloc_trim(0); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } diff --git a/src/services/execution/execute/execution_extend.c b/src/services/execution/execute/execution_extend.c index be8ea298d5e1552f3a59605296121d151f218392..b0d0c137ef2e7fe4623ff50df77abe755f9a8dba 100644 --- a/src/services/execution/execute/execution_extend.c +++ b/src/services/execution/execute/execution_extend.c @@ -30,7 +30,7 @@ #include "engine.h" #include "collector.h" #include "console.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "config.h" #include "restartmanager.h" #include "image.h" @@ -52,7 +52,7 @@ struct stats_context { container_stats_request *stats_config; }; -static int service_events_handler(const struct lcrd_events_request *request, +static int service_events_handler(const struct isulad_events_request *request, const stream_func_wrapper *stream) { int ret = 0; @@ -66,7 +66,7 @@ static int service_events_handler(const struct lcrd_events_request *request, container = containers_store_get(name); if (container == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); + isulad_set_error_message("No such container:%s", name); ret = -1; goto out; } @@ -90,10 +90,10 @@ out: return ret; } -static int container_events_cb(const struct lcrd_events_request *request, const stream_func_wrapper *stream) +static int container_events_cb(const struct isulad_events_request *request, const stream_func_wrapper *stream) { int ret = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; DAEMON_CLEAR_ERRMSG(); @@ -104,19 +104,19 @@ static int container_events_cb(const struct lcrd_events_request *request, const if (stream == NULL) { ERROR("Should provide stream function in events"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto out; } ret = service_events_handler(request, stream); if (ret != 0) { ERROR("Failed to add events monitor"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto out; } out: - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int dup_container_stats_request(const container_stats_request *src, container_stats_request **dest) @@ -306,7 +306,7 @@ static struct stats_context *fold_stats_filter(const container_stats_request *re if (!filters_args_valid_key(accepted_stats_filter_tags, sizeof(accepted_stats_filter_tags) / sizeof(char *), request->filters->keys[i])) { ERROR("Invalid filter '%s'", request->filters->keys[i]); - lcrd_set_error_message("Invalid filter '%s'", request->filters->keys[i]); + isulad_set_error_message("Invalid filter '%s'", request->filters->keys[i]); goto error_out; } for (j = 0; j < request->filters->values[i]->len; j++) { @@ -350,8 +350,8 @@ static void pack_stats_response(container_stats_response *response, uint32_t cc, response->container_stats_len = info_len; response->container_stats = info; response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -371,7 +371,7 @@ static int stats_get_all_containers_id(const container_stats_request *request, c for (n = 0; n < request->containers_len; n++) { if (!util_valid_container_id_or_name(request->containers[n])) { ERROR("Invalid container name: %s", request->containers[n]); - lcrd_set_error_message("Invalid container name: %s", request->containers[n]); + isulad_set_error_message("Invalid container name: %s", request->containers[n]); goto cleanup; } if (util_array_append(&array, request->containers[n]) != 0) { @@ -414,7 +414,7 @@ static int get_containers_stats(char **idsarray, size_t ids_len, const struct st if (cont == NULL) { if (check_exists) { ERROR("No such container: %s", idsarray[i]); - lcrd_set_error_message("No such container: %s", idsarray[i]); + isulad_set_error_message("No such container: %s", idsarray[i]); ret = -1; goto cleanup; } @@ -453,7 +453,7 @@ static int container_stats_cb(const container_stats_request *request, bool check_exists = false; size_t ids_len = 0; size_t info_len = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char **idsarray = NULL; container_info **info = NULL; struct stats_context *ctx = NULL; @@ -467,18 +467,18 @@ static int container_stats_cb(const container_stats_request *request, *response = util_common_calloc_s(sizeof(container_stats_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } ctx = fold_stats_filter(request); if (ctx == NULL) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (stats_get_all_containers_id(request, &idsarray, &ids_len, &check_exists) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (ids_len == 0) { @@ -486,7 +486,7 @@ static int container_stats_cb(const container_stats_request *request, } if (get_containers_stats(idsarray, ids_len, ctx, check_exists, &info, &info_len)) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -494,7 +494,7 @@ pack_response: pack_stats_response(*response, cc, info_len, info); util_free_array(idsarray); free_stats_context(ctx); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int resume_container(container_t *cont) @@ -507,14 +507,14 @@ static int resume_container(container_t *cont) if (!is_running(cont->state)) { ERROR("Container %s is not running", id); - lcrd_set_error_message("Container %s is not running", id); + isulad_set_error_message("Container %s is not running", id); ret = -1; goto out; } if (!is_paused(cont->state)) { ERROR("Container %s is not paused", id); - lcrd_set_error_message("Container %s is not paused", id); + isulad_set_error_message("Container %s is not paused", id); ret = -1; goto out; } @@ -601,8 +601,8 @@ static void pack_resume_response(container_resume_response *response, uint32_t c if (id != NULL) { response->id = util_strdup_s(id); } - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -610,7 +610,7 @@ static void pack_resume_response(container_resume_response *response, uint32_t c static int container_resume_cb(const container_resume_request *request, container_resume_response **response) { int ret = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *name = NULL; char *id = NULL; container_t *cont = NULL; @@ -624,29 +624,29 @@ static int container_resume_cb(const container_resume_request *request, containe *response = util_common_calloc_s(sizeof(container_resume_response)); if (*response == NULL) { ERROR("Resume: Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } name = request->id; if (name == NULL) { ERROR("Resume: receive NULL id"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name %s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } cont = containers_store_get(name); if (cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -655,16 +655,16 @@ static int container_resume_cb(const container_resume_request *request, containe EVENT("Event: {Object: %s, Type: Resuming}", id); if (gc_is_gc_progress(id)) { - lcrd_set_error_message("You cannot resume container %s in garbage collector progress.", id); + isulad_set_error_message("You cannot resume container %s in garbage collector progress.", id); ERROR("You cannot resume container %s in garbage collector progress.", id); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } ret = resume_container(cont); if (ret != 0) { - cc = LCRD_ERR_EXEC; - container_state_set_error(cont->state, (const char *)g_lcrd_errmsg); + cc = ISULAD_ERR_EXEC; + container_state_set_error(cont->state, (const char *)g_isulad_errmsg); goto pack_response; } @@ -674,7 +674,7 @@ pack_response: pack_resume_response(*response, cc, id); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int pause_container(container_t *cont) @@ -687,21 +687,21 @@ static int pause_container(container_t *cont) if (!is_running(cont->state)) { ERROR("Container %s is not running", id); - lcrd_set_error_message("Container %s is not running", id); + isulad_set_error_message("Container %s is not running", id); ret = -1; goto out; } if (is_paused(cont->state)) { ERROR("Container %s is already paused", id); - lcrd_set_error_message("Container %s is already paused", id); + isulad_set_error_message("Container %s is already paused", id); ret = -1; goto out; } if (is_restarting(cont->state)) { ERROR("Container %s is restarting, wait until the container is running", id); - lcrd_set_error_message("Container %s is restarting, wait until the container is running", id); + isulad_set_error_message("Container %s is restarting, wait until the container is running", id); ret = -1; goto out; } @@ -737,8 +737,8 @@ static void pack_pause_response(container_pause_response *response, uint32_t cc, if (id != NULL) { response->id = util_strdup_s(id); } - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -747,7 +747,7 @@ static int container_pause_cb(const container_pause_request *request, container_pause_response **response) { int ret = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *name = NULL; char *id = NULL; container_t *cont = NULL; @@ -762,7 +762,7 @@ static int container_pause_cb(const container_pause_request *request, *response = util_common_calloc_s(sizeof(container_pause_response)); if (*response == NULL) { ERROR("Pause: Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } @@ -770,22 +770,22 @@ static int container_pause_cb(const container_pause_request *request, if (name == NULL) { ERROR("Pause: receive NULL id"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name %s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } cont = containers_store_get(name); if (cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -795,16 +795,16 @@ static int container_pause_cb(const container_pause_request *request, EVENT("Event: {Object: %s, Type: Pausing}", id); if (gc_is_gc_progress(id)) { - lcrd_set_error_message("You cannot pause container %s in garbage collector progress.", id); + isulad_set_error_message("You cannot pause container %s in garbage collector progress.", id); ERROR("You cannot pause container %s in garbage collector progress.", id); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } ret = pause_container(cont); if (ret != 0) { - cc = LCRD_ERR_EXEC; - container_state_set_error(cont->state, (const char *)g_lcrd_errmsg); + cc = ISULAD_ERR_EXEC; + container_state_set_error(cont->state, (const char *)g_isulad_errmsg); goto pack_response; } @@ -814,7 +814,7 @@ pack_response: pack_pause_response(*response, cc, id); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static void host_config_restore_unlocking(container_t *cont, host_config *backup_hostconfig) @@ -859,8 +859,8 @@ static int update_container_memory(const char *id, const host_config *hostconfig hostconfig->memory_swap == 0) { ERROR("Memory limit should be smaller than already set memoryswap limit," " update the memoryswap at the same time"); - lcrd_set_error_message("Cannot update container %s: Memory limit should be smaller than" - "already set memoryswap limit, update the memoryswap at the same time.", id); + isulad_set_error_message("Cannot update container %s: Memory limit should be smaller than" + "already set memoryswap limit, update the memoryswap at the same time.", id); ret = -1; goto out; } @@ -975,16 +975,16 @@ static int update_host_config_check(container_t *cont, host_config *hostconfig) if (is_removal_in_progress(cont->state) || is_dead(cont->state)) { ERROR("Container is marked for removal and cannot be \"update\"."); - lcrd_set_error_message("Cannot update container %s: Container is marked for removal and cannot be \"update\".", - id); + isulad_set_error_message("Cannot update container %s: Container is marked for removal and cannot be \"update\".", + id); ret = -1; goto out; } if (is_running(cont->state) && hostconfig->kernel_memory) { ERROR("Can not update kernel memory to a running container, please stop it first."); - lcrd_set_error_message("Cannot update container %s: Can not update kernel memory to a running container," - " please stop it first.", id); + isulad_set_error_message("Cannot update container %s: Can not update kernel memory to a running container," + " please stop it first.", id); ret = -1; goto out; } @@ -1072,15 +1072,15 @@ static void pack_update_response(container_update_response *response, uint32_t c if (id != NULL) { response->id = util_strdup_s(id); } - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } static int container_update_cb(const container_update_request *request, container_update_response **response) { - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *container_name = NULL; char *id = NULL; container_t *cont = NULL; @@ -1094,29 +1094,29 @@ static int container_update_cb(const container_update_request *request, containe *response = util_common_calloc_s(sizeof(container_update_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } container_name = request->name; if (container_name == NULL) { DEBUG("receive NULL Request id"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } if (!util_valid_container_id_or_name(container_name)) { ERROR("Invalid container name %s", container_name); - lcrd_set_error_message("Invalid container name %s", container_name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name %s", container_name); + cc = ISULAD_ERR_EXEC; goto pack_response; } cont = containers_store_get(container_name); if (cont == NULL) { ERROR("No such container: %s", container_name); - lcrd_set_error_message("No such container: %s", container_name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container: %s", container_name); + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1125,7 +1125,7 @@ static int container_update_cb(const container_update_request *request, containe EVENT("Event: {Object: %s, Type: updating}", id); if (do_update_resources(request, cont) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1137,7 +1137,7 @@ pack_response: container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static void pack_export_response(container_export_response *response, uint32_t cc, const char *id) @@ -1149,8 +1149,8 @@ static void pack_export_response(container_export_response *response, uint32_t c if (id != NULL) { response->id = util_strdup_s(id); } - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -1161,7 +1161,7 @@ static int container_export_cb(const container_export_request *request, containe char *name = NULL; char *id = NULL; char *file = NULL; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; container_t *cont = NULL; DAEMON_CLEAR_ERRMSG(); @@ -1173,7 +1173,7 @@ static int container_export_cb(const container_export_request *request, containe *response = util_common_calloc_s(sizeof(container_export_response)); if (*response == NULL) { ERROR("Export: Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } @@ -1182,22 +1182,22 @@ static int container_export_cb(const container_export_request *request, containe if (name == NULL) { ERROR("Export: receive NULL id"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name %s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } cont = containers_store_get(name); if (cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1205,15 +1205,15 @@ static int container_export_cb(const container_export_request *request, containe set_log_prefix(id); if (gc_is_gc_progress(id)) { - lcrd_set_error_message("You cannot export container %s in garbage collector progress.", id); + isulad_set_error_message("You cannot export container %s in garbage collector progress.", id); ERROR("You cannot export container %s in garbage collector progress.", id); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } ret = export_container(cont, file); if (ret != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1221,7 +1221,7 @@ pack_response: pack_export_response(*response, cc, id); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int runtime_resize_helper(const char *id, const char *runtime, const char *rootpath, unsigned int height, @@ -1271,7 +1271,7 @@ static int resize_container(container_t *cont, const char *suffix, unsigned int if (!is_running(cont->state)) { ERROR("Container %s is not running", id); - lcrd_set_error_message("Container %s is not running", id); + isulad_set_error_message("Container %s is not running", id); ret = -1; goto out; } @@ -1296,7 +1296,7 @@ out: return ret; } -static void pack_resize_response(struct lcrd_container_resize_response *response, uint32_t cc, const char *id) +static void pack_resize_response(struct isulad_container_resize_response *response, uint32_t cc, const char *id) { if (response == NULL) { return; @@ -1305,13 +1305,13 @@ static void pack_resize_response(struct lcrd_container_resize_response *response if (id != NULL) { response->id = util_strdup_s(id); } - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } -static int resize_request_check(const struct lcrd_container_resize_request *request) +static int resize_request_check(const struct isulad_container_resize_request *request) { int ret = 0; @@ -1324,14 +1324,14 @@ static int resize_request_check(const struct lcrd_container_resize_request *requ if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); + isulad_set_error_message("Invalid container name %s", name); ret = -1; goto out; } if (request->suffix != NULL && !util_valid_exec_suffix(request->suffix)) { ERROR("Invalid suffix name %s", name); - lcrd_set_error_message("Invalid suffix name %s", name); + isulad_set_error_message("Invalid suffix name %s", name); ret = -1; goto out; } @@ -1340,11 +1340,11 @@ out: return ret; } -static int container_resize_cb(const struct lcrd_container_resize_request *request, - struct lcrd_container_resize_response **response) +static int container_resize_cb(const struct isulad_container_resize_request *request, + struct isulad_container_resize_response **response) { int ret = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *name = NULL; char *id = NULL; container_t *cont = NULL; @@ -1355,15 +1355,15 @@ static int container_resize_cb(const struct lcrd_container_resize_request *reque return -1; } - *response = util_common_calloc_s(sizeof(struct lcrd_container_resize_response)); + *response = util_common_calloc_s(sizeof(struct isulad_container_resize_response)); if (*response == NULL) { ERROR("Resume: Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } if (resize_request_check(request) != 0) { - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } @@ -1372,8 +1372,8 @@ static int container_resize_cb(const struct lcrd_container_resize_request *reque cont = containers_store_get(name); if (cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1383,8 +1383,8 @@ static int container_resize_cb(const struct lcrd_container_resize_request *reque ret = resize_container(cont, request->suffix, request->height, request->width); if (ret != 0) { - cc = LCRD_ERR_EXEC; - container_state_set_error(cont->state, (const char *)g_lcrd_errmsg); + cc = ISULAD_ERR_EXEC; + container_state_set_error(cont->state, (const char *)g_isulad_errmsg); goto pack_response; } @@ -1394,7 +1394,7 @@ pack_response: pack_resize_response(*response, cc, id); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } void container_extend_callback_init(service_container_callback_t *cb) diff --git a/src/services/execution/execute/execution_information.c b/src/services/execution/execute/execution_information.c index ab8c84cb203ebc8e08a101af91e3fd1d12cfc194..1cb8b43fe94c83a28a2ed8a6b6cc5a17e87a621a 100644 --- a/src/services/execution/execute/execution_information.c +++ b/src/services/execution/execute/execution_information.c @@ -29,7 +29,7 @@ #include "log.h" #include "engine.h" #include "console.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "config.h" #include "image.h" #include "execution.h" @@ -48,7 +48,7 @@ static int container_version_cb(const container_version_request *request, container_version_response **response) { char *rootpath = NULL; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; DAEMON_CLEAR_ERRMSG(); @@ -60,18 +60,18 @@ static int container_version_cb(const container_version_request *request, contai *response = util_common_calloc_s(sizeof(container_version_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } (*response)->version = util_strdup_s(VERSION); - (*response)->git_commit = util_strdup_s(LCRD_GIT_COMMIT); - (*response)->build_time = util_strdup_s(LCRD_BUILD_TIME); + (*response)->git_commit = util_strdup_s(ISULAD_GIT_COMMIT); + (*response)->build_time = util_strdup_s(ISULAD_BUILD_TIME); - rootpath = conf_get_lcrd_rootdir(); + rootpath = conf_get_isulad_rootdir(); if (rootpath == NULL) { ERROR("Failed to get root directory"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } (*response)->root_path = util_strdup_s(rootpath); @@ -85,7 +85,7 @@ pack_response: free_log_prefix(); DAEMON_CLEAR_ERRMSG(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } #define STOP_JSON "{\"filters\":{\"status\":{\"exited\":true}}}" @@ -187,7 +187,7 @@ static int isulad_info_cb(const host_info_request *request, host_info_response * int cPaused = 0; int cStopped = 0; size_t images_num = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; uint64_t total_mem = 0; uint64_t sysmem_limit = 0; char *http_proxy = NULL; @@ -197,6 +197,7 @@ static int isulad_info_cb(const host_info_request *request, host_info_response * char *huge_page_size = NULL; struct utsname u; im_image_count_request *im_request = NULL; + char *rootpath = NULL; DAEMON_CLEAR_ERRMSG(); @@ -208,21 +209,21 @@ static int isulad_info_cb(const host_info_request *request, host_info_response * *response = util_common_calloc_s(sizeof(host_info_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } ret = get_container_nums(&cRunning, &cPaused, &cStopped); if (ret != 0) { ERROR("Failed to get container status info!"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } im_request = util_common_calloc_s(sizeof(im_image_count_request)); if (im_request == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } #ifdef ENABLE_OCI_IMAGE @@ -233,21 +234,21 @@ static int isulad_info_cb(const host_info_request *request, host_info_response * operating_system = get_operating_system(); if (operating_system == NULL) { ERROR("Failed to get operating system info!"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } huge_page_size = get_default_huge_page_size(); if (huge_page_size == NULL) { ERROR("Failed to get system hugepage size!"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } sysmem_limit = get_default_total_mem_size(); if (sysmem_limit == 0) { ERROR("Failed to get total mem!"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -255,28 +256,34 @@ static int isulad_info_cb(const host_info_request *request, host_info_response * if (uname(&u) != 0) { ERROR("Failed to get kernel info!"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } ret = get_proxy_env(&http_proxy, HTTP_PROXY); if (ret != 0) { ERROR("Failed to get http proxy env!"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } ret = get_proxy_env(&https_proxy, HTTPS_PROXY); if (ret != 0) { ERROR("Failed to get https proxy env!"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } ret = get_proxy_env(&no_proxy, NO_PROXY); if (ret != 0) { ERROR("Failed to get no proxy env!"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; + goto pack_response; + } + rootpath = conf_get_isulad_rootdir(); + if (rootpath == NULL) { + ERROR("Get isulad rootpath failed"); + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -295,7 +302,8 @@ static int isulad_info_cb(const host_info_request *request, host_info_response * (*response)->cgroup_driver = util_strdup_s("cgroupfs"); (*response)->logging_driver = util_strdup_s("json-file"); (*response)->huge_page_size = util_strdup_s(huge_page_size); - (*response)->isulad_root_dir = util_strdup_s(LCRD_ROOT_PATH); + (*response)->isulad_root_dir = rootpath; + rootpath = NULL; (*response)->total_mem = (uint32_t)total_mem; (*response)->http_proxy = util_strdup_s(http_proxy); (*response)->https_proxy = util_strdup_s(https_proxy); @@ -305,12 +313,13 @@ pack_response: if (*response != NULL) { (*response)->cc = cc; } + free(rootpath); free(huge_page_size); free(operating_system); free_im_image_count_request(im_request); free_log_prefix(); DAEMON_CLEAR_ERRMSG(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } int get_stime(const char *title_line) @@ -356,7 +365,7 @@ static int parse_output_check(char **pid_s, int pid_num, int *out_num) int ret = 0; // be able to display thread line also when "m" option used - // in "lcrc top" client command + // in "isula top" client command if (strcmp(pid_s[pid_num], "-") == 0) { } else { if (util_safe_int(pid_s[pid_num], out_num) || *out_num < 0) { @@ -597,7 +606,7 @@ static int container_top_cb_check(const container_top_request *request, containe *response = util_common_calloc_s(sizeof(container_top_response)); if (*response == NULL) { ERROR("Out of memory"); - *cc = LCRD_ERR_MEMOUT; + *cc = ISULAD_ERR_MEMOUT; return -1; } @@ -605,36 +614,36 @@ static int container_top_cb_check(const container_top_request *request, containe if (name == NULL) { DEBUG("receive NULL Request id"); - *cc = LCRD_ERR_INPUT; + *cc = ISULAD_ERR_INPUT; return -1; } if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); - *cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name %s", name); + *cc = ISULAD_ERR_EXEC; return -1; } *cont = containers_store_get(name); if (*cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); - *cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", name); + *cc = ISULAD_ERR_EXEC; return -1; } if (!is_running((*cont)->state)) { ERROR("Container is not running"); - lcrd_set_error_message("Container is is not running."); - *cc = LCRD_ERR_EXEC; + isulad_set_error_message("Container is is not running."); + *cc = ISULAD_ERR_EXEC; return -1; } if (is_restarting((*cont)->state)) { ERROR("Container %s is restarting, wait until the container is running.", name); - lcrd_set_error_message("Container %s is restarting, wait until the container is running.", name); - *cc = LCRD_ERR_EXEC; + isulad_set_error_message("Container %s is restarting, wait until the container is running.", name); + *cc = ISULAD_ERR_EXEC; return -1; } @@ -689,8 +698,8 @@ static int do_top(const container_top_request *request, container_t *cont, size_ if (!command_ret) { ERROR("Failed to get container ps info with error: %s", *stderr_buffer ? *stderr_buffer : "Failed to exec ps command"); - lcrd_set_error_message("Failed to get container ps info with error: %s", - *stderr_buffer ? *stderr_buffer : "Failed to exec ps command"); + isulad_set_error_message("Failed to get container ps info with error: %s", + *stderr_buffer ? *stderr_buffer : "Failed to exec ps command"); free(*stdout_buffer); *stdout_buffer = NULL; free(*stderr_buffer); @@ -702,7 +711,7 @@ static int do_top(const container_top_request *request, container_t *cont, size_ if (!command_ret) { ERROR("Failed to get container ps info with error: %s", *stderr_buffer ? *stderr_buffer : "Failed to exec ps command"); - lcrd_set_error_message("Failed to container ps info with error: %s", *stderr_buffer); + isulad_set_error_message("Failed to container ps info with error: %s", *stderr_buffer); ret = -1; goto out; } @@ -715,7 +724,7 @@ out: static int container_top_cb(container_top_request *request, container_top_response **response) { size_t i = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *id = NULL; char *rootpath = NULL; char *runtime = NULL; @@ -737,7 +746,7 @@ static int container_top_cb(container_top_request *request, container_top_respon } if (top_append_args(request)) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -752,29 +761,29 @@ static int container_top_cb(container_top_request *request, container_top_respon if (get_pids(id, runtime, rootpath, &pids, &pids_len, &pid_args) != 0) { ERROR("failed to get all pids"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (do_top(request, cont, pids_len, pid_args, &stdout_buffer, &stderr_buffer) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (parse_output(&titles, &processes, stdout_buffer, pids, pids_len)) { ERROR("Failed to parse output!"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (util_array_len((const char **)processes) > SIZE_MAX / sizeof(char *)) { ERROR("invalid processe size"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } (*response)->processes = util_common_calloc_s(util_array_len((const char **)processes) * sizeof(char *)); if ((*response)->processes == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -801,7 +810,7 @@ pack_response: util_free_array(processes); free_log_prefix(); DAEMON_CLEAR_ERRMSG(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int dup_path_and_args(const container_t *cont, char **path, char ***args, size_t *args_len) @@ -1223,8 +1232,8 @@ static int merge_default_ulimit_with_ulimit(container_inspect *out_inspect) host_config_ulimits_element **rlimits = NULL; size_t i, j, ulimits_len; - if (conf_get_lcrd_default_ulimit(&rlimits) != 0) { - ERROR("Failed to get lcrd default ulimit"); + if (conf_get_isulad_default_ulimit(&rlimits) != 0) { + ERROR("Failed to get isulad default ulimit"); ret = -1; goto out; } @@ -1313,7 +1322,7 @@ static int inspect_container_helper(const char *id, int timeout, char **containe if (!util_valid_container_id_or_name(id)) { ERROR("Inspect invalid name %s", id); - lcrd_set_error_message("Inspect invalid name %s", id); + isulad_set_error_message("Inspect invalid name %s", id); ret = -1; goto out; } @@ -1321,14 +1330,14 @@ static int inspect_container_helper(const char *id, int timeout, char **containe cont = containers_store_get(id); if (cont == NULL) { ret = -1; - lcrd_try_set_error_message("No such image or container or accelerator:%s", id); + isulad_try_set_error_message("No such image or container or accelerator:%s", id); goto out; } ret = container_timedlock(cont, timeout); if (ret != 0) { ERROR("Container %s inspect failed due to trylock timeout for %ds.", id, timeout); - lcrd_try_set_error_message("Container %s inspect failed due to trylock timeout for %ds.", id, timeout); + isulad_try_set_error_message("Container %s inspect failed due to trylock timeout for %ds.", id, timeout); ret = -2; goto out; } @@ -1358,7 +1367,7 @@ out: static int container_inspect_cb(const container_inspect_request *request, container_inspect_response **response) { int timeout = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *name = NULL; char *container_json = NULL; @@ -1372,7 +1381,7 @@ static int container_inspect_cb(const container_inspect_request *request, contai *response = util_common_calloc_s(sizeof(container_inspect_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } @@ -1381,7 +1390,7 @@ static int container_inspect_cb(const container_inspect_request *request, contai if (name == NULL) { ERROR("receive NULL Request id"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } @@ -1390,14 +1399,14 @@ static int container_inspect_cb(const container_inspect_request *request, contai INFO("Inspect :%s", name); if (inspect_container_helper(name, timeout, &container_json) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; } pack_response: if (*response != NULL) { (*response)->cc = cc; - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } (*response)->container_json = container_json; @@ -1405,7 +1414,7 @@ pack_response: free_log_prefix(); malloc_trim(0); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static void pack_wait_response(container_wait_response *response, uint32_t cc, uint32_t exit_code) @@ -1414,8 +1423,8 @@ static void pack_wait_response(container_wait_response *response, uint32_t cc, u return; } response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } response->exit_code = exit_code; @@ -1425,7 +1434,7 @@ static int container_wait_cb(const container_wait_request *request, container_wa { char *name = NULL; char *id = NULL; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; uint32_t exit_code = 0; container_t *cont = NULL; @@ -1439,7 +1448,7 @@ static int container_wait_cb(const container_wait_request *request, container_wa *response = util_common_calloc_s(sizeof(container_wait_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } @@ -1447,22 +1456,22 @@ static int container_wait_cb(const container_wait_request *request, container_wa if (name == NULL) { DEBUG("receive NULL Request id"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name %s", name); + cc = ISULAD_ERR_EXEC; goto pack_response; } cont = containers_store_get(name); if (cont == NULL) { ERROR("No such container '%s'", name); - cc = LCRD_ERR_EXEC; - lcrd_try_set_error_message("No such container:%s", name); + cc = ISULAD_ERR_EXEC; + isulad_try_set_error_message("No such container:%s", name); goto pack_response; } @@ -1483,31 +1492,31 @@ pack_response: pack_wait_response(*response, cc, exit_code); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } -static int rename_request_check(const struct lcrd_container_rename_request *request) +static int rename_request_check(const struct isulad_container_rename_request *request) { int ret = 0; if (!util_valid_str(request->old_name) || !util_valid_str(request->new_name)) { ERROR("Neither old nor new names may be empty"); - lcrd_set_error_message("Neither old nor new names may be empty"); + isulad_set_error_message("Neither old nor new names may be empty"); ret = -1; goto out; } if (!util_valid_container_id_or_name(request->old_name)) { ERROR("Invalid container old name (%s)", request->old_name); - lcrd_set_error_message("Invalid container old name (%s)", request->old_name); + isulad_set_error_message("Invalid container old name (%s)", request->old_name); ret = -1; goto out; } if (!util_valid_container_name(request->new_name)) { ERROR("Invalid container new name (%s), only [a-zA-Z0-9][a-zA-Z0-9_.-]+$ are allowed.", request->new_name); - lcrd_set_error_message("Invalid container new name (%s), only [a-zA-Z0-9][a-zA-Z0-9_.-]+$ are allowed.", - request->new_name); + isulad_set_error_message("Invalid container new name (%s), only [a-zA-Z0-9][a-zA-Z0-9_.-]+$ are allowed.", + request->new_name); ret = -1; goto out; } @@ -1516,11 +1525,11 @@ out: return ret; } -static void pack_rename_response(struct lcrd_container_rename_response *response, const char *id, uint32_t cc) +static void pack_rename_response(struct isulad_container_rename_response *response, const char *id, uint32_t cc) { response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } if (id != NULL) { @@ -1552,23 +1561,23 @@ static int container_rename(container_t *cont, const char *new_name) if (strcmp(old_name, new_name) == 0) { ERROR("Renaming a container with the same name as its current name"); - lcrd_set_error_message("Renaming a container with the same name as its current name"); + isulad_set_error_message("Renaming a container with the same name as its current name"); ret = -1; goto out; } if (is_removal_in_progress(cont->state) || is_dead(cont->state)) { ERROR("Can't rename container which is dead or marked for removal"); - lcrd_set_error_message("Can't rename container which is dead or marked for removal"); + isulad_set_error_message("Can't rename container which is dead or marked for removal"); ret = -1; goto out; } if (!name_index_rename(new_name, old_name, id)) { ERROR("Name %s is in use", new_name); - lcrd_set_error_message("Conflict. The name \"%s\" is already in use by container %s. " - "You have to remove (or rename) that container to be able to reuse that name.", - new_name, new_name); + isulad_set_error_message("Conflict. The name \"%s\" is already in use by container %s. " + "You have to remove (or rename) that container to be able to reuse that name.", + new_name, new_name); ret = -1; goto out; } @@ -1578,7 +1587,7 @@ static int container_rename(container_t *cont, const char *new_name) if (container_to_disk(cont) != 0) { ERROR("Failed to save container config of %s in renaming %s progress", id, new_name); - lcrd_set_error_message("Failed to save container config of %s in renaming %s progress", id, new_name); + isulad_set_error_message("Failed to save container config of %s in renaming %s progress", id, new_name); ret = -1; goto restore; } @@ -1593,10 +1602,10 @@ out: return ret; } -static int container_rename_cb(const struct lcrd_container_rename_request *request, - struct lcrd_container_rename_response **response) +static int container_rename_cb(const struct isulad_container_rename_request *request, + struct isulad_container_rename_response **response) { - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *id = NULL; char *old_name = NULL; char *new_name = NULL; @@ -1616,7 +1625,7 @@ static int container_rename_cb(const struct lcrd_container_rename_request *reque } if (rename_request_check(request) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } old_name = request->old_name; @@ -1625,8 +1634,8 @@ static int container_rename_cb(const struct lcrd_container_rename_request *reque cont = containers_store_get(old_name); if (cont == NULL) { ERROR("No such container:%s", old_name); - lcrd_set_error_message("No such container:%s", old_name); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", old_name); + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1636,7 +1645,7 @@ static int container_rename_cb(const struct lcrd_container_rename_request *reque EVENT("Event: {Object: %s, Type: Renaming}", id); if (container_rename(cont, new_name) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -1647,7 +1656,7 @@ pack_response: pack_rename_response(*response, id, cc); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } void container_information_callback_init(service_container_callback_t *cb) diff --git a/src/services/execution/execute/execution_network.c b/src/services/execution/execute/execution_network.c index fff0e971c2365025b7403e15f3c612cf3aa7104b..85a7ba5016e0964f2ad79eedb5e0e72e0e8c635c 100644 --- a/src/services/execution/execute/execution_network.c +++ b/src/services/execution/execute/execution_network.c @@ -30,7 +30,7 @@ #include "log.h" #include "utils.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "config.h" #include "containers_store.h" #include "namespace.h" @@ -43,14 +43,14 @@ static int write_hostname_to_file(const char *rootfs, const char *hostname) if (realpath_in_scope(rootfs, "/etc/hostname", &file_path) < 0) { SYSERROR("Failed to get real path '/etc/hostname' under rootfs '%s'", rootfs); - lcrd_set_error_message("Failed to get real path '/etc/hostname' under rootfs '%s'", rootfs); + isulad_set_error_message("Failed to get real path '/etc/hostname' under rootfs '%s'", rootfs); goto error_out; } if (hostname != NULL) { ret = util_write_file(file_path, hostname, strlen(hostname)); if (ret) { SYSERROR("Failed to write %s", file_path); - lcrd_set_error_message("Failed to write %s: %s", file_path, strerror(errno)); + isulad_set_error_message("Failed to write %s: %s", file_path, strerror(errno)); goto error_out; } } @@ -64,13 +64,13 @@ static int fopen_network(FILE **fp, char **file_path, const char *rootfs, const { if (realpath_in_scope(rootfs, filename, file_path) < 0) { SYSERROR("Failed to get real path '%s' under rootfs '%s'", filename, rootfs); - lcrd_set_error_message("Failed to get real path '%s' under rootfs '%s'", filename, rootfs); + isulad_set_error_message("Failed to get real path '%s' under rootfs '%s'", filename, rootfs); return -1; } *fp = util_fopen(*file_path, "a+"); if (*fp == NULL) { SYSERROR("Failed to open %s", *file_path); - lcrd_set_error_message("Failed to open %s: %s", *file_path, strerror(errno)); + isulad_set_error_message("Failed to open %s: %s", *file_path, strerror(errno)); return -1; } return 0; @@ -142,7 +142,7 @@ static int write_content_to_file(const char *file_path, const char *content) ret = util_write_file(file_path, content, strlen(content)); if (ret != 0) { SYSERROR("Failed to write file %s", file_path); - lcrd_set_error_message("Failed to write file %s: %s", file_path, strerror(errno)); + isulad_set_error_message("Failed to write file %s: %s", file_path, strerror(errno)); return ret; } } @@ -666,17 +666,17 @@ static int chown_network(const char *user_remap, const char *rootfs, const char } if (realpath_in_scope(rootfs, filename, &file_path) < 0) { SYSERROR("Failed to get real path '%s' under rootfs '%s'", filename, rootfs); - lcrd_set_error_message("Failed to get real path '%s' under rootfs '%s'", filename, rootfs); + isulad_set_error_message("Failed to get real path '%s' under rootfs '%s'", filename, rootfs); ret = -1; goto out; } if (chown(file_path, host_uid, host_gid) != 0) { SYSERROR("Failed to chown network file '%s' to %u:%u", filename, host_uid, host_gid); - lcrd_set_error_message("Failed to chown network file '%s' to %u:%u: %s", - filename, - host_uid, - host_gid, - strerror(errno)); + isulad_set_error_message("Failed to chown network file '%s' to %u:%u: %s", + filename, + host_uid, + host_gid, + strerror(errno)); ret = -1; goto out; } @@ -730,12 +730,12 @@ static container_t *get_networked_container(const char *id, const char *connecte nc = containers_store_get(connected_id); if (nc == NULL) { ERROR("No such container: %s", connected_id); - lcrd_set_error_message("No such container: %s", connected_id); + isulad_set_error_message("No such container: %s", connected_id); return NULL; } if (strcmp(id, nc->common_config->id) == 0) { ERROR("cannot join own network"); - lcrd_set_error_message("cannot join own network"); + isulad_set_error_message("cannot join own network"); goto cleanup; } if (!check_state) { @@ -743,12 +743,12 @@ static container_t *get_networked_container(const char *id, const char *connecte } if (!is_running(nc->state)) { ERROR("cannot join network of a non running container: %s", connected_id); - lcrd_set_error_message("cannot join network of a non running container: %s", connected_id); + isulad_set_error_message("cannot join network of a non running container: %s", connected_id); goto cleanup; } if (is_restarting(nc->state)) { ERROR("Container %s is restarting, wait until the container is running", connected_id); - lcrd_set_error_message("Container %s is restarting, wait until the container is running", connected_id); + isulad_set_error_message("Container %s is restarting, wait until the container is running", connected_id); goto cleanup; } diff --git a/src/services/execution/execute/execution_stream.c b/src/services/execution/execute/execution_stream.c index c05bd9af7db398c8e5b0761b8a9aa86f7dcf31fd..26110ce2832ee5e1e7dd4e396e555239a3b68517 100644 --- a/src/services/execution/execute/execution_stream.c +++ b/src/services/execution/execute/execution_stream.c @@ -32,11 +32,11 @@ #include "log.h" #include "engine.h" #include "console.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "config.h" #include "image.h" #include "path.h" -#include "lcrdtar.h" +#include "libtar.h" #include "container_inspect.h" #include "containers_store.h" #include "container_state.h" @@ -258,13 +258,13 @@ static int exec_container(container_t *cont, const char *runtime, char * const c char *logdriver = NULL; rt_exec_params_t params = { 0 }; - loglevel = conf_get_lcrd_loglevel(); + loglevel = conf_get_isulad_loglevel(); if (loglevel == NULL) { ERROR("Exec: failed to get log level"); ret = -1; goto out; } - logdriver = conf_get_lcrd_logdriver(); + logdriver = conf_get_isulad_logdriver(); if (logdriver == NULL) { ERROR("Exec: Failed to get log driver"); ret = -1; @@ -314,7 +314,7 @@ static int container_exec_cb_check(const container_exec_request *request, contai *response = util_common_calloc_s(sizeof(container_exec_response)); if (*response == NULL) { ERROR("Out of memory"); - *cc = LCRD_ERR_MEMOUT; + *cc = ISULAD_ERR_MEMOUT; return -1; } @@ -322,29 +322,29 @@ static int container_exec_cb_check(const container_exec_request *request, contai if (container_name == NULL) { ERROR("receive NULL Request id"); - *cc = LCRD_ERR_INPUT; + *cc = ISULAD_ERR_INPUT; return -1; } if (!util_valid_container_id_or_name(container_name)) { ERROR("Invalid container name %s", container_name); - lcrd_set_error_message("Invalid container name %s", container_name); - *cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name %s", container_name); + *cc = ISULAD_ERR_EXEC; return -1; } if (request->suffix != NULL && !util_valid_exec_suffix(request->suffix)) { ERROR("Invalid exec suffix %s", request->suffix); - lcrd_set_error_message("Invalid exec suffix %s", request->suffix); - *cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid exec suffix %s", request->suffix); + *cc = ISULAD_ERR_EXEC; return -1; } *cont = containers_store_get(container_name); if (*cont == NULL) { ERROR("No such container:%s", container_name); - lcrd_set_error_message("No such container:%s", container_name); - *cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", container_name); + *cc = ISULAD_ERR_EXEC; return -1; } @@ -388,12 +388,12 @@ static void container_exec_cb_end(container_exec_response *response, uint32_t cc if (response != NULL) { response->cc = cc; response->exit_code = (uint32_t)exit_code; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } - if (sync_fd >= 0 && cc != LCRD_SUCCESS) { + if (sync_fd >= 0 && cc != ISULAD_SUCCESS) { if (eventfd_write(sync_fd, 1) < 0) { ERROR("Failed to write eventfd: %s", strerror(errno)); } @@ -441,18 +441,18 @@ static int get_user_and_groups_conf(const container_t *cont, const char *usernam // user string(UID:GID) static int generate_user_string_by_uid_gid(const oci_runtime_spec_process_user *puser, char **user) { - char uid_str[LCRD_NUMSTRLEN32] = { 0 }; - char gid_str[LCRD_NUMSTRLEN32] = { 0 }; + char uid_str[ISULAD_NUMSTRLEN32] = { 0 }; + char gid_str[ISULAD_NUMSTRLEN32] = { 0 }; size_t len; - int nret = snprintf(uid_str, LCRD_NUMSTRLEN32, "%u", (unsigned int)puser->uid); - if (nret >= LCRD_NUMSTRLEN32 || nret < 0) { + int nret = snprintf(uid_str, ISULAD_NUMSTRLEN32, "%u", (unsigned int)puser->uid); + if (nret >= ISULAD_NUMSTRLEN32 || nret < 0) { ERROR("Invalid UID:%u", (unsigned int)puser->uid); return -1; } - nret = snprintf(gid_str, LCRD_NUMSTRLEN32, "%u", (unsigned int)puser->gid); - if (nret >= LCRD_NUMSTRLEN32 || nret < 0) { + nret = snprintf(gid_str, ISULAD_NUMSTRLEN32, "%u", (unsigned int)puser->gid); + if (nret >= ISULAD_NUMSTRLEN32 || nret < 0) { ERROR("Invalid attach uid value :%u", (unsigned int)puser->gid); return -1; } @@ -510,7 +510,7 @@ static int container_exec_cb(const container_exec_request *request, container_ex { int exit_code = 0; int sync_fd = -1; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *id = NULL; char *fifos[3] = { NULL, NULL, NULL }; char *fifopath = NULL; @@ -530,7 +530,7 @@ static int container_exec_cb(const container_exec_request *request, container_ex id = cont->common_config->id; if (get_exec_user_string(cont, request->user, &user) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -538,42 +538,42 @@ static int container_exec_cb(const container_exec_request *request, container_ex EVENT("Event: {Object: %s, Type: execing}", id); if (gc_is_gc_progress(id)) { - lcrd_set_error_message("You cannot exec container %s in garbage collector progress.", id); + isulad_set_error_message("You cannot exec container %s in garbage collector progress.", id); ERROR("You cannot exec container %s in garbage collector progress.", id); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (!is_running(cont->state)) { ERROR("Container %s is not running", id); - lcrd_set_error_message("Container %s is not running", id); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Container %s is not running", id); + cc = ISULAD_ERR_EXEC; goto pack_response; } if (is_paused(cont->state)) { ERROR("Container %s ispaused, unpause the container before exec", id); - lcrd_set_error_message("Container %s paused, unpause the container before exec", id); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Container %s paused, unpause the container before exec", id); + cc = ISULAD_ERR_EXEC; goto pack_response; } if (is_restarting(cont->state)) { ERROR("Container %s is currently restarting, wait until the container is running", id); - lcrd_set_error_message("Container %s is currently restarting, wait until the container is running", id); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("Container %s is currently restarting, wait until the container is running", id); + cc = ISULAD_ERR_EXEC; goto pack_response; } if (exec_prepare_console(cont, request, stdinfd, stdout_handler, fifos, &fifopath, &sync_fd, &thread_id)) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (exec_container(cont, cont->runtime, (char * const *)fifos, user, request->argv_len, (const char **)request->argv, request->env_len, (const char **)request->env, request->timeout, request->suffix, &exit_code)) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -590,7 +590,7 @@ pack_response: container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } static int container_attach_cb_check(const container_attach_request *request, container_attach_response **response, @@ -601,7 +601,7 @@ static int container_attach_cb_check(const container_attach_request *request, co *response = util_common_calloc_s(sizeof(container_attach_response)); if (*response == NULL) { ERROR("Out of memory"); - *cc = LCRD_ERR_MEMOUT; + *cc = ISULAD_ERR_MEMOUT; return -1; } @@ -609,22 +609,22 @@ static int container_attach_cb_check(const container_attach_request *request, co if (name == NULL) { DEBUG("Receive NULL Request id"); - *cc = LCRD_ERR_INPUT; + *cc = ISULAD_ERR_INPUT; return -1; } if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); - *cc = LCRD_ERR_EXEC; + isulad_set_error_message("Invalid container name %s", name); + *cc = ISULAD_ERR_EXEC; return -1; } *cont = containers_store_get(name); if (*cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); - *cc = LCRD_ERR_EXEC; + isulad_set_error_message("No such container:%s", name); + *cc = ISULAD_ERR_EXEC; return -1; } return 0; @@ -637,21 +637,21 @@ static int attach_check_container_state(const container_t *cont) if (!is_running(cont->state)) { ERROR("Container is not running"); - lcrd_set_error_message("Container is is not running."); + isulad_set_error_message("Container is is not running."); ret = -1; goto out; } if (is_paused(cont->state)) { ERROR("Container %s is paused, unpause the container before attach.", id); - lcrd_set_error_message("Container %s is paused, unpause the container before attach.", id); + isulad_set_error_message("Container %s is paused, unpause the container before attach.", id); ret = -1; goto out; } if (is_restarting(cont->state)) { ERROR("Container %s is restarting, wait until the container is running.", id); - lcrd_set_error_message("Container %s is restarting, wait until the container is running.", id); + isulad_set_error_message("Container %s is restarting, wait until the container is running.", id); ret = -1; goto out; } @@ -701,7 +701,7 @@ static int container_attach_cb(const container_attach_request *request, containe struct io_write_wrapper *stderr_handler) { char *id = NULL; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *fifos[3] = { NULL, NULL, NULL }; char *fifopath = NULL; pthread_t tid = 0; @@ -723,12 +723,12 @@ static int container_attach_cb(const container_attach_request *request, containe if (attach_check_container_state(cont)) { close_io_writer(stdout_handler, stderr_handler); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (attach_prepare_console(cont, request, stdinfd, stdout_handler, stderr_handler, fifos, &fifopath, &tid) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; close_io_writer(stdout_handler, stderr_handler); goto pack_response; } @@ -740,15 +740,15 @@ static int container_attach_cb(const container_attach_request *request, containe if (runtime_attach(cont->common_config->id, cont->runtime, ¶ms)) { ERROR("Runtime attach container failed"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } pack_response: if (*response != NULL) { (*response)->cc = cc; - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -760,17 +760,17 @@ pack_response: free(fifopath); container_unref(cont); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } -static int copy_from_container_cb_check(const struct lcrd_copy_from_container_request *request, - struct lcrd_copy_from_container_response **response, +static int copy_from_container_cb_check(const struct isulad_copy_from_container_request *request, + struct isulad_copy_from_container_response **response, container_t **cont) { int ret = -1; char *name = NULL; - *response = util_common_calloc_s(sizeof(struct lcrd_copy_from_container_response)); + *response = util_common_calloc_s(sizeof(struct isulad_copy_from_container_response)); if (*response == NULL) { ERROR("Out of memory"); return -1; @@ -784,20 +784,20 @@ static int copy_from_container_cb_check(const struct lcrd_copy_from_container_re if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); + isulad_set_error_message("Invalid container name %s", name); goto out; } if (request->srcpath == NULL || request->srcpath[0] == '\0') { ERROR("bad parameter: path cannot be empty"); - lcrd_set_error_message("bad parameter: path cannot be empty"); + isulad_set_error_message("bad parameter: path cannot be empty"); goto out; } *cont = containers_store_get(name); if (*cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); + isulad_set_error_message("No such container:%s", name); goto out; } @@ -807,7 +807,7 @@ out: } static int archive_and_send_copy_data(const stream_func_wrapper *stream, - struct lcrd_copy_from_container_response *response, + struct isulad_copy_from_container_response *response, const char *resolvedpath, const char *abspath) { int ret = -1; @@ -874,7 +874,7 @@ cleanup: if (reader.close != NULL) { int cret = reader.close(reader.context, &err); if (err != NULL) { - lcrd_set_error_message("%s", err); + isulad_set_error_message("%s", err); } ret = (cret != 0) ? cret : ret; } @@ -894,7 +894,7 @@ static container_path_stat *do_container_stat_path(const char *rootpath, const c nret = lstat(resolvedpath, &st); if (nret < 0) { ERROR("lstat %s: %s", resolvedpath, strerror(errno)); - lcrd_set_error_message("lstat %s: %s", resolvedpath, strerror(errno)); + isulad_set_error_message("lstat %s: %s", resolvedpath, strerror(errno)); goto cleanup; } @@ -1058,7 +1058,7 @@ out: return ret; } -static int copy_from_container_cb(const struct lcrd_copy_from_container_request *request, +static int copy_from_container_cb(const struct isulad_copy_from_container_request *request, const stream_func_wrapper *stream, char **err) { int ret = -1; @@ -1067,7 +1067,7 @@ static int copy_from_container_cb(const struct lcrd_copy_from_container_request char *abspath = NULL; container_path_stat *stat = NULL; container_t *cont = NULL; - struct lcrd_copy_from_container_response *response = NULL; + struct isulad_copy_from_container_response *response = NULL; bool need_pause = false; DAEMON_CLEAR_ERRMSG(); @@ -1084,7 +1084,7 @@ static int copy_from_container_cb(const struct lcrd_copy_from_container_request if (is_removal_in_progress(cont->state) || is_dead(cont->state)) { ERROR("can't copy file from a container which is dead or marked for removal"); - lcrd_set_error_message("can't copy file from a container which is dead or marked for removal"); + isulad_set_error_message("can't copy file from a container which is dead or marked for removal"); goto unlock_container; } @@ -1092,7 +1092,7 @@ static int copy_from_container_cb(const struct lcrd_copy_from_container_request if (need_pause) { if (pause_container(cont) != 0) { ERROR("can't copy to a container which is cannot be paused"); - lcrd_set_error_message("can't copy to a container which is cannot be paused"); + isulad_set_error_message("can't copy to a container which is cannot be paused"); goto unlock_container; } } @@ -1135,10 +1135,10 @@ unlock_container: container_unlock(cont); container_unref(cont); pack_response: - if (g_lcrd_errmsg != NULL) { - *err = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + *err = util_strdup_s(g_isulad_errmsg); } - lcrd_copy_from_container_response_free(response); + isulad_copy_from_container_response_free(response); free_container_path_stat(stat); free(resolvedpath); free(abspath); @@ -1160,20 +1160,20 @@ static int copy_to_container_cb_check(const container_copy_to_request *request, if (!util_valid_container_id_or_name(name)) { ERROR("Invalid container name %s", name); - lcrd_set_error_message("Invalid container name %s", name); + isulad_set_error_message("Invalid container name %s", name); goto out; } if (request->src_path == NULL || request->src_path[0] == '\0') { ERROR("bad parameter: path cannot be empty"); - lcrd_set_error_message("bad parameter: path cannot be empty"); + isulad_set_error_message("bad parameter: path cannot be empty"); goto out; } *cont = containers_store_get(name); if (*cont == NULL) { ERROR("No such container:%s", name); - lcrd_set_error_message("No such container:%s", name); + isulad_set_error_message("No such container:%s", name); goto out; } @@ -1185,7 +1185,7 @@ out: static ssize_t extract_stream_to_io_read(void *content, void *buf, size_t buf_len) { stream_func_wrapper *stream = (stream_func_wrapper *)content; - struct lcrd_copy_to_container_data copy = { 0 }; + struct isulad_copy_to_container_data copy = { 0 }; if (!stream->read_func(stream->reader, ©)) { DEBUG("Client may exited"); @@ -1211,7 +1211,7 @@ int read_and_extract_archive(stream_func_wrapper *stream, const char *resolved_p ret = archive_untar(&content, false, resolved_path, transform, &err); if (ret != 0) { ERROR("Can not untar to container: %s", (err != NULL) ? err : "unknown"); - lcrd_set_error_message("Can not untar to container: %s", (err != NULL) ? err : "unknown"); + isulad_set_error_message("Can not untar to container: %s", (err != NULL) ? err : "unknown"); } free(err); return ret; @@ -1265,7 +1265,7 @@ static char *copy_to_container_get_dstdir(const container_t *cont, const contain ERROR("Can not prepare archive copy"); } else { ERROR("%s", error); - lcrd_set_error_message("%s", error); + isulad_set_error_message("%s", error); } goto cleanup; } @@ -1325,20 +1325,20 @@ static int copy_to_container_check_path_valid(const container_t *cont, const cha if (cont->hostconfig->readonly_rootfs) { ERROR("container rootfs is marked read-only"); - lcrd_set_error_message("container rootfs is marked read-only"); + isulad_set_error_message("container rootfs is marked read-only"); goto cleanup; } nret = lstat(resolvedpath, &st); if (nret < 0) { ERROR("lstat %s: %s", resolvedpath, strerror(errno)); - lcrd_set_error_message("lstat %s: %s", resolvedpath, strerror(errno)); + isulad_set_error_message("lstat %s: %s", resolvedpath, strerror(errno)); goto cleanup; } if (!S_ISDIR(st.st_mode)) { ERROR("extraction point is not a directory"); - lcrd_set_error_message("extraction point is not a directory"); + isulad_set_error_message("extraction point is not a directory"); goto cleanup; } ret = 0; @@ -1372,7 +1372,7 @@ static int copy_to_container_cb(const container_copy_to_request *request, if (is_removal_in_progress(cont->state) || is_dead(cont->state)) { ERROR("can't copy to a container which is dead or marked for removal"); - lcrd_set_error_message("can't copy to a container which is dead or marked for removal"); + isulad_set_error_message("can't copy to a container which is dead or marked for removal"); goto unlock_container; } @@ -1380,7 +1380,7 @@ static int copy_to_container_cb(const container_copy_to_request *request, if (need_pause) { if (pause_container(cont) != 0) { ERROR("can't copy to a container which is cannot be paused"); - lcrd_set_error_message("can't copy to a container which is cannot be paused"); + isulad_set_error_message("can't copy to a container which is cannot be paused"); goto unlock_container; } } @@ -1429,8 +1429,8 @@ unlock_container: container_unlock(cont); container_unref(cont); pack_response: - if (g_lcrd_errmsg != NULL) { - *err = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + *err = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } free(resolvedpath); @@ -1440,17 +1440,17 @@ pack_response: return ret; } -static int container_logs_cb_check(const struct lcrd_logs_request *request, struct lcrd_logs_response *response) +static int container_logs_cb_check(const struct isulad_logs_request *request, struct isulad_logs_response *response) { if (request == NULL || request->id == NULL) { - response->cc = LCRD_ERR_INPUT; + response->cc = ISULAD_ERR_INPUT; ERROR("Receive NULL request or id"); return -1; } if (!util_valid_container_id_or_name(request->id)) { ERROR("Invalid container name %s", request->id); - response->cc = LCRD_ERR_INPUT; + response->cc = ISULAD_ERR_INPUT; if (asprintf(&(response->errmsg), "Invalid container name %s", request->id) < 0) { response->errmsg = util_strdup_s("Out of memory"); } @@ -1979,13 +1979,13 @@ static int check_log_config(const struct container_log_config *log_config) return -1; } if (log_config->path == NULL) { - lcrd_set_error_message("Do not set log path"); + isulad_set_error_message("Do not set log path"); ERROR("Do not set log path"); return -1; } if (strcmp(log_config->path, "none") == 0) { ERROR("Disable console log"); - lcrd_set_error_message("disable console log"); + isulad_set_error_message("disable console log"); return -1; } return 0; @@ -2005,34 +2005,34 @@ static int container_get_container_log_config(const container_t *cont, struct co return 0; } -static void pack_logs_response(struct lcrd_logs_response *response, uint32_t cc) +static void pack_logs_response(struct isulad_logs_response *response, uint32_t cc) { if (response == NULL) { return; } response->cc = cc; - if (g_lcrd_errmsg != NULL) { - response->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + response->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } -static int container_logs_cb(const struct lcrd_logs_request *request, stream_func_wrapper *stream, - struct lcrd_logs_response **response) +static int container_logs_cb(const struct isulad_logs_request *request, stream_func_wrapper *stream, + struct isulad_logs_response **response) { int nret = 0; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; char *id = NULL; container_t *cont = NULL; struct container_log_config *log_config = NULL; struct last_log_file_position last_pos = {0}; - *response = (struct lcrd_logs_response *)util_common_calloc_s(sizeof(struct lcrd_logs_response)); + *response = (struct isulad_logs_response *)util_common_calloc_s(sizeof(struct isulad_logs_response)); if (*response == NULL) { ERROR("Out of memory"); return -1; } - (*response)->cc = LCRD_SUCCESS; + (*response)->cc = ISULAD_SUCCESS; /* check request */ if (container_logs_cb_check(request, *response) != 0) { @@ -2042,8 +2042,8 @@ static int container_logs_cb(const struct lcrd_logs_request *request, stream_fun cont = containers_store_get(request->id); if (cont == NULL) { ERROR("No such container: %s", request->id); - cc = LCRD_ERR_EXEC; - lcrd_set_error_message("No such container: %s", request->id); + cc = ISULAD_ERR_EXEC; + isulad_set_error_message("No such container: %s", request->id); goto out; } id = cont->common_config->id; @@ -2051,13 +2051,13 @@ static int container_logs_cb(const struct lcrd_logs_request *request, stream_fun /* check state of container */ if (gc_is_gc_progress(id)) { - lcrd_set_error_message("can not get logs from container which is dead or marked for removal"); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("can not get logs from container which is dead or marked for removal"); + cc = ISULAD_ERR_EXEC; ERROR("can not get logs from container which is dead or marked for removal"); goto out; } if (container_get_container_log_config(cont, &log_config) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto out; } @@ -2066,14 +2066,14 @@ static int container_logs_cb(const struct lcrd_logs_request *request, stream_fun nret = check_log_config(log_config); if (nret != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto out; } /* tail of container log file */ if (do_tail_container_logs(request->tail, log_config, stream, &last_pos) != 0) { - lcrd_set_error_message("do tail log file failed"); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("do tail log file failed"); + cc = ISULAD_ERR_EXEC; goto out; } @@ -2087,8 +2087,8 @@ static int container_logs_cb(const struct lcrd_logs_request *request, stream_fun /* follow of container log file */ if (do_follow_log_file(id, stream, &last_pos, log_config->path) != 0) { - lcrd_set_error_message("do follow log file failed"); - cc = LCRD_ERR_EXEC; + isulad_set_error_message("do follow log file failed"); + cc = ISULAD_ERR_EXEC; goto out; } @@ -2098,7 +2098,7 @@ out: container_unref(cont); container_log_config_free(log_config); free_log_prefix(); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } void container_stream_callback_init(service_container_callback_t *cb) diff --git a/src/services/execution/execute/list.c b/src/services/execution/execute/list.c index 71fdb37a16af60cc74ad4d736cbce48859faa8cc..fd61fba78789552b28622ad53d6cbd33f104adbe 100644 --- a/src/services/execution/execute/list.c +++ b/src/services/execution/execute/list.c @@ -294,16 +294,16 @@ char *container_get_health_state(const container_config_v2_state *cont_state) return util_strdup_s(cont_state->health->status); } -static int replace_labels(container_container *lcrdinfo, json_map_string_string *labels, const map_t *map_labels) +static int replace_labels(container_container *isuladinfo, json_map_string_string *labels, const map_t *map_labels) { - lcrdinfo->labels = util_common_calloc_s(sizeof(json_map_string_string)); + isuladinfo->labels = util_common_calloc_s(sizeof(json_map_string_string)); - if (lcrdinfo->labels == NULL) { + if (isuladinfo->labels == NULL) { ERROR("Out of memory"); return -1; } - if (dup_json_map_string_string(labels, lcrdinfo->labels) != 0) { + if (dup_json_map_string_string(labels, isuladinfo->labels) != 0) { ERROR("Failed to dup labels"); return -1; } @@ -318,18 +318,18 @@ static int replace_labels(container_container *lcrdinfo, json_map_string_string } static int replace_annotations(const container_config_v2_common_config *common_config, - container_container *lcrdinfo) + container_container *isuladinfo) { if (common_config->config->annotations != NULL && common_config->config->annotations->len != 0) { - lcrdinfo->annotations = util_common_calloc_s(sizeof(json_map_string_string)); - if (lcrdinfo->annotations == NULL) { + isuladinfo->annotations = util_common_calloc_s(sizeof(json_map_string_string)); + if (isuladinfo->annotations == NULL) { ERROR("Out of memory"); return -1; } if (dup_json_map_string_string(common_config->config->annotations, - lcrdinfo->annotations) != 0) { + isuladinfo->annotations) != 0) { ERROR("Failed to dup annotations"); return -1; } @@ -337,24 +337,24 @@ static int replace_annotations(const container_config_v2_common_config *common_c return 0; } -static void dup_id_name(const container_config_v2_common_config *common_config, container_container *lcrdinfo) +static void dup_id_name(const container_config_v2_common_config *common_config, container_container *isuladinfo) { if (common_config->id != NULL) { - lcrdinfo->id = util_strdup_s(common_config->id); + isuladinfo->id = util_strdup_s(common_config->id); } if (common_config->name != NULL) { - lcrdinfo->name = util_strdup_s(common_config->name); + isuladinfo->name = util_strdup_s(common_config->name); } } static int convert_common_config_info(const map_t *map_labels, const container_config_v2_common_config *common_config, - container_container *lcrdinfo) + container_container *isuladinfo) { int ret = 0; bool args_err = false; - if (map_labels == NULL || common_config == NULL || lcrdinfo == NULL) { + if (map_labels == NULL || common_config == NULL || isuladinfo == NULL) { return -1; } @@ -365,31 +365,31 @@ static int convert_common_config_info(const map_t *map_labels, const container_c if (args_err) { json_map_string_string *labels = common_config->config->labels; - ret = replace_labels(lcrdinfo, labels, map_labels); + ret = replace_labels(isuladinfo, labels, map_labels); if (ret == -1) { goto out; } } - ret = replace_annotations(common_config, lcrdinfo); + ret = replace_annotations(common_config, isuladinfo); if (ret == -1) { goto out; } - dup_id_name(common_config, lcrdinfo); + dup_id_name(common_config, isuladinfo); args_err = (common_config->created != NULL && - to_unix_nanos_from_str(common_config->created, &lcrdinfo->created) != 0); + to_unix_nanos_from_str(common_config->created, &isuladinfo->created) != 0); if (args_err) { ret = -1; goto out; } - lcrdinfo->restartcount = (uint64_t)common_config->restart_count; + isuladinfo->restartcount = (uint64_t)common_config->restart_count; out: return ret; } static int container_info_match(const struct list_context *ctx, const map_t *map_labels, - const container_container *lcrdinfo, const container_config_v2_state *cont_state) + const container_container *isuladinfo, const container_config_v2_state *cont_state) { int ret = 0; Container_Status cs; @@ -398,12 +398,12 @@ static int container_info_match(const struct list_context *ctx, const map_t *map return -1; } - if (!filters_args_match(ctx->ps_filters, "name", lcrdinfo->name)) { + if (!filters_args_match(ctx->ps_filters, "name", isuladinfo->name)) { ret = -1; goto out; } - if (!filters_args_match(ctx->ps_filters, "id", lcrdinfo->id)) { + if (!filters_args_match(ctx->ps_filters, "id", isuladinfo->id)) { ret = -1; goto out; } @@ -444,8 +444,8 @@ static int get_cnt_state(const struct list_context *ctx, const container_config_ return 0; } -static int fill_lcrdinfo(container_container *lcrdinfo, const container_config_v2_state *cont_state, - const map_t *map_labels, const container_t *cont) +static int fill_isuladinfo(container_container *isuladinfo, const container_config_v2_state *cont_state, + const map_t *map_labels, const container_t *cont) { int ret = 0; char *image = NULL; @@ -453,29 +453,29 @@ static int fill_lcrdinfo(container_container *lcrdinfo, const container_config_v char *defvalue = "-"; int64_t created_nanos = 0; - ret = convert_common_config_info(map_labels, cont->common_config, lcrdinfo); + ret = convert_common_config_info(map_labels, cont->common_config, isuladinfo); if (ret != 0) { goto out; } - lcrdinfo->pid = (int32_t)cont_state->pid; + isuladinfo->pid = (int32_t)cont_state->pid; - lcrdinfo->status = (int)state_judge_status(cont_state); + isuladinfo->status = (int)state_judge_status(cont_state); - lcrdinfo->command = container_get_command(cont); + isuladinfo->command = container_get_command(cont); image = container_get_image(cont); - lcrdinfo->image = image ? image : util_strdup_s("none"); + isuladinfo->image = image ? image : util_strdup_s("none"); - lcrdinfo->exit_code = (uint32_t)(cont_state->exit_code); + isuladinfo->exit_code = (uint32_t)(cont_state->exit_code); timestr = cont_state->started_at ? cont_state->started_at : defvalue; - lcrdinfo->startat = util_strdup_s(timestr); + isuladinfo->startat = util_strdup_s(timestr); timestr = cont_state->finished_at ? cont_state->finished_at : defvalue; - lcrdinfo->finishat = util_strdup_s(timestr); + isuladinfo->finishat = util_strdup_s(timestr); - lcrdinfo->runtime = cont->runtime ? util_strdup_s(cont->runtime) : util_strdup_s("none"); + isuladinfo->runtime = cont->runtime ? util_strdup_s(cont->runtime) : util_strdup_s("none"); - lcrdinfo->health_state = container_get_health_state(cont_state); + isuladinfo->health_state = container_get_health_state(cont_state); if (cont->common_config->created != NULL) { ret = to_unix_nanos_from_str(cont->common_config->created, &created_nanos); if (ret != 0) { @@ -483,17 +483,17 @@ static int fill_lcrdinfo(container_container *lcrdinfo, const container_config_v } } - lcrdinfo->created = created_nanos; + isuladinfo->created = created_nanos; out: return ret; } -static void free_lcrd_info(container_container **lcrdinfo, int ret) +static void free_isulad_info(container_container **isuladinfo, int ret) { if (ret != 0) { - free_container_container(*lcrdinfo); - *lcrdinfo = NULL; + free_container_container(*isuladinfo); + *isuladinfo = NULL; } return; } @@ -509,7 +509,7 @@ static void unref_cont(container_t *cont) static container_container *get_container_info(const char *name, const struct list_context *ctx) { int ret = 0; - container_container *lcrdinfo = NULL; + container_container *isuladinfo = NULL; container_t *cont = NULL; container_config_v2_state *cont_state = NULL; map_t *map_labels = NULL; @@ -533,19 +533,19 @@ static container_container *get_container_info(const char *name, const struct li goto cleanup; } - lcrdinfo = util_common_calloc_s(sizeof(container_container)); - if (lcrdinfo == NULL) { + isuladinfo = util_common_calloc_s(sizeof(container_container)); + if (isuladinfo == NULL) { ERROR("Out of memory"); ret = -1; goto cleanup; } - ret = fill_lcrdinfo(lcrdinfo, cont_state, map_labels, cont); + ret = fill_isuladinfo(isuladinfo, cont_state, map_labels, cont); if (ret != 0) { goto cleanup; } - ret = container_info_match(ctx, map_labels, lcrdinfo, cont_state); + ret = container_info_match(ctx, map_labels, isuladinfo, cont_state); if (ret != 0) { goto cleanup; } @@ -554,8 +554,8 @@ cleanup: unref_cont(cont); map_free(map_labels); free_container_config_v2_state(cont_state); - free_lcrd_info(&lcrdinfo, ret); - return lcrdinfo; + free_isulad_info(&isuladinfo, ret); + return isuladinfo; } static int do_add_filters(const char *filter_key, const json_map_string_bool *filter_value, struct list_context *ctx) @@ -568,8 +568,8 @@ static int do_add_filters(const char *filter_key, const json_map_string_bool *fi if (strcmp(filter_key, "status") == 0) { if (!is_valid_state_string(filter_value->keys[j])) { ERROR("Unrecognised filter value for status: %s", filter_value->keys[j]); - lcrd_set_error_message("Unrecognised filter value for status: %s", - filter_value->keys[j]); + isulad_set_error_message("Unrecognised filter value for status: %s", + filter_value->keys[j]); ret = -1; goto out; } @@ -605,7 +605,7 @@ static struct list_context *fold_filter(const container_list_request *request) if (!filters_args_valid_key(accepted_ps_filter_tags, sizeof(accepted_ps_filter_tags) / sizeof(char *), request->filters->keys[i])) { ERROR("Invalid filter '%s'", request->filters->keys[i]); - lcrd_set_error_message("Invalid filter '%s'", request->filters->keys[i]); + isulad_set_error_message("Invalid filter '%s'", request->filters->keys[i]); goto error_out; } if (do_add_filters(request->filters->keys[i], request->filters->values[i], ctx) != 0) { @@ -660,7 +660,7 @@ int container_list_cb(const container_list_request *request, container_list_resp { char **idsarray = NULL; map_t *map_id_name = NULL; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; struct list_context *ctx = NULL; DAEMON_CLEAR_ERRMSG(); @@ -673,19 +673,19 @@ int container_list_cb(const container_list_request *request, container_list_resp *response = util_common_calloc_s(sizeof(container_list_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } ctx = fold_filter(request); if (ctx == NULL) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } map_id_name = name_index_get_all(); if (map_id_name == NULL) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } if (map_size(map_id_name) == 0) { @@ -697,7 +697,7 @@ int container_list_cb(const container_list_request *request, container_list_resp idsarray = filter_by_name_id_matches(ctx, map_id_name); if (pack_list_containers(idsarray, ctx, (*response)) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto pack_response; } @@ -705,14 +705,14 @@ pack_response: map_free(map_id_name); if (*response != NULL) { (*response)->cc = cc; - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } util_free_array(idsarray); free_list_context(ctx); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } diff --git a/src/services/execution/log_gather.c b/src/services/execution/log_gather.c index d376f80aa77bb784c184b4a5103ff7465ad3af66..aa526102d25d028eb95236608ff3d199cbddb7f9 100644 --- a/src/services/execution/log_gather.c +++ b/src/services/execution/log_gather.c @@ -26,7 +26,7 @@ #include "log.h" #include "utils.h" -#include "lcrdtar.h" +#include "libtar.h" typedef int(*log_save_t)(const void *buf, size_t count); static log_save_t g_save_log_op = NULL; diff --git a/src/services/execution/log_gather.h b/src/services/execution/log_gather.h index 8ce7d3742e2a18ad353887b8d4697cc7dcf5a725..f5bd8602dd4abdd9364097c3a55666a7ba6a08cd 100644 --- a/src/services/execution/log_gather.h +++ b/src/services/execution/log_gather.h @@ -12,8 +12,8 @@ * Create: 2017-11-22 * Description: provide log gather definition ******************************************************************************/ -#ifndef __LCRD_LOG_GATHER_H_ -#define __LCRD_LOG_GATHER_H_ +#ifndef __ISULAD_LOG_GATHER_H_ +#define __ISULAD_LOG_GATHER_H_ #include "utils.h" #include "log.h" diff --git a/src/services/execution/manager/container_state.h b/src/services/execution/manager/container_state.h index 1fd3bf27c562f9d843d75400a389ffba7b106cd5..6afa50e309e041782fcbd5beaf33e67e9769238d 100644 --- a/src/services/execution/manager/container_state.h +++ b/src/services/execution/manager/container_state.h @@ -12,12 +12,12 @@ * Create: 2017-11-22 * Description: provide container state definition ******************************************************************************/ -#ifndef __LCRD_CONTAINER_STATE_H__ -#define __LCRD_CONTAINER_STATE_H__ +#ifndef __ISULAD_CONTAINER_STATE_H__ +#define __ISULAD_CONTAINER_STATE_H__ #include -#include "liblcrd.h" +#include "libisulad.h" #include "container_config_v2.h" #include "engine.h" @@ -96,5 +96,5 @@ int dup_health_check_status(defs_health **dst, const defs_health *src); } #endif -#endif /* __LCRD_CONTAINER_STATE_H__ */ +#endif /* __ISULAD_CONTAINER_STATE_H__ */ diff --git a/src/services/execution/manager/container_unix.c b/src/services/execution/manager/container_unix.c index 9c4c32b9838f20811bf9eb613489e4372412402b..8559ba040d2bcfc708f673514f982a75bf8e012a 100644 --- a/src/services/execution/manager/container_unix.c +++ b/src/services/execution/manager/container_unix.c @@ -407,7 +407,7 @@ static int pack_container_config_labels(container_config_v2_common_config *confi } if (custom_spec->labels->len > LIST_SIZE_MAX) { ERROR("Labels list is too long, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Labels list is too long, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Labels list is too long, the limit is %d", LIST_SIZE_MAX); ret = -1; goto out; } @@ -713,7 +713,7 @@ static int save_json_config_file(const char *id, const char *rootpath, fd = util_open(filename, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE); if (fd == -1) { ERROR("Create file %s failed: %s", filename, strerror(errno)); - lcrd_set_error_message("Create file '%s' failed: %s", filename, strerror(errno)); + isulad_set_error_message("Create file '%s' failed: %s", filename, strerror(errno)); ret = -1; goto out; } @@ -721,7 +721,7 @@ static int save_json_config_file(const char *id, const char *rootpath, len = util_write_nointr(fd, json_data, strlen(json_data)); if (len < 0 || ((size_t)len) != strlen(json_data)) { ERROR("Write file %s failed: %s", filename, strerror(errno)); - lcrd_set_error_message("Write file '%s' failed: %s", filename, strerror(errno)); + isulad_set_error_message("Write file '%s' failed: %s", filename, strerror(errno)); ret = -1; } close(fd); diff --git a/src/services/execution/manager/container_unix.h b/src/services/execution/manager/container_unix.h index cf89139d06a28fb8428faa27ed5a987cceaff48a..bc47704518f84e1cc3e38f6243a2ef5c5f4f4091 100644 --- a/src/services/execution/manager/container_unix.h +++ b/src/services/execution/manager/container_unix.h @@ -12,12 +12,12 @@ * Create: 2017-11-22 * Description: provide container unix definition ******************************************************************************/ -#ifndef __LCRD_CONTAINER_UNIX_H__ -#define __LCRD_CONTAINER_UNIX_H__ +#ifndef __ISULAD_CONTAINER_UNIX_H__ +#define __ISULAD_CONTAINER_UNIX_H__ #include -#include "liblcrd.h" +#include "libisulad.h" #include "util_atomic.h" #include "container_custom_config.h" #include "container_config_v2.h" @@ -115,5 +115,5 @@ int container_read_proc(uint32_t pid, container_pid_t *pid_info); } #endif -#endif /* __LCRD_CONTAINER_UNIX_H__ */ +#endif /* __ISULAD_CONTAINER_UNIX_H__ */ diff --git a/src/services/execution/manager/containers_gc.c b/src/services/execution/manager/containers_gc.c index 0566976352aa09263024ef15de2d42e95781a1c4..98dc38ee01d914d5b264a3a5a6f280a169c03310 100644 --- a/src/services/execution/manager/containers_gc.c +++ b/src/services/execution/manager/containers_gc.c @@ -19,7 +19,7 @@ #include "constants.h" #include "containers_gc.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "container_garbage_config.h" #include "log.h" #include "utils.h" @@ -54,7 +54,7 @@ static int save_gc_config(const char *json_gc_config) char *rootpath = NULL; int fd = -1; - rootpath = conf_get_lcrd_rootdir(); + rootpath = conf_get_isulad_rootdir(); if (rootpath == NULL) { ERROR("Root path is NULL"); ret = -1; @@ -231,7 +231,7 @@ container_garbage_config *read_gc_config() container_garbage_config *gcconfig = NULL; char *rootpath = NULL; - rootpath = conf_get_lcrd_rootdir(); + rootpath = conf_get_isulad_rootdir(); if (rootpath == NULL) { ERROR("Root path is NULL"); goto out; diff --git a/src/services/execution/manager/containers_gc.h b/src/services/execution/manager/containers_gc.h index 74b309a975a5fe233c5dde83ff6de2af19b533dc..8fae33ea85b8a1e18f3ae579002488e1e1a8fc2f 100644 --- a/src/services/execution/manager/containers_gc.h +++ b/src/services/execution/manager/containers_gc.h @@ -12,12 +12,12 @@ * Create: 2017-11-22 * Description: provide container gc definition ******************************************************************************/ -#ifndef __LCRD_CONTAINER_GC_H__ -#define __LCRD_CONTAINER_GC_H__ +#ifndef __ISULAD_CONTAINER_GC_H__ +#define __ISULAD_CONTAINER_GC_H__ #include -#include "liblcrd.h" +#include "libisulad.h" #include "linked_list.h" #include "container_unix.h" @@ -45,5 +45,5 @@ bool gc_is_gc_progress(const char *id); } #endif -#endif /* __LCRD_CONTAINER_GC_H__ */ +#endif /* __ISULAD_CONTAINER_GC_H__ */ diff --git a/src/services/execution/manager/containers_store.h b/src/services/execution/manager/containers_store.h index 530437c2adc67c12e0dca8b221f4723329ce05a1..8813497954c7b7bb64bf07d9eb8aad2867570b8b 100644 --- a/src/services/execution/manager/containers_store.h +++ b/src/services/execution/manager/containers_store.h @@ -12,8 +12,8 @@ * Create: 2017-11-22 * Description: provide containers store definition ******************************************************************************/ -#ifndef __LCRD_MEMORY_STORE_H__ -#define __LCRD_MEMORY_STORE_H__ +#ifndef __ISULAD_MEMORY_STORE_H__ +#define __ISULAD_MEMORY_STORE_H__ #include "container_unix.h" #include "map.h" @@ -53,5 +53,5 @@ bool name_index_rename(const char *new_name, const char *old_name, const char *i } #endif -#endif /* __LCRD_MEMORY_STORE_H__ */ +#endif /* __ISULAD_MEMORY_STORE_H__ */ diff --git a/src/services/execution/manager/health_check.c b/src/services/execution/manager/health_check.c index 0e707e444369a642d95db39cb91d02d6a824f9d3..ed05b83f2acb2484724e6114c8b25ffbcfedb4d4 100644 --- a/src/services/execution/manager/health_check.c +++ b/src/services/execution/manager/health_check.c @@ -342,8 +342,8 @@ static int handle_increment_streak(container_t *cont, int retries) // kill container when exit on unhealthy flag is set ret = stop_container(cont, 3, true, false); if (ret != 0) { - lcrd_try_set_error_message("Could not stop running container %s, cannot remove", - cont->common_config->id); + isulad_try_set_error_message("Could not stop running container %s, cannot remove", + cont->common_config->id); ERROR("Could not stop running container %s, cannot remove", cont->common_config->id); ret = -1; } diff --git a/src/services/execution/manager/health_check.h b/src/services/execution/manager/health_check.h index e31be62296c80e4eb6f5b02a9a730a344deeea97..e5ea27214c8b2ea570695646a17122a00d8b2f59 100644 --- a/src/services/execution/manager/health_check.h +++ b/src/services/execution/manager/health_check.h @@ -12,8 +12,8 @@ * Create: 2018-11-1 * Description: provide health check definition *********************************************************************************/ -#ifndef __LCRD_HEALTH_CHECK_H_ -#define __LCRD_HEALTH_CHECK_H_ +#ifndef __ISULAD_HEALTH_CHECK_H_ +#define __ISULAD_HEALTH_CHECK_H_ #include "types_def.h" #include "container_config_v2.h" @@ -64,6 +64,6 @@ int64_t timeout_with_default(int64_t configured_value, int64_t default_value); } #endif -#endif /* __LCRD_HEALTH_CHECK_H_ */ +#endif /* __ISULAD_HEALTH_CHECK_H_ */ diff --git a/src/services/execution/manager/monitord.c b/src/services/execution/manager/monitord.c index 0567105a5bb1d22f5439e0b09317e02a91d0c7df..2e2f08a0710f8b577d635a40bf71698b1c63ad46 100644 --- a/src/services/execution/manager/monitord.c +++ b/src/services/execution/manager/monitord.c @@ -25,7 +25,7 @@ #include "log.h" #include "monitord.h" #include "mainloop.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "collector.h" #include "utils.h" @@ -35,8 +35,8 @@ struct monitord_handler { char *fifo_path; }; -/* lcrd monitor fifo name */ -char *lcrd_monitor_fifo_name(const char *rootpath) +/* isulad monitor fifo name */ +char *isulad_monitor_fifo_name(const char *rootpath) { int ret; char fifo_file_path[PATH_MAX] = { 0 }; @@ -124,14 +124,14 @@ static void *monitord(void *arg) } mhandler.pdescr = &descr; - statedir = conf_get_lcrd_statedir(); + statedir = conf_get_isulad_statedir(); if (statedir == NULL) { - CRIT("Can not get lcrd root path"); + CRIT("Can not get isulad root path"); goto err; } /* 1. monitor fifo: to wait container monitor message */ - fifo_file_path = lcrd_monitor_fifo_name(statedir); + fifo_file_path = isulad_monitor_fifo_name(statedir); if (fifo_file_path == NULL) { goto err; } @@ -203,14 +203,14 @@ int new_monitord(struct monitord_sync_data *msync) goto out; } - statedir = conf_get_lcrd_statedir(); + statedir = conf_get_isulad_statedir(); if (statedir == NULL) { - ERROR("LCRD root path is NULL"); + ERROR("isulad root path is NULL"); ret = -1; goto out; } - if (setenv("LCRD_MONITORD_PATH", statedir, 1)) { + if (setenv("ISULAD_MONITORD_PATH", statedir, 1)) { ERROR("Setenv monitord path failed"); ret = -1; goto out; diff --git a/src/services/execution/manager/monitord.h b/src/services/execution/manager/monitord.h index e09f33e49e46b4752a3cdea755be0041cf410fbe..92401bea0ce8f377ca7bc88264574c75987fa225 100644 --- a/src/services/execution/manager/monitord.h +++ b/src/services/execution/manager/monitord.h @@ -12,8 +12,8 @@ * Create: 2017-11-22 * Description: provide monitord definition ******************************************************************************/ -#ifndef __LCRD_MONITORD_H -#define __LCRD_MONITORD_H +#ifndef __ISULAD_MONITORD_H +#define __ISULAD_MONITORD_H #include #include #include @@ -38,7 +38,7 @@ struct monitord_sync_data { int *exit_code; }; -char *lcrd_monitor_fifo_name(const char *rootpath); +char *isulad_monitor_fifo_name(const char *rootpath); int connect_monitord(const char *rootpath); diff --git a/src/services/execution/manager/restartmanager.c b/src/services/execution/manager/restartmanager.c index a376eb66b1389d83bc25e3bcc22c39b6c76eba73..b9c8b3055fb2eb0fcde799285f387d81fe2eec30 100644 --- a/src/services/execution/manager/restartmanager.c +++ b/src/services/execution/manager/restartmanager.c @@ -23,7 +23,7 @@ #include "error.h" #include "log.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "restartmanager.h" #include "utils.h" #include "containers_store.h" diff --git a/src/services/execution/manager/restore.c b/src/services/execution/manager/restore.c index 46ff8ae981b8c3bfe95ebffbb6caf53d171a8488..2638bb14d1bcd9580ae2e9fd236c68eafb5796f5 100644 --- a/src/services/execution/manager/restore.c +++ b/src/services/execution/manager/restore.c @@ -19,7 +19,7 @@ #include #include -#include "lcrd_config.h" +#include "isulad_config.h" #include "log.h" #include "restore.h" #include "containers_store.h" diff --git a/src/services/execution/manager/restore.h b/src/services/execution/manager/restore.h index 453ae9faecf964689cfb6e434a2f61c735f84d12..fb9905f946e58987dfaad349858637c0e1fca980 100644 --- a/src/services/execution/manager/restore.h +++ b/src/services/execution/manager/restore.h @@ -12,8 +12,8 @@ * Create: 2017-11-22 * Description: provide restore definition ******************************************************************************/ -#ifndef __LCRD_RESTORE_H -#define __LCRD_RESTORE_H +#ifndef __ISULAD_RESTORE_H +#define __ISULAD_RESTORE_H #include #include diff --git a/src/services/execution/manager/supervisor.c b/src/services/execution/manager/supervisor.c index e1ae95e0c13ea878f84d0d34d8f6568d3ac1dbf5..2440abe0b57adcd12de4b76cd2c88f8279b33c7a 100644 --- a/src/services/execution/manager/supervisor.c +++ b/src/services/execution/manager/supervisor.c @@ -21,7 +21,7 @@ #include "utils.h" #include "supervisor.h" #include "mainloop.h" -#include "liblcrd.h" +#include "libisulad.h" #include "collector.h" #include "execution.h" #include "containers_gc.h" @@ -187,7 +187,7 @@ retry: } } - (void)lcrd_monitor_send_event(name, STOPPED, (int)pid, data->exit_code); + (void)isulad_monitor_send_event(name, STOPPED, (int)pid, data->exit_code); supervisor_handler_data_free(data); diff --git a/src/services/execution/manager/supervisor.h b/src/services/execution/manager/supervisor.h index a6f61bf00b9ac333c43f875c0f2b7c4b7391330b..712d6f354ef22fa8a25498253ddcada62a21c77f 100644 --- a/src/services/execution/manager/supervisor.h +++ b/src/services/execution/manager/supervisor.h @@ -12,8 +12,8 @@ * Create: 2017-11-22 * Description: provide container supervisor definition ******************************************************************************/ -#ifndef __LCRD_SUPERVISOR_H -#define __LCRD_SUPERVISOR_H +#ifndef __ISULAD_SUPERVISOR_H +#define __ISULAD_SUPERVISOR_H #include #include #include "container_unix.h" diff --git a/src/services/execution/spec/specs.c b/src/services/execution/spec/specs.c index bb1785d125a74ad75077144b26d6feca01a61693..39ee4bfc56e9b7c4bd647d591466a0dde85f5808 100644 --- a/src/services/execution/spec/specs.c +++ b/src/services/execution/spec/specs.c @@ -38,7 +38,7 @@ #include "container_custom_config.h" #include "utils.h" #include "config.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "namespace.h" #include "specs_security.h" #include "specs_mount.h" @@ -84,7 +84,7 @@ static int merge_annotations(oci_runtime_spec *oci_spec, container_custom_config if (custom_conf->annotations != NULL && custom_conf->annotations->len) { if (oci_spec->annotations->len > LIST_SIZE_MAX - custom_conf->annotations->len) { ERROR("Too many annotations to add, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Too many annotations to add, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Too many annotations to add, the limit is %d", LIST_SIZE_MAX); ret = -1; goto out; } @@ -106,7 +106,7 @@ static int make_annotations_log_console(const oci_runtime_spec *oci_spec, const { int ret = 0; int nret = 0; - char tmp_str[LCRD_NUMSTRLEN64] = {0}; + char tmp_str[ISULAD_NUMSTRLEN64] = {0}; if (custom_conf->log_config != NULL) { if (custom_conf->log_config->log_file != NULL) { @@ -185,7 +185,7 @@ static int make_annotations_cgroup_dir(const oci_runtime_spec *oci_spec, const h char *default_cgroup_parent = NULL; char *path = NULL; - default_cgroup_parent = conf_get_lcrd_cgroup_parent(); + default_cgroup_parent = conf_get_isulad_cgroup_parent(); if (host_spec->cgroup_parent != NULL) { path = host_spec->cgroup_parent; } else if (default_cgroup_parent != NULL) { @@ -213,7 +213,7 @@ out: static int make_annotations_oom_score_adj(const oci_runtime_spec *oci_spec, const host_config *host_spec) { int ret = 0; - char tmp_str[LCRD_NUMSTRLEN64 + 1] = { 0 }; + char tmp_str[ISULAD_NUMSTRLEN64 + 1] = { 0 }; // oom_score_adj default value is 0, So there is no need to explicitly set this value if (host_spec->oom_score_adj != 0) { @@ -237,7 +237,7 @@ out: static int make_annotations_files_limit(const oci_runtime_spec *oci_spec, const host_config *host_spec) { int ret = 0; - char tmp_str[LCRD_NUMSTRLEN64 + 1] = { 0 }; + char tmp_str[ISULAD_NUMSTRLEN64 + 1] = { 0 }; // Not supported in oci runtime-spec, add 'files.limit' to annotations if (host_spec->files_limit != 0) { @@ -326,7 +326,7 @@ out: return ret; } -/* default_spec returns default oci spec used by lcrd. */ +/* default_spec returns default oci spec used by isulad. */ oci_runtime_spec *default_spec(bool system_container) { const char *oci_file = OCICONFIG_PATH; @@ -340,7 +340,7 @@ oci_runtime_spec *default_spec(bool system_container) oci_spec = oci_runtime_spec_parse_file(oci_file, NULL, &err); if (oci_spec == NULL) { ERROR("Failed to parse OCI specification file \"%s\", error message: %s", oci_file, err); - lcrd_set_error_message("Can not read the default /etc/default/lcrd/config.json file: %s", err); + isulad_set_error_message("Can not read the default /etc/default/isulad/config.json file: %s", err); goto out; } @@ -1129,7 +1129,7 @@ static int merge_conf_ulimits(oci_runtime_spec *oci_spec, const host_config *hos if (host_spec->ulimits != NULL && host_spec->ulimits_len != 0) { if (host_spec->ulimits_len > LIST_SIZE_MAX) { ERROR("Too many ulimits to add, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Too many ulimits to add, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Too many ulimits to add, the limit is %d", LIST_SIZE_MAX); ret = -1; goto out; } @@ -1152,7 +1152,7 @@ static int merge_conf_hugetlbs(oci_runtime_spec *oci_spec, const host_config *ho if (host_spec->hugetlbs_len != 0 && host_spec->hugetlbs != NULL) { if (host_spec->hugetlbs_len > LIST_SIZE_MAX) { ERROR("Too many hugetlbs to add, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Too many hugetlbs to add, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Too many hugetlbs to add, the limit is %d", LIST_SIZE_MAX); ret = -1; goto out; } @@ -1257,7 +1257,7 @@ static int replace_entrypoint_cmds_from_spec(const oci_runtime_spec *oci_spec, c { if (oci_spec->process->args_len == 0) { ERROR("No command specified"); - lcrd_set_error_message("No command specified"); + isulad_set_error_message("No command specified"); return -1; } return dup_array_of_strings((const char **)(oci_spec->process->args), oci_spec->process->args_len, @@ -1286,7 +1286,7 @@ static int merge_conf_args(oci_runtime_spec *oci_spec, container_custom_config * if (argslen > LIST_SIZE_MAX) { ERROR("Too many commands to add, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Too many commands to add, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Too many commands to add, the limit is %d", LIST_SIZE_MAX); return -1; } @@ -1766,14 +1766,14 @@ static int add_native_umask(const oci_runtime_spec *container) if (strcmp(container->annotations->keys[i], ANNOTATION_UMAKE_KEY) == 0) { if (!is_valid_umask_value(container->annotations->values[i])) { ERROR("native.umask option %s not supported", container->annotations->values[i]); - lcrd_set_error_message("native.umask option %s not supported", container->annotations->values[i]); + isulad_set_error_message("native.umask option %s not supported", container->annotations->values[i]); ret = -1; } goto out; } } - umask = conf_get_lcrd_native_umask(); + umask = conf_get_isulad_native_umask(); if (umask == NULL) { ERROR("Failed to get default native umask"); ret = -1; @@ -1843,7 +1843,7 @@ oci_runtime_spec *read_oci_config(const char *rootpath, const char *name) ociconfig = oci_runtime_spec_parse_file(filename, NULL, &err); if (ociconfig == NULL) { ERROR("Failed to parse oci config file:%s", err); - lcrd_set_error_message("Parse oci config file failed:%s", err); + isulad_set_error_message("Parse oci config file failed:%s", err); goto out; } out: diff --git a/src/services/execution/spec/specs.h b/src/services/execution/spec/specs.h index 14dc022588b32767f0bedc2fa1853b6224a3943c..09ecc7eb70218dd15d6f8c8c1a6b02f238172d9e 100644 --- a/src/services/execution/spec/specs.h +++ b/src/services/execution/spec/specs.h @@ -16,7 +16,7 @@ #define __SPECS_H__ #include -#include "liblcrd.h" +#include "libisulad.h" #include "host_config.h" #include "container_custom_config.h" #include "container_config_v2.h" diff --git a/src/services/execution/spec/specs_extend.c b/src/services/execution/spec/specs_extend.c index 1a36f81bbac28cf02bee9602fd637317009e3c7d..5b999a824a9acc60330d2821dde18d557b871a5c 100644 --- a/src/services/execution/spec/specs_extend.c +++ b/src/services/execution/spec/specs_extend.c @@ -36,7 +36,7 @@ #include "utils.h" #include "config.h" #include "path.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "specs_extend.h" #define MINUID 0 @@ -101,8 +101,8 @@ int merge_global_hook(oci_runtime_spec *oci_spec) oci_runtime_spec_hooks *hooks = NULL; oci_runtime_spec_hooks *tmp = NULL; - if (conf_get_lcrd_hooks(&hooks)) { - ERROR("Failed to get lcrd hooks"); + if (conf_get_isulad_hooks(&hooks)) { + ERROR("Failed to get isulad hooks"); ret = -1; goto out; } @@ -444,7 +444,7 @@ int merge_env(oci_runtime_spec *oci_spec, const char **env, size_t env_len) if (env_len > LIST_ENV_SIZE_MAX - oci_spec->process->env_len) { ERROR("The length of envionment variables is too long, the limit is %d", LIST_ENV_SIZE_MAX); - lcrd_set_error_message("The length of envionment variables is too long, the limit is %d", LIST_ENV_SIZE_MAX); + isulad_set_error_message("The length of envionment variables is too long, the limit is %d", LIST_ENV_SIZE_MAX); ret = -1; goto out; } @@ -474,7 +474,7 @@ static int read_user_file(const char *basefs, const char *user_path, FILE **stre if (realpath_in_scope(basefs, user_path, &real_path) < 0) { ERROR("user target file '%s' real path must be under '%s'", user_path, basefs); - lcrd_set_error_message("user target file '%s' real path must be under '%s'", user_path, basefs); + isulad_set_error_message("user target file '%s' real path must be under '%s'", user_path, basefs); ret = -1; goto out; } @@ -482,7 +482,7 @@ static int read_user_file(const char *basefs, const char *user_path, FILE **stre filesize = util_file_size(real_path); if (filesize > REGULAR_FILE_SIZE) { ERROR("File %s is more than %lld", real_path, (long long)REGULAR_FILE_SIZE); - lcrd_set_error_message("File %s is more than %lld", real_path, (long long)REGULAR_FILE_SIZE); + isulad_set_error_message("File %s is more than %lld", real_path, (long long)REGULAR_FILE_SIZE); ret = -1; goto out; } @@ -539,7 +539,7 @@ static void parse_user_group(const char *username, char **user, char **group, ch static void uids_gids_range_err_log() { ERROR("uids and gids must be in range 0-%d", MAXUID); - lcrd_set_error_message("uids and gids must be in range 0-%d", MAXUID); + isulad_set_error_message("uids and gids must be in range 0-%d", MAXUID); return; } @@ -603,7 +603,7 @@ static int proc_by_fpasswd(FILE *f_passwd, const char *user, oci_runtime_spec_pr if (errval != 0 && errval != ENOENT) { ERROR("Failed to parse passwd file: Insufficient buffer space supplied"); - lcrd_set_error_message("Failed to parse passwd file: Insufficient buffer space supplied"); + isulad_set_error_message("Failed to parse passwd file: Insufficient buffer space supplied"); ret = -1; goto out; } @@ -612,7 +612,7 @@ static int proc_by_fpasswd(FILE *f_passwd, const char *user, oci_runtime_spec_pr // user is not a valid numeric UID if (uret != 0) { ERROR("Unable to find user '%s'", user); - lcrd_set_error_message("Unable to find user '%s': no matching entries in passwd file", user); + isulad_set_error_message("Unable to find user '%s': no matching entries in passwd file", user); ret = -1; goto out; } @@ -747,7 +747,7 @@ static int proc_by_fgroup(FILE *f_group, const char *group, oci_runtime_spec_pro // group is not a valid numeric GID if (gret != 0) { ERROR("Unable to find group '%s'", group); - lcrd_set_error_message("Unable to find group '%s': no matching entries in group file", group); + isulad_set_error_message("Unable to find group '%s': no matching entries in group file", group); ret = -1; goto out; } @@ -856,7 +856,7 @@ static int get_one_additional_group(const char *additional_group, struct group * gret = util_safe_llong(additional_group, &n_gid); if (gret != 0) { ERROR("Unable to find group %s", additional_group); - lcrd_set_error_message("Unable to find group %s", additional_group); + isulad_set_error_message("Unable to find group %s", additional_group); ret = -1; goto out; } @@ -975,7 +975,7 @@ int get_user(const char *basefs, const host_config *hc, const char *userstr, oci if (hc->group_add != NULL && hc->group_add_len > 0) { if (hc->group_add_len > LIST_SIZE_MAX) { ERROR("Too many groups to add, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Too many groups to add, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Too many groups to add, the limit is %d", LIST_SIZE_MAX); ret = -1; goto cleanup; } @@ -1262,8 +1262,8 @@ int merge_global_ulimit(oci_runtime_spec *oci_spec) host_config_ulimits_element **ulimits = NULL; size_t ulimits_len; - if (conf_get_lcrd_default_ulimit(&ulimits) != 0) { - ERROR("Failed to get lcrd default ulimit"); + if (conf_get_isulad_default_ulimit(&ulimits) != 0) { + ERROR("Failed to get isulad default ulimit"); ret = -1; goto out; } diff --git a/src/services/execution/spec/specs_extend.h b/src/services/execution/spec/specs_extend.h index 066a330034a24a15f17655fee57e05daa7459883..3142115bd5cc9f515fd97610c03533a876077079 100644 --- a/src/services/execution/spec/specs_extend.h +++ b/src/services/execution/spec/specs_extend.h @@ -16,7 +16,7 @@ #define __SPECS_EXTEND_H__ #include -#include "liblcrd.h" +#include "libisulad.h" #include "host_config.h" #include "container_custom_config.h" #include "container_config_v2.h" diff --git a/src/services/execution/spec/specs_mount.c b/src/services/execution/spec/specs_mount.c index 3c5cfa4f04855205860767a614ec9e3d3afb2f5b..ad681c1417a75d6adae4be628027063c8a20fdc4 100644 --- a/src/services/execution/spec/specs_mount.c +++ b/src/services/execution/spec/specs_mount.c @@ -37,7 +37,7 @@ #include "utils.h" #include "config.h" #include "path.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "namespace.h" #include "parse_common.h" #include "specs_mount.h" @@ -645,7 +645,7 @@ static int get_src_dst_mode_by_volume(const char *volume, defs_mount *mount_elem // Destination + Mode is not a valid volume - volumes // cannot include a mode. eg /foo:rw ERROR("Invalid volume specification '%s'", volume); - lcrd_set_error_message("Invalid volume specification '%s',Invalid mode:%s", volume, array[1]); + isulad_set_error_message("Invalid volume specification '%s',Invalid mode:%s", volume, array[1]); ret = -1; break; } @@ -657,7 +657,7 @@ static int get_src_dst_mode_by_volume(const char *volume, defs_mount *mount_elem mount_element->destination = util_strdup_s(array[1]); if (!util_valid_mount_mode(array[2])) { ERROR("Invalid volume specification '%s'", volume); - lcrd_set_error_message("Invalid volume specification '%s'.Invalid mode:%s", volume, array[2]); + isulad_set_error_message("Invalid volume specification '%s'.Invalid mode:%s", volume, array[2]); ret = -1; break; } @@ -821,8 +821,8 @@ static int get_devices_from_path(const host_config_devices_element *dev_map, oci ret = stat(dev_map->path_on_host, &st); if (ret < 0) { ERROR("device %s no exists", dev_map->path_on_host); - lcrd_set_error_message("Error gathering device information while adding device \"%s\",stat %s: " - "no such file or directory", dev_map->path_on_host, dev_map->path_on_host); + isulad_set_error_message("Error gathering device information while adding device \"%s\",stat %s: " + "no such file or directory", dev_map->path_on_host, dev_map->path_on_host); return -1; } @@ -972,7 +972,7 @@ static int get_read_bps_devices_from_path(const host_config_blkio_device_read_bp ret = stat(read_bps_dev->path, &st); if (ret < 0) { ERROR("Failed to get state of device:%s", read_bps_dev->path); - lcrd_set_error_message("no such file or directory: %s", read_bps_dev->path); + isulad_set_error_message("no such file or directory: %s", read_bps_dev->path); return -1; } @@ -1028,7 +1028,7 @@ static int get_write_bps_devices_from_path(const host_config_blkio_device_write_ ret = stat(write_bps_dev->path, &st); if (ret < 0) { ERROR("no such file or directory :%s", write_bps_dev->path); - lcrd_set_error_message("no such file or directory: %s", write_bps_dev->path); + isulad_set_error_message("no such file or directory: %s", write_bps_dev->path); return -1; } @@ -1087,7 +1087,7 @@ static int merge_all_devices(oci_runtime_spec *oci_spec, host_config_devices_ele /* malloc for linux->device */ if (devices_len > LIST_DEVICE_SIZE_MAX - oci_spec->linux->devices_len) { ERROR("Too many linux devices to merge, the limit is %d", LIST_DEVICE_SIZE_MAX); - lcrd_set_error_message("Too many linux devices to merge, the limit is %d", LIST_DEVICE_SIZE_MAX); + isulad_set_error_message("Too many linux devices to merge, the limit is %d", LIST_DEVICE_SIZE_MAX); ret = -1; goto out; } @@ -1199,15 +1199,15 @@ static int merge_all_devices_in_dir(const char *dir, const char *dir_container, ret = get_devices(dir, &devices, &devices_len, 0); if (ret != 0) { ERROR("Failed to get host's device in directory:%s", dir); - lcrd_set_error_message("Failed to get host's device in directory:%s", dir); + isulad_set_error_message("Failed to get host's device in directory:%s", dir); ret = -1; goto out; } if (devices_len == 0) { ERROR("Error gathering device information while adding devices in directory \"%s\":no available device nodes", dir); - lcrd_set_error_message("Error gathering device information while adding devices in directory" - " \"%s\":,no available device nodes", dir); + isulad_set_error_message("Error gathering device information while adding devices in directory" + " \"%s\":,no available device nodes", dir); ret = -1; goto out; } @@ -1413,7 +1413,7 @@ int merge_volumes(oci_runtime_spec *oci_spec, char **volumes, size_t volumes_len } if (volumes_len > LIST_SIZE_MAX - oci_spec->mounts_len) { ERROR("Too many volumes to merge, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Too many volumes to merge, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Too many volumes to merge, the limit is %d", LIST_SIZE_MAX); ret = -1; goto out; } @@ -1606,7 +1606,7 @@ static int merge_blkio_weight_device(oci_runtime_spec *oci_spec, if (oci_spec->linux->resources->block_io->weight_device_len > LIST_DEVICE_SIZE_MAX - blkio_weight_device_len) { ERROR("Too many weight devices to merge, the limit is %d", LIST_DEVICE_SIZE_MAX); - lcrd_set_error_message("Too many weight devices to merge, the limit is %d", LIST_DEVICE_SIZE_MAX); + isulad_set_error_message("Too many weight devices to merge, the limit is %d", LIST_DEVICE_SIZE_MAX); ret = -1; goto out; } @@ -1659,8 +1659,8 @@ static int merge_blkio_read_bps_device(oci_runtime_spec *oci_spec, if (oci_spec->linux->resources->block_io->throttle_read_bps_device_len > LIST_DEVICE_SIZE_MAX - throttle_read_bps_device_len) { ERROR("Too many throttle read bps devices to merge, the limit is %d", LIST_DEVICE_SIZE_MAX); - lcrd_set_error_message("Too many throttle read bps devices devices to merge, the limit is %d", - LIST_DEVICE_SIZE_MAX); + isulad_set_error_message("Too many throttle read bps devices devices to merge, the limit is %d", + LIST_DEVICE_SIZE_MAX); ret = -1; goto out; } @@ -1712,8 +1712,8 @@ static int merge_blkio_write_bps_device(oci_runtime_spec *oci_spec, if (oci_spec->linux->resources->block_io->throttle_write_bps_device_len > LIST_DEVICE_SIZE_MAX - throttle_write_bps_device_len) { ERROR("Too many throttle write bps devices to merge, the limit is %d", LIST_DEVICE_SIZE_MAX); - lcrd_set_error_message("Too many throttle write bps devices devices to merge, the limit is %d", - LIST_DEVICE_SIZE_MAX); + isulad_set_error_message("Too many throttle write bps devices devices to merge, the limit is %d", + LIST_DEVICE_SIZE_MAX); ret = -1; goto out; } @@ -2099,7 +2099,7 @@ int add_rootfs_mount(const oci_runtime_spec *container) int ret = 0; char *mntparent = NULL; - mntparent = conf_get_lcrd_mount_rootfs(); + mntparent = conf_get_isulad_mount_rootfs(); if (mntparent == NULL) { ERROR("Failed to get mount parent directory"); ret = -1; diff --git a/src/services/execution/spec/specs_mount.h b/src/services/execution/spec/specs_mount.h index 8e2d444478d017f841a5dcd531e965728598c8e8..d1c22df0533418d1d2ae24214d3c41e7de7d0598 100644 --- a/src/services/execution/spec/specs_mount.h +++ b/src/services/execution/spec/specs_mount.h @@ -16,7 +16,7 @@ #define __SPECS_MOUNT_H__ #include -#include "liblcrd.h" +#include "libisulad.h" #include "host_config.h" #include "container_custom_config.h" #include "container_config_v2.h" diff --git a/src/services/execution/spec/specs_security.c b/src/services/execution/spec/specs_security.c index e9ff6fdc072497971b4e31cbed23a322cc7637a1..6d3eacbe6207cdabceda8f12ef89ba6c536d14b0 100644 --- a/src/services/execution/spec/specs_security.c +++ b/src/services/execution/spec/specs_security.c @@ -40,10 +40,10 @@ #include "container_custom_config.h" #include "utils.h" #include "config.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "parse_common.h" #include "container_def.h" -#include "liblcrd.h" +#include "libisulad.h" #include "specs_extend.h" #define MAX_CAP_LEN 32 @@ -662,14 +662,14 @@ int merge_default_seccomp_spec(oci_runtime_spec *oci_spec, const oci_runtime_spe docker_seccomp_spec = get_seccomp_security_opt_spec(SECCOMP_DEFAULT_PATH); if (docker_seccomp_spec == NULL) { ERROR("Failed to parse docker format seccomp specification file \"%s\"", SECCOMP_DEFAULT_PATH); - lcrd_set_error_message("failed to parse seccomp file: %s", SECCOMP_DEFAULT_PATH); + isulad_set_error_message("failed to parse seccomp file: %s", SECCOMP_DEFAULT_PATH); return -1; } oci_seccomp_spec = trans_docker_seccomp_to_oci_format(docker_seccomp_spec, capabilites); free_docker_seccomp(docker_seccomp_spec); if (oci_seccomp_spec == NULL) { ERROR("Failed to trans docker format seccomp profile to oci standard"); - lcrd_set_error_message("Failed to trans docker format seccomp profile to oci standard"); + isulad_set_error_message("Failed to trans docker format seccomp profile to oci standard"); return -1; } @@ -794,7 +794,7 @@ int merge_caps(oci_runtime_spec *oci_spec, const char **adds, size_t adds_len, c if (adds_len > LIST_SIZE_MAX || drops_len > LIST_SIZE_MAX) { ERROR("Too many capabilities to add or drop, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Too many capabilities to add or drop, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Too many capabilities to add or drop, the limit is %d", LIST_SIZE_MAX); ret = -1; goto out; } @@ -845,7 +845,7 @@ int merge_sysctls(oci_runtime_spec *oci_spec, const json_map_string_string *sysc if (sysctls->len > LIST_SIZE_MAX) { ERROR("Too many sysctls to add, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Too many sysctls to add, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Too many sysctls to add, the limit is %d", LIST_SIZE_MAX); ret = -1; goto out; } @@ -1016,7 +1016,7 @@ int merge_seccomp(oci_runtime_spec *oci_spec, const host_config *host_spec) if (host_spec->security_opt_len > LIST_SIZE_MAX) { ERROR("Too many security option to add, the limit is %d", LIST_SIZE_MAX); - lcrd_set_error_message("Too many security option to add, the limit is %d", LIST_SIZE_MAX); + isulad_set_error_message("Too many security option to add, the limit is %d", LIST_SIZE_MAX); ret = -1; goto out; } diff --git a/src/services/execution/spec/specs_security.h b/src/services/execution/spec/specs_security.h index 07d1e0786a3a262ec79c9034423618468a6f92b6..4454cbc1f68edecef24edfe5a0db4ff5c38ada58 100644 --- a/src/services/execution/spec/specs_security.h +++ b/src/services/execution/spec/specs_security.h @@ -16,7 +16,7 @@ #define __SPECS_SECURITY_H__ #include -#include "liblcrd.h" +#include "libisulad.h" #include "host_config.h" #include "container_custom_config.h" #include "container_config_v2.h" diff --git a/src/services/execution/spec/sysinfo.c b/src/services/execution/spec/sysinfo.c index 8c771811487c5854deee089740f468f4cf5c16d6..749e548a4e9a529241e31355d2f709845c920a7c 100644 --- a/src/services/execution/spec/sysinfo.c +++ b/src/services/execution/spec/sysinfo.c @@ -20,7 +20,7 @@ #include #include "error.h" -#include "liblcrd.h" +#include "libisulad.h" #include "sysinfo.h" #include "log.h" #include "read_file.h" @@ -1071,8 +1071,8 @@ static bool is_huge_pagesize_valid(const char *pagesize) free_out: if (!bret) { ERROR("Invalid hugepage size: %s, should be one of [%s]", pagesize, hpsbuf); - lcrd_set_error_message("Invalid hugepage size: %s, should be one of [%s]", pagesize, hpsbuf); - if (g_lcrd_errmsg == NULL) { + isulad_set_error_message("Invalid hugepage size: %s, should be one of [%s]", pagesize, hpsbuf); + if (g_isulad_errmsg == NULL) { ERROR("Out of memory"); } } diff --git a/src/services/execution/spec/verify.c b/src/services/execution/spec/verify.c index fee7af9713f600461de061a8fb34b373d96253f2..ed3da2986a82214276117b4fdba54dd8f6254fca 100644 --- a/src/services/execution/spec/verify.c +++ b/src/services/execution/spec/verify.c @@ -27,19 +27,19 @@ #include "constants.h" #include "error.h" -#include "liblcrd.h" +#include "libisulad.h" #include "log.h" #include "sysinfo.h" #include "specs.h" #include "verify.h" -#include "lcrd_config.h" +#include "isulad_config.h" /* verify hook timeout */ static int verify_hook_timeout(int t) { if (t < 0) { ERROR("Hook spec timeout invalid"); - lcrd_set_error_message("Invalid timeout: %d", t); + isulad_set_error_message("Invalid timeout: %d", t); return -1; } @@ -53,14 +53,14 @@ static int verify_hook_root_and_no_other(const struct stat *st, const char *path /* validate file owner */ if (st->st_uid != 0) { ERROR("Hook file %s isn't right,file owner should be root", path); - lcrd_set_error_message("Hook file %s isn't right,file owner should be root", path); + isulad_set_error_message("Hook file %s isn't right,file owner should be root", path); return -1; } /* validate file if can be written by other user */ if (st->st_mode & S_IWOTH) { ERROR("Hook path %s isn't right,file should not be written by non-root", path); - lcrd_set_error_message("%s should not be written by non-root", path); + isulad_set_error_message("%s should not be written by non-root", path); return -1; } return 0; @@ -75,7 +75,7 @@ static int verify_hook_path(const char *path) ret = util_validate_absolute_path(path); if (ret != 0) { ERROR("Hook path %s must be an absolute path", path); - lcrd_set_error_message("%s is not an absolute path", path); + isulad_set_error_message("%s is not an absolute path", path); goto out; } @@ -83,7 +83,7 @@ static int verify_hook_path(const char *path) /* validate file exits */ if (ret < 0) { ERROR("Hook path %s isn't exist", path); - lcrd_set_error_message("Cann't find path: %s", path); + isulad_set_error_message("Cann't find path: %s", path); ret = -1; goto out; } @@ -127,14 +127,14 @@ static int verify_mem_limit_swap(const sysinfo_t *sysinfo, int64_t limit, int64_ /* check the minimum memory limit */ if (is_mem_limit_minimum(limit)) { ERROR("Minimum memory limit allowed is 4MB"); - lcrd_set_error_message("Minimum memory limit allowed is 4MB"); + isulad_set_error_message("Minimum memory limit allowed is 4MB"); ret = -1; goto out; } if (limit > 0 && !(sysinfo->cgmeminfo.limit)) { ERROR("Your kernel does not support memory limit capabilities. Limitation discarded."); - lcrd_set_error_message( + isulad_set_error_message( "Your kernel does not support memory limit capabilities. Limitation discarded."); ret = -1; goto out; @@ -142,7 +142,7 @@ static int verify_mem_limit_swap(const sysinfo_t *sysinfo, int64_t limit, int64_ if (limit > 0 && swap != 0 && !(sysinfo->cgmeminfo.swap)) { ERROR("Your kernel does not support swap limit capabilities, memory limited without swap."); - lcrd_set_error_message( + isulad_set_error_message( "Your kernel does not support swap limit capabilities, memory limited without swap."); ret = -1; goto out; @@ -150,14 +150,14 @@ static int verify_mem_limit_swap(const sysinfo_t *sysinfo, int64_t limit, int64_ if (limit > 0 && swap > 0 && swap < limit) { ERROR("Minimum memoryswap limit should be larger than memory limit, see usage."); - lcrd_set_error_message("Minimum memoryswap limit should be larger than memory limit"); + isulad_set_error_message("Minimum memoryswap limit should be larger than memory limit"); ret = -1; goto out; } if (limit == 0 && swap > 0 && !update) { ERROR("You should always set the Memory limit when using Memoryswap limit, see usage."); - lcrd_set_error_message("You should set the memory limit when using memoryswap limit"); + isulad_set_error_message("You should set the memory limit when using memoryswap limit"); ret = -1; goto out; } @@ -178,7 +178,7 @@ static int verify_memory_swappiness(const sysinfo_t *sysinfo, uint64_t swapiness if ((int64_t)swapiness != -1 && !(sysinfo->cgmeminfo.swappiness)) { ERROR("Your kernel does not support memory swappiness capabilities, memory swappiness discarded."); - lcrd_set_error_message( + isulad_set_error_message( "Your kernel does not support memory swappiness capabilities, memory swappiness discarded."); ret = -1; goto out; @@ -186,7 +186,7 @@ static int verify_memory_swappiness(const sysinfo_t *sysinfo, uint64_t swapiness if (is_swappiness_invalid(swapiness)) { ERROR("Invalid value: %lld, valid memory swappiness range is 0-100", (long long)swapiness); - lcrd_set_error_message("Invalid value: %lld, valid memory swappiness range is 0-100", (long long)swapiness); + isulad_set_error_message("Invalid value: %lld, valid memory swappiness range is 0-100", (long long)swapiness); ret = -1; goto out; } @@ -202,7 +202,7 @@ static int verify_memory_reservation(const sysinfo_t *sysinfo, int64_t limit, in if (reservation > 0 && !(sysinfo->cgmeminfo.reservation)) { ERROR("Your kernel does not support memory soft limit capabilities. Limitation discarded"); - lcrd_set_error_message("Your kernel does not support memory soft limit capabilities. Limitation discarded"); + isulad_set_error_message("Your kernel does not support memory soft limit capabilities. Limitation discarded"); ret = -1; goto out; } @@ -210,14 +210,14 @@ static int verify_memory_reservation(const sysinfo_t *sysinfo, int64_t limit, in /* check the minimum memory limit */ if (is_mem_limit_minimum(reservation)) { ERROR("Minimum memory reservation allowed is 4MB"); - lcrd_set_error_message("Minimum memory reservation allowed is 4MB"); + isulad_set_error_message("Minimum memory reservation allowed is 4MB"); ret = -1; goto out; } if (limit > 0 && reservation > 0 && limit < reservation) { ERROR("Minimum memory limit should be larger than memory reservation limit, see usage."); - lcrd_set_error_message("Minimum memory limit should be larger than memory reservation limit, see usage."); + isulad_set_error_message("Minimum memory limit should be larger than memory reservation limit, see usage."); ret = -1; goto out; } @@ -250,14 +250,14 @@ static int verify_memory_kernel(const sysinfo_t *sysinfo, int64_t kernel) if (kernel > 0 && !(sysinfo->cgmeminfo.kernel)) { ERROR("Your kernel does not support kernel memory limit capabilities. Limitation discarded."); - lcrd_set_error_message("Your kernel does not support kernel memory limit capabilities. Limitation discarded."); + isulad_set_error_message("Your kernel does not support kernel memory limit capabilities. Limitation discarded."); ret = -1; goto out; } if (is_mem_limit_minimum(kernel)) { ERROR("Minimum kernel memory limit allowed is 4MB"); - lcrd_set_error_message("Minimum kernel memory limit allowed is 4MB"); + isulad_set_error_message("Minimum kernel memory limit allowed is 4MB"); ret = -1; goto out; } @@ -279,7 +279,7 @@ static int verify_pids_limit(const sysinfo_t *sysinfo, int64_t pids_limit) if (pids_limit != 0 && !(sysinfo->pidsinfo.pidslimit)) { ERROR("Your kernel does not support pids limit capabilities, pids limit discarded."); - lcrd_set_error_message("Your kernel does not support pids limit capabilities, pids limit discarded."); + isulad_set_error_message("Your kernel does not support pids limit capabilities, pids limit discarded."); ret = -1; } return ret; @@ -292,7 +292,7 @@ static int verify_files_limit(const sysinfo_t *sysinfo, int64_t files_limit) if (files_limit != 0 && !(sysinfo->filesinfo.fileslimit)) { ERROR("Your kernel does not support files limit capabilities, files limit discarded."); - lcrd_set_error_message("Your kernel does not support files limit capabilities, files limit discarded."); + isulad_set_error_message("Your kernel does not support files limit capabilities, files limit discarded."); ret = -1; } return ret; @@ -306,7 +306,7 @@ static int verify_oom_control(const sysinfo_t *sysinfo, bool oomdisable) if (oomdisable && !(sysinfo->cgmeminfo.oomkilldisable)) { ERROR("Your kernel does not support OomKillDisable, OomKillDisable discarded"); - lcrd_set_error_message("Your kernel does not support OomKillDisable, OomKillDisable discarded"); + isulad_set_error_message("Your kernel does not support OomKillDisable, OomKillDisable discarded"); ret = -1; } @@ -369,21 +369,21 @@ static int verify_cpu_realtime(const sysinfo_t *sysinfo, int64_t realtime_period if (realtime_period > 0 && !(sysinfo->cgcpuinfo.cpu_rt_period)) { ERROR("Invalid --cpu-rt-period: Your kernel does not support cgroup rt period"); - lcrd_set_error_message("Invalid --cpu-rt-period: Your kernel does not support cgroup rt period"); + isulad_set_error_message("Invalid --cpu-rt-period: Your kernel does not support cgroup rt period"); ret = -1; goto out; } if (realtime_runtime > 0 && !(sysinfo->cgcpuinfo.cpu_rt_runtime)) { ERROR("Invalid --cpu-rt-runtime: Your kernel does not support cgroup rt runtime"); - lcrd_set_error_message("Invalid --cpu-rt-period: Your kernel does not support cgroup rt runtime"); + isulad_set_error_message("Invalid --cpu-rt-period: Your kernel does not support cgroup rt runtime"); ret = -1; goto out; } if (realtime_period != 0 && realtime_runtime != 0 && realtime_runtime > realtime_period) { ERROR("Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period"); - lcrd_set_error_message("Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period"); + isulad_set_error_message("Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period"); ret = -1; goto out; } @@ -398,7 +398,7 @@ static int verify_cpu_shares(const sysinfo_t *sysinfo, int64_t cpu_shares) if (cpu_shares > 0 && !(sysinfo->cgcpuinfo.cpu_shares)) { ERROR("Your kernel does not support cgroup cpu shares. Shares discarded."); - lcrd_set_error_message( + isulad_set_error_message( "Your kernel does not support cgroup cpu shares. Shares discarded."); ret = -1; } @@ -412,7 +412,7 @@ static int verify_cpu_cfs_period(const sysinfo_t *sysinfo, int64_t cpu_cfs_perio if (cpu_cfs_period > 0 && !(sysinfo->cgcpuinfo.cpu_cfs_period)) { ERROR("Your kernel does not support CPU cfs period. Period discarded."); - lcrd_set_error_message("Your kernel does not support CPU cfs period. Period discarded."); + isulad_set_error_message("Your kernel does not support CPU cfs period. Period discarded."); ret = -1; goto out; } @@ -431,14 +431,14 @@ static int verify_cpu_cfs_quota(const sysinfo_t *sysinfo, int64_t cpu_cfs_quota) if (cpu_cfs_quota > 0 && !(sysinfo->cgcpuinfo.cpu_cfs_quota)) { ERROR("Your kernel does not support CPU cfs quato. Quota discarded."); - lcrd_set_error_message("Your kernel does not support CPU cfs quato. Quota discarded."); + isulad_set_error_message("Your kernel does not support CPU cfs quato. Quota discarded."); ret = -1; goto out; } if (is_cpu_cfs_quota_invalid(cpu_cfs_quota)) { ERROR("CPU cfs quota can not be less than 1ms (i.e. 1000)"); - lcrd_set_error_message("CPU cfs quota can not be less than 1ms (i.e. 1000)"); + isulad_set_error_message("CPU cfs quota can not be less than 1ms (i.e. 1000)"); ret = -1; goto out; } @@ -526,7 +526,7 @@ static bool check_cpu(const char *provided, const char *available) } if (max_request > max_available) { ERROR("invalid maxRequest is %d, max available: %d", max_request, max_available); - lcrd_set_error_message("invalid maxRequest is %d, max available: %d", max_request, max_available); + isulad_set_error_message("invalid maxRequest is %d, max available: %d", max_request, max_available); return false; } return true; @@ -641,7 +641,7 @@ bool is_cpuset_cpus_available(const sysinfo_t *sysinfo, const char *cpus) ret = is_cpuset_list_available(cpus, sysinfo->cpusetinfo.cpus); if (!ret) { ERROR("Checking cpuset.cpus got invalid format: %s.", cpus); - lcrd_set_error_message("Checking cpuset.cpus got invalid format: %s.", cpus); + isulad_set_error_message("Checking cpuset.cpus got invalid format: %s.", cpus); } return ret; } @@ -653,7 +653,7 @@ bool is_cpuset_mems_available(const sysinfo_t *sysinfo, const char *mems) ret = is_cpuset_list_available(mems, sysinfo->cpusetinfo.mems); if (!ret) { ERROR("Checking cpuset.mems got invalid format: %s.", mems); - lcrd_set_error_message("Checking cpuset.mems got invalid format: %s.", mems); + isulad_set_error_message("Checking cpuset.mems got invalid format: %s.", mems); } return ret; } @@ -667,14 +667,14 @@ static int verify_resources_cpuset(const sysinfo_t *sysinfo, const char *cpus, c if (cpus != NULL && !(sysinfo->cpusetinfo.cpuset)) { ERROR("Your kernel does not support cpuset. Cpuset discarded."); - lcrd_set_error_message("Your kernel does not support cpuset. Cpuset discarded."); + isulad_set_error_message("Your kernel does not support cpuset. Cpuset discarded."); ret = -1; goto out; } if (mems != NULL && !(sysinfo->cpusetinfo.cpuset)) { ERROR("Your kernel does not support cpuset. Cpuset discarded."); - lcrd_set_error_message("Your kernel does not support cpuset. Cpuset discarded."); + isulad_set_error_message("Your kernel does not support cpuset. Cpuset discarded."); ret = -1; goto out; } @@ -682,8 +682,8 @@ static int verify_resources_cpuset(const sysinfo_t *sysinfo, const char *cpus, c cpus_available = is_cpuset_cpus_available(sysinfo, cpus); if (!cpus_available) { ERROR("Requested CPUs are not available - requested %s, available: %s.", cpus, sysinfo->cpusetinfo.cpus); - lcrd_set_error_message("Requested CPUs are not available - requested %s, available: %s.", cpus, - sysinfo->cpusetinfo.cpus); + isulad_set_error_message("Requested CPUs are not available - requested %s, available: %s.", cpus, + sysinfo->cpusetinfo.cpus); ret = -1; goto out; } @@ -692,8 +692,8 @@ static int verify_resources_cpuset(const sysinfo_t *sysinfo, const char *cpus, c if (!mems_available) { ERROR("Requested memory nodes are not available - requested %s, available: %s.", mems, sysinfo->cpusetinfo.mems); - lcrd_set_error_message("Requested memory nodes are not available - requested %s, available: %s.", - mems, sysinfo->cpusetinfo.mems); + isulad_set_error_message("Requested memory nodes are not available - requested %s, available: %s.", + mems, sysinfo->cpusetinfo.mems); ret = -1; goto out; } @@ -742,13 +742,13 @@ static int verify_blkio_weight(const sysinfo_t *sysinfo, int weight) if (weight > 0 && !(sysinfo->blkioinfo.blkio_weight)) { ERROR("Your kernel does not support Block I/O weight. Weight discarded."); - lcrd_set_error_message("Your kernel does not support Block I/O weight. Weight discarded."); + isulad_set_error_message("Your kernel does not support Block I/O weight. Weight discarded."); ret = -1; goto out; } if (is_blkio_weight_invalid(weight)) { ERROR("Range of blkio weight is from 10 to 1000."); - lcrd_set_error_message("Range of blkio weight is from 10 to 1000."); + isulad_set_error_message("Range of blkio weight is from 10 to 1000."); ret = -1; goto out; } @@ -769,13 +769,13 @@ static int verify_hostconfig_blkio_weight(const sysinfo_t *sysinfo, uint16_t wei if (weight > 0 && !(sysinfo->blkioinfo.blkio_weight)) { ERROR("Your kernel does not support Block I/O weight. Weight in host config discarded."); - lcrd_set_error_message("Your kernel does not support Block I/O weight. Weight in host config discarded."); + isulad_set_error_message("Your kernel does not support Block I/O weight. Weight in host config discarded."); ret = -1; goto out; } if (is_hostconfig_blkio_weight_invalid(weight)) { ERROR("Range of blkio weight is from 10 to 1000."); - lcrd_set_error_message("Range of blkio weight is from 10 to 1000."); + isulad_set_error_message("Range of blkio weight is from 10 to 1000."); ret = -1; goto out; } @@ -791,7 +791,7 @@ static int verify_blkio_device(const sysinfo_t *sysinfo, size_t weight_device_le if (weight_device_len > 0 && !(sysinfo->blkioinfo.blkio_weight_device)) { ERROR("Your kernel does not support Block I/O weight_device."); - lcrd_set_error_message("Your kernel does not support Block I/O weight_device."); + isulad_set_error_message("Your kernel does not support Block I/O weight_device."); ret = -1; } @@ -804,7 +804,7 @@ static int verify_oom_score_adj(int oom_score_adj) int ret = 0; if (oom_score_adj < OOM_SCORE_ADJ_MIN || oom_score_adj > OOM_SCORE_ADJ_MAX) { ERROR("Invalid value %d, range for oom score adj is [-1000, 1000].", oom_score_adj); - lcrd_set_error_message("Invalid value %d, range for oom score adj is [-1000, 1000].", oom_score_adj); + isulad_set_error_message("Invalid value %d, range for oom score adj is [-1000, 1000].", oom_score_adj); ret = -1; } return ret; @@ -819,7 +819,7 @@ static bool is_storage_opts_valid(const json_map_string_string *storage_opts) if (strcmp(storage_opts->keys[i], "size") != 0) { // Only check key here, check value by image driver ERROR("Unknown storage option: %s", storage_opts->keys[i]); - lcrd_set_error_message("Unknown storage option: %s", storage_opts->keys[i]); + isulad_set_error_message("Unknown storage option: %s", storage_opts->keys[i]); return false; } } @@ -837,7 +837,7 @@ static int verify_storage_opts(const host_config *hc) storage_opts = hc->storage_opt; } - driver = conf_get_lcrd_storage_driver(); + driver = conf_get_isulad_storage_driver(); if (driver == NULL) { ERROR("Failed to get storage driver"); return -1; @@ -849,7 +849,7 @@ static int verify_storage_opts(const host_config *hc) if (storage_opts->len > 0) { char *backing_fs = NULL; - backing_fs = conf_get_lcrd_storage_driver_backing_fs(); + backing_fs = conf_get_isulad_storage_driver_backing_fs(); if (backing_fs == NULL) { ERROR("No backing fs detected"); ret = -1; @@ -880,14 +880,14 @@ static int verify_blkio_rw_bps_device(const sysinfo_t *sysinfo, size_t throttle_ if (throttle_read_bps_device_len > 0 && !(sysinfo->blkioinfo.blkio_read_bps_device)) { ERROR("Your kernel does not support Block read limit in bytes per second"); - lcrd_set_error_message("Your kernel does not support Block read limit in bytes per second"); + isulad_set_error_message("Your kernel does not support Block read limit in bytes per second"); ret = -1; goto out; } if (throttle_write_bps_device_len > 0 && !(sysinfo->blkioinfo.blkio_write_bps_device)) { ERROR("Your kernel does not support Block write limit in bytes per second"); - lcrd_set_error_message("Your kernel does not support Block write limit in bytes per second"); + isulad_set_error_message("Your kernel does not support Block write limit in bytes per second"); ret = -1; goto out; } @@ -903,14 +903,14 @@ static int verify_blkio_rw_iops_device(const sysinfo_t *sysinfo, size_t throttle if (throttle_read_iops_device_len > 0 && !(sysinfo->blkioinfo.blkio_read_iops_device)) { ERROR("Your kernel does not support Block read limit in IO per second"); - lcrd_set_error_message("Your kernel does not support Block read limit in IO per second"); + isulad_set_error_message("Your kernel does not support Block read limit in IO per second"); ret = -1; goto out; } if (throttle_write_iops_device_len > 0 && !(sysinfo->blkioinfo.blkio_write_iops_device)) { ERROR("Your kernel does not support Block write limit in IO per second"); - lcrd_set_error_message("Your kernel does not support Block write limit in IO per second"); + isulad_set_error_message("Your kernel does not support Block write limit in IO per second"); ret = -1; goto out; } @@ -999,7 +999,7 @@ static int verify_resources_hugetlbs(const sysinfo_t *sysinfo, if (!sysinfo->hugetlbinfo.hugetlblimit) { ERROR("Your kernel does not support hugetlb limit. --hugetlb-limit discarded."); - lcrd_set_error_message( + isulad_set_error_message( "Your kernel does not support hugetlb limit. --hugetlb-limit discarded."); ret = -1; goto out; @@ -1066,7 +1066,7 @@ static int adapt_memory_swap(const sysinfo_t *sysinfo, const int64_t *limit, int if (*limit > 0 && *swap == 0 && sysinfo->cgmeminfo.swap) { if (*limit > (INT64_MAX / 2)) { ERROR("Memory swap out of range!"); - lcrd_set_error_message("Memory swap out of range!"); + isulad_set_error_message("Memory swap out of range!"); return -1; } *swap = (*limit) * 2; @@ -1150,17 +1150,17 @@ static bool verify_oci_linux_sysctl(const oci_runtime_config_linux *l) for (i = 0; i < l->sysctl->len; i++) { if (strcmp("kernel.pid_max", l->sysctl->keys[i]) == 0) { if (!pid_max_kernel_namespaced()) { - lcrd_set_error_message("Sysctl '%s' is not kernel namespaced, it cannot be changed", - l->sysctl->keys[i]); + isulad_set_error_message("Sysctl '%s' is not kernel namespaced, it cannot be changed", + l->sysctl->keys[i]); return false; } else { return true; } } if (!check_sysctl_valid(l->sysctl->keys[i])) { - lcrd_set_error_message("Sysctl %s=%s is not whitelist", - l->sysctl->keys[i], - l->sysctl->values[i]); + isulad_set_error_message("Sysctl %s=%s is not whitelist", + l->sysctl->keys[i], + l->sysctl->values[i]); return false; } } @@ -1471,7 +1471,7 @@ static int verify_custom_mount(defs_mount **mounts, size_t len) if (!util_file_exists(iter->source) && util_mkdir_p(iter->source, CONFIG_DIRECTORY_MODE)) { ERROR("Failed to create directory '%s': %s", iter->source, strerror(errno)); - lcrd_try_set_error_message("Failed to create directory '%s': %s", iter->source, strerror(errno)); + isulad_try_set_error_message("Failed to create directory '%s': %s", iter->source, strerror(errno)); ret = -1; goto out; } @@ -1536,8 +1536,8 @@ int verify_container_settings(const oci_runtime_spec *container) if (!util_valid_host_name(container->hostname)) { ERROR("Invalid container hostname %s", container->hostname); - lcrd_set_error_message("Invalid container hostname (%s), only %s and less than 64 bytes are allowed.", - container->hostname, HOST_NAME_REGEXP); + isulad_set_error_message("Invalid container hostname (%s), only %s and less than 64 bytes are allowed.", + container->hostname, HOST_NAME_REGEXP); ret = -1; goto out; } @@ -1660,7 +1660,7 @@ static int verify_host_config_hugetlbs(const sysinfo_t *sysinfo, host_config_hug if (!sysinfo->hugetlbinfo.hugetlblimit) { ERROR("Your kernel does not support hugetlb limit. --hugetlb-limit discarded."); - lcrd_set_error_message("Your kernel does not support hugetlb limit. --hugetlb-limit discarded."); + isulad_set_error_message("Your kernel does not support hugetlb limit. --hugetlb-limit discarded."); ret = -1; goto out; } @@ -1777,24 +1777,24 @@ static int verify_restart_policy_name(const host_config_restart_policy *rp, cons if (is_restart_policy_always(rp->name) || is_restart_policy_no(rp->name) || is_restart_policy_on_reboot(rp->name)) { if (rp->maximum_retry_count != 0) { ERROR("Maximum retry count cannot be used with restart policy '%s'", rp->name); - lcrd_set_error_message("Maximum retry count cannot be used with restart policy '%s'", rp->name); + isulad_set_error_message("Maximum retry count cannot be used with restart policy '%s'", rp->name); return -1; } } else if (is_restart_policy_on_failure(rp->name)) { if (rp->maximum_retry_count < 0) { ERROR("Maximum retry count cannot be negative"); - lcrd_set_error_message("Maximum retry count cannot be negative"); + isulad_set_error_message("Maximum retry count cannot be negative"); return -1; } } else { ERROR("Invalid restart policy '%s'", rp->name); - lcrd_set_error_message("Invalid restart policy '%s'", rp->name); + isulad_set_error_message("Invalid restart policy '%s'", rp->name); return -1; } if (hostconfig->auto_remove && !is_restart_policy_no(rp->name)) { ERROR("Can't create 'AutoRemove' container with restart policy"); - lcrd_set_error_message("Can't create 'AutoRemove' container with restart policy"); + isulad_set_error_message("Can't create 'AutoRemove' container with restart policy"); return -1; } @@ -1813,7 +1813,7 @@ static int host_config_settings_restart_policy(const host_config *hostconfig) if (rp->name == NULL || rp->name[0] == '\0') { if (rp->maximum_retry_count != 0) { ERROR("Maximum retry count cannot be used with empty restart policy"); - lcrd_set_error_message("Maximum retry count cannot be used with empty restart policy"); + isulad_set_error_message("Maximum retry count cannot be used with empty restart policy"); return -1; } return 0; @@ -1944,25 +1944,25 @@ int verify_health_check_parameter(const container_custom_config *custom_spec) if (is_less_than_one_second(custom_spec->health_check->interval)) { ERROR("Interval in Healthcheck cannot be less than one second"); - lcrd_set_error_message("Interval in Healthcheck cannot be less than one second"); + isulad_set_error_message("Interval in Healthcheck cannot be less than one second"); ret = -1; goto out; } if (is_less_than_one_second(custom_spec->health_check->timeout)) { ERROR("Timeout in Healthcheck cannot be less than one second"); - lcrd_set_error_message("Timeout in Healthcheck cannot be less than one second"); + isulad_set_error_message("Timeout in Healthcheck cannot be less than one second"); ret = -1; goto out; } if (is_less_than_one_second(custom_spec->health_check->start_period)) { ERROR("StartPeriod in Healthcheck cannot be less than one second"); - lcrd_set_error_message("StartPeriod in Healthcheck cannot be less than one second"); + isulad_set_error_message("StartPeriod in Healthcheck cannot be less than one second"); ret = -1; goto out; } if (custom_spec->health_check->retries < 0) { ERROR("--health-retries cannot be negative"); - lcrd_set_error_message("--health-retries cannot be negative"); + isulad_set_error_message("--health-retries cannot be negative"); ret = -1; goto out; } diff --git a/src/services/graphdriver/driver.c b/src/services/graphdriver/driver.c index ce40134715a4449eba1092b75fe8ac161d69fd64..400a05c8db5113e302b318e665f8ce997fec53a3 100644 --- a/src/services/graphdriver/driver.c +++ b/src/services/graphdriver/driver.c @@ -21,9 +21,9 @@ #include "driver_overlay2.h" #include "utils.h" -#include "liblcrd.h" +#include "libisulad.h" #include "log.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "image.h" /* overlay2 */ @@ -61,7 +61,7 @@ struct graphdriver *graphdriver_init(const char *name, char **storage_opts, size } } - lcrd_set_error_message("Invalid storage driver name: '%s'", name); + isulad_set_error_message("Invalid storage driver name: '%s'", name); return NULL; } @@ -79,7 +79,7 @@ struct graphdriver *graphdriver_get(const char *name) } } - lcrd_set_error_message("Invalid storage driver name: '%s'", name); + isulad_set_error_message("Invalid storage driver name: '%s'", name); return NULL; } @@ -151,7 +151,7 @@ void graphdriver_umount_mntpoint(void) int nret = 0; root = conf_get_graph_rootpath(); - driver_name = conf_get_lcrd_storage_driver(); + driver_name = conf_get_isulad_storage_driver(); if (root == NULL || driver_name == NULL) { WARN("No root or driver name specified"); goto cleanup; diff --git a/src/services/graphdriver/overlay2/driver_overlay2.c b/src/services/graphdriver/overlay2/driver_overlay2.c index b6755c3737bb347072613c3e963048dd7c8f5f79..416868185c36917bd3db7da56d9be55a4a1e0cf3 100644 --- a/src/services/graphdriver/overlay2/driver_overlay2.c +++ b/src/services/graphdriver/overlay2/driver_overlay2.c @@ -16,7 +16,7 @@ #include #include -#include "liblcrd.h" +#include "libisulad.h" #include "utils.h" #define QUOTA_SIZE_OPTION "overlay2.size" @@ -45,12 +45,12 @@ int overlay2_parse_options(struct graphdriver *driver, const char **options, siz dup = util_strdup_s(options[i]); if (dup == NULL) { - lcrd_set_error_message("Out of memory"); + isulad_set_error_message("Out of memory"); return -1; } p = strchr(dup, '='); if (!p) { - lcrd_set_error_message("Unable to parse key/value option: '%s'", dup); + isulad_set_error_message("Unable to parse key/value option: '%s'", dup); free(dup); return -1; } @@ -60,16 +60,16 @@ int overlay2_parse_options(struct graphdriver *driver, const char **options, siz int64_t converted = 0; ret = util_parse_byte_size_string(val, &converted); if (ret != 0) { - lcrd_set_error_message("Invalid size: '%s': %s", val, strerror(-ret)); + isulad_set_error_message("Invalid size: '%s': %s", val, strerror(-ret)); } } else if (strcasecmp(dup, "overlay2.override_kernel_check") == 0) { bool converted_bool = 0; ret = util_str_to_bool(val, &converted_bool); if (ret != 0) { - lcrd_set_error_message("Invalid bool: '%s': %s", val, strerror(-ret)); + isulad_set_error_message("Invalid bool: '%s': %s", val, strerror(-ret)); } } else { - lcrd_set_error_message("Overlay2: unknown option: '%s'", dup); + isulad_set_error_message("Overlay2: unknown option: '%s'", dup); ret = -1; } free(dup); diff --git a/src/services/image/image_cb.c b/src/services/image/image_cb.c index 26fdee80fa24c7995470e3e0ea3c90922c73c80c..ea13a4fb0b4448b252eec4a917d2a2daf83f87ad 100644 --- a/src/services/image/image_cb.c +++ b/src/services/image/image_cb.c @@ -27,11 +27,11 @@ #include "image_cb.h" #include "utils.h" #include "error.h" -#include "liblcrd.h" +#include "libisulad.h" #include "log.h" #include "image.h" #include "engine.h" -#include "lcrd_config.h" +#include "isulad_config.h" #include "mediatype.h" #include "filters.h" #ifdef ENABLE_OCI_IMAGE @@ -80,7 +80,7 @@ static int image_load_cb(const image_load_image_request *request, image_load_image_response **response) { int ret = -1; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; if (request == NULL || response == NULL) { ERROR("Invalid input arguments"); @@ -91,13 +91,13 @@ static int image_load_cb(const image_load_image_request *request, *response = util_common_calloc_s(sizeof(image_load_image_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto out; } if (request->file == NULL || request->type == NULL) { ERROR("input arguments error"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto out; } @@ -118,8 +118,8 @@ out: if (*response != NULL) { (*response)->cc = cc; - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -161,11 +161,11 @@ static int login_cb(const image_login_request *request, image_login_response **response) { int ret = -1; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; if (request == NULL || response == NULL) { ERROR("Invalid input arguments"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto out; } @@ -173,14 +173,14 @@ static int login_cb(const image_login_request *request, *response = util_common_calloc_s(sizeof(image_login_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto out; } if (request->username == NULL || request->password == NULL || request->type == NULL || request->server == NULL) { ERROR("input arguments error"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto out; } @@ -198,8 +198,8 @@ out: if (response != NULL && *response != NULL) { (*response)->cc = cc; - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -239,11 +239,11 @@ static int logout_cb(const image_logout_request *request, image_logout_response **response) { int ret = -1; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; if (request == NULL || response == NULL) { ERROR("Invalid input arguments"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto out; } @@ -251,13 +251,13 @@ static int logout_cb(const image_logout_request *request, *response = util_common_calloc_s(sizeof(image_logout_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto out; } if (request->type == NULL || request->server == NULL) { ERROR("input arguments error"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto out; } @@ -275,8 +275,8 @@ out: if (response != NULL && *response != NULL) { (*response)->cc = cc; - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -310,10 +310,10 @@ static int delete_image_info(const char *image_ref, bool force) if (ret != 0) { if (im_response != NULL && im_response->errmsg != NULL) { ERROR("Remove image %s failed:%s", image_ref, im_response->errmsg); - lcrd_try_set_error_message("Remove image %s failed:%s", image_ref, im_response->errmsg); + isulad_try_set_error_message("Remove image %s failed:%s", image_ref, im_response->errmsg); } else { ERROR("Remove image %s failed", image_ref); - lcrd_try_set_error_message("Remove image %s failed", image_ref); + isulad_try_set_error_message("Remove image %s failed", image_ref); } ret = -1; goto out; @@ -332,7 +332,7 @@ static int image_remove_cb(const image_delete_image_request *request, { int ret = -1; char *image_ref = NULL; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; DAEMON_CLEAR_ERRMSG(); @@ -346,15 +346,15 @@ static int image_remove_cb(const image_delete_image_request *request, *response = util_common_calloc_s(sizeof(image_delete_image_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto out; } if (!util_valid_image_name(image_ref)) { ERROR("Invalid image name %s", image_ref); - cc = LCRD_ERR_INPUT; - lcrd_try_set_error_message("Invalid image name:%s", - image_ref); + cc = ISULAD_ERR_INPUT; + isulad_try_set_error_message("Invalid image name:%s", + image_ref); goto out; } @@ -362,7 +362,7 @@ static int image_remove_cb(const image_delete_image_request *request, ret = delete_image_info(image_ref, request->force); if (ret != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto out; } @@ -371,8 +371,8 @@ static int image_remove_cb(const image_delete_image_request *request, out: if (*response != NULL) { (*response)->cc = cc; - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -484,7 +484,7 @@ static int trans_im_list_images(const im_list_response *im_list, image_list_imag if (images_display_num >= (SIZE_MAX / sizeof(image_image *))) { INFO("Too many images, out of memory"); ret = -1; - lcrd_try_set_error_message("Get too many images info, out of memory"); + isulad_try_set_error_message("Get too many images info, out of memory"); goto out; } @@ -577,14 +577,14 @@ static int do_add_filters(const char *filter_key, const json_map_string_bool *fi if (strcmp(filter_key, "reference") == 0) { if (util_wildcard_to_regex(filter_value->keys[j], &value) != 0) { ERROR("Failed to convert wildcard to regex: %s", filter_value->keys[j]); - lcrd_set_error_message("Failed to convert wildcard to regex: %s", filter_value->keys[j]); + isulad_set_error_message("Failed to convert wildcard to regex: %s", filter_value->keys[j]); ret = -1; goto out; } } else if (strcmp(filter_key, "dangling") == 0) { if (!is_valid_dangling_string(filter_value->keys[j])) { ERROR("Unrecognised filter value for status: %s", filter_value->keys[j]); - lcrd_set_error_message("Unrecognised filter value for status: %s", filter_value->keys[j]); + isulad_set_error_message("Unrecognised filter value for status: %s", filter_value->keys[j]); ret = -1; goto out; } @@ -592,7 +592,7 @@ static int do_add_filters(const char *filter_key, const json_map_string_bool *fi } else if (strcmp(filter_key, "before") == 0 || strcmp(filter_key, "since") == 0) { if (!is_valid_image(filter_value->keys[j])) { ERROR("No such image: %s", filter_value->keys[j]); - lcrd_set_error_message("No such image: %s", filter_value->keys[j]); + isulad_set_error_message("No such image: %s", filter_value->keys[j]); ret = -1; goto out; } @@ -643,7 +643,7 @@ static im_list_request *fold_filter(const image_list_images_request *request) sizeof(g_accepted_image_filter_tags) / sizeof(char *), request->filters->keys[i])) { ERROR("Invalid filter '%s'", request->filters->keys[i]); - lcrd_set_error_message("Invalid filter '%s'", request->filters->keys[i]); + isulad_set_error_message("Invalid filter '%s'", request->filters->keys[i]); goto error_out; } @@ -664,7 +664,7 @@ int image_list_cb(const image_list_images_request *request, image_list_images_response **response) { int ret = -1; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; im_list_request *im_request = NULL; im_list_response *im_response = NULL; @@ -678,14 +678,14 @@ int image_list_cb(const image_list_images_request *request, *response = util_common_calloc_s(sizeof(image_list_images_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto out; } im_request = fold_filter(request); if (im_request == NULL) { ERROR("Failed to fold filters"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto out; } @@ -693,19 +693,19 @@ int image_list_cb(const image_list_images_request *request, if (ret) { if (im_response != NULL && im_response->errmsg != NULL) { ERROR("List images failed:%s", im_response->errmsg); - lcrd_try_set_error_message("List images failed:%s", im_response->errmsg); + isulad_try_set_error_message("List images failed:%s", im_response->errmsg); } else { ERROR("List images failed"); - lcrd_try_set_error_message("List images failed"); + isulad_try_set_error_message("List images failed"); } - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto out; } ret = trans_im_list_images(im_response, *response); if (ret) { ERROR("Failed to translate list images info"); - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; goto out; } @@ -716,8 +716,8 @@ out: if (*response != NULL) { (*response)->cc = cc; - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } } @@ -749,10 +749,10 @@ static int inspect_image_with_valid_name(const char *image_ref, char **inspected if (ret != 0) { if (im_response != NULL && im_response->errmsg != NULL) { ERROR("Inspect image %s failed:%s", image_ref, im_response->errmsg); - lcrd_try_set_error_message("Inspect image %s failed:%s", image_ref, im_response->errmsg); + isulad_try_set_error_message("Inspect image %s failed:%s", image_ref, im_response->errmsg); } else { ERROR("Inspect image %s failed", image_ref); - lcrd_try_set_error_message("Inspect image %s failed", image_ref); + isulad_try_set_error_message("Inspect image %s failed", image_ref); } ret = -1; goto out; @@ -795,14 +795,14 @@ static int inspect_image_helper(const char *image_ref, char **inspected_json) if (!util_valid_image_name(image_ref)) { ERROR("Inspect invalid name %s", image_ref); - lcrd_set_error_message("Inspect invalid name %s", image_ref); + isulad_set_error_message("Inspect invalid name %s", image_ref); ret = -1; goto out; } if (inspect_image_with_valid_name(image_ref, inspected_json) != 0) { ERROR("No such image or container or accelerator:%s", image_ref); - lcrd_set_error_message("No such image or container or accelerator:%s", image_ref); + isulad_set_error_message("No such image or container or accelerator:%s", image_ref); ret = -1; goto out; } @@ -815,7 +815,7 @@ static int image_inspect_cb(const image_inspect_request *request, image_inspect_ { char *name = NULL; char *image_json = NULL; - uint32_t cc = LCRD_SUCCESS; + uint32_t cc = ISULAD_SUCCESS; DAEMON_CLEAR_ERRMSG(); @@ -827,7 +827,7 @@ static int image_inspect_cb(const image_inspect_request *request, image_inspect_ *response = util_common_calloc_s(sizeof(image_inspect_response)); if (*response == NULL) { ERROR("Out of memory"); - cc = LCRD_ERR_MEMOUT; + cc = ISULAD_ERR_MEMOUT; goto pack_response; } @@ -835,7 +835,7 @@ static int image_inspect_cb(const image_inspect_request *request, image_inspect_ if (name == NULL) { ERROR("receive NULL Request id"); - cc = LCRD_ERR_INPUT; + cc = ISULAD_ERR_INPUT; goto pack_response; } @@ -844,14 +844,14 @@ static int image_inspect_cb(const image_inspect_request *request, image_inspect_ INFO("Inspect :%s", name); if (inspect_image_helper(name, &image_json) != 0) { - cc = LCRD_ERR_EXEC; + cc = ISULAD_ERR_EXEC; } pack_response: if (*response != NULL) { (*response)->cc = cc; - if (g_lcrd_errmsg != NULL) { - (*response)->errmsg = util_strdup_s(g_lcrd_errmsg); + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); DAEMON_CLEAR_ERRMSG(); } (*response)->image_json = image_json; @@ -859,7 +859,7 @@ pack_response: free_log_prefix(); malloc_trim(0); - return (cc == LCRD_SUCCESS) ? 0 : -1; + return (cc == ISULAD_SUCCESS) ? 0 : -1; } /* image callback init */ diff --git a/src/sysctl_tools.c b/src/sysctl_tools.c index 305575d60eaf54b70ac1158788783d31ada4e5e2..8af8f59f39ddbf284f77ee9edfdb4f7981233d54 100644 --- a/src/sysctl_tools.c +++ b/src/sysctl_tools.c @@ -78,15 +78,15 @@ int set_sysctl(const char *sysctl, int new_value, char **err) int fd = -1; ssize_t rsize; char fullpath[PATH_MAX] = { 0 }; - char buff[LCRD_NUMSTRLEN64] = { 0 }; + char buff[ISULAD_NUMSTRLEN64] = { 0 }; ret = snprintf(fullpath, PATH_MAX, "%s/%s", SYSCTL_BASE, sysctl); if (ret < 0 || ret >= PATH_MAX) { *err = util_strdup_s("Out of memory"); goto free_out; } - ret = snprintf(buff, LCRD_NUMSTRLEN64, "%d", new_value); - if (ret < 0 || ret >= LCRD_NUMSTRLEN64) { + ret = snprintf(buff, ISULAD_NUMSTRLEN64, "%d", new_value); + if (ret < 0 || ret >= ISULAD_NUMSTRLEN64) { *err = util_strdup_s("Out of memory"); goto free_out; } diff --git a/src/tar/lcrdtar.c b/src/tar/libtar.c similarity index 99% rename from src/tar/lcrdtar.c rename to src/tar/libtar.c index 4a693e52630719ae01fcb3a491ac9ce4fda91d0e..79c65ddf9480e49e92241cdc166b76aec7088c33 100644 --- a/src/tar/lcrdtar.c +++ b/src/tar/libtar.c @@ -26,7 +26,7 @@ #include #include -#include "lcrdtar.h" +#include "libtar.h" #include "utils.h" #include "path.h" #include "log.h" diff --git a/src/tar/lcrdtar.h b/src/tar/libtar.h similarity index 98% rename from src/tar/lcrdtar.h rename to src/tar/libtar.h index 700763d35cadf1b8270c4348bc12979cda525414..a55c83265b2419972557b25aff3492813d0bbe3e 100644 --- a/src/tar/lcrdtar.h +++ b/src/tar/libtar.h @@ -14,8 +14,8 @@ *********************************************************************************/ -#ifndef __LCRD_TAR_H_ -#define __LCRD_TAR_H_ +#ifndef __ISULAD_TAR_H_ +#define __ISULAD_TAR_H_ #include #include diff --git a/src/websocket/service/ws_server.cc b/src/websocket/service/ws_server.cc index 718df10f1f40f7e0d09b12a9cdf52d60009dc8dc..8c42aa8debdb63090b15dd51e9585ba4c10f9959 100644 --- a/src/websocket/service/ws_server.cc +++ b/src/websocket/service/ws_server.cc @@ -402,7 +402,6 @@ void WebsocketServer::Wait() CloseAllWsSession(); lws_context_destroy(m_context); - closelog(); } diff --git a/test/image/oci/oci_config_merge/CMakeLists.txt b/test/image/oci/oci_config_merge/CMakeLists.txt index 141d12080674901bd9f78f384b860526aa11bf82..bc993dedc80ed09cfbd1eda769f79dabb5d2daac 100644 --- a/test/image/oci/oci_config_merge/CMakeLists.txt +++ b/test/image/oci/oci_config_merge/CMakeLists.txt @@ -18,20 +18,20 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/services/execution/spec/specs_mount.c ${CMAKE_BINARY_DIR}/json/host_config.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/services/execution/spec/specs_extend.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/liblcrd.c + ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libisulad.c ${CMAKE_BINARY_DIR}/json/oci_runtime_defs_linux.c ${CMAKE_BINARY_DIR}/json/defs.c ${CMAKE_BINARY_DIR}/json/container_config_v2.c ${CMAKE_BINARY_DIR}/json/container_config.c ${CMAKE_BINARY_DIR}/json/container_custom_config.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/config/lcrd_config.c + ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/config/isulad_config.c ${CMAKE_BINARY_DIR}/json/oci_runtime_spec.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/services/execution/spec/sysinfo.c ${CMAKE_BINARY_DIR}/json/oci_runtime_config_linux.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/cmd/commander.c ${CMAKE_BINARY_DIR}/json/isulad_daemon_configs.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/json/schema/src/read_file.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/cmd/lcrd/arguments.c + ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/cmd/isulad/arguments.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../test/image/oci/oci_llt_common.cc ${CMAKE_BINARY_DIR}/json/imagetool_image.c ${CMAKE_BINARY_DIR}/json/oci_image_spec.c diff --git a/test/image/oci/oci_config_merge/oci_runtime_spec.json b/test/image/oci/oci_config_merge/oci_runtime_spec.json index cdc3a4e2c22dc3133f31a5991567ee0adaaa63b4..50726e69e148f41ad27c3f385c771cdbf8495522 100644 --- a/test/image/oci/oci_config_merge/oci_runtime_spec.json +++ b/test/image/oci/oci_config_merge/oci_runtime_spec.json @@ -7,7 +7,7 @@ "log.console.file": "none", "log.console.filerotate": "7", "log.console.filesize": "1MB", - "rootfs.mount": "/var/lib/lcrd/mnt/rootfs", + "rootfs.mount": "/var/lib/isulad/mnt/rootfs", "native.umask": "secure" }, "hostname": "localhost", @@ -91,7 +91,7 @@ "type": "mqueue" }, { - "source": "/var/lib/lcrd/engines/lcr/ad6c3f33518ed7e17a6d889a1327aa386f8b869927e2540821fb02310f567310/hostname", + "source": "/var/lib/isulad/engines/lcr/ad6c3f33518ed7e17a6d889a1327aa386f8b869927e2540821fb02310f567310/hostname", "destination": "/etc/hostname", "options": [ "rbind", @@ -100,7 +100,7 @@ "type": "bind" }, { - "source": "/var/lib/lcrd/engines/lcr/ad6c3f33518ed7e17a6d889a1327aa386f8b869927e2540821fb02310f567310/resolv.conf", + "source": "/var/lib/isulad/engines/lcr/ad6c3f33518ed7e17a6d889a1327aa386f8b869927e2540821fb02310f567310/resolv.conf", "destination": "/etc/resolv.conf", "options": [ "rbind", @@ -109,7 +109,7 @@ "type": "bind" }, { - "source": "/var/lib/lcrd/engines/lcr/ad6c3f33518ed7e17a6d889a1327aa386f8b869927e2540821fb02310f567310/hosts", + "source": "/var/lib/isulad/engines/lcr/ad6c3f33518ed7e17a6d889a1327aa386f8b869927e2540821fb02310f567310/hosts", "destination": "/etc/hosts", "options": [ "rbind", @@ -119,7 +119,7 @@ } ], "root": { - "path": "/var/lib/lcrd/storage/overlay/40c51530fc1b4610f7f56633ef78fc5e4ad1a6f14cad59d5a1d012ff800c4289/merged" + "path": "/var/lib/isulad/storage/overlay/40c51530fc1b4610f7f56633ef78fc5e4ad1a6f14cad59d5a1d012ff800c4289/merged" }, "process": { "args": [ diff --git a/test/image/oci/oci_llt_common.cc b/test/image/oci/oci_llt_common.cc index e3f0142552605b38b79f8c6542e7b26c4dc279af..5a6298b8900e94099dffca3001e66edf1318b279 100644 --- a/test/image/oci/oci_llt_common.cc +++ b/test/image/oci/oci_llt_common.cc @@ -42,15 +42,15 @@ char **single_array_from_string(const char *value) char *conf_get_graph_rootpath_success() { - return util_strdup_s("/var/lib/lcrd/storage"); + return util_strdup_s("/var/lib/isulad/storage"); } char *conf_get_graph_run_path_success() { - return util_strdup_s("/var/run/lcrd/storage"); + return util_strdup_s("/var/run/isulad/storage"); } -char *conf_get_lcrd_storage_driver_success() +char *conf_get_isulad_storage_driver_success() { return util_strdup_s("overlay"); } diff --git a/test/image/oci/oci_llt_common.h b/test/image/oci/oci_llt_common.h index 6bf58c494e834b61833b3cc79434c12b4548c8d9..c62d4e38ebee282bacf33ba38e5f3a3916daffbb 100644 --- a/test/image/oci/oci_llt_common.h +++ b/test/image/oci/oci_llt_common.h @@ -33,8 +33,8 @@ extern "C" { DECLARE_WRAPPER_V(conf_get_graph_run_path, char *, ());\ DEFINE_WRAPPER_V(conf_get_graph_run_path, char *, (), ());\ \ - DECLARE_WRAPPER_V(conf_get_lcrd_storage_driver, char *, ());\ - DEFINE_WRAPPER_V(conf_get_lcrd_storage_driver, char *, (), ());\ + DECLARE_WRAPPER_V(conf_get_isulad_storage_driver, char *, ());\ + DEFINE_WRAPPER_V(conf_get_isulad_storage_driver, char *, (), ());\ \ DECLARE_WRAPPER_V(conf_get_storage_opts, char **, ());\ DEFINE_WRAPPER_V(conf_get_storage_opts, char **, (), ());\ @@ -56,7 +56,7 @@ extern "C" { {\ MOCK_SET_V(conf_get_graph_rootpath, conf_get_graph_rootpath_success);\ MOCK_SET_V(conf_get_graph_run_path, conf_get_graph_run_path_success);\ - MOCK_SET_V(conf_get_lcrd_storage_driver, conf_get_lcrd_storage_driver_success);\ + MOCK_SET_V(conf_get_isulad_storage_driver, conf_get_isulad_storage_driver_success);\ MOCK_SET_V(conf_get_storage_opts, conf_get_storage_opts_success);\ MOCK_SET_V(conf_get_registry_list, conf_get_registry_list_success);\ MOCK_SET_V(conf_get_insecure_registry_list, conf_get_insecure_registry_list_success);\ @@ -67,7 +67,7 @@ extern "C" { {\ MOCK_CLEAR(conf_get_graph_rootpath);\ MOCK_CLEAR(conf_get_graph_run_path);\ - MOCK_CLEAR(conf_get_lcrd_storage_driver);\ + MOCK_CLEAR(conf_get_isulad_storage_driver);\ MOCK_CLEAR(conf_get_storage_opts);\ MOCK_CLEAR(conf_get_registry_list);\ MOCK_CLEAR(conf_get_insecure_registry_list);\ @@ -78,7 +78,7 @@ char *json_path(const char *file); int execvp_success(const char *file, char * const argv[]); char *conf_get_graph_rootpath_success(); char *conf_get_graph_run_path_success(); -char *conf_get_lcrd_storage_driver_success(); +char *conf_get_isulad_storage_driver_success(); char **conf_get_storage_opts_success(); char **conf_get_registry_list_success(); char **conf_get_insecure_registry_list_success(); diff --git a/update-version.bash b/update-version.bash index 0cfa9bfc20fd02be7574f986cf103f90a661fd13..dba43aa95de5bf0062862f9fd303bbba2d107d1a 100755 --- a/update-version.bash +++ b/update-version.bash @@ -48,7 +48,7 @@ commit_id_long=`git log --pretty=oneline -1 | awk {'print $1'}` commit_id=${commit_id_long:0:8} new_release=`date "+%Y%m%d"`.`date "+%H%M%S"`.git$commit_id echo "The relase version has been modified, it is ${new_release}" -sed -i "s/set(LCRD_VERSION \"${old_version}\")/set(LCRD_VERSION \"${new_version}\")/g" ${Version_CMakefile} +sed -i "s/set(ISULAD_VERSION \"${old_version}\")/set(ISULAD_VERSION \"${new_version}\")/g" ${Version_CMakefile} sed -i "s/^\%global _version ${old_version}$/\%global _version ${new_version}/g" ${specfile} sed -i "s/^\%global _release ${old_release}$/\%global _release ${new_release}/g" ${specfile}