Skip to content

chore(deps): Bump versionize from 0.1.9 to 0.1.10 in /tests/host_tools/uffd #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ derive_more = { version = "0.99.17", default-features = false, features = ["from
libc = "0.2.117"
serde = { version = "1.0.136", features = ["derive"] }
thiserror = "1.0.32"
versionize = "0.1.6"
versionize = "0.1.10"
versionize_derive = "0.1.3"
vmm-sys-util = "0.11.0"

Expand Down
5 changes: 3 additions & 2 deletions src/vmm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ use crate::device_manager::mmio::MMIODeviceManager;
use crate::memory_snapshot::SnapshotMemory;
use crate::persist::{MicrovmState, MicrovmStateError, VmInfo};
use crate::vmm_config::instance_info::{InstanceInfo, VmState};
use crate::vstate::vcpu::{Vcpu, VcpuEvent, VcpuHandle, VcpuResponse, VcpuState};
use crate::vstate::vm::Vm;
use crate::vstate::vcpu::VcpuState;
pub use crate::vstate::vcpu::{Vcpu, VcpuEvent, VcpuHandle, VcpuResponse, VcpuConfig};
pub use crate::vstate::vm::Vm;

/// Shorthand type for the EventManager flavour used by Firecracker.
pub type EventManager = BaseEventManager<Arc<Mutex<dyn MutEventSubscriber>>>;
Expand Down
54 changes: 32 additions & 22 deletions src/vmm/src/vstate/vcpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ impl fmt::Display for StartThreadedError {

/// A wrapper around creating and using a vcpu.
pub struct Vcpu {
// Offers kvm-arch specific functionality.
/// Access to kvm-arch specific functionality.
pub kvm_vcpu: KvmVcpu,

// File descriptor for vcpu to trigger exit event on vmm.
/// File descriptor for vcpu to trigger exit event on vmm.
exit_evt: EventFd,
// The receiving end of events channel owned by the vcpu side.
/// The receiving end of events channel owned by the vcpu side.
event_receiver: Receiver<VcpuEvent>,
// The transmitting end of the events channel which will be given to the handler.
/// The transmitting end of the events channel which will be given to the handler.
event_sender: Option<Sender<VcpuEvent>>,
// The receiving end of the responses channel which will be given to the handler.
/// The receiving end of the responses channel which will be given to the handler.
response_receiver: Option<Receiver<VcpuResponse>>,
// The transmitting end of the responses channel owned by the vcpu side.
/// The transmitting end of the responses channel owned by the vcpu side.
response_sender: Sender<VcpuResponse>,

// Exit reason used to test run_emulation function.
/// Exit reason used to test run_emulation function.
#[cfg(test)]
test_vcpu_exit_reason: Mutex<Option<std::result::Result<VcpuExit<'static>, errno::Error>>>,
}
Expand Down Expand Up @@ -434,6 +434,9 @@ impl Vcpu {
}

#[cfg(not(test))]
/// Calls `KVM_RUN` with this [`Vcpu`]'s underlying file descriptor.
///
/// Blocks until a `VM_EXIT` is received, in which case this function returns a [`VcpuExit`] containing the reason.
pub fn emulate(&self) -> std::result::Result<VcpuExit, errno::Error> {
self.kvm_vcpu.fd.run()
}
Expand Down Expand Up @@ -584,6 +587,21 @@ pub enum VcpuResponse {
SavedState(Box<VcpuState>),
}

impl fmt::Debug for VcpuResponse {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use crate::VcpuResponse::*;
match self {
Paused => write!(f, "VcpuResponse::Paused"),
Resumed => write!(f, "VcpuResponse::Resumed"),
Exited(code) => write!(f, "VcpuResponse::Exited({:?})", code),
RestoredState => write!(f, "VcpuResponse::RestoredState"),
SavedState(_) => write!(f, "VcpuResponse::SavedState"),
Error(ref err) => write!(f, "VcpuResponse::Error({:?})", err),
NotAllowed(ref reason) => write!(f, "VcpuResponse::NotAllowed({})", reason),
}
}
}

/// Wrapper over Vcpu that hides the underlying interactions with the Vcpu thread.
pub struct VcpuHandle {
event_sender: Sender<VcpuEvent>,
Expand All @@ -604,6 +622,12 @@ impl fmt::Display for VcpuSendEventError {
}

impl VcpuHandle {
/// Creates a new [`VcpuHandle`].
///
/// # Arguments
/// + `event_sender`: [`Sender`] to communicate [`VcpuEvent`] to control the vcpu.
/// + `response_received`: [`Received`] from which the vcpu's responses can be read.
/// + `vcpu_thread`: A [`JoinHandle`] for the vcpu thread.
pub fn new(
event_sender: Sender<VcpuEvent>,
response_receiver: Receiver<VcpuResponse>,
Expand Down Expand Up @@ -634,6 +658,7 @@ impl VcpuHandle {
Ok(())
}

/// Returns a reference to the [`Received`] from which the vcpu's responses can be read.
pub fn response_receiver(&self) -> &Receiver<VcpuResponse> {
&self.response_receiver
}
Expand Down Expand Up @@ -838,21 +863,6 @@ mod tests {
}
}

impl fmt::Debug for VcpuResponse {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use crate::VcpuResponse::*;
match self {
Paused => write!(f, "VcpuResponse::Paused"),
Resumed => write!(f, "VcpuResponse::Resumed"),
Exited(code) => write!(f, "VcpuResponse::Exited({:?})", code),
RestoredState => write!(f, "VcpuResponse::RestoredState"),
SavedState(_) => write!(f, "VcpuResponse::SavedState"),
Error(ref err) => write!(f, "VcpuResponse::Error({:?})", err),
NotAllowed(ref reason) => write!(f, "VcpuResponse::NotAllowed({})", reason),
}
}
}

// Auxiliary function being used throughout the tests.
#[allow(unused_mut)]
pub(crate) fn setup_vcpu(mem_size: usize) -> (Vm, Vcpu, GuestMemoryMmap) {
Expand Down
4 changes: 2 additions & 2 deletions tests/host_tools/uffd/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.