MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / get_dump_state

Method get_dump_state

vmm/src/vm.rs:3181–3219  ·  view source on GitHub ↗
(
        &mut self,
        destination_url: &str,
    )

Source from the content-addressed store, hash-verified

3179
3180 #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
3181 fn get_dump_state(
3182 &mut self,
3183 destination_url: &str,
3184 ) -> std::result::Result<DumpState, GuestDebuggableError> {
3185 let nr_cpus = self.config.lock().unwrap().cpus.boot_vcpus;
3186 let elf_note_size = self.get_note_size(NoteDescType::ElfAndVmm, nr_cpus) as isize;
3187 let mut elf_phdr_num = 1;
3188 let elf_sh_info = 0;
3189 let coredump_file_path = url_to_file(destination_url)?;
3190 let mapping_num = self.memory_manager.lock().unwrap().num_guest_ram_mappings();
3191
3192 if mapping_num < UINT16_MAX - 2 {
3193 elf_phdr_num += mapping_num as u16;
3194 } else {
3195 panic!("mapping num beyond 65535 not supported");
3196 }
3197 let coredump_file = OpenOptions::new()
3198 .read(true)
3199 .write(true)
3200 .create_new(true)
3201 .open(coredump_file_path)
3202 .map_err(|e| GuestDebuggableError::Coredump(e.into()))?;
3203
3204 let mem_offset = self.coredump_get_mem_offset(elf_phdr_num, elf_note_size);
3205 let mem_data = self
3206 .memory_manager
3207 .lock()
3208 .unwrap()
3209 .coredump_memory_regions(mem_offset);
3210
3211 Ok(DumpState {
3212 elf_note_size,
3213 elf_phdr_num,
3214 elf_sh_info,
3215 mem_offset,
3216 mem_info: Some(mem_data),
3217 file: Some(coredump_file),
3218 })
3219 }
3220
3221 #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
3222 fn coredump_get_mem_offset(&self, phdr_num: u16, note_size: isize) -> u64 {

Callers 1

coredumpMethod · 0.80

Calls 9

url_to_fileFunction · 0.85
newFunction · 0.85
get_note_sizeMethod · 0.80
openMethod · 0.80
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected