Skip to content

Commit 1484a31

Browse files
committed
Review
1 parent a207f99 commit 1484a31

File tree

3 files changed

+35
-37
lines changed

3 files changed

+35
-37
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,8 @@ impl<'a, N: 'a + Notifier> ServerWithNotifier<'a, N> {
16721672
GpadlState::OfferedTearingDown => unreachable!(),
16731673
}
16741674
}
1675+
1676+
self.check_disconnected();
16751677
}
16761678

16771679
/// Initiates a state reset and a closing of all channels.

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

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,39 @@ impl<'a, N: 'a + Notifier> super::ServerWithNotifier<'a, N> {
184184
if let Some(saved) = saved.state {
185185
self.inner.state = saved.connection.restore()?;
186186

187+
// Restore server state, and resend server notifications if needed. If these notifications
188+
// were processed before the save, it's harmless as the values will be the same.
189+
let request = match self.inner.state {
190+
super::ConnectionState::Connecting {
191+
info,
192+
next_action: _,
193+
} => Some(super::ModifyConnectionRequest {
194+
version: Some(info.version.version as u32),
195+
interrupt_page: info.interrupt_page.into(),
196+
monitor_page: info.monitor_page.into(),
197+
target_message_vp: Some(info.target_message_vp),
198+
notify_relay: true,
199+
}),
200+
super::ConnectionState::Connected(info) => Some(super::ModifyConnectionRequest {
201+
version: None,
202+
monitor_page: info.monitor_page.into(),
203+
interrupt_page: info.interrupt_page.into(),
204+
target_message_vp: Some(info.target_message_vp),
205+
// If the save didn't happen while modifying, the relay doesn't need to be notified
206+
// of this info as it doesn't constitute a change, we're just restoring existing
207+
// connection state.
208+
notify_relay: info.modifying,
209+
}),
210+
// No action needed for these states; if disconnecting, check_disconnected will resend
211+
// the reset request if needed.
212+
super::ConnectionState::Disconnected
213+
| super::ConnectionState::Disconnecting { .. } => None,
214+
};
215+
216+
if let Some(request) = request {
217+
self.notifier.modify_connection(request)?;
218+
}
219+
187220
for saved_channel in saved.channels {
188221
self.inner.restore_one_channel(saved_channel)?;
189222
}
@@ -211,42 +244,6 @@ impl<'a, N: 'a + Notifier> super::ServerWithNotifier<'a, N> {
211244
self.inner.pending_messages.0.push_back(message.restore()?);
212245
}
213246

214-
// Restore server state, and resend server notifications if needed. If these notifications
215-
// were processed before the save, it's harmless as the values will be the same.
216-
let request = match self.inner.state {
217-
super::ConnectionState::Connecting {
218-
info,
219-
next_action: _,
220-
} => Some(super::ModifyConnectionRequest {
221-
version: Some(info.version.version as u32),
222-
interrupt_page: info.interrupt_page.into(),
223-
monitor_page: info.monitor_page.into(),
224-
target_message_vp: Some(info.target_message_vp),
225-
notify_relay: true,
226-
}),
227-
super::ConnectionState::Connected(info) => Some(super::ModifyConnectionRequest {
228-
version: None,
229-
monitor_page: info.monitor_page.into(),
230-
interrupt_page: info.interrupt_page.into(),
231-
target_message_vp: Some(info.target_message_vp),
232-
// If the save didn't happen while modifying, the relay doesn't need to be notified
233-
// of this info as it doesn't constitute a change, we're just restoring existing
234-
// connection state.
235-
notify_relay: info.modifying,
236-
}),
237-
// No action needed for these states; if disconnecting, check_disconnected will resend
238-
// the reset request if needed.
239-
super::ConnectionState::Disconnected | super::ConnectionState::Disconnecting { .. } => {
240-
None
241-
}
242-
};
243-
244-
if let Some(request) = request {
245-
self.notifier.modify_connection(request)?;
246-
}
247-
248-
self.check_disconnected();
249-
250247
Ok(())
251248
}
252249
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,6 @@ impl ServerTaskInner {
17111711
Update::Set(value) => Some(value),
17121712
};
17131713

1714-
// Force is used by restore because there may be restored channels in the open state.
17151714
// TODO: can this check be moved into channels.rs?
17161715
if self.channels.iter().any(|(_, c)| {
17171716
matches!(

0 commit comments

Comments
 (0)