blob: e057814a4536f4381538e85a55c91cb67f58c590 [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 {
zamiseck3afdaaf2022-03-28 11:26:09 -050097 using InvalidSignatureErr = sdbusplus::xyz::openbmc_project::
98 Software::Version::Error::InvalidSignature;
99 report<InvalidSignatureErr>();
Lei YU7ab55e22021-05-19 13:26:53 +0800100 // Stop the activation process, if fieldMode is enabled.
101 if (parent.control::FieldMode::fieldModeEnabled())
102 {
103 return softwareServer::Activation::activation(
104 softwareServer::Activation::Activations::Failed);
105 }
106 }
107#endif
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800108
Miguel Gomez21dad042020-06-26 20:54:48 +0000109 auto versionStr = parent.versions.find(versionId)->second->version();
110
111 if (!minimum_ship_level::verify(versionStr))
112 {
Miguel Gomez21dad042020-06-26 20:54:48 +0000113 using IncompatibleErr = sdbusplus::xyz::openbmc_project::Software::
114 Version::Error::Incompatible;
115 using Incompatible =
116 xyz::openbmc_project::Software::Version::Incompatible;
117
118 report<IncompatibleErr>(
119 prev_entry<Incompatible::MIN_VERSION>(),
120 prev_entry<Incompatible::ACTUAL_VERSION>(),
121 prev_entry<Incompatible::VERSION_PURPOSE>());
122 return softwareServer::Activation::activation(
123 softwareServer::Activation::Activations::Failed);
124 }
125
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500126 if (!activationProgress)
127 {
128 activationProgress =
129 std::make_unique<ActivationProgress>(bus, path);
130 }
131
132 if (!activationBlocksTransition)
133 {
134 activationBlocksTransition =
135 std::make_unique<ActivationBlocksTransition>(bus, path);
136 }
137
Thang Tranbee62432022-03-14 22:18:38 +0700138#ifdef HOST_BIOS_UPGRADE
139 auto purpose = parent.versions.find(versionId)->second->purpose();
140 if (purpose == VersionPurpose::Host)
141 {
142 // Enable systemd signals
143 subscribeToSystemdSignals();
144
145 // Set initial progress
146 activationProgress->progress(20);
147
148 // Initiate image writing to flash
149 flashWriteHost();
150
151 return softwareServer::Activation::activation(value);
152 }
153#endif
154
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500155 activationProgress->progress(10);
156
Adriana Kobylaka6963592018-09-07 14:13:29 -0500157 parent.freeSpace(*this);
Lei YUa7853ee2018-05-23 11:13:12 +0800158
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500159 // Enable systemd signals
160 Activation::subscribeToSystemdSignals();
161
Lei YUa7853ee2018-05-23 11:13:12 +0800162 flashWrite();
163
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500164#if defined UBIFS_LAYOUT || defined MMC_LAYOUT
Lei YUa7853ee2018-05-23 11:13:12 +0800165
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500166 return softwareServer::Activation::activation(value);
Lei YUa7853ee2018-05-23 11:13:12 +0800167
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500168#else // STATIC_LAYOUT
Lei YUa7853ee2018-05-23 11:13:12 +0800169
Lei YUd8c9eea2021-12-16 16:08:30 +0800170 if (parent.runningImageSlot == 0)
171 {
172 // On primary, update it as before
173 onFlashWriteSuccess();
174 return softwareServer::Activation::activation(
175 softwareServer::Activation::Activations::Active);
176 }
177 // On secondary, wait for the service to complete
Lei YUa7853ee2018-05-23 11:13:12 +0800178#endif
Saqib Khanb0774702017-05-23 16:02:41 -0500179 }
180 else
181 {
182 activationBlocksTransition.reset(nullptr);
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500183 activationProgress.reset(nullptr);
Saqib Khanb0774702017-05-23 16:02:41 -0500184 }
185 return softwareServer::Activation::activation(value);
186}
187
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500188void Activation::onFlashWriteSuccess()
189{
190 activationProgress->progress(100);
191
192 activationBlocksTransition.reset(nullptr);
193 activationProgress.reset(nullptr);
194
195 rwVolumeCreated = false;
196 roVolumeCreated = false;
197 ubootEnvVarsUpdated = false;
198 Activation::unsubscribeFromSystemdSignals();
199
Adriana Kobylak780220f2022-01-18 20:01:53 +0000200 auto flashId = parent.versions.find(versionId)->second->path();
201 storePurpose(flashId, parent.versions.find(versionId)->second->purpose());
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500202
203 if (!redundancyPriority)
204 {
205 redundancyPriority =
206 std::make_unique<RedundancyPriority>(bus, path, *this, 0);
207 }
208
209 // Remove version object from image manager
210 Activation::deleteImageManagerObject();
211
212 // Create active association
213 parent.createActiveAssociation(path);
214
215 // Create updateable association as this
216 // can be re-programmed.
217 parent.createUpdateableAssociation(path);
218
219 if (Activation::checkApplyTimeImmediate() == true)
220 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500221 info("Image Active and ApplyTime is immediate; rebooting BMC.");
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500222 Activation::rebootBmc();
223 }
224 else
225 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500226 info("BMC image ready; need reboot to get activated.");
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500227 }
228
229 activation(softwareServer::Activation::Activations::Active);
230}
231
Saqib Khanee13e832017-10-23 12:53:11 -0500232void Activation::deleteImageManagerObject()
233{
zamiseck0b1fd512021-12-02 10:56:51 -0600234 // Call the Delete object for <versionID> inside image_manager if the object
235 // has not already been deleted due to a successful update or Delete call
236 const std::string interface = std::string{VERSION_IFACE};
237 auto method = this->bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
238 MAPPER_BUSNAME, "GetObject");
239 method.append(path.c_str());
240 method.append(std::vector<std::string>({interface}));
241
242 std::map<std::string, std::vector<std::string>> response;
243
Adriana Kobylak3b6a4cd2018-12-10 13:45:09 -0600244 try
245 {
zamiseck0b1fd512021-12-02 10:56:51 -0600246 auto reply = bus.call(method);
247 reply.read(response);
248 auto it = response.find(VERSION_IFACE);
249 if (it != response.end())
250 {
251 auto deleteMethod = this->bus.new_method_call(
252 VERSION_BUSNAME, path.c_str(),
253 "xyz.openbmc_project.Object.Delete", "Delete");
254 try
255 {
256 bus.call_noreply(deleteMethod);
257 }
258 catch (const sdbusplus::exception::exception& e)
259 {
260 error(
261 "Error deleting image ({PATH}) from image manager: {ERROR}",
262 "PATH", path, "ERROR", e);
263 return;
264 }
265 }
Adriana Kobylak3b6a4cd2018-12-10 13:45:09 -0600266 }
Patrick Williams4ce901c2021-09-02 09:34:45 -0500267 catch (const sdbusplus::exception::exception& e)
Saqib Khanee13e832017-10-23 12:53:11 -0500268 {
zamiseck0b1fd512021-12-02 10:56:51 -0600269 error("Error in mapper method call for ({PATH}, {INTERFACE}: {ERROR}",
270 "ERROR", e, "PATH", path, "INTERFACE", interface);
Saqib Khanee13e832017-10-23 12:53:11 -0500271 }
zamiseck0b1fd512021-12-02 10:56:51 -0600272 return;
Saqib Khanee13e832017-10-23 12:53:11 -0500273}
274
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600275auto Activation::requestedActivation(RequestedActivations value)
276 -> RequestedActivations
Saqib Khanb0774702017-05-23 16:02:41 -0500277{
Michael Tritzbed88af2017-07-19 16:00:06 -0500278 rwVolumeCreated = false;
279 roVolumeCreated = false;
Adriana Kobylak166bdf32018-04-09 14:24:06 -0500280 ubootEnvVarsUpdated = false;
Michael Tritzbed88af2017-07-19 16:00:06 -0500281
Saqib Khanb0774702017-05-23 16:02:41 -0500282 if ((value == softwareServer::Activation::RequestedActivations::Active) &&
283 (softwareServer::Activation::requestedActivation() !=
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600284 softwareServer::Activation::RequestedActivations::Active))
Saqib Khanb0774702017-05-23 16:02:41 -0500285 {
286 if ((softwareServer::Activation::activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600287 softwareServer::Activation::Activations::Ready) ||
Saqib Khanb0774702017-05-23 16:02:41 -0500288 (softwareServer::Activation::activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600289 softwareServer::Activation::Activations::Failed))
Saqib Khanb0774702017-05-23 16:02:41 -0500290 {
291 Activation::activation(
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600292 softwareServer::Activation::Activations::Activating);
Saqib Khanb0774702017-05-23 16:02:41 -0500293 }
294 }
295 return softwareServer::Activation::requestedActivation(value);
296}
297
Saqib Khan4c1aec02017-07-06 11:46:13 -0500298uint8_t RedundancyPriority::priority(uint8_t value)
299{
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500300 // Set the priority value so that the freePriority() function can order
301 // the versions by priority.
302 auto newPriority = softwareServer::RedundancyPriority::priority(value);
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500303 parent.parent.savePriority(parent.versionId, value);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500304 parent.parent.freePriority(value, parent.versionId);
305 return newPriority;
Saqib Khan4c1aec02017-07-06 11:46:13 -0500306}
307
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500308uint8_t RedundancyPriority::sdbusPriority(uint8_t value)
Saqib Khanf0382c32017-10-24 13:36:22 -0500309{
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500310 parent.parent.savePriority(parent.versionId, value);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500311 return softwareServer::RedundancyPriority::priority(value);
Saqib Khanf0382c32017-10-24 13:36:22 -0500312}
313
Michael Tritzbed88af2017-07-19 16:00:06 -0500314void Activation::unitStateChange(sdbusplus::message::message& msg)
315{
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500316 if (softwareServer::Activation::activation() !=
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600317 softwareServer::Activation::Activations::Activating)
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500318 {
319 return;
320 }
321
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800322#ifdef HOST_BIOS_UPGRADE
323 auto purpose = parent.versions.find(versionId)->second->purpose();
324 if (purpose == VersionPurpose::Host)
325 {
326 onStateChangesBios(msg);
327 return;
328 }
329#endif
330
Adriana Kobylak3ce563a2018-06-06 16:41:15 -0500331 onStateChanges(msg);
Michael Tritzbed88af2017-07-19 16:00:06 -0500332
333 return;
334}
335
Lei YU90532252018-05-24 11:15:24 +0800336#ifdef WANT_SIGNATURE_VERIFY
337bool Activation::verifySignature(const fs::path& imageDir,
338 const fs::path& confDir)
339{
340 using Signature = phosphor::software::image::Signature;
341
342 Signature signature(imageDir, confDir);
343
344 return signature.verify();
345}
Lei YU90532252018-05-24 11:15:24 +0800346#endif
347
Saqib Khanf37cefc2017-09-12 08:44:41 -0500348void ActivationBlocksTransition::enableRebootGuard()
349{
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500350 info("BMC image activating - BMC reboots are disabled.");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500351
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600352 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
353 SYSTEMD_INTERFACE, "StartUnit");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500354 method.append("reboot-guard-enable.service", "replace");
355 bus.call_noreply(method);
356}
357
358void ActivationBlocksTransition::disableRebootGuard()
359{
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500360 info("BMC activation has ended - BMC reboots are re-enabled.");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500361
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600362 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
363 SYSTEMD_INTERFACE, "StartUnit");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500364 method.append("reboot-guard-disable.service", "replace");
365 bus.call_noreply(method);
366}
Michael Tritzbed88af2017-07-19 16:00:06 -0500367
Jayashankar Padatha0135602019-04-22 16:22:58 +0530368bool Activation::checkApplyTimeImmediate()
369{
370 auto service = utils::getService(bus, applyTimeObjPath, applyTimeIntf);
371 if (service.empty())
372 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500373 info("Error getting the service name for BMC image ApplyTime. "
374 "The BMC needs to be manually rebooted to complete the image "
375 "activation if needed immediately.");
Jayashankar Padatha0135602019-04-22 16:22:58 +0530376 }
377 else
378 {
379
380 auto method = bus.new_method_call(service.c_str(), applyTimeObjPath,
381 dbusPropIntf, "Get");
382 method.append(applyTimeIntf, applyTimeProp);
383
384 try
385 {
386 auto reply = bus.call(method);
387
Patrick Williams24048b52020-05-13 17:51:30 -0500388 std::variant<std::string> result;
Jayashankar Padatha0135602019-04-22 16:22:58 +0530389 reply.read(result);
Patrick Williamse883fb82020-05-13 11:38:55 -0500390 auto applyTime = std::get<std::string>(result);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530391 if (applyTime == applyTimeImmediate)
392 {
393 return true;
394 }
395 }
Patrick Williams4ce901c2021-09-02 09:34:45 -0500396 catch (const sdbusplus::exception::exception& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +0530397 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500398 error("Error in getting ApplyTime: {ERROR}", "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530399 }
400 }
401 return false;
402}
403
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800404#ifdef HOST_BIOS_UPGRADE
405void Activation::flashWriteHost()
406{
407 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
408 SYSTEMD_INTERFACE, "StartUnit");
409 auto biosServiceFile = "obmc-flash-host-bios@" + versionId + ".service";
410 method.append(biosServiceFile, "replace");
411 try
412 {
413 auto reply = bus.call(method);
414 }
Patrick Williams4ce901c2021-09-02 09:34:45 -0500415 catch (const sdbusplus::exception::exception& e)
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800416 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500417 error("Error in trying to upgrade Host Bios: {ERROR}", "ERROR", e);
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800418 report<InternalFailure>();
419 }
420}
421
422void Activation::onStateChangesBios(sdbusplus::message::message& msg)
423{
424 uint32_t newStateID{};
425 sdbusplus::message::object_path newStateObjPath;
426 std::string newStateUnit{};
427 std::string newStateResult{};
428
429 // Read the msg and populate each variable
430 msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
431
432 auto biosServiceFile = "obmc-flash-host-bios@" + versionId + ".service";
433
434 if (newStateUnit == biosServiceFile)
435 {
436 // unsubscribe to systemd signals
437 unsubscribeFromSystemdSignals();
438
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800439 if (newStateResult == "done")
440 {
441 // Set activation progress to 100
442 activationProgress->progress(100);
443
444 // Set Activation value to active
445 activation(softwareServer::Activation::Activations::Active);
446
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500447 info("Bios upgrade completed successfully.");
Lei YU16aa28a2021-05-07 10:17:30 +0800448 parent.biosVersion->version(
449 parent.versions.find(versionId)->second->version());
Lei YU25868182021-05-14 14:50:51 +0800450
451 // Delete the uploaded activation
Lei YU7d2fa142021-08-06 10:58:19 +0800452 boost::asio::post(getIOContext(), [this]() {
453 this->parent.erase(this->versionId);
Lei YU25868182021-05-14 14:50:51 +0800454 });
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800455 }
456 else if (newStateResult == "failed")
457 {
458 // Set Activation value to Failed
459 activation(softwareServer::Activation::Activations::Failed);
460
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500461 error("Bios upgrade failed.");
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800462 }
463 }
464
465 return;
466}
467
468#endif
469
Jayashankar Padatha0135602019-04-22 16:22:58 +0530470void Activation::rebootBmc()
471{
472 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
473 SYSTEMD_INTERFACE, "StartUnit");
474 method.append("force-reboot.service", "replace");
475 try
476 {
477 auto reply = bus.call(method);
478 }
Patrick Williams4ce901c2021-09-02 09:34:45 -0500479 catch (const sdbusplus::exception::exception& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +0530480 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500481 alert("Error in trying to reboot the BMC. The BMC needs to be manually "
482 "rebooted to complete the image activation. {ERROR}",
483 "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530484 report<InternalFailure>();
485 }
486}
487
Saqib Khanb0774702017-05-23 16:02:41 -0500488} // namespace updater
489} // namespace software
490} // namespace phosphor