提交 57d52b24 编写于 作者: J Jiri Denemark

Replace union cpuData with virCPUData

上级 d87ca6ef
...@@ -130,7 +130,7 @@ cpuCompare(virCPUDefPtr host, ...@@ -130,7 +130,7 @@ cpuCompare(virCPUDefPtr host,
int int
cpuDecode(virCPUDefPtr cpu, cpuDecode(virCPUDefPtr cpu,
const union cpuData *data, const virCPUDataPtr data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred) const char *preferred)
...@@ -174,12 +174,12 @@ cpuDecode(virCPUDefPtr cpu, ...@@ -174,12 +174,12 @@ cpuDecode(virCPUDefPtr cpu,
int int
cpuEncode(virArch arch, cpuEncode(virArch arch,
const virCPUDefPtr cpu, const virCPUDefPtr cpu,
union cpuData **forced, virCPUDataPtr *forced,
union cpuData **required, virCPUDataPtr *required,
union cpuData **optional, virCPUDataPtr *optional,
union cpuData **disabled, virCPUDataPtr *disabled,
union cpuData **forbidden, virCPUDataPtr *forbidden,
union cpuData **vendor) virCPUDataPtr *vendor)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
...@@ -205,7 +205,7 @@ cpuEncode(virArch arch, ...@@ -205,7 +205,7 @@ cpuEncode(virArch arch,
void void
cpuDataFree(virArch arch, cpuDataFree(virArch arch,
union cpuData *data) virCPUDataPtr data)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
...@@ -228,7 +228,7 @@ cpuDataFree(virArch arch, ...@@ -228,7 +228,7 @@ cpuDataFree(virArch arch,
} }
union cpuData * virCPUDataPtr
cpuNodeData(virArch arch) cpuNodeData(virArch arch)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
...@@ -252,7 +252,7 @@ cpuNodeData(virArch arch) ...@@ -252,7 +252,7 @@ cpuNodeData(virArch arch)
virCPUCompareResult virCPUCompareResult
cpuGuestData(virCPUDefPtr host, cpuGuestData(virCPUDefPtr host,
virCPUDefPtr guest, virCPUDefPtr guest,
union cpuData **data, virCPUDataPtr *data,
char **msg) char **msg)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
...@@ -420,7 +420,7 @@ cpuUpdate(virCPUDefPtr guest, ...@@ -420,7 +420,7 @@ cpuUpdate(virCPUDefPtr guest,
int int
cpuHasFeature(virArch arch, cpuHasFeature(virArch arch,
const union cpuData *data, const virCPUDataPtr data,
const char *feature) const char *feature)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
......
...@@ -32,11 +32,12 @@ ...@@ -32,11 +32,12 @@
# include "cpu_ppc_data.h" # include "cpu_ppc_data.h"
union cpuData { typedef union _virCPUData virCPUData;
typedef virCPUData *virCPUDataPtr;
union _virCPUData {
struct cpuX86Data *x86; struct cpuX86Data *x86;
/* generic driver needs no data */
/* PowerPC driver need data*/
struct cpuPPCData ppc; struct cpuPPCData ppc;
/* generic driver needs no data */
}; };
...@@ -46,30 +47,30 @@ typedef virCPUCompareResult ...@@ -46,30 +47,30 @@ typedef virCPUCompareResult
typedef int typedef int
(*cpuArchDecode) (virCPUDefPtr cpu, (*cpuArchDecode) (virCPUDefPtr cpu,
const union cpuData *data, const virCPUDataPtr data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred); const char *preferred);
typedef int typedef int
(*cpuArchEncode) (const virCPUDefPtr cpu, (*cpuArchEncode) (const virCPUDefPtr cpu,
union cpuData **forced, virCPUDataPtr *forced,
union cpuData **required, virCPUDataPtr *required,
union cpuData **optional, virCPUDataPtr *optional,
union cpuData **disabled, virCPUDataPtr *disabled,
union cpuData **forbidden, virCPUDataPtr *forbidden,
union cpuData **vendor); virCPUDataPtr *vendor);
typedef void typedef void
(*cpuArchDataFree) (union cpuData *data); (*cpuArchDataFree) (virCPUDataPtr data);
typedef union cpuData * typedef virCPUDataPtr
(*cpuArchNodeData) (void); (*cpuArchNodeData) (void);
typedef virCPUCompareResult typedef virCPUCompareResult
(*cpuArchGuestData) (virCPUDefPtr host, (*cpuArchGuestData) (virCPUDefPtr host,
virCPUDefPtr guest, virCPUDefPtr guest,
union cpuData **data, virCPUDataPtr *data,
char **message); char **message);
typedef virCPUDefPtr typedef virCPUDefPtr
...@@ -83,7 +84,7 @@ typedef int ...@@ -83,7 +84,7 @@ typedef int
const virCPUDefPtr host); const virCPUDefPtr host);
typedef int typedef int
(*cpuArchHasFeature) (const union cpuData *data, (*cpuArchHasFeature) (const virCPUDataPtr data,
const char *feature); const char *feature);
...@@ -113,7 +114,7 @@ cpuCompare (virCPUDefPtr host, ...@@ -113,7 +114,7 @@ cpuCompare (virCPUDefPtr host,
extern int extern int
cpuDecode (virCPUDefPtr cpu, cpuDecode (virCPUDefPtr cpu,
const union cpuData *data, const virCPUDataPtr data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred); const char *preferred);
...@@ -121,24 +122,24 @@ cpuDecode (virCPUDefPtr cpu, ...@@ -121,24 +122,24 @@ cpuDecode (virCPUDefPtr cpu,
extern int extern int
cpuEncode (virArch arch, cpuEncode (virArch arch,
const virCPUDefPtr cpu, const virCPUDefPtr cpu,
union cpuData **forced, virCPUDataPtr *forced,
union cpuData **required, virCPUDataPtr *required,
union cpuData **optional, virCPUDataPtr *optional,
union cpuData **disabled, virCPUDataPtr *disabled,
union cpuData **forbidden, virCPUDataPtr *forbidden,
union cpuData **vendor); virCPUDataPtr *vendor);
extern void extern void
cpuDataFree (virArch arch, cpuDataFree (virArch arch,
union cpuData *data); virCPUDataPtr data);
extern union cpuData * extern virCPUDataPtr
cpuNodeData (virArch arch); cpuNodeData (virArch arch);
extern virCPUCompareResult extern virCPUCompareResult
cpuGuestData(virCPUDefPtr host, cpuGuestData(virCPUDefPtr host,
virCPUDefPtr guest, virCPUDefPtr guest,
union cpuData **data, virCPUDataPtr *data,
char **msg); char **msg);
extern char * extern char *
...@@ -159,7 +160,7 @@ cpuUpdate (virCPUDefPtr guest, ...@@ -159,7 +160,7 @@ cpuUpdate (virCPUDefPtr guest,
extern int extern int
cpuHasFeature(virArch arch, cpuHasFeature(virArch arch,
const union cpuData *data, const virCPUDataPtr data,
const char *feature); const char *feature);
......
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
static const virArch archs[] = { VIR_ARCH_ARMV7L }; static const virArch archs[] = { VIR_ARCH_ARMV7L };
static union cpuData * static virCPUDataPtr
ArmNodeData(void) ArmNodeData(void)
{ {
union cpuData *data; virCPUDataPtr data;
ignore_value(VIR_ALLOC(data)); ignore_value(VIR_ALLOC(data));
return data; return data;
...@@ -41,7 +41,7 @@ ArmNodeData(void) ...@@ -41,7 +41,7 @@ ArmNodeData(void)
static int static int
ArmDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED, ArmDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
const union cpuData *data ATTRIBUTE_UNUSED, const virCPUDataPtr data ATTRIBUTE_UNUSED,
const char **models ATTRIBUTE_UNUSED, const char **models ATTRIBUTE_UNUSED,
unsigned int nmodels ATTRIBUTE_UNUSED, unsigned int nmodels ATTRIBUTE_UNUSED,
const char *preferred ATTRIBUTE_UNUSED) const char *preferred ATTRIBUTE_UNUSED)
...@@ -50,7 +50,7 @@ ArmDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED, ...@@ -50,7 +50,7 @@ ArmDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
} }
static void static void
ArmDataFree(union cpuData *data) ArmDataFree(virCPUDataPtr data)
{ {
VIR_FREE(data); VIR_FREE(data);
} }
......
...@@ -301,7 +301,7 @@ ppcCompare(virCPUDefPtr host, ...@@ -301,7 +301,7 @@ ppcCompare(virCPUDefPtr host,
static int static int
ppcDecode(virCPUDefPtr cpu, ppcDecode(virCPUDefPtr cpu,
const union cpuData *data, const virCPUDataPtr data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred ATTRIBUTE_UNUSED) const char *preferred ATTRIBUTE_UNUSED)
...@@ -342,7 +342,7 @@ cleanup: ...@@ -342,7 +342,7 @@ cleanup:
static void static void
ppcDataFree(union cpuData *data) ppcDataFree(virCPUDataPtr data)
{ {
if (data == NULL) if (data == NULL)
return; return;
...@@ -351,10 +351,10 @@ ppcDataFree(union cpuData *data) ...@@ -351,10 +351,10 @@ ppcDataFree(union cpuData *data)
} }
#if defined(__powerpc__) || defined(__powerpc64__) #if defined(__powerpc__) || defined(__powerpc64__)
static union cpuData * static virCPUDataPtr
ppcNodeData(void) ppcNodeData(void)
{ {
union cpuData *data; virCPUDataPtr data;
if (VIR_ALLOC(data) < 0) if (VIR_ALLOC(data) < 0)
return NULL; return NULL;
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
static const virArch archs[] = { VIR_ARCH_S390, VIR_ARCH_S390X }; static const virArch archs[] = { VIR_ARCH_S390, VIR_ARCH_S390X };
static union cpuData * static virCPUDataPtr
s390NodeData(void) s390NodeData(void)
{ {
union cpuData *data; virCPUDataPtr data;
if (VIR_ALLOC(data) < 0) if (VIR_ALLOC(data) < 0)
return NULL; return NULL;
...@@ -45,7 +45,7 @@ s390NodeData(void) ...@@ -45,7 +45,7 @@ s390NodeData(void)
static int static int
s390Decode(virCPUDefPtr cpu ATTRIBUTE_UNUSED, s390Decode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
const union cpuData *data ATTRIBUTE_UNUSED, const virCPUDataPtr data ATTRIBUTE_UNUSED,
const char **models ATTRIBUTE_UNUSED, const char **models ATTRIBUTE_UNUSED,
unsigned int nmodels ATTRIBUTE_UNUSED, unsigned int nmodels ATTRIBUTE_UNUSED,
const char *preferred ATTRIBUTE_UNUSED) const char *preferred ATTRIBUTE_UNUSED)
...@@ -54,7 +54,7 @@ s390Decode(virCPUDefPtr cpu ATTRIBUTE_UNUSED, ...@@ -54,7 +54,7 @@ s390Decode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
} }
static void static void
s390DataFree(union cpuData *data) s390DataFree(virCPUDataPtr data)
{ {
VIR_FREE(data); VIR_FREE(data);
} }
......
...@@ -215,10 +215,10 @@ x86DataFree(struct cpuX86Data *data) ...@@ -215,10 +215,10 @@ x86DataFree(struct cpuX86Data *data)
} }
static union cpuData * static virCPUDataPtr
x86MakeCPUData(struct cpuX86Data **data) x86MakeCPUData(struct cpuX86Data **data)
{ {
union cpuData *cpuData; virCPUDataPtr cpuData;
if (VIR_ALLOC(cpuData) < 0) if (VIR_ALLOC(cpuData) < 0)
return NULL; return NULL;
...@@ -230,7 +230,7 @@ x86MakeCPUData(struct cpuX86Data **data) ...@@ -230,7 +230,7 @@ x86MakeCPUData(struct cpuX86Data **data)
} }
static void static void
x86FreeCPUData(union cpuData *data) x86FreeCPUData(virCPUDataPtr data)
{ {
if (!data) if (!data)
return; return;
...@@ -1151,7 +1151,7 @@ error: ...@@ -1151,7 +1151,7 @@ error:
static virCPUCompareResult static virCPUCompareResult
x86Compute(virCPUDefPtr host, x86Compute(virCPUDefPtr host,
virCPUDefPtr cpu, virCPUDefPtr cpu,
union cpuData **guest, virCPUDataPtr *guest,
char **message) char **message)
{ {
struct x86_map *map = NULL; struct x86_map *map = NULL;
...@@ -1303,7 +1303,7 @@ x86Compare(virCPUDefPtr host, ...@@ -1303,7 +1303,7 @@ x86Compare(virCPUDefPtr host,
static virCPUCompareResult static virCPUCompareResult
x86GuestData(virCPUDefPtr host, x86GuestData(virCPUDefPtr host,
virCPUDefPtr guest, virCPUDefPtr guest,
union cpuData **data, virCPUDataPtr *data,
char **message) char **message)
{ {
return x86Compute(host, guest, data, message); return x86Compute(host, guest, data, message);
...@@ -1413,7 +1413,7 @@ out: ...@@ -1413,7 +1413,7 @@ out:
static int static int
x86DecodeCPUData(virCPUDefPtr cpu, x86DecodeCPUData(virCPUDefPtr cpu,
const union cpuData *data, const virCPUDataPtr data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred) const char *preferred)
...@@ -1443,12 +1443,12 @@ x86EncodePolicy(const virCPUDefPtr cpu, ...@@ -1443,12 +1443,12 @@ x86EncodePolicy(const virCPUDefPtr cpu,
static int static int
x86Encode(const virCPUDefPtr cpu, x86Encode(const virCPUDefPtr cpu,
union cpuData **forced, virCPUDataPtr *forced,
union cpuData **required, virCPUDataPtr *required,
union cpuData **optional, virCPUDataPtr *optional,
union cpuData **disabled, virCPUDataPtr *disabled,
union cpuData **forbidden, virCPUDataPtr *forbidden,
union cpuData **vendor) virCPUDataPtr *vendor)
{ {
struct x86_map *map = NULL; struct x86_map *map = NULL;
struct cpuX86Data *data_forced = NULL; struct cpuX86Data *data_forced = NULL;
...@@ -1628,10 +1628,10 @@ cpuidSet(uint32_t base, struct cpuX86cpuid **set) ...@@ -1628,10 +1628,10 @@ cpuidSet(uint32_t base, struct cpuX86cpuid **set)
} }
static union cpuData * static virCPUDataPtr
x86NodeData(void) x86NodeData(void)
{ {
union cpuData *cpuData = NULL; virCPUDataPtr cpuData = NULL;
struct cpuX86Data *data; struct cpuX86Data *data;
int ret; int ret;
...@@ -1872,7 +1872,7 @@ x86Update(virCPUDefPtr guest, ...@@ -1872,7 +1872,7 @@ x86Update(virCPUDefPtr guest,
return -1; return -1;
} }
static int x86HasFeature(const union cpuData *data, static int x86HasFeature(const virCPUDataPtr data,
const char *name) const char *name)
{ {
struct x86_map *map; struct x86_map *map;
......
...@@ -832,7 +832,7 @@ virQEMUCapsInitCPU(virCapsPtr caps, ...@@ -832,7 +832,7 @@ virQEMUCapsInitCPU(virCapsPtr caps,
virArch arch) virArch arch)
{ {
virCPUDefPtr cpu = NULL; virCPUDefPtr cpu = NULL;
union cpuData *data = NULL; virCPUDataPtr data = NULL;
virNodeInfo nodeinfo; virNodeInfo nodeinfo;
int ret = -1; int ret = -1;
......
...@@ -5640,7 +5640,7 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver, ...@@ -5640,7 +5640,7 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver,
size_t ncpus = 0; size_t ncpus = 0;
char **cpus = NULL; char **cpus = NULL;
const char *default_model; const char *default_model;
union cpuData *data = NULL; virCPUDataPtr data = NULL;
bool have_cpu = false; bool have_cpu = false;
char *compare_msg = NULL; char *compare_msg = NULL;
int ret = -1; int ret = -1;
...@@ -9894,7 +9894,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom, ...@@ -9894,7 +9894,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
if (dom->os.arch == VIR_ARCH_X86_64) { if (dom->os.arch == VIR_ARCH_X86_64) {
bool is_32bit = false; bool is_32bit = false;
if (cpu) { if (cpu) {
union cpuData *cpuData = NULL; virCPUDataPtr cpuData = NULL;
if (cpuEncode(VIR_ARCH_X86_64, cpu, NULL, &cpuData, if (cpuEncode(VIR_ARCH_X86_64, cpu, NULL, &cpuData,
NULL, NULL, NULL, NULL) < 0) NULL, NULL, NULL, NULL) < 0)
......
...@@ -56,7 +56,7 @@ vmwareCapsInit(void) ...@@ -56,7 +56,7 @@ vmwareCapsInit(void)
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
virCapsGuestPtr guest = NULL; virCapsGuestPtr guest = NULL;
virCPUDefPtr cpu = NULL; virCPUDefPtr cpu = NULL;
union cpuData *data = NULL; virCPUDataPtr data = NULL;
if ((caps = virCapabilitiesNew(virArchFromHost(), if ((caps = virCapabilitiesNew(virArchFromHost(),
0, 0)) == NULL) 0, 0)) == NULL)
......
...@@ -261,7 +261,7 @@ cpuTestGuestData(const void *arg) ...@@ -261,7 +261,7 @@ cpuTestGuestData(const void *arg)
virCPUDefPtr host = NULL; virCPUDefPtr host = NULL;
virCPUDefPtr cpu = NULL; virCPUDefPtr cpu = NULL;
virCPUDefPtr guest = NULL; virCPUDefPtr guest = NULL;
union cpuData *guestData = NULL; virCPUDataPtr guestData = NULL;
virCPUCompareResult cmpResult; virCPUCompareResult cmpResult;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
char *result = NULL; char *result = NULL;
...@@ -417,7 +417,7 @@ cpuTestHasFeature(const void *arg) ...@@ -417,7 +417,7 @@ cpuTestHasFeature(const void *arg)
const struct data *data = arg; const struct data *data = arg;
int ret = -1; int ret = -1;
virCPUDefPtr host = NULL; virCPUDefPtr host = NULL;
union cpuData *hostData = NULL; virCPUDataPtr hostData = NULL;
int result; int result;
if (!(host = cpuTestLoadXML(data->arch, data->host))) if (!(host = cpuTestLoadXML(data->arch, data->host)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册