mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 10:37:22 +00:00
ID: 70 - Fixes and updates for ipmitool hpm
Update HpmfwupgPreUpgradeCheck to check if the Aux version is also different when it compares the Image version to the active and rollback versions. Fixed the indenting and style of HpmfwupgPreUpgradeCheck to make it more readable. Commit for Dan Gora
This commit is contained in:
parent
2db7f5f6b9
commit
bf8acad458
@ -1019,7 +1019,6 @@ typedef struct _VERSIONINFO
|
||||
unsigned char imageAux[4];
|
||||
unsigned char coldResetRequired;
|
||||
unsigned char rollbackSupported;
|
||||
unsigned char skipUpgrade;
|
||||
char descString[15];
|
||||
}VERSIONINFO, *PVERSIONINFO;
|
||||
|
||||
@ -1851,6 +1850,37 @@ int HpmfwupgPreparationStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx*
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int image_version_upgradable(VERSIONINFO *pVersionInfo)
|
||||
{
|
||||
/* If the image and active target versions are different, then
|
||||
* upgrade */
|
||||
if ((pVersionInfo->imageMajor != pVersionInfo->targetMajor) ||
|
||||
(pVersionInfo->imageMinor != pVersionInfo->targetMinor) ||
|
||||
(pVersionInfo->imageAux[0] != pVersionInfo->targetAux[0]) ||
|
||||
(pVersionInfo->imageAux[1] != pVersionInfo->targetAux[1]) ||
|
||||
(pVersionInfo->imageAux[2] != pVersionInfo->targetAux[2]) ||
|
||||
(pVersionInfo->imageAux[3] != pVersionInfo->targetAux[3]))
|
||||
return (1);
|
||||
|
||||
/* If the image and active target versions are the same and rollback
|
||||
* is not supported, then there's nothing to do, skip the upgrade */
|
||||
if (!pVersionInfo->rollbackSupported)
|
||||
return (0);
|
||||
|
||||
/* If the image and rollback target versions are different, then
|
||||
* go ahead and upgrade */
|
||||
if ((pVersionInfo->imageMajor != pVersionInfo->rollbackMajor) ||
|
||||
(pVersionInfo->imageMinor != pVersionInfo->rollbackMinor) ||
|
||||
(pVersionInfo->imageAux[0] != pVersionInfo->rollbackAux[0]) ||
|
||||
(pVersionInfo->imageAux[1] != pVersionInfo->rollbackAux[1]) ||
|
||||
(pVersionInfo->imageAux[2] != pVersionInfo->rollbackAux[2]) ||
|
||||
(pVersionInfo->imageAux[3] != pVersionInfo->rollbackAux[3]))
|
||||
return (1);
|
||||
|
||||
/* Image and rollback target versions are the same too, skip it */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Function Name: HpmfwupgPreUpgradeCheck
|
||||
@ -1860,48 +1890,39 @@ int HpmfwupgPreparationStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx*
|
||||
* is same as target version.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwupgCtx,
|
||||
int componentToUpload,int option)
|
||||
int HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf,
|
||||
struct HpmfwupgUpgradeCtx* pFwupgCtx,
|
||||
int componentToUpload, int option)
|
||||
{
|
||||
int rc = HPMFWUPG_SUCCESS;
|
||||
unsigned char* pImagePtr;
|
||||
struct HpmfwupgActionRecord* pActionRecord;
|
||||
unsigned int actionsSize;
|
||||
struct HpmfwupgActionRecord *pActionRecord;
|
||||
int flagColdReset = FALSE;
|
||||
struct HpmfwupgImageHeader* pImageHeader = (struct HpmfwupgImageHeader*)
|
||||
pFwupgCtx->pImageData;
|
||||
struct HpmfwupgImageHeader *pImageHeader;
|
||||
|
||||
pImageHeader = (struct HpmfwupgImageHeader*) pFwupgCtx->pImageData;
|
||||
|
||||
/* Put pointer after image header */
|
||||
pImagePtr = (unsigned char*)
|
||||
(pFwupgCtx->pImageData + sizeof(struct HpmfwupgImageHeader) +
|
||||
pImageHeader->oemDataLength + sizeof(unsigned char)/*checksum*/);
|
||||
pImageHeader->oemDataLength + sizeof(unsigned char)/*chksum*/);
|
||||
|
||||
/* Deternime actions size */
|
||||
actionsSize = pFwupgCtx->imageSize - sizeof(struct HpmfwupgImageHeader);
|
||||
|
||||
if (option & VIEW_MODE)
|
||||
{
|
||||
if (option & VIEW_MODE) {
|
||||
HpmDisplayVersionHeader(TARGET_VER|ROLLBACK_VER|IMAGE_VER);
|
||||
}
|
||||
|
||||
/* Perform actions defined in the image */
|
||||
while( ( pImagePtr < (pFwupgCtx->pImageData + pFwupgCtx->imageSize -
|
||||
HPMFWUPG_MD5_SIGNATURE_LENGTH)) &&
|
||||
( rc == HPMFWUPG_SUCCESS) )
|
||||
{
|
||||
while (pImagePtr < (pFwupgCtx->pImageData + pFwupgCtx->imageSize -
|
||||
HPMFWUPG_MD5_SIGNATURE_LENGTH)) {
|
||||
/* Get action record */
|
||||
pActionRecord = (struct HpmfwupgActionRecord*)pImagePtr;
|
||||
|
||||
/* Validate action record checksum */
|
||||
if ( HpmfwupgCalculateChecksum((unsigned char*)pActionRecord,
|
||||
sizeof(struct HpmfwupgActionRecord)) != 0 )
|
||||
{
|
||||
if (HpmfwupgCalculateChecksum((unsigned char*)pActionRecord,
|
||||
sizeof(struct HpmfwupgActionRecord)) != 0) {
|
||||
lprintf(LOG_NOTICE," Invalid Action record.");
|
||||
rc = HPMFWUPG_ERROR;
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
|
||||
if ( rc == HPMFWUPG_SUCCESS )
|
||||
{
|
||||
switch( pActionRecord->actionType )
|
||||
{
|
||||
case HPMFWUPG_ACTION_BACKUP_COMPONENTS:
|
||||
@ -1912,11 +1933,11 @@ int HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* p
|
||||
|
||||
case HPMFWUPG_ACTION_PREPARE_COMPONENTS:
|
||||
{
|
||||
if (componentToUpload != DEFAULT_COMPONENT_UPLOAD)
|
||||
{
|
||||
if (!(1<<componentToUpload & pActionRecord->components.ComponentBits.byte))
|
||||
{
|
||||
lprintf(LOG_NOTICE,"\nComponent Id given is not supported\n");
|
||||
if (componentToUpload != DEFAULT_COMPONENT_UPLOAD) {
|
||||
if (!((1 << componentToUpload) &
|
||||
pActionRecord->components.ComponentBits.byte)) {
|
||||
lprintf(LOG_NOTICE,
|
||||
"\nComponent Id given is not supported\n");
|
||||
return HPMFWUPG_ERROR;
|
||||
}
|
||||
}
|
||||
@ -1927,21 +1948,21 @@ int HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* p
|
||||
case HPMFWUPG_ACTION_UPLOAD_FIRMWARE:
|
||||
/* Upload all firmware blocks */
|
||||
{
|
||||
struct HpmfwupgFirmwareImage* pFwImage;
|
||||
unsigned char* pData;
|
||||
unsigned int firmwareLength = 0;
|
||||
unsigned char mode = 0;
|
||||
unsigned char componentId = 0x00;
|
||||
unsigned char componentIdByte = 0x00;
|
||||
struct HpmfwupgFirmwareImage *pFwImage;
|
||||
unsigned char *pData;
|
||||
unsigned int firmwareLength;
|
||||
unsigned char mode;
|
||||
unsigned char componentId;
|
||||
unsigned char componentIdByte;
|
||||
unsigned int upgrade_comp;
|
||||
VERSIONINFO *pVersionInfo;
|
||||
|
||||
struct HpmfwupgGetComponentPropertiesCtx getCompProp;
|
||||
|
||||
/* Save component ID on which the upload is done */
|
||||
componentIdByte = pActionRecord->components.ComponentBits.byte;
|
||||
|
||||
while ((componentIdByte>>=1)!=0)
|
||||
{
|
||||
componentId = 0;
|
||||
while ((componentIdByte >>= 1) !=0) {
|
||||
componentId++;
|
||||
}
|
||||
pFwupgCtx->componentId = componentId;
|
||||
@ -1949,7 +1970,8 @@ int HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* p
|
||||
pFwImage = (struct HpmfwupgFirmwareImage*)(pImagePtr +
|
||||
sizeof(struct HpmfwupgActionRecord));
|
||||
|
||||
pData = ((unsigned char*)pFwImage + sizeof(struct HpmfwupgFirmwareImage));
|
||||
pData = ((unsigned char*)pFwImage +
|
||||
sizeof(struct HpmfwupgFirmwareImage));
|
||||
|
||||
/* Get firmware length */
|
||||
firmwareLength = pFwImage->length[0];
|
||||
@ -1969,74 +1991,32 @@ int HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* p
|
||||
mode = TARGET_VER | IMAGE_VER;
|
||||
|
||||
if (pVersionInfo->coldResetRequired)
|
||||
{
|
||||
flagColdReset = TRUE;
|
||||
}
|
||||
pVersionInfo->skipUpgrade = FALSE;
|
||||
|
||||
if (option & FORCE_MODE_ALL)
|
||||
{
|
||||
/* user has given all to upload all the components on the command line */
|
||||
if(verbose) {
|
||||
lprintf(LOG_NOTICE,"Forcing ALL components");
|
||||
upgrade_comp = 0;
|
||||
if (option & FORCE_MODE_ALL) {
|
||||
upgrade_comp = 1;
|
||||
}
|
||||
else if ((option & FORCE_MODE_COMPONENT) &&
|
||||
(componentToUpload == componentId)) {
|
||||
upgrade_comp = 1;
|
||||
}
|
||||
else if( option & FORCE_MODE_COMPONENT )
|
||||
{
|
||||
if( componentToUpload != componentId )
|
||||
{
|
||||
if(verbose) {
|
||||
lprintf(LOG_NOTICE,"Forcing component %d skip", componentId);
|
||||
else if (image_version_upgradable(pVersionInfo)) {
|
||||
upgrade_comp = 1;
|
||||
}
|
||||
/* user has given the component Id to upload on the command line */
|
||||
pVersionInfo->skipUpgrade = TRUE;
|
||||
}
|
||||
else if(verbose)
|
||||
{
|
||||
lprintf(LOG_NOTICE,"Forcing component %d update", componentId);
|
||||
/* user has given the component Id to upload on the command line */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if
|
||||
(
|
||||
(pVersionInfo->imageMajor == pVersionInfo->targetMajor)
|
||||
&&
|
||||
(pVersionInfo->imageMinor == pVersionInfo->targetMinor))
|
||||
{
|
||||
|
||||
if (verbose)
|
||||
lprintf(LOG_NOTICE,"%s component %d",
|
||||
(upgrade_comp ? "Updating" : "Skipping"),
|
||||
componentId);
|
||||
|
||||
if (upgrade_comp)
|
||||
pFwupgCtx->compUpdateMask.ComponentBits.byte |=
|
||||
1 << componentId;
|
||||
|
||||
if (option & VIEW_MODE) {
|
||||
if (pVersionInfo->rollbackSupported)
|
||||
{
|
||||
/*If the Image Versions are same as Target Versions then check for the
|
||||
* rollback version*/
|
||||
if
|
||||
(
|
||||
(pVersionInfo->imageMajor == pVersionInfo->rollbackMajor)
|
||||
&&
|
||||
(pVersionInfo->imageMinor == pVersionInfo->rollbackMinor)
|
||||
)
|
||||
{
|
||||
/* This indicates that the Rollback version is also same as
|
||||
* Image version -- So now we must skip it */
|
||||
pVersionInfo->skipUpgrade = TRUE;
|
||||
}
|
||||
mode |= ROLLBACK_VER;
|
||||
}
|
||||
else
|
||||
{
|
||||
pVersionInfo->skipUpgrade = TRUE;
|
||||
}
|
||||
}
|
||||
if ( verbose ) {
|
||||
lprintf(LOG_NOTICE,"Component %d: %s", componentId , (pVersionInfo->skipUpgrade?"skipped":"to update"));
|
||||
}
|
||||
}
|
||||
if( pVersionInfo->skipUpgrade == FALSE )
|
||||
{
|
||||
pFwupgCtx->compUpdateMask.ComponentBits.byte |= 1<<componentId;
|
||||
}
|
||||
if (option & VIEW_MODE)
|
||||
{
|
||||
HpmDisplayVersion(mode,pVersionInfo);
|
||||
printf("\n");
|
||||
}
|
||||
@ -2044,22 +2024,21 @@ int HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* p
|
||||
}
|
||||
break;
|
||||
default:
|
||||
lprintf(LOG_NOTICE," Invalid Action type. Cannot continue");
|
||||
rc = HPMFWUPG_ERROR;
|
||||
lprintf(LOG_NOTICE,
|
||||
" Invalid Action type. Cannot continue");
|
||||
return HPMFWUPG_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (option & VIEW_MODE)
|
||||
{
|
||||
|
||||
if (option & VIEW_MODE) {
|
||||
HpmDisplayLine("-",71);
|
||||
if (flagColdReset)
|
||||
{
|
||||
if (flagColdReset) {
|
||||
fflush(stdout);
|
||||
lprintf(LOG_NOTICE,"(*) Component requires Payload Cold Reset");
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
return HPMFWUPG_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user