Skip to content

Conversation

@last-genius
Copy link
Contributor

@last-genius last-genius commented Jun 3, 2025

This has been always true as xapi will call valid_device on VIF creation to
make sure device is an integer, but the datamodel type of 'device' is string,
without any such guarantees.

Specify the guarantee in the documentation and make the check stricter
(int_of_string will accept "0x9fe" as an integer, for example), making sure
that the device is specifically a decimal unsigned integer. allowed_VIF_devices
has already enforced the unsigned decimal integer limitation on compliant clients.

This could be helpful in ensuring that the clients will always be right in
sorting devices as numbers, not as strings (so that "2" follows "1" instead of
the string order of "1"->"10"->"11", etc.).

@last-genius
Copy link
Contributor Author

last-genius commented Jun 3, 2025

I've tested this manually through the CLI and XenOrchestra to confirm decimals work fine, and xapi now rejects hexadecimal devices, for example:

# xe vif-create device=0xba network-uuid=XXX vm-uuid=XXX
The device name is invalid
device: 0xba

@andyhhp
Copy link
Collaborator

andyhhp commented Jun 3, 2025

hex is an unsigned integer. If you mean "unsigned decimal integer" then the description should say so.

@last-genius last-genius force-pushed the asv/vif-device-int branch from 0011f98 to f2f6c19 Compare June 3, 2025 12:02
@last-genius last-genius changed the title xapi_vif: Guarantee the device parameter is an unsigned integer xapi_vif: Guarantee the device parameter is an unsigned decimal integer Jun 3, 2025
@last-genius last-genius force-pushed the asv/vif-device-int branch from f2f6c19 to bd4361f Compare June 4, 2025 09:53
@last-genius last-genius enabled auto-merge June 4, 2025 09:54
@last-genius last-genius added this pull request to the merge queue Jun 4, 2025
@last-genius last-genius removed this pull request from the merge queue due to a manual request Jun 4, 2025
@last-genius last-genius force-pushed the asv/vif-device-int branch from bd4361f to 9b7bd73 Compare June 4, 2025 10:28
This has been always true as xapi will call valid_device on VIF creation to
make sure device is an integer, but the datamodel type of 'device' is string,
without any such guarantees.

Specify the guarantee in the documentation and make the check stricter
(int_of_string will accept "0x9fe" as an integer, for example), making sure
that the device is specifically a decimal unsigned integer. allowed_VIF_devices
has already enforced the unsigned decimal integer limitation on compliant clients.

This could be helpful in ensuring that the clients will always be right in
sorting devices as numbers, not as strings (so that "2" follows "1" instead of
the string order of "1"->"10"->"11", etc.).

Signed-off-by: Andrii Sultanov <[email protected]>
@last-genius last-genius force-pushed the asv/vif-device-int branch from 9b7bd73 to 09b6256 Compare June 4, 2025 10:30
@last-genius last-genius enabled auto-merge June 4, 2025 10:38
@last-genius last-genius added this pull request to the merge queue Jun 4, 2025
Merged via the queue into xapi-project:master with commit 4bfdf7e Jun 4, 2025
16 checks passed
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.

4 participants