mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow: Implement live resize with L1 table growth
Add support for live resizing QCOW2 images. This enables growing the virtual size of a QCOW2 disk while the VM is running. Key features: - Growing the image automatically expands the L1 table if needed - Shrinking is not supported - Resizing for images with backing files is not supported Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
caa362c31f
commit
629c117ff3
@@ -4,7 +4,7 @@
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::fs::File;
|
||||
use std::io::{Seek, SeekFrom};
|
||||
use std::io::{self, Seek, SeekFrom};
|
||||
use std::os::fd::AsRawFd;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -68,6 +68,14 @@ impl DiskFile for QcowDiskSync {
|
||||
Ok(Box::new(QcowSync::new(Arc::clone(&self.qcow_file))) as Box<dyn AsyncIo>)
|
||||
}
|
||||
|
||||
fn resize(&mut self, size: u64) -> DiskFileResult<()> {
|
||||
self.qcow_file
|
||||
.lock()
|
||||
.unwrap()
|
||||
.resize(size)
|
||||
.map_err(|e| DiskFileError::ResizeError(io::Error::other(e)))
|
||||
}
|
||||
|
||||
fn fd(&mut self) -> BorrowedDiskFd<'_> {
|
||||
BorrowedDiskFd::new(self.qcow_file.lock().unwrap().as_raw_fd())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user