vmm: Fix clippy issues under "guest_debug" feature

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2022-06-08 10:57:16 +01:00
parent 133a5a858a
commit 94fb9f817d
3 changed files with 19 additions and 19 deletions

View File

@ -174,9 +174,9 @@ pub struct CpuState {
unsafe impl ByteValued for CpuState {}
pub enum NoteDescType {
ElfDesc = 0,
VmmDesc = 1,
ElfAndVmmDesc = 2,
Elf = 0,
Vmm = 1,
ElfAndVmm = 2,
}
// "CORE" or "QEMU"
@ -239,7 +239,7 @@ pub trait Elf64Writable {
let bytes: &[u8] = elf64_ehdr.as_slice();
coredump_file
.write(bytes)
.map_err(|e| GuestDebuggableError::CoredumpFile(e.into()))?;
.map_err(GuestDebuggableError::CoredumpFile)?;
Ok(())
}
@ -264,7 +264,7 @@ pub trait Elf64Writable {
let bytes: &[u8] = elf64_phdr.as_slice();
coredump_file
.write(bytes)
.map_err(|e| GuestDebuggableError::CoredumpFile(e.into()))?;
.map_err(GuestDebuggableError::CoredumpFile)?;
Ok(())
}
@ -292,7 +292,7 @@ pub trait Elf64Writable {
let bytes: &[u8] = elf64_load.as_slice();
coredump_file
.write(bytes)
.map_err(|e| GuestDebuggableError::CoredumpFile(e.into()))?;
.map_err(GuestDebuggableError::CoredumpFile)?;
Ok(())
}
@ -324,9 +324,9 @@ pub trait Elf64Writable {
self.elf_note_size(note_head_size, COREDUMP_NAME_SIZE, cpu_state_desc_size);
match desc_type {
NoteDescType::ElfDesc => elf_note_size * nr_cpus,
NoteDescType::VmmDesc => vmm_note_size * nr_cpus,
NoteDescType::ElfAndVmmDesc => (elf_note_size + vmm_note_size) * nr_cpus,
NoteDescType::Elf => elf_note_size * nr_cpus,
NoteDescType::Vmm => vmm_note_size * nr_cpus,
NoteDescType::ElfAndVmm => (elf_note_size + vmm_note_size) * nr_cpus,
}
}
}

View File

@ -2128,9 +2128,9 @@ impl CpuElf64Writable for CpuManager {
) -> std::result::Result<(), GuestDebuggableError> {
let mut coredump_file = dump_state.file.as_ref().unwrap();
for vcpu in &self.vcpus {
let note_size = self.get_note_size(NoteDescType::ElfDesc, 1);
let note_size = self.get_note_size(NoteDescType::Elf, 1);
let mut pos: usize = 0;
let mut buf = vec![0 as u8; note_size as usize];
let mut buf = vec![0; note_size as usize];
let descsz = size_of::<X86_64ElfPrStatus>();
let vcpu_id = vcpu.lock().unwrap().id;
@ -2211,7 +2211,7 @@ impl CpuElf64Writable for CpuManager {
coredump_file
.write(&buf)
.map_err(|e| GuestDebuggableError::CoredumpFile(e.into()))?;
.map_err(GuestDebuggableError::CoredumpFile)?;
}
Ok(())
@ -2223,16 +2223,16 @@ impl CpuElf64Writable for CpuManager {
) -> std::result::Result<(), GuestDebuggableError> {
let mut coredump_file = dump_state.file.as_ref().unwrap();
for vcpu in &self.vcpus {
let note_size = self.get_note_size(NoteDescType::VmmDesc, 1);
let note_size = self.get_note_size(NoteDescType::Vmm, 1);
let mut pos: usize = 0;
let mut buf = vec![0 as u8; note_size as usize];
let mut buf = vec![0; note_size as usize];
let descsz = size_of::<DumpCpusState>();
let vcpu_id = vcpu.lock().unwrap().id;
let note = Elf64_Nhdr {
n_namesz: COREDUMP_NAME_SIZE,
n_descsz: descsz as u32,
n_type: 0 as u32,
n_type: 0,
};
let bytes: &[u8] = note.as_slice();
@ -2294,7 +2294,7 @@ impl CpuElf64Writable for CpuManager {
let idt = CpuSegment::new_from_table(sregs.idt);
let cr = [sregs.cr0, sregs.cr8, sregs.cr2, sregs.cr3, sregs.cr4];
let regs = DumpCpusState {
version: 1 as u32,
version: 1,
size: size_of::<DumpCpusState>() as u32,
regs1,
regs2,
@ -2321,7 +2321,7 @@ impl CpuElf64Writable for CpuManager {
coredump_file
.write(&buf)
.map_err(|e| GuestDebuggableError::CoredumpFile(e.into()))?;
.map_err(GuestDebuggableError::CoredumpFile)?;
}
Ok(())

View File

@ -2531,8 +2531,8 @@ impl Vm {
destination_url: &str,
) -> std::result::Result<DumpState, GuestDebuggableError> {
let nr_cpus = self.config.lock().unwrap().cpus.boot_vcpus as u32;
let elf_note_size = self.get_note_size(NoteDescType::ElfAndVmmDesc, nr_cpus) as isize;
let mut elf_phdr_num = 1 as u16;
let elf_note_size = self.get_note_size(NoteDescType::ElfAndVmm, nr_cpus) as isize;
let mut elf_phdr_num = 1;
let elf_sh_info = 0;
let coredump_file_path = url_to_file(destination_url)?;
let mapping_num = self.memory_manager.lock().unwrap().num_guest_ram_mappings();