hvlite_helpers/
underhill.rsuse anyhow::Context;
use get_resources::ged::GuestEmulationRequest;
use get_resources::ged::GuestServicingFlags;
use hvlite_defs::rpc::VmRpc;
use mesh::rpc::RpcSend;
pub async fn service_underhill(
vm_send: &mesh::Sender<VmRpc>,
send: &mesh::Sender<GuestEmulationRequest>,
flags: GuestServicingFlags,
file: std::fs::File,
) -> anyhow::Result<()> {
tracing::debug!("staging new IGVM file");
vm_send
.call_failable(VmRpc::StartReloadIgvm, file)
.await
.context("failed to stage new IGVM file")?;
tracing::debug!("waiting for guest to send saved state");
let r = send
.call_failable(GuestEmulationRequest::SaveGuestVtl2State, flags)
.await
.context("failed to save VTL2 state");
if r.is_err() {
tracing::debug!(?r, "save state failed, clearing staged IGVM file");
let _ = vm_send.call(VmRpc::CompleteReloadIgvm, false).await;
return r;
}
tracing::debug!("reloading IGVM file");
vm_send
.call_failable(VmRpc::CompleteReloadIgvm, true)
.await
.context("failed to reload VTL2 firmware")?;
tracing::debug!("waiting for VTL0 to start");
send.call_failable(GuestEmulationRequest::WaitForVtl0Start, ())
.await
.context("vtl0 start failed")?;
Ok(())
}