Wenzel / libmicrovmi

A cross-platform unified Virtual Machine Introspection API library
https://wenzel.github.io/libmicrovmi/
GNU General Public License v3.0
164 stars 16 forks source link

hypervisor detection #7

Open Wenzel opened 5 years ago

Wenzel commented 5 years ago

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:

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.

Wenzel commented 5 years ago

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

Wenzel commented 4 years ago

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:

Wenzel commented 3 years ago

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: carbon

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

rageagainsthepc commented 3 years ago

https://github.com/rust-lang/cargo/issues/1197

:(

Wenzel commented 3 years ago

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.