libs: add Stat module in Unixext to handle special device IDs#6812
Merged
psafont merged 3 commits intoxapi-project:masterfrom Jan 8, 2026
Merged
libs: add Stat module in Unixext to handle special device IDs#6812psafont merged 3 commits intoxapi-project:masterfrom
psafont merged 3 commits intoxapi-project:masterfrom
Conversation
1139dfa to
52ba24a
Compare
psafont
commented
Dec 24, 2025
| Some {major; minor} | ||
|
|
||
| let encode_st_dev {major; minor} = | ||
| 0 |
Member
Author
There was a problem hiding this comment.
the 0 |^ is added to make ocamlformat behave and keep the first major term parenthesised and aligned. The same has been done in in decode
52ba24a to
7753e0f
Compare
last-genius
approved these changes
Jan 5, 2026
Contributor
last-genius
left a comment
There was a problem hiding this comment.
Probably worth explaining the motivation for this - the fact that we saw real-world minors > 256 failing to be handled by xapi properly, as it is unable to figure out the format of the backing file, and has to handle the VDI as raw instead.
lindig
approved these changes
Jan 5, 2026
d037795 to
21cf444
Compare
These device IDs are handled in an ad-hoc way, and none of the implementations follow the actual linux behaviour. The glibc-provided macros are used for the implementation, with a pure-ocaml implementation that was useful to compare against while implementing, which has been kept in the tests, to detect any behavioural changes. Because Unix.stat returns an `int` instead of an int64, the code does not support all possible values for major supported by glibc. This shouldn't be an issue in Linux since the device value is 32-bit wide. Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
There were 5 ad-hoc implementations, they were all getting wrong results for the minor because only the lower 8 bits were accounted for. Use the unixext one which handles up to 32-bit-wide minors correctly. Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
21cf444 to
fc6ed07
Compare
Previously, when a failure happened while getting a base vhd, a non-descriptive error was printed. Because there can be many reasons that can cause this code to fail, model the possible errors and print them when needed. Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
fc6ed07 to
097d1bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These device IDs are handled in an ad-hoc way, and none of the implementations follow the actual linux behaviour, replace all of them with an in imeplementation that uses the glibc macros to handle these.
Also change vhd_wrapper_tool to print better error messages when there's an error when getting the base VHD.
Reproduction steps:
for i in $(seq 1 512) ; do tap-ctl allocate; done. This forces the minor device ID to be higher than 255 for the local VBD created.The migration succeeds when both hosts in the pool have the changes in this PR running.