Skip to content

[master] Optimize data cluster format for VHD and QCOW#7106

Open
last-genius wants to merge 8 commits into
xapi-project:masterfrom
last-genius:asv/qcow-master
Open

[master] Optimize data cluster format for VHD and QCOW#7106
last-genius wants to merge 8 commits into
xapi-project:masterfrom
last-genius:asv/qcow-master

Conversation

@last-genius
Copy link
Copy Markdown
Contributor

@last-genius last-genius commented Jun 1, 2026

This is a forward-port of #6895 (with the exception of commits later reverted in #7030 and #7022).

Changes to VHD code are gated behind a feature flag (with previous behaviour kept by default). XCP-ng has been running the new VHD and QCOW code for a while now with no issues.

This PR needs to be merged before the corresponding xs-opam PR (xapi-project/xs-opam#768)

This allows to switch on the more efficient interval format later.
(QCOW always uses the new format)

Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
(cherry picked from commit 1aa52ef)
This command returns a more efficient representation of allocated clusters
(when compared to read_headers), utilizing a sparse interval format instead of
returning every single allocated cluster.

This is the more efficient option, decreasing the filesize and memory usage in
vhd-tool, but it's currently under a feature flag, so it's added as a new
command instead of replacing read_headers immediately.

Cram test for read_headers is still passing, so this refactoring has preserved
the legacy format.

Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
(cherry picked from commit fa4f516)
Since the runtime feature flag vhd_legacy_blocks_format determines which block
format is used to describe allocated VHD clusters, this requires duplicate
parse_header_interval functions for VHD and QCOW.

The right functions are selected in stream_vdi based on the feature flag.

Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
(cherry picked from commit 5457512)
…er allocation

Instead of using a set with every individual allocated cluster index as a
member, use a sorted list of intervals to verify if cluster is allocated - this
uses much less memory and directly follows from the JSON format
qcow-stream-tool and vhd-tool output now.

Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
(cherry picked from commit 1fc8ee7)
…_clusters

nonzero_clusters no longer contain every single allocated cluster and instead
are intervals of allocated clusters.

Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
(cherry picked from commit a52b126)
Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
(cherry picked from commit f9db34b)
This proves much more reliable than code based on ocaml-qcow.

Since qemu-img has a different format (with the needed information spread
across two files resulting from calls to 'qemu-img info' and 'qemu-img map'),
change the parsing code in vhd_qcow_parsing and qcow2-to-stdout.

Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
(cherry picked from commit 3f6f6dd)
qemu-img is now used to determine allocated clusters, so this command is no
longer needed.

Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
(cherry picked from commit 829c018)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants