Thanks to visit codestin.com
Credit goes to github.com

Skip to content

block: qcow: Add live disk resize support - #7687

Merged
rbradford merged 3 commits into
cloud-hypervisor:mainfrom
weltling:qcow-live-resize
Feb 12, 2026
Merged

rbradford merged 3 commits into
cloud-hypervisor:mainfrom
weltling:qcow-live-resize

Conversation

@weltling

Copy link
Copy Markdown
Member

Enables growing QCOW2 virtual disk size at runtime through the resize-disk API. When the new size requires additional L1 table entries, the implementation automatically expands the L1 table.

Limitations:

  • Grow only, shrink returns error
  • No support for images with backing files

Added unit tests covering grow, shrink rejection, backing file rejection and integration test exercising resize based on the existing test for RAW.

@weltling
weltling requested a review from a team as a code owner February 10, 2026 19:44
@phip1611

Copy link
Copy Markdown
Member

Follow-up of #7476 - ping @tpressure

@phip1611 phip1611 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good contribution, thanks! Left a few remarks

I pinged @tpressure as he created the original PR #7476

Comment thread block/src/qcow_sync.rs Outdated
.lock()
.unwrap()
.resize(size)
.map_err(|e| DiskFileError::ResizeError(std::io::Error::other(e)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd prefer use std::io + io::Error::other(e))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought to do that. Just in this case it's a single occurrence, so seemed more idiomatic to me. Fixed now. Thanks

Comment thread block/src/qcow/mod.rs

let result = q.resize(smaller_size);
assert!(result.is_err());
assert!(matches!(result.unwrap_err(), Error::ShrinkNotSupported));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be a single

assert_eq!(result, Err(Error::ShrinkNotSupported)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread block/src/qcow/mod.rs

let result = overlay.resize(backing_size * 2);
assert!(result.is_err());
assert!(matches!(result.unwrap_err(), Error::ResizeWithBackingFile));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

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]>
Verify live resize of QCOW2 disks works via the API, including
resizing that requires L1 table growth.

Signed-off-by: Anatol Belski <[email protected]>
@weltling

Copy link
Copy Markdown
Member Author

Good contribution, thanks! Left a few remarks

I pinged @tpressure as he created the original PR #7476

Thanks for attracting my attention to this :)

Comment thread block/src/qcow/mod.rs
Comment thread block/src/qcow/mod.rs
Comment thread block/src/qcow/mod.rs

@russell-islam russell-islam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rbradford rbradford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rslgtm

@rbradford
rbradford added this pull request to the merge queue Feb 12, 2026
Merged via the queue into cloud-hypervisor:main with commit 9ba9c08 Feb 12, 2026
43 checks passed
@weltling
weltling deleted the qcow-live-resize branch February 13, 2026 08:13
@github-project-automation github-project-automation Bot moved this from 🆕 New to ✅ Done in Cloud Hypervisor Roadmap Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

5 participants