Skip to content

Conversation

@sboeuf
Copy link

@sboeuf sboeuf commented May 31, 2019

This pull request primary goal is to add the support for the KVM ioctl KVM_SIGNAL_MSI.
The reason being to allow consumers of this crate to directly inject MSI messages instead of using legacy pin based interrupts.

The second part of this pull request implements the Clone trait for VmFd so that anyone can safely clone VmFd. The need for cloning is to be able to move the VmFd into a closure or a thread.

@sboeuf
Copy link
Author

sboeuf commented May 31, 2019

@andreeaflorescu @sameo @rbradford I don't see how I can properly test this new ioctl...
The reason signal_msi() seems impossible to test is tied to the fact that MSI vectors are not chosen from the HW side. The guest OS (or anything that runs inside the VM) is supposed to allocate the MSI/MSI-X vectors, and usually communicate back through PCI configuration space.
If I simply send a random MSI vector, the call to signal_msi() fails.
It seems to me this kind of ioctls can only be tested from an integration test perspective, but not directly from the crate itself.
Please let me know what you think!

rbradford
rbradford previously approved these changes Jun 1, 2019
Copy link
Contributor

@rbradford rbradford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think testing such ioctls will often present challenges and we need to be tolerant of lowering the coverage where necessary. With such little logic in the handling of this ioctl I do not feel overly concerned that anything might break it.

@sboeuf
Copy link
Author

sboeuf commented Jun 3, 2019

@andreeaflorescu @rbradford PR updated, let me know what you think?

@rbradford
Copy link
Contributor

@sboeuf need to update your coverage amount.

rbradford
rbradford previously approved these changes Jun 3, 2019
@sboeuf
Copy link
Author

sboeuf commented Jun 3, 2019

Yeah so I lowered the coverage from 91.3 to 91.2 and now all green!
@andreeaflorescu PTAL

sameo
sameo previously approved these changes Jun 3, 2019
src/ioctls/vm.rs Outdated
// exactly the size of the struct
let ret = unsafe { ioctl_with_ref(self, KVM_SIGNAL_MSI(), &msi) };
if ret != -1 {
Ok(())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per KVM API documentation this ioctl:
Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error

We should keep the same return values in this wrapper as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I create a new error for 0?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should return 0 and let the caller handle that exit code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sounds good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S. It's worth specifying this in the function documentation as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok it's updated now, let me know what you think.

@sboeuf sboeuf force-pushed the kvm_signal_msi branch 3 times, most recently from 8f48374 to f883bcc Compare June 4, 2019 13:31
@sboeuf sboeuf force-pushed the kvm_signal_msi branch 3 times, most recently from ff3b30a to 2feeda7 Compare June 4, 2019 16:00
andreeaflorescu
andreeaflorescu previously approved these changes Jun 5, 2019
rbradford
rbradford previously approved these changes Jun 5, 2019
Any consumer of this crate who would like to implement MSI/MSI-X
support will need KVM_SIGNAL_MSI to notify directly the local APIC
emulated by KVM, using MSI/MSI-X vectors.

Signed-off-by: Sebastien Boeuf <[email protected]>
@andreeaflorescu andreeaflorescu merged commit e7a0ccc into rust-vmm:master Jun 5, 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