Skip to content

Commit

Permalink
fix: insert missing activate_fails metrics increases
Browse files Browse the repository at this point in the history
Make sure that whenever the activation of a virtio device fails, we set
the `activate_fails` metric.

Signed-off-by: Patrick Roy <[email protected]>
  • Loading branch information
roypat committed Jul 4, 2024
1 parent 057d0d8 commit 8eb2229
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/vmm/src/devices/virtio/block/vhost_user/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ impl<T: VhostUserHandleBackend + Send + 'static> VirtioDevice for VhostUserBlock
// with guest driver as well.
self.vu_handle
.set_features(self.acked_features)
.map_err(ActivateError::VhostUser)?;
self.vu_handle
.setup_backend(
&mem,
&[(0, &self.queues[0], &self.queue_evts[0])],
&self.irq_trigger,
)
.and_then(|()| {
self.vu_handle.setup_backend(
&mem,
&[(0, &self.queues[0], &self.queue_evts[0])],
&self.irq_trigger,
)
})
.map_err(|err| {
self.metrics.activate_fails.inc();
ActivateError::VhostUser(err)
Expand Down
1 change: 1 addition & 0 deletions src/vmm/src/devices/virtio/block/virtio/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ impl VirtioDevice for VirtioBlock {
}

if self.activate_evt.write(1).is_err() {
self.metrics.activate_fails.inc();
return Err(ActivateError::EventFd);

Check warning on line 656 in src/vmm/src/devices/virtio/block/virtio/device.rs

View check run for this annotation

Codecov / codecov/patch

src/vmm/src/devices/virtio/block/virtio/device.rs#L655-L656

Added lines #L655 - L656 were not covered by tests
}
self.device_state = DeviceState::Activated(mem);
Expand Down
1 change: 1 addition & 0 deletions src/vmm/src/devices/virtio/net/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ impl VirtioDevice for Net {
}

if self.activate_evt.write(1).is_err() {
self.metrics.activate_fails.inc();
return Err(ActivateError::EventFd);

Check warning on line 866 in src/vmm/src/devices/virtio/net/device.rs

View check run for this annotation

Codecov / codecov/patch

src/vmm/src/devices/virtio/net/device.rs#L865-L866

Added lines #L865 - L866 were not covered by tests
}
self.device_state = DeviceState::Activated(mem);
Expand Down

0 comments on commit 8eb2229

Please sign in to comment.