Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
7b5ae2f0
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看板
提交
7b5ae2f0
编写于
1月 26, 2010
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement cpuArchBaseline in generic CPU driver
上级
388f3cb5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
101 addition
and
2 deletion
+101
-2
src/cpu/cpu_generic.c
src/cpu/cpu_generic.c
+101
-2
未找到文件。
src/cpu/cpu_generic.c
浏览文件 @
7b5ae2f0
...
...
@@ -2,7 +2,7 @@
* cpu_generic.c: CPU manipulation driver for architectures which are not
* handled by their own driver
*
* Copyright (C) 2009 Red Hat, Inc.
* Copyright (C) 2009
--2010
Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -24,6 +24,7 @@
#include <config.h>
#include "memory.h"
#include "hash.h"
#include "cpu.h"
#include "cpu_generic.h"
...
...
@@ -109,6 +110,104 @@ cleanup:
}
static
virCPUDefPtr
genericBaseline
(
virCPUDefPtr
*
cpus
,
unsigned
int
ncpus
,
const
char
**
models
,
unsigned
int
nmodels
)
{
virCPUDefPtr
cpu
=
NULL
;
virCPUFeatureDefPtr
features
=
NULL
;
unsigned
int
nfeatures
;
unsigned
int
count
;
unsigned
int
i
,
j
;
if
(
models
)
{
bool
found
=
false
;
for
(
i
=
0
;
i
<
nmodels
;
i
++
)
{
if
(
STREQ
(
cpus
[
0
]
->
model
,
models
[
i
]))
{
found
=
true
;
break
;
}
}
if
(
!
found
)
{
virCPUReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"CPU model '%s' is not support by hypervisor"
),
cpus
[
0
]
->
model
);
goto
error
;
}
}
if
(
VIR_ALLOC
(
cpu
)
<
0
||
!
(
cpu
->
arch
=
strdup
(
cpus
[
0
]
->
arch
))
||
!
(
cpu
->
model
=
strdup
(
cpus
[
0
]
->
model
))
||
VIR_ALLOC_N
(
features
,
cpus
[
0
]
->
nfeatures
)
<
0
)
goto
no_memory
;
cpu
->
type
=
VIR_CPU_TYPE_HOST
;
count
=
nfeatures
=
cpus
[
0
]
->
nfeatures
;
for
(
i
=
0
;
i
<
nfeatures
;
i
++
)
features
[
i
].
name
=
cpus
[
0
]
->
features
[
i
].
name
;
for
(
i
=
1
;
i
<
ncpus
;
i
++
)
{
virHashTablePtr
hash
;
if
(
STRNEQ
(
cpu
->
arch
,
cpus
[
i
]
->
arch
))
{
virCPUReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"CPUs have incompatible architectures: '%s' != '%s'"
),
cpu
->
arch
,
cpus
[
i
]
->
arch
);
goto
error
;
}
if
(
STRNEQ
(
cpu
->
model
,
cpus
[
i
]
->
model
))
{
virCPUReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"CPU models don't match: '%s' != '%s'"
),
cpu
->
model
,
cpus
[
i
]
->
model
);
goto
error
;
}
if
(
!
(
hash
=
genericHashFeatures
(
cpus
[
i
])))
goto
no_memory
;
for
(
j
=
0
;
j
<
nfeatures
;
j
++
)
{
if
(
features
[
j
].
name
&&
!
virHashLookup
(
hash
,
features
[
j
].
name
))
{
features
[
j
].
name
=
NULL
;
count
--
;
}
}
virHashFree
(
hash
,
NULL
);
}
if
(
VIR_ALLOC_N
(
cpu
->
features
,
count
)
<
0
)
goto
no_memory
;
cpu
->
nfeatures
=
count
;
j
=
0
;
for
(
i
=
0
;
i
<
nfeatures
;
i
++
)
{
if
(
!
features
[
i
].
name
)
continue
;
if
(
!
(
cpu
->
features
[
j
++
].
name
=
strdup
(
features
[
i
].
name
)))
goto
no_memory
;
}
cleanup:
VIR_FREE
(
features
);
return
cpu
;
no_memory:
virReportOOMError
();
error:
virCPUDefFree
(
cpu
);
cpu
=
NULL
;
goto
cleanup
;
}
struct
cpuArchDriver
cpuDriverGeneric
=
{
.
name
=
"generic"
,
.
arch
=
NULL
,
...
...
@@ -119,5 +218,5 @@ struct cpuArchDriver cpuDriverGeneric = {
.
free
=
NULL
,
.
nodeData
=
NULL
,
.
guestData
=
NULL
,
.
baseline
=
NULL
,
.
baseline
=
genericBaseline
,
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录