hypervisor detection
Libmicrovmi's api needs to explicitely specify the hypervisor that we want to use.
We could improve that behavior by detecting if a given hypervisor is present, and test all possible hypervisors (the ones compiled in the library).
As we are only compiling a specific hypervisor, there will be only 2 hypervisors available:
- Dummy
- the selected feature (xen or kvm at this point)
How can we modify the init function, so that it takes an optional driver type ?
pub fn init(driver_type: Option<DriverType>, domain_name: &String) -> Box<Introspectable> {
So we could pass None and let the function decide.
What do you think @tathanhdinh, how to implement this feature ?
Thanks.
I was looking at adding a new function in the Introspectable trait:
fn detect() -> Result<bool,Box<Error>> where Self: Sized {
And then you could loop over the DriverType enum, and pick the only hypervisor that will return true
We should rename this feature as hypervisor test, and test whether a given domain name is available on for a specific hypervisor.
Implementing the same logic that LibVMI's driver_init_mode function does.
Overview:
- xen_test
- xen_init
- xen_get_version
- reading /sys/hypervisor/major/minor
- init libxc_wrapper
- init libxs_wrapper
- xen_get_version
- test converting domain name to domain id
- via xenstore directories
- xen_init
- kvm_test
- kvm_init
- init libvirt_wrapper
- connect to qemu:///system
- kvm_init
Next here would be to enable a set of features by default. Of course, we have to take the platform into account, Linux or Windows.
I tried to play with Cargo conditional compilation, but I can't get this thing working as I expect:

Im getting
warning: unused manifest key: target.cfg(target_os="linux").features
warning: unused manifest key: target.cfg(target_os="windows").features
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
I saw the syntax in a SO post: https://stackoverflow.com/questions/39709542/why-does-the-last-platform-specific-dependency-take-precedence-in-cargo
of course, if this isn't supported for the features section, we can ditch the hyper-v driver and set the default linux drivers
https://github.com/rust-lang/cargo/issues/1197
:(
Thanks for finding this. At least this should be available in nightly already, according to:
Target-specific features for dependencies has been implemented and is available as a nightly-only feature on the latest nightly 2020-02-23. See the tracking issue at #7914.
In the meantime, we can assume linux by default.