mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-10-26 07:34:04 +03:00
host-validate: Improve CPU flags processing
Instead of relying on substring search, tokenize the input and process each CPU flag separately. This ensures CPU flag detection will continue to work correctly even if we start looking for CPU flags whose name might appear as part of other CPU flags' names. The result of processing is stored in a virBitmap, which means we don't have to parse /proc/cpuinfo in its entirety for each single CPU flag we want to check. Moreover, use of the newly-introduced virHostValidateCPUFlag enumeration ensures we don't go looking for random CPU flags which might actually be simple typos.
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
# define __VIRT_HOST_VALIDATE_COMMON_H__
|
||||
|
||||
# include "internal.h"
|
||||
# include "virutil.h"
|
||||
# include "virbitmap.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_HOST_VALIDATE_FAIL,
|
||||
@@ -32,6 +34,15 @@ typedef enum {
|
||||
VIR_HOST_VALIDATE_LAST,
|
||||
} virHostValidateLevel;
|
||||
|
||||
typedef enum {
|
||||
VIR_HOST_VALIDATE_CPU_FLAG_VMX = 0,
|
||||
VIR_HOST_VALIDATE_CPU_FLAG_SVM,
|
||||
|
||||
VIR_HOST_VALIDATE_CPU_FLAG_LAST,
|
||||
} virHostValidateCPUFlag;
|
||||
|
||||
VIR_ENUM_DECL(virHostValidateCPUFlag);
|
||||
|
||||
extern void virHostMsgSetQuiet(bool quietFlag);
|
||||
|
||||
extern void virHostMsgCheck(const char *prefix,
|
||||
@@ -53,7 +64,7 @@ extern int virHostValidateDeviceAccessible(const char *hvname,
|
||||
virHostValidateLevel level,
|
||||
const char *hint);
|
||||
|
||||
extern bool virHostValidateHasCPUFlag(const char *name);
|
||||
extern virBitmapPtr virHostValidateGetCPUFlags(void);
|
||||
|
||||
extern int virHostValidateLinuxKernel(const char *hvname,
|
||||
int version,
|
||||
|
||||
Reference in New Issue
Block a user