summaryrefslogtreecommitdiffstats
path: root/image_manager.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor: only untar onceHEADmasterLei YU2019-04-021-53/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | The code in processImage() execute "tar xf" twice, the first time to extract the MANIFEST, and the second time to extract the whole tarball. On a tarball without compression, it's OK. But if the tarball is compressed, it takes much longer time to de-compress the tarball for twice. This commit changes the behavior by: 1. Untar the whole tarball into a temp dir; 2. Parse the manifest as before; 3. If something is wrong, remove the temp dir as before; 4. If it's valid, rename the temp dir to the valid image dir. It also fixes an issue that it uses const_cast in mkdtemp, which is undefined behavior because the returned const char* shall be read-only, writing this memory could cause undefined behavior. Partially resovles openbmc/bmcweb#60 Tested: Verify the image upload works well, and it takes much less time on a gzip compressed tarball. Change-Id: I0af81acbd948e9c54d5d168c9f72e8ebbf8daebe Signed-off-by: Lei YU <mine260309@gmail.com>
* Rename Version::Errors to Image::ErrorsAdriana Kobylak2018-10-171-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The Version interface is a public interface, and errors are being added to it: https://gerrit.openbmc-project.xyz/#/c/openbmc/phosphor-dbus-interfaces/+/13836/ This conflicts with the internal Version errors, so rename the internal one to an Image namespace since that's not a public interface and make more sense since the errors deal with failures during image file extraction. Tested: Uploaded an invalid tar file (u-boot.bin) and the new Image::Error was created: "/xyz/openbmc_project/logging/entry/2": { "AdditionalData": [ "PATH=/tmp/images/u-boot.bin", "_PID=1348" ], "Description": "An internal BMC error occurred", "EventID": "None", "Id": 2, "Message": "xyz.openbmc_project.Software.Image.Error.UnTarFailure", Change-Id: I6f6c84e2ea782c8ebc952bba4d5cee6be232f08f Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* clang-format: Update to match docs repoGunnar Mills2018-09-111-12/+16
| | | | | | | | Update the .clang-format file. Now includes header sorting and updating PointerAlignment. Change-Id: I5c7690d8d83cdebe26ff3a73b90a2a8c17dd8054 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Clang 6 updatesGunnar Mills2018-09-071-1/+1
| | | | | | | Just some minor fixes. Change-Id: I000c456e51c62220d7a5fed8100cfc6c13ef9551 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Enable clang code formatAdriana Kobylak2018-03-021-22/+17
| | | | | Change-Id: Ia899858c11cff6e4fa26b820b35b1e5dca1b57df Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Fix error loggingAdriana Kobylak2018-02-131-14/+29
| | | | | | | | | | | | | | | | - 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>
* image_manager: Check if tmp dir exists before removeAdriana Kobylak2018-02-131-1/+10
| | | | | | | | | | | | | | | | | | There was an error seen where the version manager core dumped when it tried to remove the temporary directory after a manifest failure: phosphor-version-software-manager[1264]: Error No manifest file phosphor-version-software-manager[1264]: terminate called after throwing an instance of 'std::experimental::filesystem::v1::__cxx11::filesystem_error' phosphor-version-software-manager[1264]: what(): filesystem error: cannot remove all: No such file or directory [/tmp/images/imageKcwJFc] To prevent the core dump, check that the directory exists before trying to remove it. Create a journal error entry to aid debug since path should exist. Change-Id: Ifb47f9a44aa8835c8b7416c7e1a0e67c664d6160 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* BMC: Fix the delete implementation.Saqib Khan2017-12-061-32/+13
| | | | | | | | | | | | | | | | | | | - 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>
* Spelling fixes in image_manager.cppGunnar Mills2017-10-311-3/+3
| | | | | | | | | 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. Change-Id: Ia499821e053e2d4280cd74d4020eab6b2febe854 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Move duplicate image upload log inside image_managerSaqib Khan2017-10-251-8/+16
| | | | | | | | | | | | | | | The item_updater is called multiple times to createActivation object when a new image is uploaded. This ends up producing a log in the journal suggesting the image was already uploaded even if the image didn't exist before. Therefore moving the log inside the image_mananger so that its called once when the image is uploaded. Resolves openbmc/openbmc#2261 Change-Id: Ia6590a3a77ccb577c65803de3233b06e7bfb1320 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Style changes in image_manager.cppGunnar Mills2017-10-081-40/+31
| | | | | | | Style changes only. Change-Id: Ic2a8f5b012849da657af24724b3fc55c5efeb979 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Add checks for currently running bmc image before erasingEddie James2017-09-151-0/+9
| | | | | | | | - Check if the image to be erased is currently running on the BMC. If it is, fail to erase the image. Change-Id: Ief2ba2e5e16f6664eeb429699b826cae78ef9291 Signed-off-by: Eddie James <eajames@us.ibm.com>
* Fix problem requiring two Delete calls to remove an imageEddie James2017-09-121-4/+24
| | | | | | | | | | | | - 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>
* item_updater: Added erase methodLeonel Gonzalez2017-07-261-1/+4
| | | | | | | | | | | Implements Object.Delete, so item_updater deletes ReadWrite, ReadOnly partitions, and removes Version, and Activation from maps. Resolves openbmc/openbmc#1550 Change-Id: If6d08bc7d380d043c28a26570e4698201cd7f5b0 Signed-off-by: Leonel Gonzalez <lgonzalez@us.ibm.com>
* image_manager: Added erase methodLeonel Gonzalez2017-07-261-0/+16
| | | | | | | | Image manager deletes image, image directory, and the version from its map. Change-Id: Ica128927b706257eb8c4b28d3b9d2ac9ca397b91 Signed-off-by: Leonel Gonzalez <lgonzalez@us.ibm.com>
* Change image_manager.cpp to accept the correct purposeLeonel Gonzalez2017-06-261-17/+4
| | | | | Change-Id: If8961a8582f1d25fa4275d915795beb50366060f Signed-off-by: Leonel Gonzalez <lgonzalez@us.ibm.com>
* Move Active BMC version object to item_updater.Saqib Khan2017-06-261-1/+0
| | | | | | | | | - There needs to be only one version class for both BMC and PNOR images. Thus removing the BMCVERSION class and moving the functionality to MANAGER class. Change-Id: I6dda818960588cfd9ed345fe93068531efc7a877 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Remove unnecessary namespaceGunnar Mills2017-05-241-1/+1
| | | | | Change-Id: I69123c1c3ea66595d0a1deafbf2f8705fe58660e Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Add check for image dirGunnar Mills2017-05-241-0/+4
| | | | | | | If the image dir exists already, delete it. Change-Id: I36242ee50d8af828784efa54a46f92ca3e3c971f Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Create error log on failGunnar Mills2017-05-241-0/+33
| | | | | | | | Use elog to create error log on fail. Resolves openbmc/openbmc#1352 Change-Id: I1c362390110c5b3fcae3335a0bd0a7dd11540883 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Create version dbus objectGunnar Mills2017-05-241-3/+48
| | | | | | | | | | Read the version and purpose from the manifest. Compute the id from the version. Create the image dir, <IMAGE_UPLOAD_DIR>/<id>/. Create the version object with the version, purpose, id and image dir path. Change-Id: I6d2d710fb8eeeda085af8ab116f2dafc720a2ade Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Untar tarballGunnar Mills2017-05-241-0/+147
| | | | | | | | | Untar the tarball to the image dir. The image dir is <IMG_UPLOAD_DIR>/<id>/. The MANIFEST is first extracted, the version is read from the MANIFEST and used to compute the id. Change-Id: Ifed01e980202404e104ce7c20beb85ab23527913 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Call processImage from inotifyGunnar Mills2017-05-111-0/+18
Change-Id: I0b748f93f8e34552cef67616317c28660284ac99 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
OpenPOWER on IntegriCloud