Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b370cd29
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,发现更多精彩内容 >>
提交
b370cd29
编写于
12月 17, 2012
作者:
R
Roman Bogorodskiy
提交者:
Peter Krempa
12月 19, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
nodeinfo: add FreeBSD support
Uses sysctl(3) interface to obtain CPU and memory information on FreeBSD
上级
dc068e35
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
1 deletion
+61
-1
src/nodeinfo.c
src/nodeinfo.c
+61
-1
未找到文件。
src/nodeinfo.c
浏览文件 @
b370cd29
...
...
@@ -38,6 +38,11 @@
# include <numa.h>
#endif
#ifdef __FreeBSD__
# include <sys/types.h>
# include <sys/sysctl.h>
#endif
#include "c-ctype.h"
#include "memory.h"
#include "nodeinfo.h"
...
...
@@ -54,6 +59,23 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#ifdef __FreeBSD__
static
int
freebsdNodeGetCPUCount
(
void
)
{
int
ncpu_mib
[
2
]
=
{
CTL_HW
,
HW_NCPU
};
unsigned
long
ncpu
;
size_t
ncpu_len
=
sizeof
(
ncpu
);
if
(
sysctl
(
ncpu_mib
,
2
,
&
ncpu
,
&
ncpu_len
,
NULL
,
0
)
==
-
1
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"Cannot obtain CPU count"
));
return
-
1
;
}
return
ncpu
;
}
#endif
#ifdef __linux__
# define CPUINFO_PATH "/proc/cpuinfo"
# define SYSFS_SYSTEM_PATH "/sys/devices/system"
...
...
@@ -870,6 +892,42 @@ cleanup:
VIR_FORCE_FCLOSE
(
cpuinfo
);
return
ret
;
}
#elif defined(__FreeBSD__)
{
nodeinfo
->
nodes
=
1
;
nodeinfo
->
sockets
=
1
;
nodeinfo
->
threads
=
1
;
nodeinfo
->
cpus
=
freebsdNodeGetCPUCount
();
if
(
nodeinfo
->
cpus
==
-
1
)
return
-
1
;
nodeinfo
->
cores
=
nodeinfo
->
cpus
;
unsigned
long
cpu_freq
;
size_t
cpu_freq_len
=
sizeof
(
cpu_freq
);
if
(
sysctlbyname
(
"dev.cpu.0.freq"
,
&
cpu_freq
,
&
cpu_freq_len
,
NULL
,
0
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"cannot obtain CPU freq"
));
return
-
1
;
}
nodeinfo
->
mhz
=
cpu_freq
;
/* get memory information */
int
mib
[
2
]
=
{
CTL_HW
,
HW_PHYSMEM
};
unsigned
long
physmem
;
size_t
len
=
sizeof
(
physmem
);
if
(
sysctl
(
mib
,
2
,
&
physmem
,
&
len
,
NULL
,
0
)
==
-
1
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"cannot obtain memory size"
));
return
-
1
;
}
nodeinfo
->
memory
=
(
unsigned
long
)(
physmem
/
1024
);
return
0
;
}
#else
/* XXX Solaris will need an impl later if they port QEMU driver */
virReportError
(
VIR_ERR_NO_SUPPORT
,
"%s"
,
...
...
@@ -977,7 +1035,7 @@ int nodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int
nodeGetCPUCount
(
void
)
{
#if
def __linux__
#if
defined(__linux__)
/* To support older kernels that lack cpu/present, such as 2.6.18
* in RHEL5, we fall back to count cpu/cpuNN entries; this assumes
* that such kernels also lack hotplug, and therefore cpu/cpuNN
...
...
@@ -1007,6 +1065,8 @@ nodeGetCPUCount(void)
VIR_FREE
(
cpupath
);
return
i
;
#elif defined(__FreeBSD__)
return
freebsdNodeGetCPUCount
();
#else
virReportError
(
VIR_ERR_NO_SUPPORT
,
"%s"
,
_
(
"host cpu counting not implemented on this platform"
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录