Skip to content

Commit 6131da7

Browse files
vmm: removed unnecessary pubs
The public interface of the VMM should contain just the following structures, enums and types along with their implementation: * VmmAction & VmmActionError * the oneshot channels: OutcomeSender & OutcomeReceiver * the data sent on the channels: VmmRequestOutcome and the function start_vmm_thread, which is called from the main crate. Removed all the other pubs. Moved test code to mod tests and added the test directive where it was missing. Signed-off-by: Andreea Florescu <[email protected]>
1 parent 3a048d9 commit 6131da7

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

vmm/src/default_syscalls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ pub fn default_context() -> Result<SeccompFilterContext, Error> {
607607
)?)
608608
}
609609

610+
#[cfg(test)]
610611
mod tests {
611612
extern crate libc;
612613
extern crate seccomp;

vmm/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static START_INSTANCE_REQUEST_TS: AtomicUsize = ATOMIC_USIZE_INIT;
7676
/// input, but can result from bad configuration of the host (for example if Firecracker doesn't
7777
/// have permissions to open the KVM fd).
7878
#[derive(Debug)]
79-
pub enum Error {
79+
enum Error {
8080
/// Cannot receive message from the API.
8181
ApiChannel,
8282
/// Legacy devices work with Event file descriptors and the creation can fail because
@@ -306,7 +306,7 @@ impl EpollContext {
306306
})
307307
}
308308

309-
pub fn enable_stdin_event(&mut self) -> Result<()> {
309+
fn enable_stdin_event(&mut self) -> Result<()> {
310310
if let Err(e) = epoll::ctl(
311311
self.epoll_raw_fd,
312312
epoll::EPOLL_CTL_ADD,
@@ -433,13 +433,13 @@ impl Drop for EpollContext {
433433
}
434434
}
435435

436-
pub struct KernelConfig {
436+
struct KernelConfig {
437437
cmdline: kernel_cmdline::Cmdline,
438438
kernel_file: File,
439439
cmdline_addr: GuestAddress,
440440
}
441441

442-
pub struct Vmm {
442+
struct Vmm {
443443
_kvm: KvmContext,
444444

445445
vm_config: VmConfig,
@@ -1512,8 +1512,9 @@ impl Vmm {
15121512
}
15131513
}
15141514

1515-
// Implementation for the "==" operator.
15161515
// Can't derive PartialEq directly because the sender members can't be compared.
1516+
// This implementation is only used in tests, but cannot be moved to mod tests,
1517+
// because it is used in tests outside of the vmm crate (api_server).
15171518
impl PartialEq for VmmAction {
15181519
fn eq(&self, other: &VmmAction) -> bool {
15191520
match (self, other) {

vmm/src/vstate.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ impl Vcpu {
141141
})
142142
}
143143

144-
/// Returns a clone of the CPUID entries of this vCPU
145-
/// For now this function is only used for testing; the cfg(test) should be removed when
146-
/// this function will be used for configuring the cpu features
147-
#[cfg(test)]
148-
pub fn get_cpuid(&self) -> CpuId {
149-
return self.cpuid.clone();
150-
}
151-
152144
/// /// Configures the vcpu and should be called once per vcpu from the vcpu's thread.
153145
///
154146
/// # Arguments
@@ -206,6 +198,16 @@ impl Vcpu {
206198

207199
#[cfg(test)]
208200
mod tests {
201+
202+
impl Vcpu {
203+
/// Returns a clone of the CPUID entries of this vCPU
204+
/// For now this function is only used for testing; the cfg(test) should be removed when
205+
/// this function will be used for configuring the cpu features
206+
pub fn get_cpuid(&self) -> CpuId {
207+
return self.cpuid.clone();
208+
}
209+
}
210+
209211
use super::*;
210212
use data_model::vm::CpuFeaturesTemplate;
211213

0 commit comments

Comments
 (0)