hv: Move uuid_is_equal to util.h

This patch moves uuid_is_equal from vm_config.c to util.h as inline API.

Tracked-On: #6320
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
This commit is contained in:
Yifan Liu 2021-08-20 14:24:20 +08:00 committed by wenlingz
parent 32d6ead8de
commit 975ff33e01
3 changed files with 15 additions and 11 deletions

View File

@ -5,6 +5,7 @@
*/
#include <asm/vm_config.h>
#include <util.h>
/*
* @pre vm_id < CONFIG_MAX_VM_NUM
@ -23,16 +24,6 @@ uint8_t get_vm_severity(uint16_t vm_id)
return vm_configs[vm_id].severity;
}
bool uuid_is_equal(const uint8_t *uuid1, const uint8_t *uuid2)
{
uint64_t uuid1_h = *(const uint64_t *)uuid1;
uint64_t uuid1_l = *(const uint64_t *)(uuid1 + 8);
uint64_t uuid2_h = *(const uint64_t *)uuid2;
uint64_t uuid2_l = *(const uint64_t *)(uuid2 + 8);
return ((uuid1_h == uuid2_h) && (uuid1_l == uuid2_l));
}
/**
* return true if the input uuid is configured in VM
*

View File

@ -57,4 +57,17 @@ static inline uint8_t calculate_checksum8(const void *buf, uint32_t len)
return (uint8_t)(0x100U - calculate_sum8(buf, len));
}
/**
* @pre (uuid1 != NULL) && (uuid2 != NULL)
*/
static inline bool uuid_is_equal(const uint8_t *uuid1, const uint8_t *uuid2)
{
uint64_t uuid1_h = *(const uint64_t *)uuid1;
uint64_t uuid1_l = *(const uint64_t *)(uuid1 + 8);
uint64_t uuid2_h = *(const uint64_t *)uuid2;
uint64_t uuid2_l = *(const uint64_t *)(uuid2 + 8);
return ((uuid1_h == uuid2_h) && (uuid1_l == uuid2_l));
}
#endif /* UTIL_H */

View File

@ -8,6 +8,6 @@
#define size_t new_size_t
#include <stdio.h>
#undef size_t
#include <util.h>
bool uuid_is_equal(const uint8_t *uuid1, const uint8_t *uuid2);
bool sanitize_vm_config(void);