From 040e39827049cd557987f505d1bd6c6e4f18b4b3 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Mon, 11 Mar 2024 17:48:11 +0800
Subject: [PATCH 48/69] CDI:interface definition

---
 cmake/options.cmake                           | 11 +++
 src/daemon/modules/CMakeLists.txt             | 11 +++
 src/daemon/modules/api/cdi_operate_api.h      | 39 ++++++++++
 src/daemon/modules/device/CMakeLists.txt      | 23 ++++++
 src/daemon/modules/device/cdi/CMakeLists.txt  | 13 ++++
 .../device/cdi/behavior/CMakeLists.txt        | 13 ++++
 .../device/cdi/behavior/cdi_container_edits.c | 49 ++++++++++++
 .../device/cdi/behavior/cdi_container_edits.h | 39 ++++++++++
 .../modules/device/cdi/behavior/cdi_device.c  | 40 ++++++++++
 .../modules/device/cdi/behavior/cdi_device.h  | 46 ++++++++++++
 .../modules/device/cdi/behavior/cdi_spec.c    | 60 +++++++++++++++
 .../modules/device/cdi/behavior/cdi_spec.h    | 56 ++++++++++++++
 .../device/cdi/behavior/cdi_spec_dirs.c       | 29 +++++++
 .../device/cdi/behavior/cdi_spec_dirs.h       | 47 ++++++++++++
 .../modules/device/cdi/behavior/cdi_version.c | 40 ++++++++++
 .../modules/device/cdi/behavior/cdi_version.h | 34 +++++++++
 .../device/cdi/behavior/parser/CMakeLists.txt |  3 +
 .../device/cdi/behavior/parser/cdi_parser.c   | 55 ++++++++++++++
 .../device/cdi/behavior/parser/cdi_parser.h   | 38 ++++++++++
 .../modules/device/cdi/cdi_annotations.c      | 31 ++++++++
 .../modules/device/cdi/cdi_annotations.h      | 32 ++++++++
 src/daemon/modules/device/cdi/cdi_cache.c     | 69 +++++++++++++++++
 src/daemon/modules/device/cdi/cdi_cache.h     | 75 +++++++++++++++++++
 src/daemon/modules/device/cdi/cdi_registry.c  | 25 +++++++
 src/daemon/modules/device/cdi/cdi_registry.h  | 36 +++++++++
 src/daemon/modules/device/cdi_operate.c       | 35 +++++++++
 26 files changed, 949 insertions(+)
 create mode 100644 src/daemon/modules/api/cdi_operate_api.h
 create mode 100644 src/daemon/modules/device/CMakeLists.txt
 create mode 100644 src/daemon/modules/device/cdi/CMakeLists.txt
 create mode 100644 src/daemon/modules/device/cdi/behavior/CMakeLists.txt
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_container_edits.c
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_container_edits.h
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_device.c
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_device.h
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_spec.c
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_spec.h
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_version.c
 create mode 100644 src/daemon/modules/device/cdi/behavior/cdi_version.h
 create mode 100644 src/daemon/modules/device/cdi/behavior/parser/CMakeLists.txt
 create mode 100644 src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c
 create mode 100644 src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h
 create mode 100644 src/daemon/modules/device/cdi/cdi_annotations.c
 create mode 100644 src/daemon/modules/device/cdi/cdi_annotations.h
 create mode 100644 src/daemon/modules/device/cdi/cdi_cache.c
 create mode 100644 src/daemon/modules/device/cdi/cdi_cache.h
 create mode 100644 src/daemon/modules/device/cdi/cdi_registry.c
 create mode 100644 src/daemon/modules/device/cdi/cdi_registry.h
 create mode 100644 src/daemon/modules/device/cdi_operate.c

diff --git a/cmake/options.cmake b/cmake/options.cmake
index b7a7c65d..c1eac472 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -40,6 +40,17 @@ if (ENABLE_CRI_API_V1 STREQUAL "ON")
     message("${Green}--  Enable CRI API V1${ColourReset}")
 endif()
 
+option(ENABLE_CDI "Enable CDI" OFF)
+if (ENABLE_CDI STREQUAL "ON")
+    if (ENABLE_CRI_API_V1)
+        add_definitions(-DENABLE_CDI)
+        set(ENABLE_CDI 1)
+        message("${Green}--  Enable CDI${ColourReset}")
+    else()
+        message("${Yellow}-- Can not enable CDI, CDI need enable CRI API V1 first ${ColourReset}")
+    endif()
+endif()
+
 option(ENABLE_SANDBOXER "Enable sandbox API" ON)
 if (ENABLE_SANDBOXER STREQUAL "ON")
     add_definitions(-DENABLE_SANDBOXER)
diff --git a/src/daemon/modules/CMakeLists.txt b/src/daemon/modules/CMakeLists.txt
index a70c094f..ff2ea226 100644
--- a/src/daemon/modules/CMakeLists.txt
+++ b/src/daemon/modules/CMakeLists.txt
@@ -49,6 +49,16 @@ if (ENABLE_PLUGIN)
         )
 endif()
 
+if (ENABLE_CDI)
+    add_subdirectory(device)
+    list(APPEND local_modules_srcs
+        ${DEVICE_SRCS}
+        )
+    list(APPEND local_modules_incs
+        ${DEVICE_INCS}
+        )
+endif()
+
 set(MODULES_SRCS
     ${local_modules_srcs}
     PARENT_SCOPE
@@ -70,3 +80,4 @@ if(ENABLE_NETWORK)
         )
 endif()
 
+
diff --git a/src/daemon/modules/api/cdi_operate_api.h b/src/daemon/modules/api/cdi_operate_api.h
new file mode 100644
index 00000000..4f4c339e
--- /dev/null
+++ b/src/daemon/modules/api/cdi_operate_api.h
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi device manager function definition
+ ******************************************************************************/
+#ifndef CDI_OPERATE_API_H
+#define CDI_OPERATE_API_H
+
+#include <isula_libutils/oci_runtime_spec.h>
+#include <isula_libutils/json_common.h>
+
+#include "utils_array.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int cdi_operate_registry_init(char **specs_dirs, size_t specs_dirs_len);
+
+char *cdi_operate_refresh(void);
+
+string_array *cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices, char **error);
+
+char *cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/daemon/modules/device/CMakeLists.txt b/src/daemon/modules/device/CMakeLists.txt
new file mode 100644
index 00000000..e3468c0b
--- /dev/null
+++ b/src/daemon/modules/device/CMakeLists.txt
@@ -0,0 +1,23 @@
+# get current directory sources files
+aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} device_top_srcs)
+
+add_subdirectory(cdi)
+
+set(local_device_srcs
+    ${device_top_srcs}
+    ${CDI_SRCS}
+    )
+
+set(local_device_incs
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CDI_INCS}
+    )
+
+set(DEVICE_SRCS
+    ${local_device_srcs}
+    PARENT_SCOPE
+    )
+set(DEVICE_INCS
+    ${local_device_incs}
+    PARENT_SCOPE
+    )
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/CMakeLists.txt b/src/daemon/modules/device/cdi/CMakeLists.txt
new file mode 100644
index 00000000..12d9b222
--- /dev/null
+++ b/src/daemon/modules/device/cdi/CMakeLists.txt
@@ -0,0 +1,13 @@
+aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} cdi_top_srcs)
+add_subdirectory(behavior)
+
+set(CDI_SRCS
+    ${cdi_top_srcs}
+    ${BEHAVIOR_SRCS}
+    PARENT_SCOPE
+    )
+set(CDI_INCS
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${BEHAVIOR_INCS}
+    PARENT_SCOPE
+    )
diff --git a/src/daemon/modules/device/cdi/behavior/CMakeLists.txt b/src/daemon/modules/device/cdi/behavior/CMakeLists.txt
new file mode 100644
index 00000000..39881a7b
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/CMakeLists.txt
@@ -0,0 +1,13 @@
+aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} behavior_top_srcs)
+add_subdirectory(parser)
+
+set(BEHAVIOR_SRCS
+    ${behavior_top_srcs}
+    ${PARSER_SRCS}
+    PARENT_SCOPE
+    )
+set(BEHAVIOR_INCS
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}/parser/
+    PARENT_SCOPE
+    )
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c
new file mode 100644
index 00000000..ce7b16db
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi container edits function
+ ******************************************************************************/
+#include "cdi_container_edits.h"
+
+// PRESTART_HOOK is the name of the OCI "prestart" hook.
+#define PRESTART_HOOK "prestart"
+// CREATE_RUNTIME_HOOK is the name of the OCI "createRuntime" hook.
+#define CREATE_RUNTIME_HOOK "createRuntime"
+// CREATE_CONTAINER_HOOK is the name of the OCI "createContainer" hook.
+#define CREATE_CONTAINER_HOOK "createContainer"
+// START_CONTAINER_HOOK is the name of the OCI "startContainer" hook.
+#define START_CONTAINER_HOOK "startContainer"
+// POSTSTART_HOOK is the name of the OCI "poststart" hook.
+#define POSTSTART_HOOK "poststart"
+// POSTSTOP_HOOK is the name of the OCI "poststop" hook.
+#define POSTSTOP_HOOK "poststop"
+
+char *cdi_container_edits_apply(cdi_container_edits *e, oci_runtime_spec *spec)
+{
+    return NULL;
+}
+
+char *cdi_container_edits_validate(cdi_container_edits *e)
+{
+    return NULL;
+}
+
+cdi_container_edits *cdi_container_edits_append(cdi_container_edits *e, cdi_container_edits *o)
+{
+    return NULL;
+}
+
+bool cdi_container_edits_is_empty(cdi_container_edits *e)
+{
+    return true;
+}
+
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h
new file mode 100644
index 00000000..7b16d2bc
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi container edits function definition
+ ******************************************************************************/
+#ifndef CDI_CONTAINER_EDITS_H
+#define CDI_CONTAINER_EDITS_H
+
+#include <isula_libutils/cdi_container_edits.h>
+#include <isula_libutils/cdi_device_node.h>
+#include <isula_libutils/oci_runtime_spec.h>
+#include <isula_libutils/cdi_hook.h>
+#include <isula_libutils/cdi_mount.h>
+
+#include "utils_array.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *cdi_container_edits_apply(cdi_container_edits *e, oci_runtime_spec *spec);
+char *cdi_container_edits_validate(cdi_container_edits *e);
+cdi_container_edits *cdi_container_edits_append(cdi_container_edits *e, cdi_container_edits *o);
+bool cdi_container_edits_is_empty(cdi_container_edits *e);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_device.c b/src/daemon/modules/device/cdi/behavior/cdi_device.c
new file mode 100644
index 00000000..9904e9ee
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_device.c
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi device function
+ ******************************************************************************/
+#include "cdi_device.h"
+
+void free_cdi_cache_device(struct cdi_cache_device *d)
+{
+    (void)d;
+}
+
+struct cdi_cache_device *cdi_device_new_device(struct cdi_cache_spec *spec, cdi_device *d, char **error)
+{
+    return NULL;
+}
+
+struct cdi_cache_spec *cdi_device_get_spec(struct cdi_cache_device *d)
+{
+    return NULL;
+}
+
+char *cdi_device_get_qualified_name(struct cdi_cache_device *d)
+{
+    return NULL;
+}
+
+cdi_container_edits *cdi_device_edits(struct cdi_cache_device *d)
+{
+    return NULL;
+}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_device.h b/src/daemon/modules/device/cdi/behavior/cdi_device.h
new file mode 100644
index 00000000..3f460152
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_device.h
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi device function definition
+ ******************************************************************************/
+#ifndef CDI_DEVICE_H
+#define CDI_DEVICE_H
+
+#include <stdbool.h>
+#include <isula_libutils/cdi_device.h>
+#include <isula_libutils/oci_runtime_spec.h>
+
+#include "cdi_container_edits.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct cdi_cache_spec;
+
+struct cdi_cache_device {
+    cdi_device *raw_device;
+    struct cdi_cache_spec *cache_spec;
+};
+
+void free_cdi_cache_device(struct cdi_cache_device *d);
+
+struct cdi_cache_device *cdi_device_new_device(struct cdi_cache_spec *spec, cdi_device *d, char **error);
+struct cdi_cache_spec *cdi_device_get_spec(struct cdi_cache_device *d);
+char *cdi_device_get_qualified_name(struct cdi_cache_device *d);
+cdi_container_edits *cdi_device_edits(struct cdi_cache_device *d);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec.c b/src/daemon/modules/device/cdi/behavior/cdi_spec.c
new file mode 100644
index 00000000..38fc9e38
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec.c
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi spec function
+ ******************************************************************************/
+#include "cdi_spec.h"
+
+void free_cdi_cache_spec(struct cdi_cache_spec *s)
+{
+    (void)s;
+}
+
+struct cdi_cache_spec *cdi_spec_read_spec(const char *path, int priority, char **error)
+{
+    return NULL;
+}
+
+struct cdi_cache_spec *cdi_spec_new_spec(cdi_spec *raw, const char *path, int priority, char **error)
+{
+    return NULL;
+}
+
+const char *cdi_spec_get_vendor(struct cdi_cache_spec *s)
+{
+    return NULL;
+}
+
+const char *cdi_spec_get_class(struct cdi_cache_spec *s)
+{
+    return NULL;
+}
+
+struct cdi_cache_device *cdi_spec_get_cache_device(struct cdi_cache_spec *s, const char *name)
+{
+    return NULL;
+}
+
+const char *cdi_spec_get_path(struct cdi_cache_spec *s)
+{
+    return NULL;
+}
+
+int cdi_spec_get_priority(struct cdi_cache_spec *s)
+{
+    return 0;
+}
+
+cdi_container_edits *cdi_spec_edits(struct cdi_cache_spec *s)
+{
+    return NULL;
+}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec.h b/src/daemon/modules/device/cdi/behavior/cdi_spec.h
new file mode 100644
index 00000000..bd4fc9d1
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec.h
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi spec function definition
+ ******************************************************************************/
+#ifndef CDI_SPEC_H
+#define CDI_SPEC_H
+
+#include <isula_libutils/cdi_spec.h>
+#include <isula_libutils/oci_runtime_spec.h>
+
+#include "map.h"
+#include "cdi_container_edits.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct cdi_cache_device;
+
+struct cdi_cache_spec {
+    cdi_spec *raw_spec;
+    char *vendor;
+    char *class;
+    char *path;
+    int priority;
+    map_t *devices;  // MAP_STR_PTR  devices[cdi_device.name] = cdi_cache_device*
+};
+
+#define CDI_DEFAULT_SPEC_EXT ".json"
+ 
+void free_cdi_cache_spec(struct cdi_cache_spec *s);
+
+struct cdi_cache_spec *cdi_spec_read_spec(const char *path, int priority, char **error);
+struct cdi_cache_spec *cdi_spec_new_spec(cdi_spec *raw, const char *path, int priority, char **error);
+const char *cdi_spec_get_vendor(struct cdi_cache_spec *s);
+const char *cdi_spec_get_class(struct cdi_cache_spec *s);
+struct cdi_cache_device *cdi_spec_get_cache_device(struct cdi_cache_spec *s, const char *name);
+const char *cdi_spec_get_path(struct cdi_cache_spec *s);
+int cdi_spec_get_priority(struct cdi_cache_spec *s);
+cdi_container_edits *cdi_spec_edits(struct cdi_cache_spec *s);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c
new file mode 100644
index 00000000..5df4c937
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c
@@ -0,0 +1,29 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi spec dirs function
+ ******************************************************************************/
+#include "cdi_spec_dirs.h"
+
+#define DEFAULT_SPEC_DIRS_LEN   2
+static char *default_spec_dirs_items[DEFAULT_SPEC_DIRS_LEN] = {CDI_DEFAULT_STATIC_DIR, CDI_DEFAULT_DYNAMIC_DIR};
+ 
+string_array g_default_spec_dirs = {
+    .items = default_spec_dirs_items,
+    .len = DEFAULT_SPEC_DIRS_LEN,
+    .cap = DEFAULT_SPEC_DIRS_LEN,
+};
+ 
+char *cdi_scan_spec_dirs(string_array *dirs, struct cdi_scan_fn_maps *scan_fn_maps, cdi_scan_spec_func scan_fn)
+{
+    return NULL;
+}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h
new file mode 100644
index 00000000..bd00e318
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi spec dirs function definition
+ ******************************************************************************/
+#ifndef CDI_SPEC_DIRS_H
+#define CDI_SPEC_DIRS_H
+
+#include "cdi_cache.h"
+#include "utils_array.h"
+#include "map.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CDI_DEFAULT_STATIC_DIR "/etc/cdi"
+#define CDI_DEFAULT_DYNAMIC_DIR "/var/run/cdi"
+
+extern string_array g_default_spec_dirs;
+ 
+struct cdi_scan_fn_maps {
+    map_t *specs;
+    map_t *devices;
+    map_t *conflicts;
+    map_t *spec_errors;
+    string_array *result;
+};
+typedef char *(*cdi_scan_spec_func)(struct cdi_scan_fn_maps *scan_fn_maps, const char *path, int priority,
+                                    struct cdi_cache_spec *spec, char **error);
+
+char *cdi_scan_spec_dirs(string_array *dirs, struct cdi_scan_fn_maps *scan_fn_maps, cdi_scan_spec_func scan_fn);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_version.c b/src/daemon/modules/device/cdi/behavior/cdi_version.c
new file mode 100644
index 00000000..3e87c111
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_version.c
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi version function
+ ******************************************************************************/
+#include "cdi_version.h"
+
+#define CDI_V_CURRENT_VERSION "v"##CDI_CURRENT_VERSION
+
+#define CDI_V010        "v0.1.0"
+#define CDI_V020        "v0.2.0"
+#define CDI_V030        "v0.3.0"
+#define CDI_V040        "v0.4.0"
+#define CDI_V050        "v0.5.0"
+#define CDI_V060        "v0.6.0"
+#define CDI_V_EARLIEST  CDI_V030
+
+const char *cdi_minimum_required_version(cdi_spec *spec)
+{
+    return NULL;
+}
+
+bool cdi_is_greater_than_version(const char *v, const char *o)
+{
+    return true;
+}
+
+bool cdi_is_valid_version(const char *spec_version)
+{
+    return true;
+}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_version.h b/src/daemon/modules/device/cdi/behavior/cdi_version.h
new file mode 100644
index 00000000..99b7e692
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/cdi_version.h
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi version function definition
+ ******************************************************************************/
+#ifndef CDI_VERSION_H
+#define CDI_VERSION_H
+
+#include <isula_libutils/cdi_spec.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CDI_CURRENT_VERSION "0.6.0"
+
+const char *cdi_minimum_required_version(cdi_spec *spec);
+bool cdi_is_greater_than_version(const char *v, const char *o);
+bool cdi_is_valid_version(const char *spec_version);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/behavior/parser/CMakeLists.txt b/src/daemon/modules/device/cdi/behavior/parser/CMakeLists.txt
new file mode 100644
index 00000000..9bf5f3f2
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/parser/CMakeLists.txt
@@ -0,0 +1,3 @@
+# get current directory sources files
+aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} local_cdi_parser_srcs)
+set(PARSER_SRCS ${local_cdi_parser_srcs} PARENT_SCOPE)
diff --git a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c
new file mode 100644
index 00000000..45048f9a
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi parser linux function
+ ******************************************************************************/
+#include "cdi_parser.h"
+
+char *cdi_parser_qualified_name(const char *vendor, const char *class, const char *name)
+{
+    return NULL;
+}
+
+bool cdi_parser_is_qualified_name(const char *device)
+{
+    return true;
+}
+
+char *cdi_parser_parse_qualified_name(const char *device, char **vendor, char **class, char **name)
+{
+    return NULL;
+}
+
+int cdi_parser_parse_device(const char *device, char **vendor, char **class, char **name)
+{
+    return 0;
+}
+
+int cdi_parser_parse_qualifier(const char *kind, char **vendor, char **class)
+{
+    return 0;
+}
+
+char *cdi_parser_validate_vendor_name(const char *vendor)
+{
+    return NULL;
+}
+
+char *cdi_parser_validate_class_name(const char *class)
+{
+    return NULL;
+}
+
+char *cdi_parser_validate_device_name(const char *name)
+{
+    return NULL;
+}
diff --git a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h
new file mode 100644
index 00000000..d9c057ea
--- /dev/null
+++ b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi parser function definition
+ ******************************************************************************/
+#ifndef CDI_PARSER_H
+#define CDI_PARSER_H
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *cdi_parser_qualified_name(const char *vendor, const char *class, const char *name);
+bool cdi_parser_is_qualified_name(const char *device);
+char *cdi_parser_parse_qualified_name(const char *device, char **vendor, char **class, char **name);
+int cdi_parser_parse_device(const char *device, char **vendor, char **class, char **name);
+int cdi_parser_parse_qualifier(const char *kind, char **vendor, char **class);
+char *cdi_parser_validate_vendor_name(const char *vendor);
+char *cdi_parser_validate_class_name(const char *class);
+char *cdi_parser_validate_device_name(const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/cdi_annotations.c b/src/daemon/modules/device/cdi/cdi_annotations.c
new file mode 100644
index 00000000..3cb9be84
--- /dev/null
+++ b/src/daemon/modules/device/cdi/cdi_annotations.c
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi annotations function
+ ******************************************************************************/
+#include "cdi_annotations.h"
+
+#include <ctype.h>
+#include <isula_libutils/log.h>
+#include <isula_libutils/auto_cleanup.h>
+#include <isula_libutils/utils_string.h>
+
+#include "error.h"
+#include "utils.h"
+#include "cdi_parser.h"
+
+#define CDI_ANNOTATIONS_PREFIX "cdi.k8s.io/"
+
+char *cdi_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices)
+{
+    return NULL;
+}
diff --git a/src/daemon/modules/device/cdi/cdi_annotations.h b/src/daemon/modules/device/cdi/cdi_annotations.h
new file mode 100644
index 00000000..52355099
--- /dev/null
+++ b/src/daemon/modules/device/cdi/cdi_annotations.h
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi annotations function definition
+ ******************************************************************************/
+#ifndef CDI_ANNOTATIONS_H
+#define CDI_ANNOTATIONS_H
+
+#include <isula_libutils/json_common.h>
+
+#include "utils_array.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *cdi_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/cdi_cache.c b/src/daemon/modules/device/cdi/cdi_cache.c
new file mode 100644
index 00000000..9c54acbf
--- /dev/null
+++ b/src/daemon/modules/device/cdi/cdi_cache.c
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi cache function
+ ******************************************************************************/
+#include "cdi_cache.h"
+
+void free_cdi_cache(struct cdi_cache *c)
+{
+    (void)c;
+}
+
+struct cdi_cache *cdi_new_cache(string_array *spec_dirs, char **error)
+{
+    return NULL;
+}
+
+static string_array *cdi_inject_devices(struct cdi_cache *c, oci_runtime_spec *oci_spec, string_array *devices, char **error)
+{
+    return NULL;
+}
+
+static char *cdi_configure(struct cdi_cache *c, string_array *spec_dirs)
+{
+    return NULL;
+}
+
+static char *cdi_refresh(struct cdi_cache *c)
+{
+    return NULL;
+}
+
+static map_t *cdi_get_errors(struct cdi_cache *c)
+{
+    return NULL;
+}
+
+static string_array *cdi_get_spec_directories(struct cdi_cache *c)
+{
+    return NULL;
+}
+
+static map_t *cdi_get_spec_dir_errors(struct cdi_cache *c)
+{
+    return NULL;
+}
+
+static struct cdi_cache_ops g_cdi_cache_ops = {
+    .inject_devices = cdi_inject_devices,
+    .configure = cdi_configure,
+    .refresh = cdi_refresh,
+    .get_errors = cdi_get_errors,
+    .get_spec_directories = cdi_get_spec_directories,
+    .get_spec_dir_errors = cdi_get_spec_dir_errors
+};
+
+struct cdi_cache_ops *cdi_get_cache_ops(void)
+{
+    return &g_cdi_cache_ops;
+}
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/cdi_cache.h b/src/daemon/modules/device/cdi/cdi_cache.h
new file mode 100644
index 00000000..92fb64af
--- /dev/null
+++ b/src/daemon/modules/device/cdi/cdi_cache.h
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi cache function definition
+ ******************************************************************************/
+#ifndef CDI_CACHE_H
+#define CDI_CACHE_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <isula_libutils/oci_runtime_spec.h>
+
+#include "utils_array.h"
+#include "map.h"
+#include "cdi_device.h"
+#include "cdi_spec.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct cdi_cache;
+
+struct cdi_cache_ops {
+    // injecting CDI devices into an OCI Spec.
+    // Resolver
+    string_array *(*inject_devices)(struct cdi_cache *c, oci_runtime_spec *spec, string_array *devices, char **error);
+    
+    // refreshing the cache of CDI Specs and devices.
+    // Refresher
+    char *(*configure)(struct cdi_cache *c, string_array *spec_dirs);
+    char *(*refresh)(struct cdi_cache *c);
+    map_t *(*get_errors)(struct cdi_cache *c);
+    string_array *(*get_spec_directories)(struct cdi_cache *c);
+    map_t *(*get_spec_dir_errors)(struct cdi_cache *c);
+};
+
+struct cdi_watch {
+    int watcher_fd; // inotify fd
+    map_t *tracked; // MAP_STR_BOOL     tracked[spec_dirs[i]] = bool
+    map_t *wd_dirs; // MAP_INT_STR      wd_dirs[wd] = spec_dirs[i]
+};
+
+// Cache stores CDI Specs loaded from Spec directories.
+struct cdi_cache {
+    pthread_mutex_t mutex;
+    string_array *spec_dirs; // cdi-spec-dirs will scan for CDI Spec files
+    map_t *specs;        // MAP_STR_PTR     specs[vendor] = cdi_cache_spec**
+    map_t *devices;      // MAP_STR_PTR     devices[cdi_device.name] = cdi_cache_device*
+    map_t *errors;       // MAP_STR_PTR     errors[cdi_cache_spec.path] = string_array *errors
+    map_t *dir_errors;   // MAP_STR_STR     dir_errors[spec_dirs[i]] = error
+
+    bool auto_refresh; 
+    struct cdi_watch *watch;
+};
+
+void free_cdi_cache(struct cdi_cache *c);
+ 
+struct cdi_cache *cdi_new_cache(string_array *spec_dirs, char **error);
+struct cdi_cache_ops *cdi_get_cache_ops(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi/cdi_registry.c b/src/daemon/modules/device/cdi/cdi_registry.c
new file mode 100644
index 00000000..68767a5f
--- /dev/null
+++ b/src/daemon/modules/device/cdi/cdi_registry.c
@@ -0,0 +1,25 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi registry function
+ ******************************************************************************/
+#include "cdi_registry.h"
+
+int cdi_registry_init(string_array *spec_dirs)
+{
+    return 0;
+}
+
+struct cdi_registry *cdi_get_registry(void)
+{
+    return NULL;
+}
diff --git a/src/daemon/modules/device/cdi/cdi_registry.h b/src/daemon/modules/device/cdi/cdi_registry.h
new file mode 100644
index 00000000..c27d37e3
--- /dev/null
+++ b/src/daemon/modules/device/cdi/cdi_registry.h
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi registry function definition
+ ******************************************************************************/
+#ifndef CDI_REGISTRY_H
+#define CDI_REGISTRY_H
+
+#include "cdi_cache.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct cdi_registry {
+    struct cdi_cache *cdi_cache;
+    struct cdi_cache_ops *ops;
+};
+
+int cdi_registry_init(string_array *spec_dirs);
+struct cdi_registry *cdi_get_registry(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/daemon/modules/device/cdi_operate.c b/src/daemon/modules/device/cdi_operate.c
new file mode 100644
index 00000000..c7aa77d8
--- /dev/null
+++ b/src/daemon/modules/device/cdi_operate.c
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * 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 v2 for more details.
+ * Author: liuxu
+ * Create: 2024-03-06
+ * Description: provide cdi device manager function
+ ******************************************************************************/
+#include "cdi_operate_api.h"
+
+int cdi_operate_registry_init(char **specs_dirs, size_t specs_dirs_len)
+{
+    return 0;
+}
+
+char *cdi_operate_refresh(void)
+{
+    return NULL;
+}
+
+string_array *cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices, char **error)
+{
+    return NULL;
+}
+
+char *cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices)
+{
+    return NULL;
+}
\ No newline at end of file
-- 
2.34.1

