Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
1dfa174a
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1dfa174a
编写于
7月 16, 2013
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cpu: Store arch in virCPUData
上级
57d52b24
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
55 addition
and
54 deletion
+55
-54
src/cpu/cpu.c
src/cpu/cpu.c
+9
-12
src/cpu/cpu.h
src/cpu/cpu.h
+12
-10
src/cpu/cpu_powerpc.c
src/cpu/cpu_powerpc.c
+2
-2
src/cpu/cpu_x86.c
src/cpu/cpu_x86.c
+20
-14
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.c
+1
-1
src/qemu/qemu_command.c
src/qemu/qemu_command.c
+4
-5
src/vmware/vmware_conf.c
src/vmware/vmware_conf.c
+4
-5
tests/cputest.c
tests/cputest.c
+3
-5
未找到文件。
src/cpu/cpu.c
浏览文件 @
1dfa174a
...
...
@@ -198,29 +198,28 @@ cpuEncode(virArch arch,
return
-
1
;
}
return
driver
->
encode
(
cpu
,
forced
,
required
,
return
driver
->
encode
(
arch
,
cpu
,
forced
,
required
,
optional
,
disabled
,
forbidden
,
vendor
);
}
void
cpuDataFree
(
virArch
arch
,
virCPUDataPtr
data
)
cpuDataFree
(
virCPUDataPtr
data
)
{
struct
cpuArchDriver
*
driver
;
VIR_DEBUG
(
"
arch=%s, data=%p"
,
virArchToString
(
arch
)
,
data
);
VIR_DEBUG
(
"
data=%p"
,
data
);
if
(
data
==
NULL
)
return
;
if
((
driver
=
cpuGetSubDriver
(
arch
))
==
NULL
)
if
((
driver
=
cpuGetSubDriver
(
data
->
arch
))
==
NULL
)
return
;
if
(
driver
->
free
==
NULL
)
{
virReportError
(
VIR_ERR_NO_SUPPORT
,
_
(
"cannot free CPU data for %s architecture"
),
virArchToString
(
arch
));
virArchToString
(
data
->
arch
));
return
;
}
...
...
@@ -419,22 +418,20 @@ cpuUpdate(virCPUDefPtr guest,
}
int
cpuHasFeature
(
virArch
arch
,
const
virCPUDataPtr
data
,
cpuHasFeature
(
const
virCPUDataPtr
data
,
const
char
*
feature
)
{
struct
cpuArchDriver
*
driver
;
VIR_DEBUG
(
"arch=%s, data=%p, feature=%s"
,
virArchToString
(
arch
),
data
,
feature
);
VIR_DEBUG
(
"data=%p, feature=%s"
,
data
,
feature
);
if
((
driver
=
cpuGetSubDriver
(
arch
))
==
NULL
)
if
((
driver
=
cpuGetSubDriver
(
data
->
arch
))
==
NULL
)
return
-
1
;
if
(
driver
->
hasFeature
==
NULL
)
{
virReportError
(
VIR_ERR_NO_SUPPORT
,
_
(
"cannot check guest CPU data for %s architecture"
),
virArchToString
(
arch
));
virArchToString
(
data
->
arch
));
return
-
1
;
}
...
...
src/cpu/cpu.h
浏览文件 @
1dfa174a
...
...
@@ -32,12 +32,15 @@
# include "cpu_ppc_data.h"
typedef
union
_virCPUData
virCPUData
;
typedef
struct
_virCPUData
virCPUData
;
typedef
virCPUData
*
virCPUDataPtr
;
union
_virCPUData
{
struct
cpuX86Data
*
x86
;
struct
cpuPPCData
ppc
;
/* generic driver needs no data */
struct
_virCPUData
{
virArch
arch
;
union
{
struct
cpuX86Data
*
x86
;
struct
cpuPPCData
ppc
;
/* generic driver needs no data */
}
data
;
};
...
...
@@ -53,7 +56,8 @@ typedef int
const
char
*
preferred
);
typedef
int
(
*
cpuArchEncode
)
(
const
virCPUDefPtr
cpu
,
(
*
cpuArchEncode
)
(
virArch
arch
,
const
virCPUDefPtr
cpu
,
virCPUDataPtr
*
forced
,
virCPUDataPtr
*
required
,
virCPUDataPtr
*
optional
,
...
...
@@ -130,8 +134,7 @@ cpuEncode (virArch arch,
virCPUDataPtr
*
vendor
);
extern
void
cpuDataFree
(
virArch
arch
,
virCPUDataPtr
data
);
cpuDataFree
(
virCPUDataPtr
data
);
extern
virCPUDataPtr
cpuNodeData
(
virArch
arch
);
...
...
@@ -159,8 +162,7 @@ cpuUpdate (virCPUDefPtr guest,
const
virCPUDefPtr
host
);
extern
int
cpuHasFeature
(
virArch
arch
,
const
virCPUDataPtr
data
,
cpuHasFeature
(
const
virCPUDataPtr
data
,
const
char
*
feature
);
...
...
src/cpu/cpu_powerpc.c
浏览文件 @
1dfa174a
...
...
@@ -313,10 +313,10 @@ ppcDecode(virCPUDefPtr cpu,
if
(
data
==
NULL
||
(
map
=
ppcLoadMap
())
==
NULL
)
return
-
1
;
if
(
!
(
model
=
ppcModelFindPVR
(
map
,
data
->
ppc
.
pvr
)))
{
if
(
!
(
model
=
ppcModelFindPVR
(
map
,
data
->
data
.
ppc
.
pvr
)))
{
virReportError
(
VIR_ERR_OPERATION_FAILED
,
_
(
"Cannot find CPU model with PVR 0x%08x"
),
data
->
ppc
.
pvr
);
data
->
data
.
ppc
.
pvr
);
goto
cleanup
;
}
...
...
src/cpu/cpu_x86.c
浏览文件 @
1dfa174a
...
...
@@ -216,14 +216,15 @@ x86DataFree(struct cpuX86Data *data)
static
virCPUDataPtr
x86MakeCPUData
(
struct
cpuX86Data
**
data
)
x86MakeCPUData
(
virArch
arch
,
struct
cpuX86Data
**
data
)
{
virCPUDataPtr
cpuData
;
if
(
VIR_ALLOC
(
cpuData
)
<
0
)
return
NULL
;
cpuData
->
x86
=
*
data
;
cpuData
->
arch
=
arch
;
cpuData
->
data
.
x86
=
*
data
;
*
data
=
NULL
;
return
cpuData
;
...
...
@@ -235,7 +236,7 @@ x86FreeCPUData(virCPUDataPtr data)
if
(
!
data
)
return
;
x86DataFree
(
data
->
x86
);
x86DataFree
(
data
->
data
.
x86
);
VIR_FREE
(
data
);
}
...
...
@@ -1165,6 +1166,7 @@ x86Compute(virCPUDefPtr host,
struct
x86_model
*
guest_model
=
NULL
;
virCPUCompareResult
ret
;
enum
compare_result
result
;
virArch
arch
;
size_t
i
;
if
(
cpu
->
arch
!=
VIR_ARCH_NONE
)
{
...
...
@@ -1187,6 +1189,9 @@ x86Compute(virCPUDefPtr host,
goto
error
;
return
VIR_CPU_COMPARE_INCOMPATIBLE
;
}
arch
=
cpu
->
arch
;
}
else
{
arch
=
host
->
arch
;
}
if
(
cpu
->
vendor
&&
...
...
@@ -1266,7 +1271,7 @@ x86Compute(virCPUDefPtr host,
x86DataSubtract
(
guest_model
->
data
,
cpu_disable
->
data
);
if
(
!
(
guestData
=
x86DataCopy
(
guest_model
->
data
))
||
!
(
*
guest
=
x86MakeCPUData
(
&
guestData
)))
{
!
(
*
guest
=
x86MakeCPUData
(
arch
,
&
guestData
)))
{
x86DataFree
(
guestData
);
goto
error
;
}
...
...
@@ -1418,7 +1423,7 @@ x86DecodeCPUData(virCPUDefPtr cpu,
unsigned
int
nmodels
,
const
char
*
preferred
)
{
return
x86Decode
(
cpu
,
data
->
x86
,
models
,
nmodels
,
preferred
);
return
x86Decode
(
cpu
,
data
->
data
.
x86
,
models
,
nmodels
,
preferred
);
}
...
...
@@ -1442,7 +1447,8 @@ x86EncodePolicy(const virCPUDefPtr cpu,
static
int
x86Encode
(
const
virCPUDefPtr
cpu
,
x86Encode
(
virArch
arch
,
const
virCPUDefPtr
cpu
,
virCPUDataPtr
*
forced
,
virCPUDataPtr
*
required
,
virCPUDataPtr
*
optional
,
...
...
@@ -1522,22 +1528,22 @@ x86Encode(const virCPUDefPtr cpu,
}
if
(
forced
&&
!
(
*
forced
=
x86MakeCPUData
(
&
data_forced
)))
!
(
*
forced
=
x86MakeCPUData
(
arch
,
&
data_forced
)))
goto
error
;
if
(
required
&&
!
(
*
required
=
x86MakeCPUData
(
&
data_required
)))
!
(
*
required
=
x86MakeCPUData
(
arch
,
&
data_required
)))
goto
error
;
if
(
optional
&&
!
(
*
optional
=
x86MakeCPUData
(
&
data_optional
)))
!
(
*
optional
=
x86MakeCPUData
(
arch
,
&
data_optional
)))
goto
error
;
if
(
disabled
&&
!
(
*
disabled
=
x86MakeCPUData
(
&
data_disabled
)))
!
(
*
disabled
=
x86MakeCPUData
(
arch
,
&
data_disabled
)))
goto
error
;
if
(
forbidden
&&
!
(
*
forbidden
=
x86MakeCPUData
(
&
data_forbidden
)))
!
(
*
forbidden
=
x86MakeCPUData
(
arch
,
&
data_forbidden
)))
goto
error
;
if
(
vendor
&&
!
(
*
vendor
=
x86MakeCPUData
(
&
data_vendor
)))
!
(
*
vendor
=
x86MakeCPUData
(
arch
,
&
data_vendor
)))
goto
error
;
ret
=
0
;
...
...
@@ -1646,7 +1652,7 @@ x86NodeData(void)
goto
error
;
data
->
extended_len
=
ret
;
if
(
!
(
cpuData
=
x86MakeCPUData
(
&
data
)))
if
(
!
(
cpuData
=
x86MakeCPUData
(
virArchFromHost
(),
&
data
)))
goto
error
;
return
cpuData
;
...
...
@@ -1885,7 +1891,7 @@ static int x86HasFeature(const virCPUDataPtr data,
if
(
!
(
feature
=
x86FeatureFind
(
map
,
name
)))
goto
cleanup
;
ret
=
x86DataIsSubset
(
data
->
x86
,
feature
->
data
)
?
1
:
0
;
ret
=
x86DataIsSubset
(
data
->
data
.
x86
,
feature
->
data
)
?
1
:
0
;
cleanup:
x86MapFree
(
map
);
...
...
src/qemu/qemu_capabilities.c
浏览文件 @
1dfa174a
...
...
@@ -857,7 +857,7 @@ virQEMUCapsInitCPU(virCapsPtr caps,
ret
=
0
;
cleanup:
cpuDataFree
(
arch
,
data
);
cpuDataFree
(
data
);
return
ret
;
...
...
src/qemu/qemu_command.c
浏览文件 @
1dfa174a
...
...
@@ -5704,7 +5704,7 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver,
/* Only 'svm' requires --enable-nesting. The nested
* 'vmx' patches now simply hook off the CPU features
*/
hasSVM
=
cpuHasFeature
(
host
->
arch
,
data
,
"svm"
);
hasSVM
=
cpuHasFeature
(
data
,
"svm"
);
if
(
hasSVM
<
0
)
goto
cleanup
;
*
hasHwVirt
=
hasSVM
>
0
?
true
:
false
;
...
...
@@ -5845,8 +5845,7 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver,
cleanup:
VIR_FREE
(
compare_msg
);
if
(
host
)
cpuDataFree
(
host
->
arch
,
data
);
cpuDataFree
(
data
);
virCPUDefFree
(
guest
);
virCPUDefFree
(
cpu
);
virObjectUnref
(
caps
);
...
...
@@ -9900,8 +9899,8 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
NULL
,
NULL
,
NULL
,
NULL
)
<
0
)
goto
cleanup
;
is_32bit
=
(
cpuHasFeature
(
VIR_ARCH_X86_64
,
cpuData
,
"lm"
)
!=
1
);
cpuDataFree
(
VIR_ARCH_X86_64
,
cpuData
);
is_32bit
=
(
cpuHasFeature
(
cpuData
,
"lm"
)
!=
1
);
cpuDataFree
(
cpuData
);
}
else
if
(
model
)
{
is_32bit
=
STREQ
(
model
,
"qemu32"
);
}
...
...
src/vmware/vmware_conf.c
浏览文件 @
1dfa174a
...
...
@@ -97,9 +97,9 @@ vmwareCapsInit(void)
* - Host CPU is x86_64 with virtualization extensions
*/
if
(
caps
->
host
.
arch
==
VIR_ARCH_X86_64
||
(
cpuHasFeature
(
caps
->
host
.
arch
,
data
,
"lm"
)
&&
(
cpuHasFeature
(
caps
->
host
.
arch
,
data
,
"vmx"
)
||
cpuHasFeature
(
caps
->
host
.
arch
,
data
,
"svm"
))))
{
(
cpuHasFeature
(
data
,
"lm"
)
&&
(
cpuHasFeature
(
data
,
"vmx"
)
||
cpuHasFeature
(
data
,
"svm"
))))
{
if
((
guest
=
virCapabilitiesAddGuest
(
caps
,
"hvm"
,
...
...
@@ -115,8 +115,7 @@ vmwareCapsInit(void)
cleanup:
virCPUDefFree
(
cpu
);
if
(
caps
)
cpuDataFree
(
caps
->
host
.
arch
,
data
);
cpuDataFree
(
data
);
return
caps
;
...
...
tests/cputest.c
浏览文件 @
1dfa174a
...
...
@@ -308,8 +308,7 @@ cpuTestGuestData(const void *arg)
cleanup:
VIR_FREE
(
result
);
if
(
host
)
cpuDataFree
(
host
->
arch
,
guestData
);
cpuDataFree
(
guestData
);
virCPUDefFree
(
host
);
virCPUDefFree
(
cpu
);
virCPUDefFree
(
guest
);
...
...
@@ -427,7 +426,7 @@ cpuTestHasFeature(const void *arg)
NULL
,
NULL
,
NULL
,
NULL
)
<
0
)
goto
cleanup
;
result
=
cpuHasFeature
(
host
->
arch
,
host
Data
,
data
->
name
);
result
=
cpuHasFeature
(
hostData
,
data
->
name
);
if
(
data
->
result
==
-
1
)
virResetLastError
();
...
...
@@ -445,8 +444,7 @@ cpuTestHasFeature(const void *arg)
ret
=
0
;
cleanup:
if
(
host
)
cpuDataFree
(
host
->
arch
,
hostData
);
cpuDataFree
(
hostData
);
virCPUDefFree
(
host
);
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录