Make KVM versions mutually exclusive #3
Description
Context
The Linux version is selected by using cargo features. If the client doesn't want to use the default bindings (at the moment generated from kernel version 4.20) other versions can be selected by using rust features.
For example, to select the kvm bindings generated from the linux version 4.14, you would need to write the following line in Cargo.toml
:
kvm_wrapper = { version = "0.1.0", features = ["kvm_v4_14_0"]}
Problem
The problem is that nothing stops you from writing the following in your Cargo.toml
file:
kvm_wrapper = { version = "0.1.0", features = ["kvm_v4_14_0", "kvm_v4_20_0"]}
If the user selects more than one version though cargo will try to export bindings for all the existing versions which results in unused warnings:
...
warning: constant item is never used: `kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_ITS`
--> src/x86/bindings_v4_20_0.rs:9589:1
|
9589 | pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_ITS: kvm_device_type = 8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: constant item is never used: `kvm_device_type_KVM_DEV_TYPE_MAX`
--> src/x86/bindings_v4_20_0.rs:9590:1
|
9590 | pub const kvm_device_type_KVM_DEV_TYPE_MAX: kvm_device_type = 9;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
Nice to Have
It would be nice to make features mutually exclusive, but this is not currently possible out of the box. See cargo issue rust-lang/cargo#2980.
We should anyway find a hack to fix this.