@@ -3528,12 +3528,12 @@ int syncd_main(int argc, char **argv)
35283528
35293529 SWSS_LOG_NOTICE (" syncd started" );
35303530
3531- syncd_restart_type_t restartType = SYNCD_RESTART_TYPE_COLD;
3531+ syncd_restart_type_t shutdownType = SYNCD_RESTART_TYPE_COLD;
35323532
35333533 try
35343534 {
35353535 SWSS_LOG_NOTICE (" before onSyncdStart" );
3536- onSyncdStart (options. startType == SAI_WARM_BOOT );
3536+ onSyncdStart (false );
35373537 SWSS_LOG_NOTICE (" after onSyncdStart" );
35383538
35393539 startNotificationsProcessingThread ();
@@ -3565,7 +3565,7 @@ int syncd_main(int argc, char **argv)
35653565 * lead to unable to find some objects.
35663566 */
35673567
3568- restartType = handleRestartQuery (*restartQuery);
3568+ shutdownType = handleRestartQuery (*restartQuery);
35693569 break ;
35703570 }
35713571 else if (sel == flexCounter.get ())
@@ -3589,7 +3589,10 @@ int syncd_main(int argc, char **argv)
35893589 exit_and_notify (EXIT_FAILURE);
35903590 }
35913591
3592- if (restartType == SYNCD_RESTART_TYPE_WARM)
3592+ sai_switch_api_t *sai_switch_api = NULL ;
3593+ sai_api_query (SAI_API_SWITCH, (void **)&sai_switch_api);
3594+
3595+ if (shutdownType == SYNCD_RESTART_TYPE_WARM)
35933596 {
35943597 const char *warmBootWriteFile = profile_get_value (0 , SAI_KEY_WARM_BOOT_WRITE_FILE);
35953598
@@ -3599,17 +3602,33 @@ int syncd_main(int argc, char **argv)
35993602 {
36003603 SWSS_LOG_WARN (" user requested warm shutdown but warmBootWriteFile is not specified, forcing cold shutdown" );
36013604
3602- restartType = SYNCD_RESTART_TYPE_COLD;
3605+ shutdownType = SYNCD_RESTART_TYPE_COLD;
3606+ }
3607+ else
3608+ {
3609+ SWSS_LOG_NOTICE (" Warm Reboot requested, keeping data plane running" );
3610+
3611+ sai_attribute_t attr;
3612+
3613+ attr.id = SAI_SWITCH_ATTR_RESTART_WARM;
3614+ attr.value .booldata = true ;
3615+
3616+ status = sai_switch_api->set_switch_attribute (gSwitchId , &attr);
3617+
3618+ if (status != SAI_STATUS_SUCCESS)
3619+ {
3620+ SWSS_LOG_ERROR (" Failed to set SAI_SWITCH_ATTR_RESTART_WARM=true: %s, fall back to cold restart" ,
3621+ sai_serialize_status (status).c_str ());
3622+ shutdownType = SYNCD_RESTART_TYPE_COLD;
3623+ }
36033624 }
36043625 }
36053626
36063627 SWSS_LOG_NOTICE (" Removing the switch gSwitchId=0x%lx" , gSwitchId );
3607- sai_switch_api_t *sai_switch_api = NULL ;
3608- sai_api_query (SAI_API_SWITCH, (void **)&sai_switch_api);
36093628
36103629#ifdef SAI_SWITCH_ATTR_UNINIT_DATA_PLANE_ON_REMOVAL
36113630
3612- if (restartType == SYNCD_RESTART_TYPE_FAST)
3631+ if (shutdownType == SYNCD_RESTART_TYPE_FAST)
36133632 {
36143633 SWSS_LOG_NOTICE (" Fast Reboot requested, keeping data plane running" );
36153634
0 commit comments