Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
e8d6b293
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,发现更多精彩内容 >>
提交
e8d6b293
编写于
12月 29, 2011
作者:
H
Hu Tao
提交者:
Osier Yang
12月 29, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
domiftune: Add virDomain{S,G}etInterfaceParameters support to qemu driver
* src/qemu/qemu_driver.c: implement the qemu driver support
上级
ee3de186
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
351 addition
and
0 deletion
+351
-0
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+351
-0
未找到文件。
src/qemu/qemu_driver.c
浏览文件 @
e8d6b293
...
@@ -119,6 +119,8 @@
...
@@ -119,6 +119,8 @@
#define QEMU_NB_BLKIO_PARAM 2
#define QEMU_NB_BLKIO_PARAM 2
#define QEMU_NB_BANDWIDTH_PARAM 6
static
void
processWatchdogEvent
(
void
*
data
,
void
*
opaque
);
static
void
processWatchdogEvent
(
void
*
data
,
void
*
opaque
);
static
int
qemudShutdown
(
void
);
static
int
qemudShutdown
(
void
);
...
@@ -7851,6 +7853,353 @@ qemudDomainInterfaceStats (virDomainPtr dom,
...
@@ -7851,6 +7853,353 @@ qemudDomainInterfaceStats (virDomainPtr dom,
}
}
#endif
#endif
static
int
qemuDomainSetInterfaceParameters
(
virDomainPtr
dom
,
const
char
*
device
,
virTypedParameterPtr
params
,
int
nparams
,
unsigned
int
flags
)
{
struct
qemud_driver
*
driver
=
dom
->
conn
->
privateData
;
int
i
;
virCgroupPtr
group
=
NULL
;
virDomainObjPtr
vm
=
NULL
;
virDomainDefPtr
persistentDef
=
NULL
;
int
ret
=
-
1
;
virDomainNetDefPtr
net
=
NULL
,
persistentNet
=
NULL
;
virNetDevBandwidthPtr
bandwidth
=
NULL
;
virCheckFlags
(
VIR_DOMAIN_AFFECT_LIVE
|
VIR_DOMAIN_AFFECT_CONFIG
,
-
1
);
qemuDriverLock
(
driver
);
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
if
(
vm
==
NULL
)
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"No such domain %s"
),
dom
->
uuid
);
goto
cleanup
;
}
if
(
virDomainLiveConfigHelperMethod
(
driver
->
caps
,
vm
,
&
flags
,
&
persistentDef
)
<
0
)
goto
cleanup
;
if
(
flags
&
VIR_DOMAIN_AFFECT_LIVE
)
{
net
=
virDomainNetFind
(
vm
->
def
,
device
);
if
(
!
net
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"Can't find device %s"
),
device
);
goto
cleanup
;
}
}
if
(
flags
&
VIR_DOMAIN_AFFECT_CONFIG
)
{
persistentNet
=
virDomainNetFind
(
persistentDef
,
device
);
if
(
!
persistentNet
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"Can't find device %s"
),
device
);
goto
cleanup
;
}
}
if
(
VIR_ALLOC
(
bandwidth
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
if
(
VIR_ALLOC
(
bandwidth
->
in
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
memset
(
bandwidth
->
in
,
0
,
sizeof
(
*
bandwidth
->
in
));
if
(
VIR_ALLOC
(
bandwidth
->
out
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
memset
(
bandwidth
->
out
,
0
,
sizeof
(
*
bandwidth
->
out
));
for
(
i
=
0
;
i
<
nparams
;
i
++
)
{
virTypedParameterPtr
param
=
&
params
[
i
];
if
(
STREQ
(
param
->
field
,
VIR_DOMAIN_BANDWIDTH_IN_AVERAGE
))
{
if
(
param
->
type
!=
VIR_TYPED_PARAM_UINT
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"invalid type for bandwidth average tunable, expected a 'unsigned int'"
));
goto
cleanup
;
}
bandwidth
->
in
->
average
=
params
[
i
].
value
.
ui
;
}
else
if
(
STREQ
(
param
->
field
,
VIR_DOMAIN_BANDWIDTH_IN_PEAK
))
{
if
(
param
->
type
!=
VIR_TYPED_PARAM_UINT
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"invalid type for bandwidth peak tunable, expected a 'unsigned int'"
));
goto
cleanup
;
}
bandwidth
->
in
->
peak
=
params
[
i
].
value
.
ui
;
}
else
if
(
STREQ
(
param
->
field
,
VIR_DOMAIN_BANDWIDTH_IN_BURST
))
{
if
(
param
->
type
!=
VIR_TYPED_PARAM_UINT
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"invalid type for bandwidth burst tunable, expected a 'unsigned int'"
));
goto
cleanup
;
}
bandwidth
->
in
->
burst
=
params
[
i
].
value
.
ui
;
}
else
if
(
STREQ
(
param
->
field
,
VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE
))
{
if
(
param
->
type
!=
VIR_TYPED_PARAM_UINT
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"invalid type for bandwidth average tunable, expected a 'unsigned int'"
));
goto
cleanup
;
}
bandwidth
->
out
->
average
=
params
[
i
].
value
.
ui
;
}
else
if
(
STREQ
(
param
->
field
,
VIR_DOMAIN_BANDWIDTH_OUT_PEAK
))
{
if
(
param
->
type
!=
VIR_TYPED_PARAM_UINT
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"invalid type for bandwidth peak tunable, expected a 'unsigned int'"
));
goto
cleanup
;
}
bandwidth
->
out
->
peak
=
params
[
i
].
value
.
ui
;
}
else
if
(
STREQ
(
param
->
field
,
VIR_DOMAIN_BANDWIDTH_OUT_BURST
))
{
if
(
param
->
type
!=
VIR_TYPED_PARAM_UINT
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"invalid type for bandwidth burst tunable, expected a 'unsigned int'"
));
goto
cleanup
;
}
bandwidth
->
out
->
burst
=
params
[
i
].
value
.
ui
;
}
else
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"Parameter `%s' not supported"
),
param
->
field
);
goto
cleanup
;
}
}
/* average is mandatory, peak and burst is optional. So if no
* average is given, we free inbound/outbound here which causes
* inbound/outbound won't be set. */
if
(
!
bandwidth
->
in
->
average
)
{
VIR_FREE
(
bandwidth
->
in
);
bandwidth
->
in
=
NULL
;
}
if
(
!
bandwidth
->
out
->
average
)
{
VIR_FREE
(
bandwidth
->
out
);
bandwidth
->
out
=
NULL
;
}
if
(
flags
&
VIR_DOMAIN_AFFECT_LIVE
)
{
virNetDevBandwidthPtr
newBandwidth
;
if
(
VIR_ALLOC
(
newBandwidth
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
memset
(
newBandwidth
,
0
,
sizeof
(
newBandwidth
));
/* virNetDevBandwidthSet() will clear any previous value of
* bandwidth parameters, so merge with old bandwidth parameters
* here to prevent them from losing. */
if
(
bandwidth
->
in
||
net
->
bandwidth
->
in
)
{
if
(
VIR_ALLOC
(
newBandwidth
->
in
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
if
(
bandwidth
->
in
)
memcpy
(
newBandwidth
->
in
,
bandwidth
->
in
,
sizeof
(
*
newBandwidth
->
in
));
else
if
(
net
->
bandwidth
->
in
)
memcpy
(
newBandwidth
->
in
,
net
->
bandwidth
->
in
,
sizeof
(
*
newBandwidth
->
in
));
}
if
(
bandwidth
->
out
||
net
->
bandwidth
->
out
)
{
if
(
VIR_ALLOC
(
newBandwidth
->
out
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
if
(
bandwidth
->
out
)
memcpy
(
newBandwidth
->
out
,
bandwidth
->
out
,
sizeof
(
*
newBandwidth
->
out
));
else
if
(
net
->
bandwidth
->
out
)
memcpy
(
newBandwidth
->
out
,
net
->
bandwidth
->
out
,
sizeof
(
*
newBandwidth
->
out
));
}
if
(
virNetDevBandwidthSet
(
net
->
ifname
,
newBandwidth
)
<
0
)
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"cannot set bandwidth limits on %s"
),
device
);
goto
cleanup
;
}
virNetDevBandwidthFree
(
net
->
bandwidth
);
net
->
bandwidth
=
newBandwidth
;
}
if
(
flags
&
VIR_DOMAIN_AFFECT_CONFIG
)
{
if
(
!
persistentNet
->
bandwidth
)
{
persistentNet
->
bandwidth
=
bandwidth
;
bandwidth
=
NULL
;
}
else
{
if
(
bandwidth
->
in
)
{
VIR_FREE
(
persistentNet
->
bandwidth
->
in
);
persistentNet
->
bandwidth
->
in
=
bandwidth
->
in
;
bandwidth
->
in
=
NULL
;
}
if
(
bandwidth
->
out
)
{
VIR_FREE
(
persistentNet
->
bandwidth
->
out
);
persistentNet
->
bandwidth
->
out
=
bandwidth
->
out
;
bandwidth
->
out
=
NULL
;
}
}
if
(
virDomainSaveConfig
(
driver
->
configDir
,
persistentDef
)
<
0
)
goto
cleanup
;
}
ret
=
0
;
cleanup:
virNetDevBandwidthFree
(
bandwidth
);
virCgroupFree
(
&
group
);
if
(
vm
)
virDomainObjUnlock
(
vm
);
qemuDriverUnlock
(
driver
);
return
ret
;
}
static
int
qemuDomainGetInterfaceParameters
(
virDomainPtr
dom
,
const
char
*
device
,
virTypedParameterPtr
params
,
int
*
nparams
,
unsigned
int
flags
)
{
struct
qemud_driver
*
driver
=
dom
->
conn
->
privateData
;
int
i
;
virCgroupPtr
group
=
NULL
;
virDomainObjPtr
vm
=
NULL
;
virDomainDefPtr
def
=
NULL
;
virDomainDefPtr
persistentDef
=
NULL
;
virDomainNetDefPtr
net
=
NULL
;
int
ret
=
-
1
;
virCheckFlags
(
VIR_DOMAIN_AFFECT_LIVE
|
VIR_DOMAIN_AFFECT_CONFIG
|
VIR_TYPED_PARAM_STRING_OKAY
,
-
1
);
qemuDriverLock
(
driver
);
flags
&=
~
VIR_TYPED_PARAM_STRING_OKAY
;
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
if
(
vm
==
NULL
)
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"No such domain %s"
),
dom
->
uuid
);
goto
cleanup
;
}
if
(
virDomainLiveConfigHelperMethod
(
driver
->
caps
,
vm
,
&
flags
,
&
persistentDef
)
<
0
)
goto
cleanup
;
if
((
*
nparams
)
==
0
)
{
*
nparams
=
QEMU_NB_BANDWIDTH_PARAM
;
ret
=
0
;
goto
cleanup
;
}
def
=
persistentDef
;
if
(
!
def
)
def
=
vm
->
def
;
net
=
virDomainNetFind
(
def
,
device
);
if
(
!
net
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"Can't find device %s"
),
device
);
goto
cleanup
;
}
for
(
i
=
0
;
i
<
*
nparams
&&
i
<
QEMU_NB_BANDWIDTH_PARAM
;
i
++
)
{
params
[
i
].
value
.
ui
=
0
;
params
[
i
].
type
=
VIR_TYPED_PARAM_UINT
;
switch
(
i
)
{
case
0
:
/* inbound.average */
if
(
virStrcpyStatic
(
params
[
i
].
field
,
VIR_DOMAIN_BANDWIDTH_IN_AVERAGE
)
==
NULL
)
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Field name '%s' too long"
),
VIR_DOMAIN_BANDWIDTH_IN_AVERAGE
);
goto
cleanup
;
}
if
(
net
->
bandwidth
&&
net
->
bandwidth
->
in
)
params
[
i
].
value
.
ui
=
net
->
bandwidth
->
in
->
average
;
break
;
case
1
:
/* inbound.peak */
if
(
virStrcpyStatic
(
params
[
i
].
field
,
VIR_DOMAIN_BANDWIDTH_IN_PEAK
)
==
NULL
)
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Field name '%s' too long"
),
VIR_DOMAIN_BANDWIDTH_IN_PEAK
);
goto
cleanup
;
}
if
(
net
->
bandwidth
&&
net
->
bandwidth
->
in
)
params
[
i
].
value
.
ui
=
net
->
bandwidth
->
in
->
peak
;
break
;
case
2
:
/* inbound.burst */
if
(
virStrcpyStatic
(
params
[
i
].
field
,
VIR_DOMAIN_BANDWIDTH_IN_BURST
)
==
NULL
)
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Field name '%s' too long"
),
VIR_DOMAIN_BANDWIDTH_IN_BURST
);
goto
cleanup
;
}
if
(
net
->
bandwidth
&&
net
->
bandwidth
->
in
)
params
[
i
].
value
.
ui
=
net
->
bandwidth
->
in
->
burst
;
break
;
case
3
:
/* outbound.average */
if
(
virStrcpyStatic
(
params
[
i
].
field
,
VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE
)
==
NULL
)
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Field name '%s' too long"
),
VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE
);
goto
cleanup
;
}
if
(
net
->
bandwidth
&&
net
->
bandwidth
->
out
)
params
[
i
].
value
.
ui
=
net
->
bandwidth
->
out
->
average
;
break
;
case
4
:
/* outbound.peak */
if
(
virStrcpyStatic
(
params
[
i
].
field
,
VIR_DOMAIN_BANDWIDTH_OUT_PEAK
)
==
NULL
)
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Field name '%s' too long"
),
VIR_DOMAIN_BANDWIDTH_OUT_PEAK
);
goto
cleanup
;
}
if
(
net
->
bandwidth
&&
net
->
bandwidth
->
out
)
params
[
i
].
value
.
ui
=
net
->
bandwidth
->
out
->
peak
;
break
;
case
5
:
/* outbound.burst */
if
(
virStrcpyStatic
(
params
[
i
].
field
,
VIR_DOMAIN_BANDWIDTH_OUT_BURST
)
==
NULL
)
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Field name '%s' too long"
),
VIR_DOMAIN_BANDWIDTH_OUT_BURST
);
goto
cleanup
;
}
if
(
net
->
bandwidth
&&
net
->
bandwidth
->
out
)
params
[
i
].
value
.
ui
=
net
->
bandwidth
->
out
->
burst
;
break
;
default:
break
;
/* should not hit here */
}
}
if
(
*
nparams
>
QEMU_NB_BANDWIDTH_PARAM
)
*
nparams
=
QEMU_NB_BANDWIDTH_PARAM
;
ret
=
0
;
cleanup:
if
(
group
)
virCgroupFree
(
&
group
);
if
(
vm
)
virDomainObjUnlock
(
vm
);
qemuDriverUnlock
(
driver
);
return
ret
;
}
static
int
static
int
qemudDomainMemoryStats
(
virDomainPtr
dom
,
qemudDomainMemoryStats
(
virDomainPtr
dom
,
struct
_virDomainMemoryStat
*
stats
,
struct
_virDomainMemoryStat
*
stats
,
...
@@ -11642,6 +11991,8 @@ static virDriver qemuDriver = {
...
@@ -11642,6 +11991,8 @@ static virDriver qemuDriver = {
.
domainGetBlockIoTune
=
qemuDomainGetBlockIoTune
,
/* 0.9.8 */
.
domainGetBlockIoTune
=
qemuDomainGetBlockIoTune
,
/* 0.9.8 */
.
domainSetNumaParameters
=
qemuDomainSetNumaParameters
,
/* 0.9.9 */
.
domainSetNumaParameters
=
qemuDomainSetNumaParameters
,
/* 0.9.9 */
.
domainGetNumaParameters
=
qemuDomainGetNumaParameters
,
/* 0.9.9 */
.
domainGetNumaParameters
=
qemuDomainGetNumaParameters
,
/* 0.9.9 */
.
domainGetInterfaceParameters
=
qemuDomainGetInterfaceParameters
,
/* 0.9.9 */
.
domainSetInterfaceParameters
=
qemuDomainSetInterfaceParameters
,
/* 0.9.9 */
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录