-
Notifications
You must be signed in to change notification settings - Fork 22
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
Interrupt v3: Add interrupt traits and a KVM based implementation #21
base: main
Are you sure you want to change the base?
Conversation
src/interrupt/kvm/legacy_irq.rs
Outdated
Ok(()) | ||
} | ||
|
||
#[cfg(any(target_arch = "aarch", target_arch = "aarch64"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be "arm" for the architecture before aarch64.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My remarks from sameo#3 still apply; I don't think that having the interrupt type as an enum is future proof, since it prevents you from using the interrupt traits internally (for example for buses that are internal to device emulation). I'm not a contributor to vm-device so I'm not making this a reject, but anyway that's my opinion.
Introduce traits InterruptManager and InterruptSourceGroup to manage interrupt sources for virtual devices. Signed-off-by: Liu Jiang <[email protected]> Signed-off-by: Bin Zha <[email protected]>
497c92d
to
9e5bc2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asking for a rework of the features, leaving them to later commits that implement the KVM integrations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, now including the comments. I just cannot get this GitHub thing. :D
src/interrupt/mod.rs
Outdated
#[cfg(feature = "msi-irq")] | ||
/// Configuration data for PciMsi, PciMsix and generic MSI interrupts. | ||
MsiIrq(MsiIrqSourceConfig), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would go a step further if possible:
-
make this enum an associated type of
InterruptSourceGroup
-
move
InterruptSourceConfig
to the implementation of the KVM manager, removing the two features.
Hi, @bonzini @sameo @sboeuf @alexandruag I have merged most changed from Cloud Hypervisor into the new InterruptSourceGroup trait, with two main changes:
|
I would actually prefer the KVM implementations to live in a separate crate or in the VMM specific code. In the future, I would love to see vm-device independent of KVM and extend this code to support other hypervisors as well. Right now it feels a bit targeted at x86_64 and KVM. |
To me it's okay as long as it's hidden behind a feature, just like we have an mmap backend in |
75f73a9
to
b33c69e
Compare
I agree it would be better to make the interface trait as common as possible, and use feature to gate platform/hypervisor specific implementation. I also prefer including such a reference implementation in the same crate, it helps to verify that the interfaces really work. It's challenge to design interface by rust without a reference implementation:( |
Sorry, interrupt_type() getter should be removed, but the len() method should be kept. Will recover it . |
pardon, which method? |
|
The main use case of mask/unmask/get_pending_state() is to support PCI MSI/MSIx. PCI MSI/MSIx is edge triggered and supports pending state bit. So used It's really challenge to support PCI bus, much more complex than MMIO. We have used MSI with MMIO devices without support of mask/unmask for a long time. |
Looking more at the cloud-hypervisor code, a lot of the MsiInterruptGroup group seems to be a very boring wrapper around Vec. I wonder if the best solution is to have
Something like this:
create_group then can just return an |
See bonzini@388a575 for an example (also including unit tests). |
This PR is the successor of PR #11. The #11 has too many discussions so we reopen a new PR for clear review history, it also rebases to the latest vm-device code base.
The adds consts/structs/traits to manage interrupt sources for backend devices.
It also provides a KVM hypervisor based implementation for x86 legacy interrupts, PCI MSI/MSI-x interrupts.
There are also two planned PR based on this one: