mirror of
https://github.com/ipmitool/ipmitool.git
synced 2026-01-23 15:12:19 +08:00
ID: 50 - ipmi_hpmfwupg needs a clean up
Rather major re-work of internal logic in HpmfwupgPreparationStage().
This commit is contained in:
parent
f4730e1f67
commit
968f5d6552
@ -602,13 +602,17 @@ int
|
||||
HpmfwupgPreparationStage(struct ipmi_intf *intf,
|
||||
struct HpmfwupgUpgradeCtx *pFwupgCtx, int option)
|
||||
{
|
||||
int componentId;
|
||||
int rc = HPMFWUPG_SUCCESS;
|
||||
struct HpmfwupgGetTargetUpgCapabilitiesCtx targetCapCmd;
|
||||
struct HpmfwupgImageHeader *pImageHeader = (struct HpmfwupgImageHeader*)
|
||||
pFwupgCtx->pImageData;
|
||||
/* Get device ID */
|
||||
rc = HpmfwupgGetDeviceId(intf, &pFwupgCtx->devId);
|
||||
/* Match current IPMC IDs with upgrade image */
|
||||
if (rc == HPMFWUPG_SUCCESS) {
|
||||
if (rc != HPMFWUPG_SUCCESS) {
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
/* Validate device ID */
|
||||
if (pImageHeader->deviceId == pFwupgCtx->devId.device_id) {
|
||||
/* Validate product ID */
|
||||
@ -631,8 +635,7 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
|
||||
rc = HPMFWUPG_ERROR;
|
||||
}
|
||||
} else {
|
||||
lprintf(LOG_NOTICE,
|
||||
"\n Invalid device ID %x",
|
||||
lprintf(LOG_NOTICE, "\n Invalid device ID %x",
|
||||
pFwupgCtx->devId.device_id);
|
||||
rc = HPMFWUPG_ERROR;
|
||||
}
|
||||
@ -642,7 +645,10 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
|
||||
* and dont care whether we have a different product Id. If the user says NO then
|
||||
* we need to just bail out from here
|
||||
*/
|
||||
if ((option & FORCE_MODE) || (option & VIEW_MODE)) {
|
||||
if (!((option & FORCE_MODE) || (option & VIEW_MODE))) {
|
||||
printf("\n\n Use \"force\" option for copying all the components\n");
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
printf("\n Image Information");
|
||||
printf("\n Device Id : 0x%x", pImageHeader->deviceId);
|
||||
printf("\n Prod Id : 0x%02x%02x",
|
||||
@ -661,14 +667,11 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
|
||||
pFwupgCtx->devId.manufacturer_id[0]);
|
||||
if (HpmGetUserInput("\n Continue ignoring DeviceID/ProductID/ManufacturingID (Y/N): ")) {
|
||||
rc = HPMFWUPG_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
printf("\n\n Use \"force\" option for copying all the components\n");
|
||||
}
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
}
|
||||
/* Validate earliest compatible revision */
|
||||
if (rc == HPMFWUPG_SUCCESS) {
|
||||
/* Validate major & minor revision */
|
||||
if (pImageHeader->compRevision[0] > pFwupgCtx->devId.fw_rev1
|
||||
|| (pImageHeader->compRevision[0] == pFwupgCtx->devId.fw_rev1
|
||||
@ -679,22 +682,21 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
|
||||
lprintf(LOG_NOTICE, " Not compatible with ");
|
||||
lprintf(LOG_NOTICE, " Version: Major: %d", pFwupgCtx->devId.fw_rev1);
|
||||
lprintf(LOG_NOTICE, " Minor: %x", pFwupgCtx->devId.fw_rev2);
|
||||
rc = HPMFWUPG_ERROR;
|
||||
}
|
||||
if (rc != HPMFWUPG_SUCCESS) {
|
||||
/* Confirming it once again */
|
||||
if ((option & FORCE_MODE) || (option & VIEW_MODE)) {
|
||||
if (!((option & FORCE_MODE) || (option & VIEW_MODE))) {
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
if (HpmGetUserInput("\n Continue IGNORING Earliest compatibility (Y/N): ")) {
|
||||
rc = HPMFWUPG_SUCCESS;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
}
|
||||
/* Get target upgrade capabilities */
|
||||
if (rc == HPMFWUPG_SUCCESS) {
|
||||
struct HpmfwupgGetTargetUpgCapabilitiesCtx targetCapCmd;
|
||||
rc = HpmfwupgGetTargetUpgCapabilities(intf, &targetCapCmd);
|
||||
if (rc == HPMFWUPG_SUCCESS) {
|
||||
if (rc != HPMFWUPG_SUCCESS) {
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
/* Copy response to context */
|
||||
memcpy(&pFwupgCtx->targetCap,
|
||||
&targetCapCmd.resp,
|
||||
@ -710,12 +712,12 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
|
||||
pImageHeader->components.ComponentBits.byte) {
|
||||
lprintf(LOG_NOTICE,
|
||||
"\n Some components present in the image file are not supported by the IPMC");
|
||||
rc = HPMFWUPG_ERROR;
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
/* Make sure the upgrade is desirable rigth now */
|
||||
if (pFwupgCtx->targetCap.GlobalCapabilities.bitField.fwUpgUndesirable == 1) {
|
||||
lprintf(LOG_NOTICE, "\n Upgrade undesirable at this moment");
|
||||
rc = HPMFWUPG_ERROR;
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
/* Get confimation from the user if he wants to continue when
|
||||
* service affected during upgrade
|
||||
@ -723,18 +725,14 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
|
||||
if (!(option & COMPARE_MODE)
|
||||
&& (pFwupgCtx->targetCap.GlobalCapabilities.bitField.servAffectDuringUpg == 1
|
||||
|| pImageHeader->imageCapabilities.bitField.servAffected == 1)) {
|
||||
if (HpmGetUserInput("\nServices may be affected during upgrade. Do you wish to continue? y/n ")) {
|
||||
if (HpmGetUserInput("\nServices may be affected during upgrade. Do you wish to continue? (y/n): ")) {
|
||||
rc = HPMFWUPG_SUCCESS;
|
||||
} else {
|
||||
rc = HPMFWUPG_ERROR;
|
||||
}
|
||||
}
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Get the general properties of each component present in image */
|
||||
if (rc == HPMFWUPG_SUCCESS) {
|
||||
int componentId;
|
||||
for (componentId = HPMFWUPG_COMPONENT_ID_0;
|
||||
componentId < HPMFWUPG_COMPONENT_ID_MAX;
|
||||
componentId++) {
|
||||
@ -755,7 +753,6 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user