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

Function new_self_referential_qcow

block/src/qcow/mod.rs:2709–2717  ·  view source on GitHub ↗

Create a qcow2 file with itself as its backing file. Without configuration `max_nesting_depth`, this will cause infinite recursion when loading the file until stack overflow.

(path: &Path)

Source from the content-addressed store, hash-verified

2707 /// Without configuration `max_nesting_depth`, this will cause infinite recursion when loading
2708 /// the file until stack overflow.
2709 fn new_self_referential_qcow(path: &Path) -> Result<()> {
2710 let header = QcowHeader::create_for_size_and_path(3, 0x10_0000, path.to_str())?;
2711 let mut disk_file = RawFile::new(
2712 File::create(path).expect("Failed to create image file."),
2713 false,
2714 );
2715 header.write_to(&mut disk_file)?;
2716 Ok(())
2717 }
2718
2719 #[test]
2720 fn max_nesting_backing() {

Callers 1

max_nesting_backingFunction · 0.85

Calls 3

newFunction · 0.85
createFunction · 0.85
write_toMethod · 0.45

Tested by 1

max_nesting_backingFunction · 0.68