blob: 8e71d8ccc0cb4ab9c0ef490fc463ebfd0fb99527 [file] [log] [blame]
Saqib Khanb0774702017-05-23 16:02:41 -05001#include "activation.hpp"
Gunnar Millsb0ce9962018-09-07 13:39:10 -05002
Lei YU1be8d502018-06-20 11:48:36 +08003#include "images.hpp"
Saqib Khan4c1aec02017-07-06 11:46:13 -05004#include "item_updater.hpp"
Miguel Gomez21dad042020-06-26 20:54:48 +00005#include "msl_verify.hpp"
Saqib Khan5d532672017-08-09 10:44:50 -05006#include "serialize.hpp"
Gunnar Millsb0ce9962018-09-07 13:39:10 -05007
Lei YU25868182021-05-14 14:50:51 +08008#include <boost/asio/io_context.hpp>
Lei YU7d2fa142021-08-06 10:58:19 +08009#include <boost/asio/post.hpp>
Jayashankar Padatha0135602019-04-22 16:22:58 +053010#include <phosphor-logging/elog-errors.hpp>
11#include <phosphor-logging/elog.hpp>
Patrick Williamsc9bb6422021-08-27 06:18:35 -050012#include <phosphor-logging/lg2.hpp>
Adriana Kobylakaea48f22018-07-10 10:20:56 -050013#include <sdbusplus/exception.hpp>
Jayashankar Padatha0135602019-04-22 16:22:58 +053014#include <xyz/openbmc_project/Common/error.hpp>
Miguel Gomez21dad042020-06-26 20:54:48 +000015#include <xyz/openbmc_project/Software/Version/error.hpp>
Saqib Khanb9da6632017-09-13 09:48:37 -050016
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060017#ifdef WANT_SIGNATURE_VERIFY
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060018#include "image_verify.hpp"
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060019#endif
20
Lei YU25868182021-05-14 14:50:51 +080021extern boost::asio::io_context& getIOContext();
22
Saqib Khanb0774702017-05-23 16:02:41 -050023namespace phosphor
24{
25namespace software
26{
27namespace updater
28{
29
30namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
31
Patrick Williamsc9bb6422021-08-27 06:18:35 -050032PHOSPHOR_LOG2_USING;
Saqib Khanb9da6632017-09-13 09:48:37 -050033using namespace phosphor::logging;
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060034using InternalFailure =
35 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
Jayashankar Padatha0135602019-04-22 16:22:58 +053036
37#ifdef WANT_SIGNATURE_VERIFY
Jayanth Othayoth9a9d7c22018-03-28 10:05:26 -050038namespace control = sdbusplus::xyz::openbmc_project::Control::server;
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060039#endif
40
Michael Tritzbed88af2017-07-19 16:00:06 -050041void Activation::subscribeToSystemdSignals()
42{
Adriana Kobylak2285fe02018-02-27 15:36:59 -060043 auto method = this->bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
44 SYSTEMD_INTERFACE, "Subscribe");
Adriana Kobylakaea48f22018-07-10 10:20:56 -050045 try
46 {
47 this->bus.call_noreply(method);
48 }
Patrick Williams4ce901c2021-09-02 09:34:45 -050049 catch (const sdbusplus::exception::exception& e)
Adriana Kobylakaea48f22018-07-10 10:20:56 -050050 {
51 if (e.name() != nullptr &&
52 strcmp("org.freedesktop.systemd1.AlreadySubscribed", e.name()) == 0)
53 {
54 // If an Activation attempt fails, the Unsubscribe method is not
55 // called. This may lead to an AlreadySubscribed error if the
56 // Activation is re-attempted.
57 }
58 else
59 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -050060 error("Error subscribing to systemd: {ERROR}", "ERROR", e);
Adriana Kobylakaea48f22018-07-10 10:20:56 -050061 }
62 }
Michael Tritzbed88af2017-07-19 16:00:06 -050063
64 return;
65}
66
Michael Tritzf2b5e0d2017-07-25 14:39:34 -050067void Activation::unsubscribeFromSystemdSignals()
68{
Adriana Kobylak2285fe02018-02-27 15:36:59 -060069 auto method = this->bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
70 SYSTEMD_INTERFACE, "Unsubscribe");
Jayashankar Padatha0135602019-04-22 16:22:58 +053071 try
72 {
73 this->bus.call_noreply(method);
74 }
Patrick Williams4ce901c2021-09-02 09:34:45 -050075 catch (const sdbusplus::exception::exception& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +053076 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -050077 error("Error unsubscribing from systemd signals: {ERROR}", "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +053078 }
Michael Tritzf2b5e0d2017-07-25 14:39:34 -050079
80 return;
81}
82
Adriana Kobylak2285fe02018-02-27 15:36:59 -060083auto Activation::activation(Activations value) -> Activations
Saqib Khanb0774702017-05-23 16:02:41 -050084{
Adriana Kobylak8bd84c82018-01-24 14:19:24 -060085 if ((value != softwareServer::Activation::Activations::Active) &&
86 (value != softwareServer::Activation::Activations::Activating))
Saqib Khan4c1aec02017-07-06 11:46:13 -050087 {
88 redundancyPriority.reset(nullptr);
89 }
90
Saqib Khanb0774702017-05-23 16:02:41 -050091 if (value == softwareServer::Activation::Activations::Activating)
92 {
Lei YU7ab55e22021-05-19 13:26:53 +080093#ifdef WANT_SIGNATURE_VERIFY
94 fs::path uploadDir(IMG_UPLOAD_DIR);
95 if (!verifySignature(uploadDir / versionId, SIGNED_IMAGE_CONF_PATH))
96 {
97 onVerifyFailed();
98 // Stop the activation process, if fieldMode is enabled.
99 if (parent.control::FieldMode::fieldModeEnabled())
100 {
101 return softwareServer::Activation::activation(
102 softwareServer::Activation::Activations::Failed);
103 }
104 }
105#endif
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800106
Miguel Gomez21dad042020-06-26 20:54:48 +0000107 auto versionStr = parent.versions.find(versionId)->second->version();
108
109 if (!minimum_ship_level::verify(versionStr))
110 {
111 using namespace phosphor::logging;
112 using IncompatibleErr = sdbusplus::xyz::openbmc_project::Software::
113 Version::Error::Incompatible;
114 using Incompatible =
115 xyz::openbmc_project::Software::Version::Incompatible;
116
117 report<IncompatibleErr>(
118 prev_entry<Incompatible::MIN_VERSION>(),
119 prev_entry<Incompatible::ACTUAL_VERSION>(),
120 prev_entry<Incompatible::VERSION_PURPOSE>());
121 return softwareServer::Activation::activation(
122 softwareServer::Activation::Activations::Failed);
123 }
124
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500125 if (!activationProgress)
126 {
127 activationProgress =
128 std::make_unique<ActivationProgress>(bus, path);
129 }
130
131 if (!activationBlocksTransition)
132 {
133 activationBlocksTransition =
134 std::make_unique<ActivationBlocksTransition>(bus, path);
135 }
136
Thang Tranbee62432022-03-14 22:18:38 +0700137#ifdef HOST_BIOS_UPGRADE
138 auto purpose = parent.versions.find(versionId)->second->purpose();
139 if (purpose == VersionPurpose::Host)
140 {
141 // Enable systemd signals
142 subscribeToSystemdSignals();
143
144 // Set initial progress
145 activationProgress->progress(20);
146
147 // Initiate image writing to flash
148 flashWriteHost();
149
150 return softwareServer::Activation::activation(value);
151 }
152#endif
153
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500154 activationProgress->progress(10);
155
Adriana Kobylaka6963592018-09-07 14:13:29 -0500156 parent.freeSpace(*this);
Lei YUa7853ee2018-05-23 11:13:12 +0800157
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500158 // Enable systemd signals
159 Activation::subscribeToSystemdSignals();
160
Lei YUa7853ee2018-05-23 11:13:12 +0800161 flashWrite();
162
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500163#if defined UBIFS_LAYOUT || defined MMC_LAYOUT
Lei YUa7853ee2018-05-23 11:13:12 +0800164
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500165 return softwareServer::Activation::activation(value);
Lei YUa7853ee2018-05-23 11:13:12 +0800166
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500167#else // STATIC_LAYOUT
Lei YUa7853ee2018-05-23 11:13:12 +0800168
Lei YUd8c9eea2021-12-16 16:08:30 +0800169 if (parent.runningImageSlot == 0)
170 {
171 // On primary, update it as before
172 onFlashWriteSuccess();
173 return softwareServer::Activation::activation(
174 softwareServer::Activation::Activations::Active);
175 }
176 // On secondary, wait for the service to complete
Lei YUa7853ee2018-05-23 11:13:12 +0800177#endif
Saqib Khanb0774702017-05-23 16:02:41 -0500178 }
179 else
180 {
181 activationBlocksTransition.reset(nullptr);
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500182 activationProgress.reset(nullptr);
Saqib Khanb0774702017-05-23 16:02:41 -0500183 }
184 return softwareServer::Activation::activation(value);
185}
186
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500187void Activation::onFlashWriteSuccess()
188{
189 activationProgress->progress(100);
190
191 activationBlocksTransition.reset(nullptr);
192 activationProgress.reset(nullptr);
193
194 rwVolumeCreated = false;
195 roVolumeCreated = false;
196 ubootEnvVarsUpdated = false;
197 Activation::unsubscribeFromSystemdSignals();
198
Adriana Kobylak780220f2022-01-18 20:01:53 +0000199 auto flashId = parent.versions.find(versionId)->second->path();
200 storePurpose(flashId, parent.versions.find(versionId)->second->purpose());
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500201
202 if (!redundancyPriority)
203 {
204 redundancyPriority =
205 std::make_unique<RedundancyPriority>(bus, path, *this, 0);
206 }
207
208 // Remove version object from image manager
209 Activation::deleteImageManagerObject();
210
211 // Create active association
212 parent.createActiveAssociation(path);
213
214 // Create updateable association as this
215 // can be re-programmed.
216 parent.createUpdateableAssociation(path);
217
218 if (Activation::checkApplyTimeImmediate() == true)
219 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500220 info("Image Active and ApplyTime is immediate; rebooting BMC.");
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500221 Activation::rebootBmc();
222 }
223 else
224 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500225 info("BMC image ready; need reboot to get activated.");
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500226 }
227
228 activation(softwareServer::Activation::Activations::Active);
229}
230
Saqib Khanee13e832017-10-23 12:53:11 -0500231void Activation::deleteImageManagerObject()
232{
zamiseck0b1fd512021-12-02 10:56:51 -0600233 // Call the Delete object for <versionID> inside image_manager if the object
234 // has not already been deleted due to a successful update or Delete call
235 const std::string interface = std::string{VERSION_IFACE};
236 auto method = this->bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
237 MAPPER_BUSNAME, "GetObject");
238 method.append(path.c_str());
239 method.append(std::vector<std::string>({interface}));
240
241 std::map<std::string, std::vector<std::string>> response;
242
Adriana Kobylak3b6a4cd2018-12-10 13:45:09 -0600243 try
244 {
zamiseck0b1fd512021-12-02 10:56:51 -0600245 auto reply = bus.call(method);
246 reply.read(response);
247 auto it = response.find(VERSION_IFACE);
248 if (it != response.end())
249 {
250 auto deleteMethod = this->bus.new_method_call(
251 VERSION_BUSNAME, path.c_str(),
252 "xyz.openbmc_project.Object.Delete", "Delete");
253 try
254 {
255 bus.call_noreply(deleteMethod);
256 }
257 catch (const sdbusplus::exception::exception& e)
258 {
259 error(
260 "Error deleting image ({PATH}) from image manager: {ERROR}",
261 "PATH", path, "ERROR", e);
262 return;
263 }
264 }
Adriana Kobylak3b6a4cd2018-12-10 13:45:09 -0600265 }
Patrick Williams4ce901c2021-09-02 09:34:45 -0500266 catch (const sdbusplus::exception::exception& e)
Saqib Khanee13e832017-10-23 12:53:11 -0500267 {
zamiseck0b1fd512021-12-02 10:56:51 -0600268 error("Error in mapper method call for ({PATH}, {INTERFACE}: {ERROR}",
269 "ERROR", e, "PATH", path, "INTERFACE", interface);
Saqib Khanee13e832017-10-23 12:53:11 -0500270 }
zamiseck0b1fd512021-12-02 10:56:51 -0600271 return;
Saqib Khanee13e832017-10-23 12:53:11 -0500272}
273
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600274auto Activation::requestedActivation(RequestedActivations value)
275 -> RequestedActivations
Saqib Khanb0774702017-05-23 16:02:41 -0500276{
Michael Tritzbed88af2017-07-19 16:00:06 -0500277 rwVolumeCreated = false;
278 roVolumeCreated = false;
Adriana Kobylak166bdf32018-04-09 14:24:06 -0500279 ubootEnvVarsUpdated = false;
Michael Tritzbed88af2017-07-19 16:00:06 -0500280
Saqib Khanb0774702017-05-23 16:02:41 -0500281 if ((value == softwareServer::Activation::RequestedActivations::Active) &&
282 (softwareServer::Activation::requestedActivation() !=
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600283 softwareServer::Activation::RequestedActivations::Active))
Saqib Khanb0774702017-05-23 16:02:41 -0500284 {
285 if ((softwareServer::Activation::activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600286 softwareServer::Activation::Activations::Ready) ||
Saqib Khanb0774702017-05-23 16:02:41 -0500287 (softwareServer::Activation::activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600288 softwareServer::Activation::Activations::Failed))
Saqib Khanb0774702017-05-23 16:02:41 -0500289 {
290 Activation::activation(
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600291 softwareServer::Activation::Activations::Activating);
Saqib Khanb0774702017-05-23 16:02:41 -0500292 }
293 }
294 return softwareServer::Activation::requestedActivation(value);
295}
296
Saqib Khan4c1aec02017-07-06 11:46:13 -0500297uint8_t RedundancyPriority::priority(uint8_t value)
298{
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500299 // Set the priority value so that the freePriority() function can order
300 // the versions by priority.
301 auto newPriority = softwareServer::RedundancyPriority::priority(value);
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500302 parent.parent.savePriority(parent.versionId, value);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500303 parent.parent.freePriority(value, parent.versionId);
304 return newPriority;
Saqib Khan4c1aec02017-07-06 11:46:13 -0500305}
306
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500307uint8_t RedundancyPriority::sdbusPriority(uint8_t value)
Saqib Khanf0382c32017-10-24 13:36:22 -0500308{
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500309 parent.parent.savePriority(parent.versionId, value);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500310 return softwareServer::RedundancyPriority::priority(value);
Saqib Khanf0382c32017-10-24 13:36:22 -0500311}
312
Michael Tritzbed88af2017-07-19 16:00:06 -0500313void Activation::unitStateChange(sdbusplus::message::message& msg)
314{
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500315 if (softwareServer::Activation::activation() !=
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600316 softwareServer::Activation::Activations::Activating)
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500317 {
318 return;
319 }
320
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800321#ifdef HOST_BIOS_UPGRADE
322 auto purpose = parent.versions.find(versionId)->second->purpose();
323 if (purpose == VersionPurpose::Host)
324 {
325 onStateChangesBios(msg);
326 return;
327 }
328#endif
329
Adriana Kobylak3ce563a2018-06-06 16:41:15 -0500330 onStateChanges(msg);
Michael Tritzbed88af2017-07-19 16:00:06 -0500331
332 return;
333}
334
Lei YU90532252018-05-24 11:15:24 +0800335#ifdef WANT_SIGNATURE_VERIFY
336bool Activation::verifySignature(const fs::path& imageDir,
337 const fs::path& confDir)
338{
339 using Signature = phosphor::software::image::Signature;
340
341 Signature signature(imageDir, confDir);
342
343 return signature.verify();
344}
345
346void Activation::onVerifyFailed()
347{
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500348 error("Error occurred during image validation");
Lei YU90532252018-05-24 11:15:24 +0800349 report<InternalFailure>();
350}
351#endif
352
Saqib Khanf37cefc2017-09-12 08:44:41 -0500353void ActivationBlocksTransition::enableRebootGuard()
354{
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500355 info("BMC image activating - BMC reboots are disabled.");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500356
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600357 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
358 SYSTEMD_INTERFACE, "StartUnit");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500359 method.append("reboot-guard-enable.service", "replace");
360 bus.call_noreply(method);
361}
362
363void ActivationBlocksTransition::disableRebootGuard()
364{
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500365 info("BMC activation has ended - BMC reboots are re-enabled.");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500366
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600367 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
368 SYSTEMD_INTERFACE, "StartUnit");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500369 method.append("reboot-guard-disable.service", "replace");
370 bus.call_noreply(method);
371}
Michael Tritzbed88af2017-07-19 16:00:06 -0500372
Jayashankar Padatha0135602019-04-22 16:22:58 +0530373bool Activation::checkApplyTimeImmediate()
374{
375 auto service = utils::getService(bus, applyTimeObjPath, applyTimeIntf);
376 if (service.empty())
377 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500378 info("Error getting the service name for BMC image ApplyTime. "
379 "The BMC needs to be manually rebooted to complete the image "
380 "activation if needed immediately.");
Jayashankar Padatha0135602019-04-22 16:22:58 +0530381 }
382 else
383 {
384
385 auto method = bus.new_method_call(service.c_str(), applyTimeObjPath,
386 dbusPropIntf, "Get");
387 method.append(applyTimeIntf, applyTimeProp);
388
389 try
390 {
391 auto reply = bus.call(method);
392
Patrick Williams24048b52020-05-13 17:51:30 -0500393 std::variant<std::string> result;
Jayashankar Padatha0135602019-04-22 16:22:58 +0530394 reply.read(result);
Patrick Williamse883fb82020-05-13 11:38:55 -0500395 auto applyTime = std::get<std::string>(result);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530396 if (applyTime == applyTimeImmediate)
397 {
398 return true;
399 }
400 }
Patrick Williams4ce901c2021-09-02 09:34:45 -0500401 catch (const sdbusplus::exception::exception& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +0530402 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500403 error("Error in getting ApplyTime: {ERROR}", "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530404 }
405 }
406 return false;
407}
408
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800409#ifdef HOST_BIOS_UPGRADE
410void Activation::flashWriteHost()
411{
412 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
413 SYSTEMD_INTERFACE, "StartUnit");
414 auto biosServiceFile = "obmc-flash-host-bios@" + versionId + ".service";
415 method.append(biosServiceFile, "replace");
416 try
417 {
418 auto reply = bus.call(method);
419 }
Patrick Williams4ce901c2021-09-02 09:34:45 -0500420 catch (const sdbusplus::exception::exception& e)
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800421 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500422 error("Error in trying to upgrade Host Bios: {ERROR}", "ERROR", e);
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800423 report<InternalFailure>();
424 }
425}
426
427void Activation::onStateChangesBios(sdbusplus::message::message& msg)
428{
429 uint32_t newStateID{};
430 sdbusplus::message::object_path newStateObjPath;
431 std::string newStateUnit{};
432 std::string newStateResult{};
433
434 // Read the msg and populate each variable
435 msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
436
437 auto biosServiceFile = "obmc-flash-host-bios@" + versionId + ".service";
438
439 if (newStateUnit == biosServiceFile)
440 {
441 // unsubscribe to systemd signals
442 unsubscribeFromSystemdSignals();
443
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800444 if (newStateResult == "done")
445 {
446 // Set activation progress to 100
447 activationProgress->progress(100);
448
449 // Set Activation value to active
450 activation(softwareServer::Activation::Activations::Active);
451
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500452 info("Bios upgrade completed successfully.");
Lei YU16aa28a2021-05-07 10:17:30 +0800453 parent.biosVersion->version(
454 parent.versions.find(versionId)->second->version());
Lei YU25868182021-05-14 14:50:51 +0800455
456 // Delete the uploaded activation
Lei YU7d2fa142021-08-06 10:58:19 +0800457 boost::asio::post(getIOContext(), [this]() {
458 this->parent.erase(this->versionId);
Lei YU25868182021-05-14 14:50:51 +0800459 });
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800460 }
461 else if (newStateResult == "failed")
462 {
463 // Set Activation value to Failed
464 activation(softwareServer::Activation::Activations::Failed);
465
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500466 error("Bios upgrade failed.");
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800467 }
468 }
469
470 return;
471}
472
473#endif
474
Jayashankar Padatha0135602019-04-22 16:22:58 +0530475void Activation::rebootBmc()
476{
477 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
478 SYSTEMD_INTERFACE, "StartUnit");
479 method.append("force-reboot.service", "replace");
480 try
481 {
482 auto reply = bus.call(method);
483 }
Patrick Williams4ce901c2021-09-02 09:34:45 -0500484 catch (const sdbusplus::exception::exception& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +0530485 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500486 alert("Error in trying to reboot the BMC. The BMC needs to be manually "
487 "rebooted to complete the image activation. {ERROR}",
488 "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530489 report<InternalFailure>();
490 }
491}
492
Saqib Khanb0774702017-05-23 16:02:41 -0500493} // namespace updater
494} // namespace software
495} // namespace phosphor