Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
02a0500d
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看板
提交
02a0500d
编写于
12月 06, 2005
作者:
D
Daniel Veillard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* include/libvir.h src/libvir.c src/virsh.c: adding the extraction
of the number of virtual CPUs for both interfaces. Daniel
上级
6564f33f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
5 deletion
+56
-5
ChangeLog
ChangeLog
+5
-0
include/libvir.h
include/libvir.h
+4
-3
src/libvir.c
src/libvir.c
+45
-1
src/virsh.c
src/virsh.c
+2
-1
未找到文件。
ChangeLog
浏览文件 @
02a0500d
Tue Dec 6 17:12:52 CET 2005 Daniel Veillard <veillard@redhat.com>
* include/libvir.h src/libvir.c src/virsh.c: adding the extraction
of the number of virtual CPUs for both interfaces.
Tue Dec 6 14:46:50 CET 2005 Daniel Veillard <veillard@redhat.com>
* include/libvir.h src/libvir.c src/virsh.c: tweaking of the
...
...
include/libvir.h
浏览文件 @
02a0500d
...
...
@@ -70,9 +70,10 @@ typedef enum {
typedef
struct
_virDomainInfo
virDomainInfo
;
struct
_virDomainInfo
{
unsigned
char
state
;
/* the running state, a virDomainFlags */
unsigned
long
maxMem
;
/* the maximum number of bytes allowed */
unsigned
long
memory
;
/* the number of bytes used by the domain */
unsigned
char
state
;
/* the running state, one of virDomainFlags */
unsigned
long
maxMem
;
/* the maximum memory in bytes allowed */
unsigned
long
memory
;
/* the memory in bytes used by the domain */
unsigned
short
nrVirtCpu
;
/* the number of virtual CPUs for the domain */
/*
* Informations below are only available to clients with a connection
...
...
src/libvir.c
浏览文件 @
02a0500d
...
...
@@ -298,6 +298,8 @@ virDomainLookupByName(virConnectPtr conn, const char *name) {
return
(
NULL
);
}
#if 0
/* Not used ATM */
/**
* virConnectDoStoreQuery:
* @conn: pointer to the hypervisor connection
...
...
@@ -319,6 +321,34 @@ virConnectDoStoreQuery(virConnectPtr conn, const char *path) {
ret = xs_read(conn->xshandle, t, path, &len);
done:
if (t != NULL)
xs_transaction_end(conn->xshandle, t, 0);
return(ret);
}
#endif
/**
* virConnectDoStoreList:
* @conn: pointer to the hypervisor connection
* @path: the absolute path of the directory in the store to list
* @nb: OUT pointer to the number of items found
*
* Internal API querying the Xenstore for a list
*
* Returns a string which must be freed by the caller or NULL in case of error
*/
static
char
**
virConnectDoStoreList
(
virConnectPtr
conn
,
const
char
*
path
,
unsigned
int
*
nb
)
{
struct
xs_transaction_handle
*
t
;
char
**
ret
=
NULL
;
t
=
xs_transaction_start
(
conn
->
xshandle
);
if
(
t
==
NULL
)
goto
done
;
ret
=
xs_directory
(
conn
->
xshandle
,
t
,
path
,
nb
);
done:
if
(
t
!=
NULL
)
xs_transaction_end
(
conn
->
xshandle
,
t
,
0
);
...
...
@@ -542,7 +572,9 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) {
return
(
-
1
);
memset
(
info
,
0
,
sizeof
(
virDomainInfo
));
if
(
domain
->
conn
->
flags
&
VIR_CONNECT_RO
)
{
char
*
tmp
;
char
*
tmp
,
**
tmp2
;
unsigned
int
nb_vcpus
;
char
request
[
200
];
tmp
=
virDomainDoStoreQuery
(
domain
,
"running"
);
if
(
tmp
!=
NULL
)
{
...
...
@@ -561,6 +593,8 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) {
info
->
memory
=
0
;
info
->
maxMem
=
0
;
}
#if 0
/* doesn't seems to work */
tmp = virDomainDoStoreQuery(domain, "cpu_time");
if (tmp != NULL) {
info->cpuTime = atol(tmp);
...
...
@@ -568,6 +602,15 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) {
} else {
info->cpuTime = 0;
}
#endif
snprintf
(
request
,
199
,
"/local/domain/%d/cpu"
,
domain
->
handle
);
request
[
199
]
=
0
;
tmp2
=
virConnectDoStoreList
(
domain
->
conn
,
request
,
&
nb_vcpus
);
if
(
tmp2
!=
NULL
)
{
info
->
nrVirtCpu
=
nb_vcpus
;
free
(
tmp2
);
}
}
else
{
xc_domaininfo_t
dominfo
;
...
...
@@ -604,6 +647,7 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) {
info
->
cpuTime
=
dominfo
.
cpu_time
;
info
->
memory
=
dominfo
.
tot_pages
*
4096
;
info
->
maxMem
=
dominfo
.
max_pages
*
4096
;
info
->
nrVirtCpu
=
dominfo
.
nr_online_vcpus
;
}
return
(
0
);
}
src/virsh.c
浏览文件 @
02a0500d
...
...
@@ -48,11 +48,12 @@ static void printDomain(virDomainPtr dom) {
default:
break
;
}
printf
(
"%d vCPU, "
,
info
.
nrVirtCpu
);
if
(
info
.
cpuTime
!=
0
)
{
float
cpuUsed
=
info
.
cpuTime
;
cpuUsed
/=
1000000000
;
printf
(
"%.1f
s CPU
time, "
,
cpuUsed
);
printf
(
"%.1f
s
time, "
,
cpuUsed
);
}
mem
=
info
.
memory
;
mem
/=
1024
*
1024
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录