summaryrefslogtreecommitdiffstats
path: root/activation.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Code Update: Host ApplyTime supportJayashankar Padath2019-08-091-7/+73
| | | | | | | | | | | | | | | | | | | | Get the requested image apply time value provided through the UpdateService redfish schema. If the apply time value is Immediate, then host reboot will be triggered just after the new pnor image activation. The default apply time value is OnReset in which the new image remains at Active state and user has to manualy reboot the host for applying the new image. Tested: Verified that host is getting rebooted while doing a pnor code update if the apply time value is Immediate. Tested this use case at server power Off and Running scenarios. OnReset scenario was also tested in which new image remained at Active state as pnor code update application did not trigger the host reboot. Note: This change is applicable to ubi based systems (Witherspoon) Signed-off-by: Jayashankar Padath <jayashankar.padath@in.ibm.com> Change-Id: I74f73172626919b225efef43d9baacd64eadbf60
* Remove deprecated is_method_error codeAdriana Kobylak2019-06-031-24/+25
| | | | | | | | | | | | | 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 Tested: Code update with field mode enabled, and ran Delete while host powered on, to check things still worked as expected. Change-Id: I8ba8da32fe787c3151cc5be7cb9f55d1901e57cd Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Static layout: support image verificationLei YU2019-04-041-2/+3
| | | | | | | | | | | Add support of image verification for static layout PNOR code update. Tested: Verify the PNOR code update succeeds with valid-signed PNOR; and fails with invalid-signed PNOR or a PNOR tarball without signature. Change-Id: I1aafeb4e8e07eaa16c170f33f4f21940f7c9c146 Signed-off-by: Lei YU <mine260309@gmail.com>
* Refactor: Use hiomapd instead of mboxdLei YU2019-03-181-35/+2
| | | | | | | | | | | | | | mbox service is renamed to hiomapd and provides "Suspend" and "Resume" method calls, which is more appropriate for raw "cmd" calls. Use the new methods to suspend and resume hiomapd. Move "getService()" function into utils so it is shared by multiple files. Tested: Verify the reset works on Romulus Change-Id: I8f89de134b13126697bfc69a21a3148a01c34cca Signed-off-by: Lei YU <mine260309@gmail.com>
* Refactor: Fix issues found by cppcheckLei YU2019-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Resolve several issues found by cppcheck: [msl_verify.hpp:28]: (style) Class 'MinimumShipLevel' has a constructor with 1 argument that is not explicit. [ubi/watch.hpp:21]: (warning) Assignment of function parameter has no effect outside the function. Did you forget dereferencing it? [item_updater_main.cpp:22] -> [item_updater_main.cpp:49]: (style) Local variable rc shadows outer symbol [serialize.cpp:19]: (performance) Function parameter 'versionId' should be passed by const reference. [ubi/watch.hpp:43]: (style) Struct 'CustomFd' has a constructor with 1 argument that is not explicit. [serialize.cpp:52]: (performance) Function parameter 'versionId' should be passed by const reference. [serialize.cpp:116]: (performance) Function parameter 'versionId' should be passed by const reference. [activation.cpp:115] -> [activation.cpp:152]: (style) Local variable mapperResponseMsg shadows outer symbol [version.hpp:114]: (performance) Variable 'eraseCallback' is assigned in constructor body. Consider performing initialization in initialization list. [image_verify.hpp:53]: (style) Struct 'CustomFd' has a constructor with 1 argument that is not explicit. [ubi/item_updater_ubi.cpp:192]: (performance) Function parameter 'versionId' should be passed by const reference. [ubi/item_updater_ubi.cpp:203]: (performance) Function parameter 'versionId' should be passed by const reference. Tested: Verify the code compiles and cppcheck does not report the above issues. Change-Id: I096392a2a7a283fe198c9c29185125e61295e10f Signed-off-by: Lei YU <mine260309@gmail.com>
* Static layout: Implement PNOR code updateLei YU2019-03-131-2/+1
| | | | | | | | | | Implement the PNOR code update by pflash tool in openpower-pnor-update service, and update the related associations. Tested: Verify PNOR code update succeeds. Change-Id: I53781d6420071200ac2ed6837f7a79bf5e1162c2 Signed-off-by: Lei YU <mine260309@gmail.com>
* Refactor: Move serialize to ubiLei YU2019-03-081-1/+0
| | | | | | | | | | Functions in serialize are specific to UBI, move it to ubi dir. Tested: On the last commit of the patch series, run code update and factory reset on Witherspoon and all work fine. Change-Id: I9176e638d9f3bfe0d424b57f8da4667a751cb5bd Signed-off-by: Lei YU <mine260309@gmail.com>
* Refactor: Split Activation into common and ubiLei YU2019-03-081-156/+1
| | | | | | | | | | | | | | | | | Activations has a few functions coupled with ubi, split them into ubi/activation_ubi * Keep common code in activation. * Make start/finishActivation() pure virtual. * Move ubi specific code into ubi. * Move ubiVolumnCreated into ubi. * Make validateSignature() not inline, otherwise it gets compile error. Tested: On the last commit of the patch series, run code update and factory reset on Witherspoon and all work fine. Change-Id: I7c8a0de6b0be4b1e9814ea75fd802a014b4aacfc Signed-off-by: Lei YU <mine260309@gmail.com>
* Invoke Delete method to correct serviceLei YU2019-01-291-5/+22
| | | | | | | | | | | | | | | | | | | | When PNOR code update is finished, it needs to invoke Delete interface to xyz.openbmc_project.Software.Version service to delete the temporary files in /tmp/images. The code was using the first service from mapper call, and the first service may be org.open_power.Software.Host.Updater, which is itself, and this method call results in ELOOP error. Change the code to pick the correct service to invoke Delete method. Resovles: openbmc/openbmc#3311 Tested: Verify the temp files in /tmp/images/<versionID> is deleted after PNOR code update, and no ELOOP error occurs. Change-Id: I855db171a05db66a5e4540d662031c3d219d4a9e Signed-off-by: Lei YU <mine260309@gmail.com>
* std::variant: Fix forgotten conversionWilliam A. Kennington III2018-11-271-1/+1
| | | | | Change-Id: Ie802ac340ebc0fde965bd84e18d2af9391136626 Signed-off-by: William A. Kennington III <wak@google.com>
* clang-format: Update to match docs repoGunnar Mills2018-09-111-5/+9
| | | | | | | | Update the .clang-format file. Now includes header sorting and updating PointerAlignment. Change-Id: I7119c12f1cc0a461cb7e4576dff6a02dcc95cbc4 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* activation: Add error handling in deleteImageManagerObjectAdriana Kobylak2018-07-161-5/+22
| | | | | | | | | | | | | | | | Handle exceptions from the sdbusplus method call API. The call to Delete an object from the image manager fails with: sd_bus_call: System.Error.ELOOP: Too many levels of symbolic links Catch the error so the app doesn't core dump. Issue openbmc/openbmc#3311 will track root cause of the error. Tested: A PNOR code update operation succeeds without core dumps or error messages. Change-Id: Ib384a16436bbb0521d247b7b6157b8877db5a4cb Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* activation: Improve error handling in SubscribeGunnar Mills2018-07-161-2/+23
| | | | | | | | | | | | | | | | | | | | | | | 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. This is very similar to: https://gerrit.openbmc-project.xyz/#/c/11428/ Tested: Code updated an image. Change-Id: Ia35b7f2fc24c0b605692bc534c54e18742027061 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Use s.c_str() in log messagesJoseph Reynolds2018-05-311-3/+3
| | | | | | | | | | | | | Part of a series of commits that resolve openbmc 2905 Here is something funny: in item_updater.cpp:300 is a string and on line 316 it is const char*. It may be confusing to have the same variable name with two different related types. Tested: static_assert only Change-Id: I59556fc184ef1f1047bd8a76062598b7518c36ae Signed-off-by: Joseph Reynolds <jrey@us.ibm.com>
* PNOR Signature validation failure handling based on field modeJayanth Othayoth2018-04-301-12/+96
| | | | | | | | | | Added support to stop the codeupdate only for the fieldmode enabled systems, for signature validation failures. Resolves openbmc/openbmc#3047 Change-Id: Idf47b122a60d5d14e6e7f134d8067d20e09e7c76 Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
* Fix compilation issuesJayanth Othayoth2018-03-281-1/+2
| | | | | | | | -Added fix for squashFSImage file name print error. -Added fix for conf path name typo. Change-Id: Ic11509a16d5d7c35b1bbb191175a8f710e66caad Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
* Enabled PNOR signed image validationJayanth Othayoth2018-03-231-0/+32
| | | | | | | | | Enable signature validation during version activation based on the WANT_SIGNATURE_VERIFY flag. Change-Id: If8f4357553be9ed2fbcf86b4dddec768532a043a 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-51/+38
| | | | | Change-Id: I4490e930459a7eab6f6dd15198418c5314755d3f Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* PNOR: Fix the delete implementationSaqib Khan2017-12-051-40/+48
| | | | | | | | | | | | | | | | - In order to remove the delete object from functional image, the delete interface is moved inside the version class so that both item_updater and image_manager can make use of the same implementation. - To avoid having two delete objects attached to the same HOST version (item_updater and image_manager), we are now deleting the image_manager object once the activation is complete. Partially resolves openbmc/openbmc#2490 Change-Id: Ie515cc01d5f154e6e55b9a3fb71d831730cd46f6 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Host updater: Remove the Object.Delete interface from functional versionMichael Tritz2017-11-281-3/+35
| | | | | | | | | | | | | | | | | | | | This commit enhances the host updater by dynamically removing the Object.Delete interface from a host activation that is currently running. Once the host isn't running anymore, the interface is re-added so that the activation may be deleted. Additionally, isVersionFunctional() from the parent updater is exposed, since this function is needed to determine whether a given activation is currently running on the host. Add the Delete interface to all interfaces when the item updater starts up, because the chassis state would be off initially, and in the case where it automatically powers on because the BMC rebooted while the host was on, the chassis property signal would cause the Delete interface to be removed. Change-Id: I4afcc1ebe2e8a3ce212b426749295e79b68cac62 Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* Combine the creation of ro and rw partition in one service fileSaqib Khan2017-09-061-32/+8
| | | | | | | | - Use the combine ubimount service file that creates both rw and ro partition. Change-Id: I40438bc16ac4f5734a749b7bf218ea5c6f628339 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Create active associationGunnar Mills2017-09-051-0/+5
| | | | | | | | | | Create an association between an active image and the active image's version object. This change includes code to remove the active association if the image is deleted. Change-Id: Id5b2d353d7df05854b035641765e1066d64a3ef5 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Limit the number of Active pnor versionsSaqib Khan2017-08-191-0/+1
| | | | | | | | | | | | | | | | | | | - We need to limit the number of pnor versions because pnor chip has limited space. If we run out of space and the user tries another pnor code update then the update will fail. - Currently we can only hold two images on pnor at this point. As we continue to decrease the size of pnor image we will increment the number of active pnor chips we can hold. - This check will need to be removed once we have complete issue #1402 which will automatically monitor the flash usage and delete any image accordingly. Resolves openbmc/openbmc#2155 Change-Id: Id62ba8554fba1ddb78286f70b0c3482a7beb8a6b Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Remove symlink creation during code updateSaqib Khan2017-08-181-40/+0
| | | | | | | | | | | | - We have created a service file that updates the symlinks based on lowest priority while HOST is powering on. This prevents the case of someone mistakenly updating PNOR and symlinks while the HOST is already powered on. Resolves openbmc/openbmc#1847 Change-Id: Ib2f269e4be1ebb501aba9fa0c1c7204661a0afbf Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* item_updater: Ignore base version when trying to free up priority.Saqib Khan2017-08-161-1/+1
| | | | | | | | | | | | | - There is a bug in our code where a user can try to allocate the existing priority of a version to itself and this would cause all subsequent priorities to be incremented by 2 instead of 1. - By checking the base versionId we can skip the operation to free the priority of the base version since it will be reassigned. Resolves openbmc/openbmc#2075 Change-Id: Ice21d701bb2e964c5734273f4e8a3821b96f4830 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* PNOR Activation: Minor code-review fixesMichael Tritz2017-08-021-84/+85
| | | | | | | | | | | | | | | | | This commit follows openbmc/openbmc#1716, addressing a pair of minor issues raised in the code review process for that issue. In order to shorten and clarify the function Activation::activation(), much of the content is moved to a pair of private member functions. A few other miscellaneous cosmetic changes are made for similar reasons. Additionally, a function is added to unsubscribe activation objects from dbus signals after the completion of the activation process. Resolves openbmc/openbmc#1843 Change-Id: I815e3d70850aac1f870aa741b6415a7714696367 Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* PNOR: Restore RedundancyPriority on resetMichael Tritz2017-07-301-0/+2
| | | | | | | | | | | | | | | | | | This commit extends the functionality of the PNOR 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/openpower-pnor-code-mgmt/ using the Cereal library. Each time a priority value is modified, the value in the corresponding version file is adjusted. When the item updater resets, it reads back the priority values from these files. Resolves openbmc/openbmc#2040 Change-Id: I908431801e541a1e5b39bcf49ae057f7e340eecc Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* item_updater : Implementing Object.Delete for versionLeonel Gonzalez2017-07-281-0/+5
| | | | | Change-Id: If962dec1da2d2fe925374bb37f89ed23f04c5ab6 Signed-off-by: Leonel Gonzalez <lgonzalez@us.ibm.com>
* PNOR: Switch Software Version based on priority.Saqib Khan2017-07-251-28/+40
| | | | | | | | | If the user specifically sets the priority of a version to the lowest value, then we need to update the symlinks and change PNOR current version. Change-Id: I8bb46800e30ec0afd7726cceb8566915a48b5e88 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Activation: Reset service file booleans after activationMichael Tritz2017-07-251-0/+5
| | | | | | | | | | | | | | | | | | | | During the activation process, two booleans are used to keep track of the state of service files that are called as a part of the process. These booleans are left "true" at the end of the process and the activated image is still subscribed to systemd signals (to be addressed in openbmc/openbmc#1843), so the second half of activation runs again upon the state change of any service file. At that time, we attempt to set the value of an ActivationProgress parameter that doesn't exist, crashing the application. This commit simply resets the booleans to false at the end of activation, resolving this crash. Resolves openbmc/openbmc#1984 Change-Id: I6f77778c2d44c10757dd4aca5e846b9e09596957 Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* Activation: Implement ActivationProgress interfaceMichael Tritz2017-07-071-1/+20
| | | | | | | | | | | This commit implements the ActivationProgress interface, which maintains a value representing percentage completion of the activation process. This value is periodically updated throughout the process. Resolves openbmc/openbmc#1554 Change-Id: I7dafb32995c4c95d86e1cc17ca42065065eee2f4 Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* PNOR: implement Software RedundancyPriority interface.Saqib Khan2017-07-061-1/+5
| | | | | | | | | | | - Create override function for redundancepriority. - Update RedundancyPriority for image that holds that already holds the requested priority. Resolves openbmc/openbmc#1553 Change-Id: I1a5c35826c881f6e9e21550c664b033c6f4b4bc0 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* PNOR: Remove the BlocksTransition object when activation completesSaqib Khan2017-06-291-1/+2
| | | | | | | Resolves openbmc/openbmc#1841 Change-Id: If89b02a2ab318140c0b193c72edb2dcf2d3acbcf Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Activation: Wait for service files to completeMichael Tritz2017-06-281-63/+154
| | | | | | | | | | | | | | | | | The Activation process calls a pair of service files upon which later steps are dependent. These units take some time to run, so the later steps would fail. This commit subscribes the Activation object to systemd signals and puts the later steps on hold until the service files have finished running. Additionally, the service file used to move the squashfs to flash is moved into the activation process, so not all images that the user downloads are saved to flash. Resolves openbmc/openbmc#1716 Change-Id: Id3ecf6334e069f69c355f0c0e8901a93fd95d496 Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
* activation: Replace exists() with is_symlink()/is_directory()Adriana Kobylak2017-06-231-7/+7
| | | | | | | | | | | | | | | | | | When the symlink is pointing to a directory that doesn't exist, the exists() check returns false even though the symlink exists, causing the symlink to not be removed so a failure occurs when changing the symlink to point to a new version. Check instead via is_symlink which doesn't care if the target that the symlink is pointing at exists or not. This could happen when the user deletes the image that the symlink is pointing at before activating a new image. Also use is_directory() to check for directory existance. Change-Id: Id4548c2f3292b5460317951334d9151e2c4fbab7 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* RedundancyPriority: Override set property functionSaqib Khan2017-06-141-0/+5
| | | | | | | | Create override function so that actions can be taken based on value that the property is being set to. Change-Id: I875fe8238718efb6b4d6dcd9f9bf26a8bc4998f1 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* PNOR: Implement Software RedundancyPriority.interfaceSaqib Khan2017-06-051-0/+15
| | | | | | | | | | - 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 Change-Id: If4fdb466d3e0319b57a381c80e25457d689b8785 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Code update flow: Set properties and load squashfs on object creationAdriana Kobylak2017-05-241-29/+28
| | | | | | | | | | | | | | | | | Set the Activation properties during the code update flow and do some checkings: Only activate an image that has a value of Ready or Failed. Only validate an image if a corresponding object doesn't exist. Move the activating of the partitions from the RequestedActivation to the Activation function to have it in a central location, and set the Activation to Activating during that process. Load the squashfs image when the Activation object is created since the image can be deleted from the BMC and would not be able to be activated when requested. Change-Id: I7eba400ca29461e2f41a8d8889a9825572b98344 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Activation: Point active image to requested imageAdriana Kobylak2017-05-241-0/+48
| | | | | | | | | Once an image has been updated, point the current image to it. Closes openbmc/openbmc#1278 Change-Id: If21938283913d4b40cadf44952b2a530c9266812 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Mount a SquashFS image to a read-only partition on PNORSaqib Khan2017-05-051-0/+13
| | | | | | | | | | | | | | Creating a mount point for SquashFS image so that the pnor can access the image without explicitly copying the image on to the PNOR partitions. The contents of the SquashFS image will be under /media/pnor-ro-%i. Resolves openbmc/openbmc#1206 Change-Id: I68b8cf094f9abe192bd697ff32728c959cad26c5 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Activation: Create UBI volume on RequestedActivationAdriana Kobylak2017-04-271-0/+18
| | | | | | | | | When the RequestedActivation property is set to Active, call the ubimount service with the version id to create a ubi volume with the version id as its name. Change-Id: I0479cb7daa82c845ef87f319180f8c0e0d5535a5 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Activation: Create ActivationBlocksTransitionAdriana Kobylak2017-04-271-4/+18
| | | | | | | | Create ActivationBlocksTransition when the Activation property is set to Activating. Remove it when the property is set to anything else. Change-Id: I7a6a1921f040a2e738751de1a3a138be5869afda Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Activation: Override the set property functionsAdriana Kobylak2017-04-191-0/+27
Create override functions so that actions can be taken based on the value that the properties are being set to. Change-Id: I70e9519246662d516a109af91f4456fb4f001c4f Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
OpenPOWER on IntegriCloud