@@ -117,6 +117,10 @@ void RebootThread::do_reboot(void) {
117
117
118
118
if (m_request.method () == RebootMethod::COLD) {
119
119
do_cold_reboot (s);
120
+ } else if (m_request.method () == RebootMethod::HALT) {
121
+ do_halt_reboot (s);
122
+ } else if (m_request.method () == RebootMethod::WARM) {
123
+ do_warm_reboot (s);
120
124
} else {
121
125
// This shouldn't be possible. Reference check_start_preconditions()
122
126
SWSS_LOG_ERROR (" Received unrecognized method type = %s" ,
@@ -163,6 +167,45 @@ void RebootThread::do_cold_reboot(swss::Select &s) {
163
167
// We shouldn't be here. Platform reboot should've killed us.
164
168
log_error_and_set_non_retry_failure (" platform failed to reboot" );
165
169
170
+ // Set critical state
171
+ // m_critical_interface.report_critical_state("platform failed to reboot");
172
+ return ;
173
+ }
174
+
175
+ void RebootThread::do_halt_reboot (swss::Select &s) {
176
+ SWSS_LOG_ENTER ();
177
+ SWSS_LOG_NOTICE (" Sending halt reboot request to platform" );
178
+ if (send_dbus_reboot_request () == Progress::EXIT_EARLY) {
179
+ return ;
180
+ }
181
+
182
+ // Wait for platform to reboot. If we return, reboot failed.
183
+ // Logging, error status and monitoring for critical state are handled within.
184
+ if (wait_for_platform_reboot (s) == Progress::EXIT_EARLY) {
185
+ return ;
186
+ }
187
+
188
+ // We shouldn't be here. Platform reboot halt should've killed us.
189
+ log_error_and_set_non_retry_failure (" platform failed to halt the system" );
190
+
191
+ return ;
192
+ }
193
+
194
+ void RebootThread::do_warm_reboot (swss::Select &s) {
195
+ SWSS_LOG_ENTER ();
196
+ SWSS_LOG_NOTICE (" Sending warm reboot request to platform" );
197
+ if (send_dbus_reboot_request () == Progress::EXIT_EARLY) {
198
+ return ;
199
+ }
200
+
201
+ // Wait for warm reboot. If we return, reboot failed.
202
+ if (wait_for_platform_reboot (s) == Progress::EXIT_EARLY) {
203
+ return ;
204
+ }
205
+
206
+ // We shouldn't be here. Platform reboot should've killed us.
207
+ log_error_and_set_non_retry_failure (" failed to warm reboot" );
208
+
166
209
return ;
167
210
}
168
211
@@ -184,9 +227,19 @@ bool RebootThread::check_start_preconditions(const RebootRequest &request,
184
227
response.json_string = " RebootThread: can't Start while active" ;
185
228
response.status = swss::StatusCode::SWSS_RC_IN_USE;
186
229
} else if (request.method () != RebootMethod::COLD &&
230
+ request.method () != RebootMethod::HALT &&
187
231
request.method () != RebootMethod::WARM) {
188
232
response.json_string = " RebootThread: Start rx'd unsupported method" ;
189
233
response.status = swss::StatusCode::SWSS_RC_INVALID_PARAM;
234
+ } else if (request.method () == RebootMethod::WARM) {
235
+ if (m_status.get_last_reboot_status () ==
236
+ RebootStatus_Status::RebootStatus_Status_STATUS_FAILURE) {
237
+ // If the last reboot failed with a non-retriable failure, don't retry.
238
+ // But, we will allow a cold boot to recover.
239
+ response.json_string =
240
+ " RebootThread: last WARM reboot failed with non-retriable failure" ;
241
+ response.status = swss::StatusCode::SWSS_RC_FAILED_PRECONDITION;
242
+ }
190
243
} else if (request.delay () != 0 ) {
191
244
response.json_string = " RebootThread: delayed start not supported" ;
192
245
response.status = swss::StatusCode::SWSS_RC_INVALID_PARAM;
0 commit comments