Skip to content

Commit d1cf7b0

Browse files
committed
refactor: 移除未使用的常量和字段,优化代码结构
1 parent f3c369d commit d1cf7b0

File tree

5 files changed

+16
-33
lines changed

5 files changed

+16
-33
lines changed

src/arch/aarch64/vm/inited.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ use crate::{
77
vm::VmId,
88
};
99

10-
const VM_ASPACE_BASE: GuestPhysAddr = GuestPhysAddr::from_usize(0);
11-
const VM_ASPACE_SIZE: usize = 0x7fff_ffff_f000;
12-
const VM_ASPACE_END: GuestPhysAddr =
13-
GuestPhysAddr::from_usize(VM_ASPACE_BASE.as_usize() + VM_ASPACE_SIZE);
14-
1510
pub struct VmMachineInited {
1611
pub id: VmId,
1712
pub name: String,

src/arch/aarch64/vm/running.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ impl VmMachineRunningOps for VmMachineRunning {
1919

2020
fn stop(self) -> Self::Stopping {
2121
Self::Stopping {
22-
vmspace: self.common.vmspace,
22+
_vmspace: self.common.vmspace,
2323
}
2424
}
2525
}
2626

2727
pub struct VmStatusStopping {
28-
vmspace: VmAddrSpace,
28+
_vmspace: VmAddrSpace,
2929
}
3030

3131
impl VmMachineStoppingOps for VmStatusStopping {}

src/arch/aarch64/vm/unint.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ use crate::{
1111
fdt::FdtBuilder,
1212
};
1313

14-
const VM_ASPACE_BASE: GuestPhysAddr = GuestPhysAddr::from_usize(0);
15-
const VM_ASPACE_SIZE: usize = 0x7fff_ffff_f000;
16-
const VM_ASPACE_END: GuestPhysAddr =
17-
GuestPhysAddr::from_usize(VM_ASPACE_BASE.as_usize() + VM_ASPACE_SIZE);
18-
1914
pub struct VmMachineUninit {
2015
config: AxVMConfig,
2116
pt_levels: usize,

src/vm/addrspace.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,18 +364,18 @@ impl GuestMemory {
364364
self.layout.size()
365365
}
366366

367-
pub fn to_vec(&self) -> Vec<u8> {
368-
let mut result = vec![];
369-
let g = self.aspace.lock();
370-
let hva = g
371-
.translated_byte_buffer(self.gpa.as_usize().into(), self.size())
372-
.expect("Failed to translate memory region");
373-
for buff in hva {
374-
result.extend_from_slice(buff);
375-
}
376-
result.resize(self.size(), 0);
377-
result
378-
}
367+
// pub fn to_vec(&self) -> Vec<u8> {
368+
// let mut result = vec![];
369+
// let g = self.aspace.lock();
370+
// let hva = g
371+
// .translated_byte_buffer(self.gpa.as_usize().into(), self.size())
372+
// .expect("Failed to translate memory region");
373+
// for buff in hva {
374+
// result.extend_from_slice(buff);
375+
// }
376+
// result.resize(self.size(), 0);
377+
// result
378+
// }
379379
}
380380

381381
impl Drop for GuestMemory {

src/vm/machine/mod.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mod running;
1111

1212
pub(crate) use running::*;
1313

14+
#[allow(unused)]
1415
pub trait VmMachineUninitOps {
1516
type Inited: VmMachineInitedOps;
1617
fn new(config: AxVMConfig) -> Self;
@@ -29,22 +30,14 @@ pub trait VmMachineInitedOps {
2930
Self: Sized;
3031
}
3132

33+
#[allow(unused)]
3234
pub trait VmMachineRunningOps {
3335
type Stopping: VmMachineStoppingOps;
3436
fn stop(self) -> Self::Stopping;
3537
}
3638

3739
pub trait VmMachineStoppingOps {}
3840

39-
/// A lightweight container that stores the identifier and human readable name
40-
/// for a VM instance. Shared between the public [`Vm`] object and the
41-
/// background machine thread for logging and observability.
42-
#[derive(Debug, Clone)]
43-
pub struct VmCommon {
44-
pub id: VmId,
45-
pub name: String,
46-
}
47-
4841
pub enum VmMachineState {
4942
Uninit(VmMachineUninit),
5043
Inited(VmMachineInited),

0 commit comments

Comments
 (0)