From 4d8a89e0a3700253db044f6641d91ab10ad6ce10 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Sat, 20 Apr 2024 19:36:55 +0800
Subject: [PATCH 73/73] bugfix: cdi version check

Signed-off-by: liuxu <liuxu156@huawei.com>
---
 src/daemon/modules/device/cdi/behavior/cdi_spec.c    | 2 +-
 src/daemon/modules/device/cdi/behavior/cdi_version.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec.c b/src/daemon/modules/device/cdi/behavior/cdi_spec.c
index 235b1863..8783debc 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_spec.c
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec.c
@@ -199,7 +199,7 @@ static int cdi_spec_init(struct cdi_cache_spec *s)
         return -1;
     }
     if (version_result) {
-        ERROR("The spec version must be at least v%s", min_version);
+        ERROR("The %s spec version must be at least v%s", s->path, min_version);
         return -1;
     }
 
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_version.c b/src/daemon/modules/device/cdi/behavior/cdi_version.c
index 882a965e..550f3107 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_version.c
+++ b/src/daemon/modules/device/cdi/behavior/cdi_version.c
@@ -138,9 +138,9 @@ static struct required_version_map g_valid_spec_versions[VALID_SPEC_VERSIONS_LEN
     {CDI_V010, NULL},
     {CDI_V020, NULL},
     {CDI_V030, NULL},
-    {CDI_V040, requires_v060},
+    {CDI_V040, requires_v040},
     {CDI_V050, requires_v050},
-    {CDI_V060, requires_v040}
+    {CDI_V060, requires_v060}
 };
 
 const char *cdi_minimum_required_version(cdi_spec *spec)
@@ -166,7 +166,7 @@ const char *cdi_minimum_required_version(cdi_spec *spec)
                 min_version = g_valid_spec_versions[i].version;
             }
         }
-        if (strcmp(min_version, CDI_CURRENT_VERSION)) {
+        if (strcmp(min_version, CDI_CURRENT_VERSION) == 0) {
             break;
         }
     }
-- 
2.34.1

