summaryrefslogtreecommitdiffstats
path: root/activation.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove deprecated is_method_error codeAdriana Kobylak2018-12-111-3/+5
| | | | | | | | | | The is_method_error() function is no longer needed, instead a try-catch block should be used instead. Reference: https://lists.ozlabs.org/pipermail/openbmc/2018-October/013696.html, Change-Id: I1919ea33fc18be2b8afd51fb1f85ddef15041e7c Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Fix being able to activate a Failed versionAdriana Kobylak2018-09-191-2/+2
| | | | | | | | | | | | | | | | | When an activation fails, the version is marked as Failed. On a subsequent activation, the bmc updater core dumps due to 2 issues during the freeSpace call: 1. The Failed activation doesn't have a Priority object, so default its priority to a large value. 2. If the subsequent activation is to the same version id, then freeSpace should not do an erase on it, because that removes the activations object that it's trying to activate. Tested: Verified that doing an activation after a version was marked as Failed did not core dump the updater anymore. Change-Id: Iba36497b53738e00283cfec55e8c666f943cd5d5 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* clang-format: Update to match docs repoGunnar Mills2018-09-111-2/+5
| | | | | | | | Update the .clang-format file. Now includes header sorting and updating PointerAlignment. Change-Id: I5c7690d8d83cdebe26ff3a73b90a2a8c17dd8054 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Move setting the priority U-Boot variable to ubiAdriana Kobylak2018-07-191-2/+2
| | | | | | | | | | | | | | | The service that sets the priority value is unique to the ubi layout because there is only one version at a time on the static layout. Move the calling of the service to the ubi implementation. Tested: - Witherspoon: Priorities are still set. - Romulus: The BMC.Updater app does not core dump with the latest sdbusplus changes due to calling a non-existent service. Change-Id: Ica1c68f00d5cb43c51ee09c5a3851613edf941d5 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Refactor of bmcImagesLei YU2018-07-171-0/+1
| | | | | | | | | | | | | | bmcImages were in image_verify.hpp but it is used not only in image verification, but elsewhere. Move it into a more generic header file, images.hpp, so it makes more clear that users of bmcImages include images.hpp instead of image_verify.hpp Tested: Verify the code pass the build. Change-Id: If9adf315eee9047d9d08ab93ed7c0ff3c97f7a1e Signed-off-by: Lei YU <mine260309@gmail.com>
* Verify signature for non ubifs imageLei YU2018-07-171-12/+33
| | | | | | | | | | | | | | Enable signature verification on non ubifs build. The code is the same for ubifs and non ubifs, so move related code into separated functions. Tested: Verify that the signature check happens during code update, and successfully updated the code when the image is valid; verify it fails to update in field mode when the image is modified. Change-Id: I81a536fb7ea05d804fa592c57bbed8f32f07a559 Signed-off-by: Lei YU <mine260309@gmail.com>
* Support non-ubifs layoutLei YU2018-07-171-0/+23
| | | | | | | | | | | | | | | | | Add ubifs_layout as config argument, so a build could select if it needs ubifs_layout feature or not. Add code to update non-ubifs layout image by 1. Putting the bmc image in /run/initramfs; 2. Set its state as Active when it is ready to update 3. Let user to initiate the reboot request Tested: Generate a tarball with Romulus bmc image and manifest, update it with REST API (image upload, activation, and reboot) Verify the code update works well in WebUI. Change-Id: I5b122211fafb7cb9d96ee67317db139ed0b7d0a7 Signed-off-by: Lei YU <mine260309@gmail.com>
* activation: Improve error handling in SubscribeAdriana Kobylak2018-07-101-1/+24
| | | | | | | | | | | | | | | | | | | | | | Handle exceptions from the sdbusplus method call_noreply API. The Activation constructor was subscribing to systemd signals, which would cause an "Already Subscribed" error when creating multiple Activation instances because the bus is common. There is no reason to subscribe to systemd signals in the constructor, since the signals are only triggered during the activation process. Move the Subscribe call to the activation process which calls Unsubscribe at the end. There's a scenario where there could still be an "Already Subscribed" error if the activation fails, so add error handling there. Tested: Verified code update worked with this change, and the app would not core dump with the latest sdbusplus changes. Change-Id: I065baca2586fa64c138d847187303464123cc01a Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* activation: Move out code that monitors for ubi servicesAdriana Kobylak2018-06-151-45/+1
| | | | | | | | | | | | Move the code that monitors for ubi services into the ubi subdirectory. Other filesystem layouts can just ignore the service monitoring by setting the *VolumeCreated variables to true. Tested: Verified code update on Witherspoon still worked. Change-Id: I135e66225d0e8d692d430efd864252b822b069db Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* activation: Create ubi write functionAdriana Kobylak2018-06-061-11/+1
| | | | | | | | | | | | | | | | | | | | | Move the code that creates the ubi volumes into a separate write flash function to make it easier to implement different flash write functions for other flash layouts. To implement a different write flash function: 1. Modify the Makefile.am file to include the desired code location. Ex: if UBI include ubi/Makefile.am.include else include <other>/Makefile.am.include 2. Implement the Activation::flashWrite in <other>/flash.cpp Tested: Verified code update still worked. Change-Id: Ide4d135695dad27e0dc1b5a776a276dfb2ca9aa6 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Revert "Revert "Wait for obmc-flash-bmc-updateubootvars@.service""Adriana Kobylak2018-04-091-20/+36
| | | | | | | | | | This reverts commit e24fd6f7deadddc2867b2c417590da0ff093e5e2. The code that waits for the service file to complete causes intermittent issues, so will be reverted. Change-Id: I830f8a2e4914694889c3626bb67bd1fe422e984d Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Revert "Wait for obmc-flash-bmc-updateubootvars@.service"Adriana Kobylak2018-04-061-36/+20
| | | | | | | | | | | | | | | | | | | | | This reverts commit 4c3edc911ba880f7643f15679018c436aa94e0aa The code now blocks until the updateubootvars service completes (https://gerrit.openbmc-project.xyz/#/c/9418/) so there is no need to monitor this service anymore. Tested: Verified that the activation still waits for the env vars to be upated before completing the activation process: Apr 06 16:58:07 witherspoon systemd[1]: Started Store read-only images 84fb16be to BMC storage. Apr 06 16:58:07 witherspoon systemd[1]: Starting Set U-Boot environment variable... Apr 06 16:58:08 witherspoon systemd[1]: Started Set U-Boot environment variable. Apr 06 16:58:08 witherspoon systemd[1]: Starting Updates the u-boot variable to point BMC version to 84fb16be... Apr 06 16:58:11 witherspoon systemd[1]: Started Updates the u-boot variable to point BMC version to 84fb16be. Apr 06 16:58:11 witherspoon phosphor-image-updater[1919]: BMC activation has ended - BMC reboots are re-enabled. Change-Id: I6b98c2136948ddd251c4070f697ce1eda66214d6 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Signature validation failure handling based on field modeJayanth Othayoth2018-03-301-3/+11
| | | | | | | | Added support to stop the codeupdate only for the fieldmode enabled systems, for signature validation failures. Change-Id: Icaea4c7c80eca42a22794bbb67d93b8a95058ab8 Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
* Spelling fixesGunnar Mills2018-03-231-1/+1
| | | | | | | | | | Spelling errors found using github.com/lucasdemarchi/codespell A tool to fix common misspellings. This tool is licensed under GNU General Public License, version 2. Tested: Built the repo Change-Id: I4fb378699d436e0c41adf80978f7cdaec12c6404 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Enabled Signed image validation in Item UpdaterJayanth Othayoth2018-03-141-0/+31
| | | | | | | | | Added build level support to enable/disable signed validation using WANT_SIGNATURE_VERIFY flag. Change-Id: I93bc72a69b877baa9df27272c0b20426069b7557 Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com> Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Enable clang code formatAdriana Kobylak2018-03-021-65/+39
| | | | | Change-Id: Ia899858c11cff6e4fa26b820b35b1e5dca1b57df Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* BMC: Block BMC reboots during Code UpdateSaqib Khan2018-02-271-0/+25
| | | | | | | | | | | | | | | | | | - Enable the service that blocks reboot within the constructor of ActivationBlockTransition, so that the user can't reboot BMC while code update is in progress. - Once the code update is complete the destructor of ActivationBlockTransition will disable any reboot guard that prevents user from rebooting the BMC. Tested: Verified that the user is unable to reboot during the activation process and that journal logs are present to indicate why the user is unable to reboot. Resolves openbmc/openbmc#1944 Change-Id: Ia149a76bcf093b011fe243fc609ae83358a0f933 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Call freeSpace() function before updateAdriana Kobylak2018-02-161-0/+2
| | | | | | | | | | | | | | | | | Add new function to delete version objects as part of the Activation. The code update service automatically removes the ubi volumes to make space, but it does not remove the dbus object associated with the removed volume. The side effect of leaving the dbus object is that when freePriority() is called at the end of the Activation, a new priority value is assigned to all version dbus objects (including the deleted one) which fills up the u-boot environment variables. Tested: Verified that after an Activation, there were only 2 priority values in the u-boot env variables instead of 3, and they corresponded to existing volumes. Change-Id: I41a7ea95eeea1c8a2cb8ce4b41671e77f5c42cac Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Fix error loggingAdriana Kobylak2018-02-131-1/+1
| | | | | | | | | | | | | | | | - The logging interfaces don't support std::string, so need to pass c-strings to the metadata fields, or the pointer address will be the one added to the log. - Log the name of the file uploaded to the BMC instead of the manifest path when there is a manifest error. The manifest path is always /tmp/imgXXXX/MANIFEST which doesn't help debug. - Check the status of the child process after waitpid returns. The execl call returns when there was an error executing execl, not if the command executed failed. This will catch when tar returns a non-0 return code. Change-Id: Ia4bd2666fc6beec28dee7e821d959a336800d282 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Wait for obmc-flash-bmc-updateubootvars@.serviceAdriana Kobylak2018-01-251-24/+41
| | | | | | | | | | | | | | | The service file obmc-flash-bmc-updateubootvars@.service updates the boot environment variables to point to the newly updated image. Need to wait for this service to finish before marking the update as complete. Otherwise the user may reboot the system while the env vars are being updated thinking that the update has completed because the Activation value would be set to Active. Resolves openbmc/openbmc#2764 Change-Id: Ic33cf62e46555c9925385bb5d9d28de9aeee85a1 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Avoid calling Activation repeatedly during updateAdriana Kobylak2018-01-241-10/+13
| | | | | | | | | | | | | | | | | | | | The Activation code monitors the systemd service files that create the volumes, and sets the value to Activating if the services are running, or Failed if they fail. This monitoring code checks the name of the service file for when it fails, but it wasn't checking it for when it succeeds, leading to any systemd file that finished to trigger calling the Activation function multiple times. Also avoid removing the Priority object if the requested Activation value is Activating, since that's what the value the monitoring code calls during the update. Part of openbmc/openbmc#2764 Change-Id: Ib6681ce5d63d184a2ee9ffe05c083e1085efd2ac Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Fix "Error in Deleting image from image manager"Adriana Kobylak2018-01-241-26/+2
| | | | | | | | | | | | | | | | | | | | When deleting the updated image from the Version object, the code would query the mapper to get the busname. This call would return 2 busnames, the one for the Activation object and the one for the Version object. Then the code would call Delete on the first busname on the list which would be the Activation one, causing an error because the running image can't be deleted from the Activation object. Instead of querying the mapper for all busnames of a path, and adding logic to figure out which one is the Version one, the updater already knows the Version busname, so just use that directly. Part of openbmc/openbmc#2764 Change-Id: Ia490e11c0fd312fe0c05279964c2cb0c4461ccb3 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* BMC: Fix the delete implementation.Saqib Khan2017-12-061-6/+44
| | | | | | | | | | | | | | | | | | | - Implement delete interface inside version class so that both item_updater and image_manager can share the same interface. This meant removing the delete interface from inside the activation class. - The delete is created as a separate object inside version, only if the image is non-functional. This helps remove the delete interface from a running BMC/HOST image. - As part of the activation process, the version from inside the image_manager is deleted and so is the version's tarfile from the image upload dir. Partially resolves openbmc/openbmc#2490 Change-Id: Ib35bf188df85ebd2277d3d9ad04300e434965eea Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Call update u-boot env once when a priority is changedAdriana Kobylak2017-10-301-34/+8
| | | | | | | | | | | | | | | | | | | | | | The recursive nature of calling the free priority function would trigger setting the u-boot env multiple times. Make a change so that the priorities are sorted and updated once. - Create a non-overriden priority setter function to be called by the free priority function and by the function that creates the dbus objects after a bmc reboot. There's no need to call to free the priorities after reboot since the priorities are preserved on the bmc, and if they're not they default to 0 or 255. - When a dbus request is made to update the priority, update the value, then call the free priority function, which will sort the versions by priority and bump the priority of any duplicate ones. Resolves openbmc/openbmc#2535 Change-Id: Ib92cc0ca6c4d5f6e986f3cde7156d63b53844b46 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* BMC Updater: Remove the Object.Delete interface from functional versionMichael Tritz2017-10-261-2/+2
| | | | | | | | | | | | | | | | | | This commit enhances the functionality of the BMC software updater. Previously, each BMC version uploaded to the system would implement the Object.Delete D-Bus interface, including the version currently running on the BMC. In principle, this is a pretty major issue - at best, the Delete would do nothing to the current version but throw an error, and at worst, it could partially remove it and cause problems. This commit fixes that problem by moving the Delete implementation into a separate object for each activation and removing that interface for the current version. Resolves openbmc/openbmc#2335 Change-Id: I721b7455c9fb309ecbb50f807aaa44a16d51ba5a Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* Update U-boot env variablesSaqib Khan2017-10-241-1/+35
| | | | | | | | | | | | - If the new priority is the lowest then set the uboot to point to that particular version - Otherwise reset the Uboot environment variable to find the version with the lowest priority and then set that in uboot. Resolves openbmc/openbmc#2512 Change-Id: Id27e78a85662e0ff2e941515bb467a43c6076d96 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Update Uboot environment variables when a version is deleted or updatedSaqib Khan2017-10-231-30/+1
| | | | | | | | | | | | - We need to update the uboot env variables to point to the version that has the lowest priority when the version with lowest priority gets deleted or when the version with lowest priority gets a higher priority Resolves openbmc/openbmc#2372 Change-Id: If43105c9ee2c3ada8aeb19939a428eb05e621ee9 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Style changes in activation.cppGunnar Mills2017-10-081-6/+6
| | | | | | | Style changes only. Change-Id: I29127c1fa45bbe24fd252fb7c0fe95fb229d0129 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* BMC: Update u-boot environment variable based on lowest prioritySaqib Khan2017-09-281-1/+35
| | | | | | | | | | | - If a BMC is set to the lowest priority then update the u-boot environment variables so that that system boots from that version on the next reboot. Resolves openbmc/openbmc#2284 Change-Id: If0b67b07496f602fa06607bd0685d6394cb8d9fd Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Fix problem requiring two Delete calls to remove an imageEddie James2017-09-121-0/+5
| | | | | | | | | | | | - Remove Delete inheritance and method from Version object. - Add Delete inheritance and method to Activation object. - Add a listener in the image Manager for deleted Versions and remove its 'backup' copy of the Version. Resolves openbmc/openbmc#2086 Change-Id: If41783319cf1ff5b840b747ba457d0570bc52918 Signed-off-by: Eddie James <eajames@us.ibm.com>
* Create active associationGunnar Mills2017-09-051-0/+3
| | | | | | | | | | Create an association between an active image and the active image's version object. Resolves openbmc/openbmc#2007 Change-Id: I4fd27235db97a3cee87d2da335245e00ec602fba Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* BMC: Store RedundancyPriority on System.Saqib Khan2017-08-201-0/+2
| | | | | | | | | | | | | | | This commit extends the functionality of the BMC software updater by preserving RedundancyPriority values through any kind of reset. This is accomplished by storing priority values in serial files in /var/lib/obmc/phosphor-bmc-code-mgmt/ using the Cereal library. Each time a priority value is modified, the value in the corresponding version file is adjusted. Resolves openbmc/openbmc#2125 Change-Id: Ie697279895bc5ff5fdef31fa88c78dc2bc63390a Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* BMC Activation: Implement ActivationProgress interfaceMichael Tritz2017-08-011-0/+22
| | | | | | | | | | | | | | This commit extends the BMC activation progress by implementing the generic ActivationProgress interface, in order to periodically update the user with the current status of the process. Dependent on openbmc/openbmc#2031 to avoid crashes in multiple image scenarios. Resolves openbmc/openbmc#2030 Change-Id: If52426ea1eae93f32166a255072f813d6a056172 Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* Miscellaneous improvements to activation/item updaterMichael Tritz2017-08-011-11/+23
| | | | | | | | | | | | | | | | | | | This commit slightly enhances and improves the item updater and the activation process, addressing a few issues that were raised in code review of openbmc/openbmc#1756 1.) Service file booleans used in activation are reset to false, to avoid a BMC-flavored issue in the vein of openbmc/openbmc#1984 2.) systemd constants used in multiple places are moved to configure.ac 3.) Activation objects are unsubscribed from systemd signals at the end of that process. Resolves openbmc/openbmc#2031 Change-Id: I573645b16bca28ac6bf3b173d5b4845205224e07 Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* Activation: Start service files and wait for completionMichael Tritz2017-07-211-18/+98
| | | | | | | | | | | | In this commit, the BMC activation flow is implemented. When the user starts an activation, two service files are called to create read-only and read-write volumes. Once these service files are finished running, activation is marked as complete. Resolves openbmc/openbmc#1756 Change-Id: I3874c2d04a1a2b07eea4e34789ba5ece0ff6979c Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* BMC: Implement Software RedundancyPriority.interfaceSaqib Khan2017-07-131-0/+28
| | | | | | | | | | | | | - Create Redundancy Priority interface after a successful PNOR update and set the priority. - Remove Redundancy Priority interface once the activation state changes from being Active. - Create override function for RedundancyPriority. Resolves openbmc/openbmc#1755 Change-Id: I160dc4a6cad243d58759c71bbeb218aab841cf7a Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Create Constructor for BMC ActivationSaqib Khan2017-06-021-0/+54
- Create Activation Block Transition - Create override functions so that actions can be taken based on the value that the properties are being set to. - Create ActivationBlockTransition when the Activating property is set to Activating. Remove it when the property is set to anything else. Change-Id: Id48d049cca54ae0bcbed6afe41e67e20e6a5e44c Signed-off-by: Saqib Khan <khansa@us.ibm.com>
OpenPOWER on IntegriCloud