Skip to content

Implement MsrList and Msrs as FamStructWrappers #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 11, 2019
Merged

Implement MsrList and Msrs as FamStructWrappers #64

merged 3 commits into from
Nov 11, 2019

Conversation

acatangiu
Copy link
Collaborator

@acatangiu acatangiu commented Oct 16, 2019

Description of changes

kvm_msr_list and kvm_msrs each contain a flexible array member and were forcing users of kvm-ioctls crate to work with unsafe code.
Use the kvm-bindings CpuId, MsrList and Msrs safe wrappers over them and change our ioctl functions to use these safe wrappers.

@jiangliu
Copy link
Member

Could we implement this in kvm-bindings crate? It should be simpler and natural to implement mechanism to access syscall related structs within the kvm-bindings crate.

@andreeaflorescu
Copy link
Member

@jiangliu I don't think that implementing these traits in the kvm-bindings crate is a good idea at the moment. There are a few reasons for that:

  1. kvm-bindings still separates clearly the autogenerated code from the one that is not autogenerated. I would prefer to keep it this way for now.
  2. we are in discussions about merging/collaborating with ketuvim (Collaboration / Merge with Ketuvim community#62). Probably it will become more clear after the rust-vmm meetup what is the plan there.

While I believe that it's not the best thing now to move this functionality in kvm-bindings, we can discuss about it again once the rust-vmm components and their separation are more obvious.

What do you say?

@jiangliu
Copy link
Member

@jiangliu I don't think that implementing these traits in the kvm-bindings crate is a good idea at the moment. There are a few reasons for that:

  1. kvm-bindings still separates clearly the autogenerated code from the one that is not autogenerated. I would prefer to keep it this way for now.
    When enabling serde for kvm-bindings, I ran into the same issue to add non-auto-generated code to the kvm-bindings crate. In some sense, we are enhancing the bindgen tool to better support FAM structs, so
    propose to implement in the kvm-binding crate.
    It's great to collaborate with the ketuvim project, which may help to solve all these issues.
  1. we are in discussions about merging/collaborating with ketuvim (rust-vmm/community#62). Probably it will become more clear after the rust-vmm meetup what is the plan there.

While I believe that it's not the best thing now to move this functionality in kvm-bindings, we can discuss about it again once the rust-vmm components and their separation are more obvious.

What do you say?

@acatangiu
Copy link
Collaborator Author

After some thought, I agree that the FamWrappers over the kvm FAM structures belong in the same crate as the structs themselves (kvm-bindings). Doing that also simplifies the implementation since we can directly implement the external FamStructWrapper trait on a local struct.

I've opened rust-vmm/kvm-bindings#8 that exemplifies how that'd look.
The PR adds a new module in that crate that doesn't touch the generated files, it just imports the structs from there, so that's nice. The downside is that kvm-bindings would depend on vmm-sys-utils.

Signed-off-by: Adrian Catangiu <[email protected]>
Use safe fam-wrapper over kvm_cpuid2 exported by the
kvm-bindings crate instead of implementing our own.

Coverage decreases by 0.1% because of the removed code.

Signed-off-by: Adrian Catangiu <[email protected]>
Refactor the unsafe code concerning kvm_msr_list and kvm_msrs,
to work with the safe fam-wrappers MsrList and Msrs.

Signed-off-by: Adrian Catangiu <[email protected]>
@acatangiu
Copy link
Collaborator Author

The PR is updated to use the kvm-bindings safe wrappers. Please review when you get the chance.

@alxiord alxiord merged commit 652eb11 into rust-vmm:master Nov 11, 2019
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