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

Function disable_backing_file

block/src/qcow/mod.rs:2686–2703  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2684
2685 #[test]
2686 fn disable_backing_file() {
2687 // `backing_file` is `Some`
2688 let header =
2689 QcowHeader::create_for_size_and_path(3, 0x10_0000, Some("/path/to/backing/file"))
2690 .expect("Failed to create header.");
2691 let mut disk_file: RawFile = RawFile::new(TempFile::new().unwrap().into_file(), false);
2692 header
2693 .write_to(&mut disk_file)
2694 .expect("Failed to write header to shm.");
2695 disk_file.rewind().unwrap();
2696 // The maximum nesting depth is 0, which means backing file is not allowed.
2697 let res = QcowFile::from_with_nesting_depth(disk_file, 0, true);
2698 let err = res.unwrap_err();
2699 assert!(matches!(err.kind(), BlockErrorKind::Overflow));
2700 let source = StdError::source(&err).unwrap();
2701 let qcow_err = source.downcast_ref::<Error>().unwrap();
2702 assert!(matches!(qcow_err, Error::MaxNestingDepthExceeded));
2703 }
2704
2705 /// Create a qcow2 file with itself as its backing file.
2706 ///

Callers

nothing calls this directly

Calls 2

newFunction · 0.85
write_toMethod · 0.45

Tested by

no test coverage detected