bmc: ItemUpdater: Erase tmp folder in erase()

When bmcweb's `redfish-updateservice-use-dbus` is enabled and
`software-update-dbus-interface` option is enabled for this repo,
firmware update to bios_active target via Redfish will be handled by
bmc/ItemUpdater class. During the verification to create new software
objects in `ItemUpdater::verifyAndCreateObjects()`,
`ItemUpdater::erase()` is registered as the erasing callback when
`.Delete` method is called for the software object.

However, in `ItemUpdater::erase()`, in terms of image data, it only
erases RO partition and persist data for BMC image. For BIOS image, it
leaves off the temporary image folder of the software entry under
`$IMG_UPLOAD_DIR` (aka `/tmp/images/`), which can lead to memory leak
issue if BIOS firmware update is performed multiple times without BMC
reboot.

This commit handles removing the temporary image folder in
`ItemUpdater::erase()` for non-BMC firmware image when
`useUpdateDBusInterface` is true, which means this ItemUpdater object is
created when `software-update-dbus-interface` option is enabled.

Tested:

1. Execute BIOS firmware upgrade via Redfish

token=`curl -k -H "Content-Type: application/json" -X POST \
https://${BMC_IP}/login -d '{"username" :  "root", "password" :  \
"0penBmc"}' | grep token | awk '{print $2;}' | tr -d '"'`

uri=$(curl -k -H "X-Auth-Token: $token" \
https://${BMC_IP}/redfish/v1/UpdateService | jq -r ' \
.MultipartHttpPushUri')

curl -k -H "X-Auth-Token: $token" \
-H "Content-Type:multipart/form-data" -X POST \
-F UpdateParameters="{\"Targets\":[\
"/redfish/v1/UpdateService/FirmwareInventory/bios_active\"], \
"@Redfish.OperationApplyTime\":\"OnReset\"};type=application/json"\
-F "UpdateFile=@${IMG_PATH}" https://${BMC_IP}${uri}

Expected that upon upgrade completion, the newly added BIOS software
entry is removed from D-Bus, and the image folder with the software
entry name under `/tmp/images/` is removed too.

Change-Id: I7208cf2381af7db75bfd3cec99b0b891efa91cc8
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
1 file changed
tree: b77802085c7028afb3c2a14543d54e0fd215111a
  1. bios/
  2. bmc/
  3. common/
  4. cpld/
  5. eeprom-device/
  6. i2c-vr/
  7. subprojects/
  8. test/
  9. .clang-format
  10. .clang-tidy
  11. .gitignore
  12. .shellcheck
  13. LICENSE
  14. meson.build
  15. meson.options
  16. OWNERS
  17. README.md
README.md

phosphor-bmc-code-mgmt

Phosphor BMC Code Management provides a set of system software management applications. More information can be found at Software Architecture

To Build

To build this package, do the following steps:

  1. meson build
  2. ninja -C build

To clean the repository run rm -r build.