Skip to content

Commit c7ef5bf

Browse files
committed
vmbus_server: add vtl to trace events
1 parent 4f0f099 commit c7ef5bf

File tree

1 file changed

+61
-10
lines changed

1 file changed

+61
-10
lines changed

vm/devices/vmbus/vmbus_server/src/channels.rs

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,7 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
16921692
let info = channel.info.expect("assigned");
16931693
if channel.restore_state == RestoreState::Unmatched {
16941694
tracing::debug!(
1695+
vtl = self.inner.assigned_channels.vtl as u8,
16951696
offer_id = offer_id.0,
16961697
key = %channel.offer.key(),
16971698
"matched channel"
@@ -1718,7 +1719,12 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
17181719
// reference to it. Save the offer for reoffering immediately
17191720
// after the child releases it.
17201721
channel.state = ChannelState::Reoffered;
1721-
tracing::info!(?offer_id, key = %channel.offer.key(), "channel marked for reoffer");
1722+
tracing::info!(
1723+
vtl = self.inner.assigned_channels.vtl as u8,
1724+
offer_id = offer_id.0,
1725+
key = %channel.offer.key(),
1726+
"channel marked for reoffer"
1727+
);
17221728
}
17231729

17241730
channel.offer = offer;
@@ -1773,7 +1779,14 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
17731779
.send_offer(channel, version);
17741780
}
17751781

1776-
tracing::info!(?offer_id, %key, confidential_ring_buffer, confidential_external_memory, "new channel");
1782+
tracing::info!(
1783+
vtl = self.inner.assigned_channels.vtl as u8,
1784+
offer_id = offer_id.0,
1785+
%key,
1786+
confidential_ring_buffer,
1787+
confidential_external_memory,
1788+
"new channel"
1789+
);
17771790
Ok(offer_id)
17781791
}
17791792

@@ -1797,7 +1810,12 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
17971810

17981811
/// Completes an open operation with `result`.
17991812
pub fn open_complete(&mut self, offer_id: OfferId, result: i32) {
1800-
tracing::debug!(offer_id = offer_id.0, result, "open complete");
1813+
tracing::debug!(
1814+
vtl = self.inner.assigned_channels.vtl as u8,
1815+
offer_id = offer_id.0,
1816+
result,
1817+
"open complete"
1818+
);
18011819

18021820
let channel = &mut self.inner.channels[offer_id];
18031821
match channel.state {
@@ -1808,6 +1826,7 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
18081826
let channel_id = channel.info.expect("assigned").channel_id;
18091827
if result >= 0 {
18101828
tracelimit::info_ratelimited!(
1829+
vtl = self.inner.assigned_channels.vtl as u8,
18111830
offer_id = offer_id.0,
18121831
channel_id = channel_id.0,
18131832
result,
@@ -1816,6 +1835,7 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
18161835
} else {
18171836
// Log channel open failures at error level for visibility.
18181837
tracelimit::error_ratelimited!(
1838+
vtl = self.inner.assigned_channels.vtl as u8,
18191839
offer_id = offer_id.0,
18201840
channel_id = channel_id.0,
18211841
result,
@@ -1844,6 +1864,7 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
18441864
}
18451865
ChannelState::OpeningClientRelease => {
18461866
tracing::info!(
1867+
vtl = self.inner.assigned_channels.vtl as u8,
18471868
offer_id = offer_id.0,
18481869
result,
18491870
"opened channel (client released)"
@@ -1866,7 +1887,12 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
18661887
| ChannelState::Revoked
18671888
| ChannelState::Reoffered
18681889
| ChannelState::ClosingClientRelease => {
1869-
tracing::error!(?offer_id, state = ?channel.state, "invalid open complete")
1890+
tracing::error!(
1891+
vtl = self.inner.assigned_channels.vtl as u8,
1892+
offer_id = offer_id.0,
1893+
state = ?channel.state,
1894+
"invalid open complete"
1895+
);
18701896
}
18711897
}
18721898
}
@@ -1933,8 +1959,13 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
19331959

19341960
/// Completes a channel close operation.
19351961
pub fn close_complete(&mut self, offer_id: OfferId) {
1962+
tracing::info!(
1963+
vtl = self.inner.assigned_channels.vtl as u8,
1964+
offer_id = offer_id.0,
1965+
"closed channel"
1966+
);
1967+
19361968
let channel = &mut self.inner.channels[offer_id];
1937-
tracing::info!(offer_id = offer_id.0, "closed channel");
19381969
match channel.state {
19391970
ChannelState::Closing {
19401971
reserved_state: Some(reserved_state),
@@ -1985,7 +2016,12 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
19852016
| ChannelState::Revoked
19862017
| ChannelState::Reoffered
19872018
| ChannelState::OpeningClientRelease => {
1988-
tracing::error!(?offer_id, state = ?channel.state, "invalid close complete")
2019+
tracing::error!(
2020+
vtl = self.inner.assigned_channels.vtl as u8,
2021+
offer_id = offer_id.0,
2022+
state = ?channel.state,
2023+
"invalid close complete"
2024+
);
19892025
}
19902026
}
19912027
}
@@ -2649,6 +2685,7 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
26492685
input: &protocol::GpadlTeardown,
26502686
) -> Result<(), ChannelError> {
26512687
tracing::debug!(
2688+
vtl = self.inner.assigned_channels.vtl as u8,
26522689
channel_id = input.channel_id.0,
26532690
gpadl_id = input.gpadl_id.0,
26542691
"Received GPADL teardown request"
@@ -2686,6 +2723,7 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
26862723

26872724
if channel.state.is_revoked() {
26882725
tracing::trace!(
2726+
vtl = self.inner.assigned_channels.vtl as u8,
26892727
channel_id = input.channel_id.0,
26902728
gpadl_id = input.gpadl_id.0,
26912729
"Gpadl teardown for revoked channel"
@@ -3255,14 +3293,21 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
32553293

32563294
info.modifying = true;
32573295
info.monitor_page = monitor_page;
3258-
tracing::debug!("modifying connection parameters.");
3296+
tracing::debug!(
3297+
vtl = self.inner.assigned_channels.vtl as u8,
3298+
"modifying connection parameters."
3299+
);
32593300
self.notifier.modify_connection(request.into())?;
32603301

32613302
Ok(())
32623303
}
32633304

32643305
pub fn complete_modify_connection(&mut self, response: ModifyConnectionResponse) {
3265-
tracing::debug!(?response, "modifying connection parameters complete");
3306+
tracing::debug!(
3307+
vtl = self.inner.assigned_channels.vtl as u8,
3308+
?response,
3309+
"modifying connection parameters complete"
3310+
);
32663311

32673312
// InitiateContact, Unload, and actual ModifyConnection messages are all sent to the relay
32683313
// as ModifyConnection requests, so use the server state to determine how to handle the
@@ -3314,7 +3359,12 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
33143359

33153360
let version = self.inner.state.get_version();
33163361
let msg = Message::parse(&message.data, version)?;
3317-
tracing::trace!(?msg, message.trusted, "received vmbus message");
3362+
tracing::trace!(
3363+
vtl = self.inner.assigned_channels.vtl as u8,
3364+
?msg,
3365+
message.trusted,
3366+
"received vmbus message"
3367+
);
33183368
// Do not allow untrusted messages if the connection was established
33193369
// using a trusted message.
33203370
//
@@ -3465,6 +3515,7 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
34653515
/// Releases a GPADL that is being torn down.
34663516
pub fn gpadl_teardown_complete(&mut self, offer_id: OfferId, gpadl_id: GpadlId) {
34673517
tracing::debug!(
3518+
vtl = self.inner.assigned_channels.vtl as u8,
34683519
offer_id = offer_id.0,
34693520
gpadl_id = gpadl_id.0,
34703521
"Gpadl teardown complete"
@@ -4155,7 +4206,7 @@ mod tests {
41554206

41564207
impl Notifier for TestNotifier {
41574208
fn notify(&mut self, offer_id: OfferId, action: Action) {
4158-
tracing::debug!(?offer_id, ?action, "notify");
4209+
tracing::debug!(offer_id = offer_id.0, ?action, "notify");
41594210
self.send.send((offer_id, action)).unwrap()
41604211
}
41614212

0 commit comments

Comments
 (0)