From db302040877925a365ffa0df120d8c4977c12a35 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Fri, 14 Sep 2018 01:33:33 +0000 Subject: [PATCH 1/2] [syncd] setup warm reboot when requested and possible Signed-off-by: Ying Xie --- syncd/syncd.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index 64778f1b0c..0481692597 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -3589,6 +3589,9 @@ int syncd_main(int argc, char **argv) exit_and_notify(EXIT_FAILURE); } + sai_switch_api_t *sai_switch_api = NULL; + sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); + if (restartType == SYNCD_RESTART_TYPE_WARM) { const char *warmBootWriteFile = profile_get_value(0, SAI_KEY_WARM_BOOT_WRITE_FILE); @@ -3601,11 +3604,27 @@ int syncd_main(int argc, char **argv) restartType = SYNCD_RESTART_TYPE_COLD; } + else + { + SWSS_LOG_NOTICE("Warm Reboot requested, keeping data plane running"); + + sai_attribute_t attr; + + attr.id = SAI_SWITCH_ATTR_RESTART_WARM; + attr.value.booldata = true; + + status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); + + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to set SAI_SWITCH_ATTR_RESTART_WARM=true: %s, fall back to cold restart", + sai_serialize_status(status).c_str()); + restartType = SYNCD_RESTART_TYPE_COLD; + } + } } SWSS_LOG_NOTICE("Removing the switch gSwitchId=0x%lx", gSwitchId); - sai_switch_api_t *sai_switch_api = NULL; - sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); #ifdef SAI_SWITCH_ATTR_UNINIT_DATA_PLANE_ON_REMOVAL From bee3196bbed53afc585adbde24288d52a96fbe8a Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Tue, 25 Sep 2018 00:08:43 +0000 Subject: [PATCH 2/2] [syncd] rename restartType to shutdownType since it only controls shutdown Signed-off-by: Ying Xie --- syncd/syncd.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index 0481692597..31a5a829ce 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -3528,12 +3528,12 @@ int syncd_main(int argc, char **argv) SWSS_LOG_NOTICE("syncd started"); - syncd_restart_type_t restartType = SYNCD_RESTART_TYPE_COLD; + syncd_restart_type_t shutdownType = SYNCD_RESTART_TYPE_COLD; try { SWSS_LOG_NOTICE("before onSyncdStart"); - onSyncdStart(options.startType == SAI_WARM_BOOT); + onSyncdStart(false); SWSS_LOG_NOTICE("after onSyncdStart"); startNotificationsProcessingThread(); @@ -3565,7 +3565,7 @@ int syncd_main(int argc, char **argv) * lead to unable to find some objects. */ - restartType = handleRestartQuery(*restartQuery); + shutdownType = handleRestartQuery(*restartQuery); break; } else if (sel == flexCounter.get()) @@ -3592,7 +3592,7 @@ int syncd_main(int argc, char **argv) sai_switch_api_t *sai_switch_api = NULL; sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); - if (restartType == SYNCD_RESTART_TYPE_WARM) + if (shutdownType == SYNCD_RESTART_TYPE_WARM) { const char *warmBootWriteFile = profile_get_value(0, SAI_KEY_WARM_BOOT_WRITE_FILE); @@ -3602,7 +3602,7 @@ int syncd_main(int argc, char **argv) { SWSS_LOG_WARN("user requested warm shutdown but warmBootWriteFile is not specified, forcing cold shutdown"); - restartType = SYNCD_RESTART_TYPE_COLD; + shutdownType = SYNCD_RESTART_TYPE_COLD; } else { @@ -3619,7 +3619,7 @@ int syncd_main(int argc, char **argv) { SWSS_LOG_ERROR("Failed to set SAI_SWITCH_ATTR_RESTART_WARM=true: %s, fall back to cold restart", sai_serialize_status(status).c_str()); - restartType = SYNCD_RESTART_TYPE_COLD; + shutdownType = SYNCD_RESTART_TYPE_COLD; } } } @@ -3628,7 +3628,7 @@ int syncd_main(int argc, char **argv) #ifdef SAI_SWITCH_ATTR_UNINIT_DATA_PLANE_ON_REMOVAL - if (restartType == SYNCD_RESTART_TYPE_FAST) + if (shutdownType == SYNCD_RESTART_TYPE_FAST) { SWSS_LOG_NOTICE("Fast Reboot requested, keeping data plane running");