Skip to content

Design: Driver initialization argument handling #197

@Wenzel

Description

@Wenzel

Opening a design issue to address the issue of passing initialization parameters to drivers.

Currently the library assumes that a domain_name parameter is required
https://github.com/Wenzel/libmicrovmi/blob/master/src/lib.rs#L30

and additional parameters can be passed via Option<DriverInitParam>.

adding Memflow comes with new requirements

The issue comes from integrating Memflow.

Memflow has multiple connectors to choose from

  • qemu_procfs
  • kvm
  • pcileech
  • coredump

each one having a different set of parameters:

  • qemu_procfs
    • required: none (will select the first qemu process)
    • optional: vm_name
  • kvm
    • required: pid
  • pcileech
    • required: device, default value: FPGA
    • optional: memap, path to a file
  • coredump
    • required: filepath

also, we might want to initialize the memflow driver without specifying the connector, and let it scan and select the appropriate connector.

Issue with the current implementation

  • we require a domain_name even though it might no be necessary with memflow
  • not related to memflow, but DriverInitParam can contain only a single enum for a single driver. It's impossible to pass multiple init args for multiple driver. (eg pass --kvmi-unix-socket=xxx and --memflow-param-xxx=yyy on the command line, in case one or the other is found)

Proposed solution

I'm in favor a removing the domain_name / DriverInitParam and switching to a HashMap<str, str> for connector arguments.
This solves both issues

  1. passing a domain_name is not required
  2. you can pack multiple init args for multiple drivers in the hashmap

Looking at Memflow's own implementation of ConnectorArgs, they wrapped a HashMap.
Also they added a convenient way to set a default value.

Question now, if we go this way, is how to reflect from the examples the arguments that each driver can take (required and optional) ?
Ideally, each driver would explain what its requirements are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions