mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-21 01:13:56 +00:00
Merge pull request #11474 from Apokleos/remote-annotation
runtime-rs: Add GPU annotations for remote hypervisor
This commit is contained in:
commit
e66baf503b
@ -276,6 +276,14 @@ pub const KATA_ANNO_CFG_HYPERVISOR_MSIZE_9P: &str = "io.katacontainers.config.hy
|
||||
pub const KATA_ANNO_CFG_HYPERVISOR_INIT_DATA: &str =
|
||||
"io.katacontainers.config.hypervisor.cc_init_data";
|
||||
|
||||
/// GPU specific annotations for remote hypervisor to help with instance selection
|
||||
/// It's for minimum number of GPUs required for the VM.
|
||||
pub const KATA_ANNO_CFG_HYPERVISOR_DEFAULT_GPUS: &str =
|
||||
"io.katacontainers.config.hypervisor.default_gpus";
|
||||
/// It's for the GPU model(tesla, h100, a100, radeon etc.) required for the VM.
|
||||
pub const KATA_ANNO_CFG_HYPERVISOR_DEFAULT_GPU_MODEL: &str =
|
||||
"io.katacontainers.config.hypervisor.default_gpu_model";
|
||||
|
||||
// Runtime related annotations
|
||||
/// Prefix for Runtime configurations.
|
||||
pub const KATA_ANNO_CFG_RUNTIME_PREFIX: &str = "io.katacontainers.config.runtime.";
|
||||
@ -888,6 +896,17 @@ impl Annotation {
|
||||
hv.security_info.initdata =
|
||||
add_hypervisor_initdata_overrides(value).unwrap();
|
||||
}
|
||||
KATA_ANNO_CFG_HYPERVISOR_DEFAULT_GPUS => match self.get_value::<u32>(key) {
|
||||
Ok(r) => {
|
||||
hv.remote_info.default_gpus = r.unwrap_or_default();
|
||||
}
|
||||
Err(_e) => {
|
||||
return Err(u32_err);
|
||||
}
|
||||
},
|
||||
KATA_ANNO_CFG_HYPERVISOR_DEFAULT_GPU_MODEL => {
|
||||
hv.remote_info.default_gpu_model = value.to_string();
|
||||
}
|
||||
KATA_ANNO_CFG_HYPERVISOR_ENABLE_ROOTLESS_HYPERVISOR => {
|
||||
match self.get_value::<bool>(key) {
|
||||
Ok(r) => {
|
||||
|
@ -1110,6 +1110,14 @@ pub struct RemoteInfo {
|
||||
/// Remote hyperisor timeout of creating (in seconds)
|
||||
#[serde(default)]
|
||||
pub hypervisor_timeout: i32,
|
||||
|
||||
/// GPU specific annotations (currently only applicable for Remote Hypervisor)
|
||||
/// default_gpus specifies the number of GPUs required for the Kata VM
|
||||
#[serde(default)]
|
||||
pub default_gpus: u32,
|
||||
/// default_gpu_model specifies GPU model like tesla, h100, a100, readeon etc.
|
||||
#[serde(default)]
|
||||
pub default_gpu_model: String,
|
||||
}
|
||||
|
||||
/// Common configuration information for hypervisors.
|
||||
|
@ -41,7 +41,7 @@ remote_hypervisor_timeout = 600
|
||||
# Each member of the list is a regular expression, which is the base name
|
||||
# of the annotation, e.g. "path" for io.katacontainers.config.hypervisor.path"
|
||||
# Note: Remote hypervisor is only handling the following annotations
|
||||
enable_annotations = ["machine_type", "default_memory", "default_vcpus"]
|
||||
enable_annotations = ["machine_type", "default_memory", "default_vcpus", "default_gpus", "default_gpu_model"]
|
||||
|
||||
# Optional space-separated list of options to pass to the guest kernel.
|
||||
# For example, use `kernel_params = "vsyscall=emulate"` if you are having
|
||||
|
@ -12,6 +12,7 @@ use async_trait::async_trait;
|
||||
use kata_types::{
|
||||
annotations::{
|
||||
cri_containerd::{SANDBOX_NAMESPACE_LABEL_KEY, SANDBOX_NAME_LABEL_KEY},
|
||||
KATA_ANNO_CFG_HYPERVISOR_DEFAULT_GPUS, KATA_ANNO_CFG_HYPERVISOR_DEFAULT_GPU_MODEL,
|
||||
KATA_ANNO_CFG_HYPERVISOR_DEFAULT_MEMORY, KATA_ANNO_CFG_HYPERVISOR_DEFAULT_VCPUS,
|
||||
KATA_ANNO_CFG_HYPERVISOR_IMAGE_PATH, KATA_ANNO_CFG_HYPERVISOR_MACHINE_TYPE,
|
||||
},
|
||||
@ -124,6 +125,14 @@ impl RemoteInner {
|
||||
KATA_ANNO_CFG_HYPERVISOR_IMAGE_PATH.to_string(),
|
||||
config.boot_info.image.to_string(),
|
||||
);
|
||||
annotations.insert(
|
||||
KATA_ANNO_CFG_HYPERVISOR_DEFAULT_GPUS.to_string(),
|
||||
config.remote_info.default_gpus.to_string(),
|
||||
);
|
||||
annotations.insert(
|
||||
KATA_ANNO_CFG_HYPERVISOR_DEFAULT_GPU_MODEL.to_string(),
|
||||
config.remote_info.default_gpu_model.to_string(),
|
||||
);
|
||||
annotations
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user