Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
667ce289
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看板
提交
667ce289
编写于
10月 27, 2009
作者:
C
Cole Robinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: Use privateData to track running VM vcpu state
上级
4e40aee2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
134 addition
and
2 deletion
+134
-2
src/test/test_driver.c
src/test/test_driver.c
+134
-2
未找到文件。
src/test/test_driver.c
浏览文件 @
667ce289
...
...
@@ -53,6 +53,15 @@
#define VIR_FROM_THIS VIR_FROM_TEST
/* Driver specific info to carry with a domain */
struct
_testDomainObjPrivate
{
virVcpuInfoPtr
vcpu_infos
;
unsigned
char
*
cpumaps
;
};
typedef
struct
_testDomainObjPrivate
testDomainObjPrivate
;
typedef
struct
_testDomainObjPrivate
*
testDomainObjPrivatePtr
;
#define MAX_CPUS 128
struct
_testCell
{
...
...
@@ -126,6 +135,25 @@ static void testDriverUnlock(testConnPtr driver)
virMutexUnlock
(
&
driver
->
lock
);
}
static
void
*
testDomainObjPrivateAlloc
(
void
)
{
testDomainObjPrivatePtr
priv
;
if
(
VIR_ALLOC
(
priv
)
<
0
)
return
NULL
;
return
priv
;
}
static
void
testDomainObjPrivateFree
(
void
*
data
)
{
testDomainObjPrivatePtr
priv
=
data
;
VIR_FREE
(
priv
->
cpumaps
);
VIR_FREE
(
priv
);
}
static
virCapsPtr
testBuildCapabilities
(
virConnectPtr
conn
)
{
testConnPtr
privconn
=
conn
->
privateData
;
...
...
@@ -173,6 +201,9 @@ testBuildCapabilities(virConnectPtr conn) {
goto
no_memory
;
}
caps
->
privateDataAllocFunc
=
testDomainObjPrivateAlloc
;
caps
->
privateDataFreeFunc
=
testDomainObjPrivateFree
;
return
caps
;
no_memory:
...
...
@@ -269,7 +300,9 @@ static const char *defaultNodeXML =
static
const
unsigned
long
long
defaultPoolCap
=
(
100
*
1024
*
1024
*
1024ull
);
static
const
unsigned
long
long
defaultPoolAlloc
=
0
;
static
int
testStoragePoolObjSetDefaults
(
virConnectPtr
conn
,
virStoragePoolObjPtr
pool
);
static
int
testStoragePoolObjSetDefaults
(
virConnectPtr
conn
,
virStoragePoolObjPtr
pool
);
static
int
testNodeGetInfo
(
virConnectPtr
conn
,
virNodeInfoPtr
info
);
static
char
*
testDomainGenerateIfname
(
virConnectPtr
conn
,
...
...
@@ -325,16 +358,115 @@ testDomainGenerateIfnames(virConnectPtr conn,
return
0
;
}
/* Helper to update info for a single VCPU */
static
int
testDomainUpdateVCPU
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virDomainObjPtr
dom
,
int
vcpu
,
int
maplen
,
int
maxcpu
)
{
testDomainObjPrivatePtr
privdata
=
dom
->
privateData
;
virVcpuInfoPtr
info
=
&
privdata
->
vcpu_infos
[
vcpu
];
unsigned
char
*
cpumap
=
VIR_GET_CPUMAP
(
privdata
->
cpumaps
,
maplen
,
vcpu
);
int
j
;
memset
(
info
,
0
,
sizeof
(
virVcpuInfo
));
memset
(
cpumap
,
0
,
maplen
);
info
->
number
=
vcpu
;
info
->
state
=
VIR_VCPU_RUNNING
;
info
->
cpuTime
=
5000000
;
info
->
cpu
=
0
;
if
(
dom
->
def
->
cpumask
)
{
for
(
j
=
0
;
j
<
maxcpu
&&
j
<
VIR_DOMAIN_CPUMASK_LEN
;
++
j
)
{
if
(
dom
->
def
->
cpumask
[
j
])
{
VIR_USE_CPU
(
cpumap
,
j
);
info
->
cpu
=
j
;
}
}
}
else
{
for
(
j
=
0
;
j
<
maxcpu
;
++
j
)
{
if
((
j
%
3
)
==
0
)
{
/* Mark of every third CPU as usable */
VIR_USE_CPU
(
cpumap
,
j
);
info
->
cpu
=
j
;
}
}
}
return
0
;
}
/*
* Update domain VCPU amount and info
*
* @conn: virConnectPtr
* @dom : domain needing updates
* @nvcpus: New amount of vcpus for the domain
* @clear_all: If true, rebuild info for ALL vcpus, not just newly added vcpus
*/
static
int
testDomainUpdateVCPUs
(
virConnectPtr
conn
,
virDomainObjPtr
dom
,
int
nvcpus
,
unsigned
int
clear_all
)
{
testConnPtr
privconn
=
conn
->
privateData
;
testDomainObjPrivatePtr
privdata
=
dom
->
privateData
;
int
i
,
ret
=
-
1
;
int
cpumaplen
,
maxcpu
;
maxcpu
=
VIR_NODEINFO_MAXCPUS
(
privconn
->
nodeInfo
);
cpumaplen
=
VIR_CPU_MAPLEN
(
maxcpu
);
if
(
VIR_REALLOC_N
(
privdata
->
vcpu_infos
,
nvcpus
)
<
0
)
{
virReportOOMError
(
conn
);
goto
cleanup
;
}
if
(
VIR_REALLOC_N
(
privdata
->
cpumaps
,
nvcpus
*
cpumaplen
)
<
0
)
{
virReportOOMError
(
conn
);
goto
cleanup
;
}
/* Set running VCPU and cpumap state */
if
(
clear_all
)
{
for
(
i
=
0
;
i
<
nvcpus
;
++
i
)
if
(
testDomainUpdateVCPU
(
conn
,
dom
,
i
,
cpumaplen
,
maxcpu
)
<
0
)
goto
cleanup
;
}
else
if
(
nvcpus
>
dom
->
def
->
vcpus
)
{
/* VCPU amount has grown, populate info for the new vcpus */
for
(
i
=
dom
->
def
->
vcpus
;
i
<
nvcpus
;
++
i
)
if
(
testDomainUpdateVCPU
(
conn
,
dom
,
i
,
cpumaplen
,
maxcpu
)
<
0
)
goto
cleanup
;
}
ret
=
0
;
cleanup:
return
ret
;
}
/* Set up domain runtime state */
static
int
testDomainStartState
(
virConnectPtr
conn
,
virDomainObjPtr
dom
)
{
testConnPtr
privconn
=
conn
->
privateData
;
int
ret
=
-
1
;
if
(
testDomainUpdateVCPUs
(
conn
,
dom
,
dom
->
def
->
vcpus
,
1
)
<
0
)
goto
cleanup
;
/* Set typical run state */
dom
->
state
=
VIR_DOMAIN_RUNNING
;
dom
->
def
->
id
=
privconn
->
nextDomID
++
;
return
0
;
ret
=
0
;
cleanup:
return
ret
;
}
static
int
testOpenDefault
(
virConnectPtr
conn
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录