Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
6c175fa3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6c175fa3
编写于
4月 03, 2010
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove virConnectPtr from nodeReportError
上级
8bd8bcac
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
25 addition
and
26 deletion
+25
-26
src/nodeinfo.c
src/nodeinfo.c
+23
-24
tests/nodeinfotest.c
tests/nodeinfotest.c
+2
-2
未找到文件。
src/nodeinfo.c
浏览文件 @
6c175fa3
...
...
@@ -51,8 +51,8 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define nodeReportError(co
nn, code, ...)
\
virReportErrorHelper(
conn
, VIR_FROM_NONE, code, __FILE__, \
#define nodeReportError(co
de, ...)
\
virReportErrorHelper(
NULL
, VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#ifdef __linux__
...
...
@@ -60,7 +60,7 @@
# define CPU_SYS_PATH "/sys/devices/system/cpu"
/* NB, this is not static as we need to call it from the testsuite */
int
linuxNodeInfoCPUPopulate
(
virConnectPtr
conn
,
FILE
*
cpuinfo
,
int
linuxNodeInfoCPUPopulate
(
FILE
*
cpuinfo
,
virNodeInfoPtr
nodeinfo
);
static
unsigned
long
count_thread_siblings
(
unsigned
int
cpu
)
...
...
@@ -133,7 +133,7 @@ static int parse_socket(unsigned int cpu)
goto
cleanup
;
}
if
(
virStrToLong_i
(
socket_str
,
&
tmp
,
10
,
&
socket
)
<
0
)
{
nodeReportError
(
NULL
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"could not convert '%s' to an integer"
),
socket_str
);
goto
cleanup
;
...
...
@@ -146,7 +146,7 @@ cleanup:
return
socket
;
}
int
linuxNodeInfoCPUPopulate
(
virConnectPtr
conn
,
FILE
*
cpuinfo
,
int
linuxNodeInfoCPUPopulate
(
FILE
*
cpuinfo
,
virNodeInfoPtr
nodeinfo
)
{
char
line
[
1024
];
...
...
@@ -178,7 +178,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
while
(
*
buf
&&
c_isspace
(
*
buf
))
buf
++
;
if
(
*
buf
!=
':'
)
{
nodeReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"parsing cpuinfo processor"
));
return
-
1
;
}
...
...
@@ -190,7 +190,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
while
(
*
buf
&&
c_isspace
(
*
buf
))
buf
++
;
if
(
*
buf
!=
':'
||
!
buf
[
1
])
{
nodeReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"parsing cpuinfo cpu MHz"
));
return
-
1
;
}
...
...
@@ -205,7 +205,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
while
(
*
buf
&&
c_isspace
(
*
buf
))
buf
++
;
if
(
*
buf
!=
':'
||
!
buf
[
1
])
{
nodeReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
"parsing cpuinfo cpu cores %c"
,
*
buf
);
return
-
1
;
}
...
...
@@ -217,7 +217,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
}
if
(
!
nodeinfo
->
cpus
)
{
nodeReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"no cpus found"
));
return
-
1
;
}
...
...
@@ -257,12 +257,12 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
/* there should always be at least one socket and one thread */
if
(
nodeinfo
->
sockets
==
0
)
{
nodeReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"no sockets found"
));
return
-
1
;
}
if
(
nodeinfo
->
threads
==
0
)
{
nodeReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"no threads found"
));
return
-
1
;
}
...
...
@@ -272,8 +272,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
#endif
int
nodeGetInfo
(
virConnectPtr
conn
,
virNodeInfoPtr
nodeinfo
)
{
int
nodeGetInfo
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virNodeInfoPtr
nodeinfo
)
{
memset
(
nodeinfo
,
0
,
sizeof
(
*
nodeinfo
));
#ifdef HAVE_UNAME
...
...
@@ -296,7 +295,7 @@ int nodeGetInfo(virConnectPtr conn,
_
(
"cannot open %s"
),
CPUINFO_PATH
);
return
-
1
;
}
ret
=
linuxNodeInfoCPUPopulate
(
c
onn
,
c
puinfo
,
nodeinfo
);
ret
=
linuxNodeInfoCPUPopulate
(
cpuinfo
,
nodeinfo
);
fclose
(
cpuinfo
);
if
(
ret
<
0
)
return
-
1
;
...
...
@@ -308,7 +307,7 @@ int nodeGetInfo(virConnectPtr conn,
}
#else
/* XXX Solaris will need an impl later if they port QEMU driver */
nodeReportError
(
conn
,
VIR_ERR_NO_SUPPORT
,
"%s"
,
nodeReportError
(
VIR_ERR_NO_SUPPORT
,
"%s"
,
_
(
"node info not implemented on this platform"
));
return
-
1
;
#endif
...
...
@@ -380,7 +379,7 @@ cleanup:
int
nodeGetCellsFreeMemory
(
virConnectPtr
conn
,
nodeGetCellsFreeMemory
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
unsigned
long
long
*
freeMems
,
int
startCell
,
int
maxCells
)
...
...
@@ -390,13 +389,13 @@ nodeGetCellsFreeMemory(virConnectPtr conn,
int
maxCell
;
if
(
numa_available
()
<
0
)
{
nodeReportError
(
conn
,
VIR_ERR_NO_SUPPORT
,
nodeReportError
(
VIR_ERR_NO_SUPPORT
,
"%s"
,
_
(
"NUMA not supported on this host"
));
goto
cleanup
;
}
maxCell
=
numa_max_node
();
if
(
startCell
>
maxCell
)
{
nodeReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"start cell %d out of range (0-%d)"
),
startCell
,
maxCell
);
goto
cleanup
;
...
...
@@ -408,7 +407,7 @@ nodeGetCellsFreeMemory(virConnectPtr conn,
for
(
numCells
=
0
,
n
=
startCell
;
n
<=
lastCell
;
n
++
)
{
long
long
mem
;
if
(
numa_node_size64
(
n
,
&
mem
)
<
0
)
{
nodeReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"Failed to query NUMA free memory"
));
goto
cleanup
;
}
...
...
@@ -421,13 +420,13 @@ cleanup:
}
unsigned
long
long
nodeGetFreeMemory
(
virConnectPtr
conn
)
nodeGetFreeMemory
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
)
{
unsigned
long
long
freeMem
=
0
;
int
n
;
if
(
numa_available
()
<
0
)
{
nodeReportError
(
conn
,
VIR_ERR_NO_SUPPORT
,
nodeReportError
(
VIR_ERR_NO_SUPPORT
,
"%s"
,
_
(
"NUMA not supported on this host"
));
goto
cleanup
;
}
...
...
@@ -435,7 +434,7 @@ nodeGetFreeMemory(virConnectPtr conn)
for
(
n
=
0
;
n
<=
numa_max_node
()
;
n
++
)
{
long
long
mem
;
if
(
numa_node_size64
(
n
,
&
mem
)
<
0
)
{
nodeReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
nodeReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"Failed to query NUMA free memory"
));
goto
cleanup
;
}
...
...
@@ -456,14 +455,14 @@ int nodeGetCellsFreeMemory(virConnectPtr conn,
int
startCell
ATTRIBUTE_UNUSED
,
int
maxCells
ATTRIBUTE_UNUSED
)
{
nodeReportError
(
conn
,
VIR_ERR_NO_SUPPORT
,
"%s"
,
nodeReportError
(
VIR_ERR_NO_SUPPORT
,
"%s"
,
_
(
"NUMA memory information not available on this platform"
));
return
-
1
;
}
unsigned
long
long
nodeGetFreeMemory
(
virConnectPtr
conn
)
{
nodeReportError
(
conn
,
VIR_ERR_NO_SUPPORT
,
"%s"
,
nodeReportError
(
VIR_ERR_NO_SUPPORT
,
"%s"
,
_
(
"NUMA memory information not available on this platform"
));
return
0
;
}
...
...
tests/nodeinfotest.c
浏览文件 @
6c175fa3
...
...
@@ -25,7 +25,7 @@ static char *abs_srcdir;
# define MAX_FILE 4096
extern
int
linuxNodeInfoCPUPopulate
(
virConnectPtr
conn
,
FILE
*
cpuinfo
,
virNodeInfoPtr
nodeinfo
);
extern
int
linuxNodeInfoCPUPopulate
(
FILE
*
cpuinfo
,
virNodeInfoPtr
nodeinfo
);
static
int
linuxTestCompareFiles
(
const
char
*
cpuinfofile
,
const
char
*
outputfile
)
{
char
actualData
[
MAX_FILE
];
...
...
@@ -40,7 +40,7 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile
cpuinfo
=
fopen
(
cpuinfofile
,
"r"
);
if
(
!
cpuinfo
)
return
-
1
;
if
(
linuxNodeInfoCPUPopulate
(
NULL
,
cpuinfo
,
&
nodeinfo
)
<
0
)
{
if
(
linuxNodeInfoCPUPopulate
(
cpuinfo
,
&
nodeinfo
)
<
0
)
{
fclose
(
cpuinfo
);
return
-
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录