|
33 | 33 | from kubernetes import client, config, watch |
34 | 34 | from kubernetes.client.rest import ApiException |
35 | 35 |
|
36 | | -from cpuinfo import get_cpu_info |
37 | | - |
38 | 36 | # Import gpu-admin-tools |
39 | 37 | try: |
40 | 38 | from nvidia_gpu_tools import Gpu |
@@ -86,19 +84,23 @@ def is_host_cc_enabled() -> bool: |
86 | 84 | Returns: |
87 | 85 | boolean status |
88 | 86 | """ |
89 | | - try: |
90 | | - info = get_cpu_info() |
91 | | - except Exception as e: |
92 | | - logger.error(f"Failed to get CPU info for CC detection: {e}") |
93 | | - return False |
94 | | - |
95 | | - flags = info.get('flags', []) |
96 | | - |
97 | | - # Check for specific CoCo indicators |
98 | | - is_sev = 'sev' in flags |
99 | | - is_tdx = 'tdx' in flags |
100 | | - |
101 | | - return is_sev or is_tdx |
| 87 | + # 1. Check Intel TDX Host Status |
| 88 | + # Verify kvm_intel is loaded with tdx=1 and module is initialized |
| 89 | + tdx_param = "/sys/module/kvm_intel/parameters/tdx" |
| 90 | + if os.path.exists(tdx_param): |
| 91 | + with open(tdx_param, "r") as f: |
| 92 | + if f.read().strip().lower() in ['y', '1']: |
| 93 | + return True |
| 94 | + |
| 95 | + # 2. Check AMD SEV-SNP Host Status |
| 96 | + # Verify kvm_amd is loaded with sev_snp enabled |
| 97 | + snp_param = "/sys/module/kvm_amd/parameters/sev_snp" |
| 98 | + if os.path.exists(snp_param): |
| 99 | + with open(snp_param, "r") as f: |
| 100 | + if f.read().strip().lower() in ['y', '1']: |
| 101 | + return True |
| 102 | + |
| 103 | + return False |
102 | 104 |
|
103 | 105 | class CCManager: |
104 | 106 | """Manages NVIDIA GPU Confidential Computing mode based on Kubernetes node labels.""" |
|
0 commit comments