block: qcow: Add live disk resize support - #7687
Conversation
|
Follow-up of #7476 - ping @tpressure |
phip1611
left a comment
There was a problem hiding this comment.
Good contribution, thanks! Left a few remarks
I pinged @tpressure as he created the original PR #7476
| .lock() | ||
| .unwrap() | ||
| .resize(size) | ||
| .map_err(|e| DiskFileError::ResizeError(std::io::Error::other(e))) |
There was a problem hiding this comment.
nit: I'd prefer use std::io + io::Error::other(e))
There was a problem hiding this comment.
Yeah, I thought to do that. Just in this case it's a single occurrence, so seemed more idiomatic to me. Fixed now. Thanks
|
|
||
| let result = q.resize(smaller_size); | ||
| assert!(result.is_err()); | ||
| assert!(matches!(result.unwrap_err(), Error::ShrinkNotSupported)); |
There was a problem hiding this comment.
I think this could be a single
assert_eq!(result, Err(Error::ShrinkNotSupported)
There was a problem hiding this comment.
It seems that matches! is the correct solution here, otherwise:
error[E0369]: binary operation `==` cannot be applied to type `Result<(), qcow::Error>`
note: an implementation of `PartialEq` might be missing for `qcow::Error`
This could be a good point to the planned refactorings, but Error might not be able to derive PartialEq in this case, as it wraps io::Error.
Thanks
|
|
||
| let result = overlay.resize(backing_size * 2); | ||
| assert!(result.is_err()); | ||
| assert!(matches!(result.unwrap_err(), Error::ResizeWithBackingFile)); |
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 <[email protected]>
- No-op resize when size unchanged - Growing with L1 table expansion - Shrink attempts return error - Resize with backing file returns error Signed-off-by: Anatol Belski <[email protected]>
3b18bd6 to
24a0edd
Compare
Verify live resize of QCOW2 disks works via the API, including resizing that requires L1 table growth. Signed-off-by: Anatol Belski <[email protected]>
24a0edd to
25b514d
Compare
Thanks for attracting my attention to this :) |
Enables growing QCOW2 virtual disk size at runtime through the
resize-diskAPI. When the new size requires additional L1 table entries, the implementation automatically expands the L1 table.Limitations:
Added unit tests covering grow, shrink rejection, backing file rejection and integration test exercising resize based on the existing test for RAW.