364 lines
15 KiB
Diff
364 lines
15 KiB
Diff
From e7b94411b174c8445d9bdc84ec6c94b5d4343470 Mon Sep 17 00:00:00 2001
|
|
From: liuxu <liuxu156@huawei.com>
|
|
Date: Mon, 15 Apr 2024 15:38:57 +0800
|
|
Subject: [PATCH 60/69] cdi:return int instead of error string
|
|
|
|
---
|
|
src/daemon/modules/api/cdi_operate_api.h | 7 ++++---
|
|
.../device/cdi/behavior/cdi_container_edits.c | 12 ++++++------
|
|
.../device/cdi/behavior/cdi_container_edits.h | 6 +++---
|
|
.../modules/device/cdi/behavior/cdi_device.c | 2 +-
|
|
.../modules/device/cdi/behavior/cdi_device.h | 2 +-
|
|
.../modules/device/cdi/behavior/cdi_spec.c | 2 +-
|
|
.../modules/device/cdi/behavior/cdi_spec.h | 2 +-
|
|
.../modules/device/cdi/behavior/cdi_spec_dirs.c | 4 ++--
|
|
.../modules/device/cdi/behavior/cdi_spec_dirs.h | 6 +++---
|
|
.../device/cdi/behavior/parser/cdi_parser.c | 16 ++++++++--------
|
|
.../device/cdi/behavior/parser/cdi_parser.h | 8 ++++----
|
|
src/daemon/modules/device/cdi/cdi_annotations.c | 5 +++--
|
|
src/daemon/modules/device/cdi/cdi_annotations.h | 3 ++-
|
|
src/daemon/modules/device/cdi/cdi_cache.c | 14 +++++++-------
|
|
src/daemon/modules/device/cdi/cdi_cache.h | 8 ++++----
|
|
src/daemon/modules/device/cdi_operate.c | 13 +++++++------
|
|
16 files changed, 57 insertions(+), 53 deletions(-)
|
|
|
|
diff --git a/src/daemon/modules/api/cdi_operate_api.h b/src/daemon/modules/api/cdi_operate_api.h
|
|
index 4f4c339e..49820ed7 100644
|
|
--- a/src/daemon/modules/api/cdi_operate_api.h
|
|
+++ b/src/daemon/modules/api/cdi_operate_api.h
|
|
@@ -26,11 +26,12 @@ extern "C" {
|
|
|
|
int cdi_operate_registry_init(char **specs_dirs, size_t specs_dirs_len);
|
|
|
|
-char *cdi_operate_refresh(void);
|
|
+int cdi_operate_refresh(void);
|
|
|
|
-string_array *cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices, char **error);
|
|
+int cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices);
|
|
|
|
-char *cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices);
|
|
+int cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys,
|
|
+ string_array **devices, char **error);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c
|
|
index ce7b16db..590118b1 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c
|
|
+++ b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c
|
|
@@ -27,19 +27,19 @@
|
|
// 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)
|
|
+int cdi_container_edits_apply(cdi_container_edits *e, oci_runtime_spec *spec)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
-char *cdi_container_edits_validate(cdi_container_edits *e)
|
|
+int cdi_container_edits_validate(cdi_container_edits *e, char **error)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
-cdi_container_edits *cdi_container_edits_append(cdi_container_edits *e, cdi_container_edits *o)
|
|
+int cdi_container_edits_append(cdi_container_edits *e, cdi_container_edits *o)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
bool cdi_container_edits_is_empty(cdi_container_edits *e)
|
|
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h
|
|
index 7b16d2bc..ea921e37 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h
|
|
+++ b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h
|
|
@@ -27,9 +27,9 @@
|
|
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);
|
|
+int cdi_container_edits_apply(cdi_container_edits *e, oci_runtime_spec *spec);
|
|
+int cdi_container_edits_validate(cdi_container_edits *e, char **error);
|
|
+int cdi_container_edits_append(cdi_container_edits *e, cdi_container_edits *o);
|
|
bool cdi_container_edits_is_empty(cdi_container_edits *e);
|
|
|
|
#ifdef __cplusplus
|
|
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_device.c b/src/daemon/modules/device/cdi/behavior/cdi_device.c
|
|
index 9904e9ee..0fef8f42 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/cdi_device.c
|
|
+++ b/src/daemon/modules/device/cdi/behavior/cdi_device.c
|
|
@@ -34,7 +34,7 @@ char *cdi_device_get_qualified_name(struct cdi_cache_device *d)
|
|
return NULL;
|
|
}
|
|
|
|
-cdi_container_edits *cdi_device_edits(struct cdi_cache_device *d)
|
|
+cdi_container_edits *cdi_device_get_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
|
|
index 3f460152..5d63a576 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/cdi_device.h
|
|
+++ b/src/daemon/modules/device/cdi/behavior/cdi_device.h
|
|
@@ -37,7 +37,7 @@ 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);
|
|
+cdi_container_edits *cdi_device_get_edits(struct cdi_cache_device *d);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec.c b/src/daemon/modules/device/cdi/behavior/cdi_spec.c
|
|
index 38fc9e38..f79b5a44 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/cdi_spec.c
|
|
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec.c
|
|
@@ -54,7 +54,7 @@ int cdi_spec_get_priority(struct cdi_cache_spec *s)
|
|
return 0;
|
|
}
|
|
|
|
-cdi_container_edits *cdi_spec_edits(struct cdi_cache_spec *s)
|
|
+cdi_container_edits *cdi_spec_get_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
|
|
index bd4fc9d1..87248041 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/cdi_spec.h
|
|
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec.h
|
|
@@ -47,7 +47,7 @@ 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);
|
|
+cdi_container_edits *cdi_spec_get_edits(struct cdi_cache_spec *s);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c
|
|
index 5df4c937..e340abc0 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c
|
|
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c
|
|
@@ -23,7 +23,7 @@ string_array g_default_spec_dirs = {
|
|
.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)
|
|
+int cdi_scan_spec_dirs(string_array *dirs, struct cdi_scan_fn_maps *scan_fn_maps, cdi_scan_spec_func scan_fn)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h
|
|
index bd00e318..73d8c0f5 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h
|
|
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h
|
|
@@ -35,10 +35,10 @@ struct cdi_scan_fn_maps {
|
|
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);
|
|
+typedef void(*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);
|
|
+int cdi_scan_spec_dirs(string_array *dirs, struct cdi_scan_fn_maps *scan_fn_maps, cdi_scan_spec_func scan_fn);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
diff --git a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c
|
|
index 45048f9a..14293c72 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c
|
|
+++ b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c
|
|
@@ -24,9 +24,9 @@ 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)
|
|
+int cdi_parser_parse_qualified_name(const char *device, char **vendor, char **class, char **name)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
int cdi_parser_parse_device(const char *device, char **vendor, char **class, char **name)
|
|
@@ -39,17 +39,17 @@ int cdi_parser_parse_qualifier(const char *kind, char **vendor, char **class)
|
|
return 0;
|
|
}
|
|
|
|
-char *cdi_parser_validate_vendor_name(const char *vendor)
|
|
+int cdi_parser_validate_vendor_name(const char *vendor, char **error)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
-char *cdi_parser_validate_class_name(const char *class)
|
|
+int cdi_parser_validate_class_name(const char *class, char **error)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
-char *cdi_parser_validate_device_name(const char *name)
|
|
+int cdi_parser_validate_device_name(const char *name, char **error)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
diff --git a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h
|
|
index d9c057ea..467641a1 100644
|
|
--- a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h
|
|
+++ b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h
|
|
@@ -24,12 +24,12 @@ extern "C" {
|
|
|
|
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_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);
|
|
+int cdi_parser_validate_vendor_name(const char *vendor, char **error);
|
|
+int cdi_parser_validate_class_name(const char *class, char **error);
|
|
+int cdi_parser_validate_device_name(const char *name, char **error);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
diff --git a/src/daemon/modules/device/cdi/cdi_annotations.c b/src/daemon/modules/device/cdi/cdi_annotations.c
|
|
index 3cb9be84..cfe6e099 100644
|
|
--- a/src/daemon/modules/device/cdi/cdi_annotations.c
|
|
+++ b/src/daemon/modules/device/cdi/cdi_annotations.c
|
|
@@ -25,7 +25,8 @@
|
|
|
|
#define CDI_ANNOTATIONS_PREFIX "cdi.k8s.io/"
|
|
|
|
-char *cdi_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices)
|
|
+int cdi_parse_annotations(json_map_string_string *annotations, string_array **keys,
|
|
+ string_array **devices, char **error)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
diff --git a/src/daemon/modules/device/cdi/cdi_annotations.h b/src/daemon/modules/device/cdi/cdi_annotations.h
|
|
index 52355099..49930963 100644
|
|
--- a/src/daemon/modules/device/cdi/cdi_annotations.h
|
|
+++ b/src/daemon/modules/device/cdi/cdi_annotations.h
|
|
@@ -23,7 +23,8 @@
|
|
extern "C" {
|
|
#endif
|
|
|
|
-char *cdi_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices);
|
|
+int cdi_parse_annotations(json_map_string_string *annotations, string_array **keys,
|
|
+ string_array **devices, char **error);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
diff --git a/src/daemon/modules/device/cdi/cdi_cache.c b/src/daemon/modules/device/cdi/cdi_cache.c
|
|
index 9c54acbf..cfc23a1c 100644
|
|
--- a/src/daemon/modules/device/cdi/cdi_cache.c
|
|
+++ b/src/daemon/modules/device/cdi/cdi_cache.c
|
|
@@ -19,24 +19,24 @@ void free_cdi_cache(struct cdi_cache *c)
|
|
(void)c;
|
|
}
|
|
|
|
-struct cdi_cache *cdi_new_cache(string_array *spec_dirs, char **error)
|
|
+struct cdi_cache *cdi_new_cache(string_array *spec_dirs)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
-static string_array *cdi_inject_devices(struct cdi_cache *c, oci_runtime_spec *oci_spec, string_array *devices, char **error)
|
|
+static int cdi_inject_devices(struct cdi_cache *c, oci_runtime_spec *oci_spec, string_array *devices)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
-static char *cdi_configure(struct cdi_cache *c, string_array *spec_dirs)
|
|
+static int cdi_configure(struct cdi_cache *c, string_array *spec_dirs)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
-static char *cdi_refresh(struct cdi_cache *c)
|
|
+static int cdi_refresh(struct cdi_cache *c)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
static map_t *cdi_get_errors(struct cdi_cache *c)
|
|
diff --git a/src/daemon/modules/device/cdi/cdi_cache.h b/src/daemon/modules/device/cdi/cdi_cache.h
|
|
index 92fb64af..34c27471 100644
|
|
--- a/src/daemon/modules/device/cdi/cdi_cache.h
|
|
+++ b/src/daemon/modules/device/cdi/cdi_cache.h
|
|
@@ -33,12 +33,12 @@ 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);
|
|
+ int (*inject_devices)(struct cdi_cache *c, oci_runtime_spec *spec, string_array *devices);
|
|
|
|
// 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);
|
|
+ int (*configure)(struct cdi_cache *c, string_array *spec_dirs);
|
|
+ int (*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);
|
|
@@ -65,7 +65,7 @@ struct cdi_cache {
|
|
|
|
void free_cdi_cache(struct cdi_cache *c);
|
|
|
|
-struct cdi_cache *cdi_new_cache(string_array *spec_dirs, char **error);
|
|
+struct cdi_cache *cdi_new_cache(string_array *spec_dirs);
|
|
struct cdi_cache_ops *cdi_get_cache_ops(void);
|
|
|
|
#ifdef __cplusplus
|
|
diff --git a/src/daemon/modules/device/cdi_operate.c b/src/daemon/modules/device/cdi_operate.c
|
|
index c7aa77d8..c5187ab1 100644
|
|
--- a/src/daemon/modules/device/cdi_operate.c
|
|
+++ b/src/daemon/modules/device/cdi_operate.c
|
|
@@ -19,17 +19,18 @@ int cdi_operate_registry_init(char **specs_dirs, size_t specs_dirs_len)
|
|
return 0;
|
|
}
|
|
|
|
-char *cdi_operate_refresh(void)
|
|
+int cdi_operate_refresh(void)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
-string_array *cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices, char **error)
|
|
+int cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
|
|
-char *cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices)
|
|
+int cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys,
|
|
+ string_array **devices, char **error)
|
|
{
|
|
- return NULL;
|
|
+ return 0;
|
|
}
|
|
\ No newline at end of file
|
|
--
|
|
2.34.1
|
|
|