Skip to content

Commit

Permalink
chore: make info_vcpu_states be available on x86
Browse files Browse the repository at this point in the history
Since x86 now has vcpu states printable, make
info_vcpu_states available on x86 as well.

Signed-off-by: Sudan Landge <sudanl@amazon.com>
  • Loading branch information
Sudan Landge authored and sudanl0 committed Oct 30, 2023
1 parent 42d35dc commit 4b81147
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/snapshot-editor/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::path::PathBuf;
use clap::Subcommand;
use vmm::persist::MicrovmState;
use vmm::version_map::FC_VERSION_TO_SNAP_VERSION;
use vmm::vstate::vcpu::VcpuState;

use crate::utils::*;

Expand All @@ -26,7 +27,6 @@ pub enum InfoVmStateSubCommand {
vmstate_path: PathBuf,
},
/// Print info about vcpu states.
#[cfg(target_arch = "aarch64")]
VcpuStates {
/// Path to the vmstate file.
#[arg(short, long)]
Expand All @@ -43,7 +43,6 @@ pub enum InfoVmStateSubCommand {
pub fn info_vmstate_command(command: InfoVmStateSubCommand) -> Result<(), InfoVmStateError> {
match command {
InfoVmStateSubCommand::Version { vmstate_path } => info(&vmstate_path, info_version)?,
#[cfg(target_arch = "aarch64")]
InfoVmStateSubCommand::VcpuStates { vmstate_path } => {
info(&vmstate_path, info_vcpu_states)?
}
Expand Down Expand Up @@ -75,22 +74,31 @@ fn info_version(_: &MicrovmState, version: u16) -> Result<(), InfoVmStateError>
}

#[cfg(target_arch = "aarch64")]
fn info_vcpu_states_arch(state: &VcpuState) {
println!("kvm_mp_state: {:#x}", state.mp_state.mp_state);
println!("mpidr: {:#x}", state.mpidr);
for reg in state.regs.iter() {
println!(
"{:#x} 0x{}",
reg.id,
reg.as_slice()
.iter()
.rev()
.map(|b| format!("{b:x}"))
.collect::<String>()
);
}
}

Check warning on line 91 in src/snapshot-editor/src/info.rs

View check run for this annotation

Codecov / codecov/patch

src/snapshot-editor/src/info.rs#L77-L91

Added lines #L77 - L91 were not covered by tests

#[cfg(target_arch = "x86_64")]
fn info_vcpu_states_arch(state: &VcpuState) {
println!("{state:#?}");
}

Check warning on line 96 in src/snapshot-editor/src/info.rs

View check run for this annotation

Codecov / codecov/patch

src/snapshot-editor/src/info.rs#L94-L96

Added lines #L94 - L96 were not covered by tests

fn info_vcpu_states(state: &MicrovmState, _: u16) -> Result<(), InfoVmStateError> {
for (i, state) in state.vcpu_states.iter().enumerate() {
println!("vcpu {i}:");
println!("kvm_mp_state: {:#x}", state.mp_state.mp_state);
println!("mpidr: {:#x}", state.mpidr);
for reg in state.regs.iter() {
println!(
"{:#x} 0x{}",
reg.id,
reg.as_slice()
.iter()
.rev()
.map(|b| format!("{b:x}"))
.collect::<String>()
);
}
info_vcpu_states_arch(state);

Check warning on line 101 in src/snapshot-editor/src/info.rs

View check run for this annotation

Codecov / codecov/patch

src/snapshot-editor/src/info.rs#L101

Added line #L101 was not covered by tests
}
Ok(())
}
Expand Down

0 comments on commit 4b81147

Please sign in to comment.