Skip to content

Commit

Permalink
virtio/net: propagate interrupt controller
Browse files Browse the repository at this point in the history
Propagate interrupt controller into the virtio-net device. Without this,
virtio-net can't send interrupts in macOS/hvf.

Signed-off-by: Sergio Lopez <slp@redhat.com>
  • Loading branch information
slp committed Feb 7, 2024
1 parent 5bbb70c commit 8a61a87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/devices/src/virtio/net/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ impl Net {
&self.id
}

pub fn set_intc(&mut self, intc: Arc<Mutex<Gic>>) {
self.intc = Some(intc);
}

pub(crate) fn process_rx_queue_event(&mut self) {
if let Err(e) = self.queue_evts[RX_INDEX].read() {
log::error!("Failed to get rx event from queue: {:?}", e);
Expand Down
15 changes: 13 additions & 2 deletions src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,17 @@ pub fn build_microvm(
#[cfg(feature = "blk")]
attach_block_devices(&mut vmm, &vm_resources.block, event_manager, intc.clone())?;
if let Some(vsock) = vm_resources.vsock.get() {
attach_unixsock_vsock_device(&mut vmm, vsock, event_manager, intc)?;
attach_unixsock_vsock_device(&mut vmm, vsock, event_manager, intc.clone())?;
vmm.kernel_cmdline.insert_str("tsi_hijack")?;
}

#[cfg(feature = "net")]
attach_net_devices(&mut vmm, vm_resources.net_builder.iter(), event_manager)?;
attach_net_devices(
&mut vmm,
vm_resources.net_builder.iter(),
event_manager,
intc,
)?;

if let Some(s) = &vm_resources.boot_config.kernel_cmdline_epilog {
vmm.kernel_cmdline.insert_str(s).unwrap();
Expand Down Expand Up @@ -1159,9 +1164,15 @@ fn attach_net_devices<'a>(
vmm: &mut Vmm,
net_devices: impl Iterator<Item = &'a Arc<Mutex<Net>>>,
event_manager: &mut EventManager,
intc: Option<Arc<Mutex<Gic>>>,
) -> Result<(), StartMicrovmError> {
for net_device in net_devices {
let id = net_device.lock().unwrap().id().to_string();

if let Some(ref intc) = intc {
net_device.lock().unwrap().set_intc(intc.clone());
}

event_manager
.add_subscriber(net_device.clone())
.map_err(StartMicrovmError::RegisterEvent)?;
Expand Down

0 comments on commit 8a61a87

Please sign in to comment.