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 <roypat@amazon.co.uk>
  • Loading branch information
roypat committed Jul 4, 2024
1 parent bb8fb62 commit 5b74fef
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);
}
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);
}
self.device_state = DeviceState::Activated(mem);
Expand Down

0 comments on commit 5b74fef

Please sign in to comment.