Skip to content

Commit

Permalink
teepod: Better status display
Browse files Browse the repository at this point in the history
  • Loading branch information
kvinwang committed Dec 18, 2024
1 parent be3c137 commit 6e25422
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions teepod/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ impl App {
}

pub async fn start_vm(&self, id: &str) -> Result<()> {
let is_running = self
.supervisor
.info(id)
.await?
.map_or(false, |info| info.state.status.is_running());
let process_config = {
let mut state = self.lock();
let vm_state = state.get_mut(id).context("VM not found")?;
Expand All @@ -153,7 +158,7 @@ impl App {
.config_qemu(&self.config.qemu_path, &work_dir)?;
// Older images does not support for progress reporting
if vm_state.config.image.info.shared_ro {
vm_state.state.clear();
vm_state.state.start(is_running);
} else {
vm_state.state.reset_na();
}
Expand Down Expand Up @@ -327,8 +332,12 @@ struct VmStateMut {
}

impl VmStateMut {
pub fn clear(&mut self) {
self.boot_progress.clear();
pub fn start(&mut self, already_running: bool) {
self.boot_progress = if already_running {
"running".to_string()
} else {
"booting".to_string()
};
self.boot_error.clear();
self.shutdown_progress.clear();
}
Expand Down
6 changes: 6 additions & 0 deletions teepod/src/console.html
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,12 @@ <h3>Derive VM</h3>
if (vm.shutdown_progress) {
return "shutting down";
}
// If boot_progress is 'running', it means the vm is already running before
// teepod was started, so it's state is unknown to teepod.
// TODO: read the status from the guest
if (vm.boot_progress == 'running') {
return "running";
}
if (vm.boot_progress != 'done') {
return "booting";
}
Expand Down

0 comments on commit 6e25422

Please sign in to comment.