Guest required capabilities may cause failures at runtime after restore

Abierto
#1,863 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust

Línea de trabajo

Start at the OutBAction restore handling for TraceBatch and memory-profile actions, then inspect the existing ELF metadata and snapshot restore flow. Determine whether the immediate fix should safely ignore unavailable guest actions or whether capability metadata and host validation are required. Done means restoring a guest does not fail with invalid port values when host features are disabled.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

S-needs-triage

There are a couple of guest-features that produce specific port values, e.g.:

#[cfg(feature = "trace_guest")]
TraceBatch = 104,

#[cfg(feature = "mem_profile")]
TraceMemoryAlloc = 105,

Right now if these are enabled and then restored in a host where those features are not enabled it will result in an error something like Invalid OutBAction value: 104

A simple fix for this would be something like:

OutBAction::TraceBatch => {
    #[cfg(feature = "trace_guest")]
    handle_trace_batch(...);

    Ok(())
}

OutBAction::TraceMemoryAlloc | OutBAction::TraceMemoryFree => {
    #[cfg(feature = "mem_profile")]
    handle_memory_profile_action(...)?;

    Ok(())
}

This would not work for any potential future feature where the guest depended on the host to do work, in such a case we would need to detect features in the guest and host and ensure that there was alignment when restoring, since rust does not enable runtime reflection of what features are enabled we would have to do something along these lines:

  1. Define a host function that lists capabilities
fn host_capabilities() -> CapabilitySet {
    let mut capabilities = CapabilitySet::core();

    if cfg!(feature = "trace_guest") {
        capabilities.insert(TRACE_BATCH_V1);
    }
    if cfg!(feature = "mem_profile") {
        capabilities.insert(MEM_PROFILE_V1);
    }

    capabilities
}
  1. Extend the existing elf metadata to add .note.hyperlight-capabilities and add features with ABI versions, e.g.:
hyperlight.outb.trace-batch.v1
hyperlight.outb.memory-profile.v1
  1. Then
  • At snapshot time query the guest binary elf headers and record the values as OCI snapshot configuration.
  • At restore validate that no required features are missing

If we implement this we might want to also validate when we initially load a guest binary. We might want to make this mechanism extensible by consumers of hyperlight.

Lenguaje dominante
Rust
Estrellas
4.8k
Forks
222
Merge medio
1 d 16 h
PR fusionados (30 d)
60

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de hyperlight-dev/hyperlight

Todos los issues de hyperlight-dev/hyperlight

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.