Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
d2a6fc79
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看板
提交
d2a6fc79
编写于
1月 29, 2016
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
conf: Store cpu pinning data in def->vcpus
Now with the new struct the data can be stored in a much saner place.
上级
856f254e
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
190 addition
and
249 deletion
+190
-249
src/conf/domain_conf.c
src/conf/domain_conf.c
+54
-82
src/conf/domain_conf.h
src/conf/domain_conf.h
+1
-2
src/libxl/libxl_domain.c
src/libxl/libxl_domain.c
+8
-9
src/libxl/libxl_driver.c
src/libxl/libxl_driver.c
+16
-20
src/qemu/qemu_cgroup.c
src/qemu/qemu_cgroup.c
+4
-11
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+64
-73
src/qemu/qemu_process.c
src/qemu/qemu_process.c
+18
-18
src/test/test_driver.c
src/test/test_driver.c
+17
-26
src/vz/vz_sdk.c
src/vz/vz_sdk.c
+8
-8
未找到文件。
src/conf/domain_conf.c
浏览文件 @
d2a6fc79
...
...
@@ -1289,6 +1289,9 @@ virDomainVcpuInfoClear(virDomainVcpuInfoPtr info)
{
if (!info)
return;
virBitmapFree(info->cpumask);
info->cpumask = NULL;
}
...
...
@@ -1422,7 +1425,14 @@ virDomainDefGetVcpu(virDomainDefPtr def,
static bool
virDomainDefHasVcpuPin(const virDomainDef *def)
{
return !!def->cputune.vcpupin;
size_t i;
for (i = 0; i < def->maxvcpus; i++) {
if (def->vcpus[i].cpumask)
return true;
}
return false;
}
...
...
@@ -2593,8 +2603,6 @@ void virDomainDefFree(virDomainDefPtr def)
virDomainIOThreadIDDefArrayFree(def->iothreadids, def->niothreadids);
virDomainPinDefArrayFree(def->cputune.vcpupin, def->cputune.nvcpupin);
virBitmapFree(def->cputune.emulatorpin);
for (i = 0; i < def->cputune.nvcpusched; i++)
...
...
@@ -14110,83 +14118,68 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node,
}
/* Check if pin with same id already exists. */
static bool
virDomainPinIsDuplicate(virDomainPinDefPtr *def,
int npin,
int id)
{
size_t i;
if (!def || !npin)
return false;
for (i = 0; i < npin; i++) {
if (def[i]->id == id)
return true;
}
return false;
}
/* Parse the XML definition for a vcpupin
*
* vcpupin has the form of
* <vcpupin vcpu='0' cpuset='0'/>
*/
static
virDomainPinDefPtr
virDomainVcpuPinDefParseXML(
xmlNodePtr node
,
xml
XPathContextPtr ctxt
)
static
int
virDomainVcpuPinDefParseXML(
virDomainDefPtr def
,
xml
NodePtr node
)
{
virDomainPinDefPtr def;
xmlNodePtr oldnode = ctxt->node;
virDomainVcpuInfoPtr vcpu;
unsigned int vcpuid;
char *tmp = NULL;
int ret = -1;
if (VIR_ALLOC(def) < 0)
return NULL;
ctxt->node = node;
if (!(tmp = virXPathString("string(./@vcpu)", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing vcpu id in vcpupin"));
goto error;
if (!(tmp = virXMLPropString(node, "vcpu"))) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("missing vcpu id in vcpupin"));
goto cleanup;
}
if (virStrToLong_uip(tmp, NULL, 10, &vcpuid) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid setting for vcpu '%s'"), tmp);
goto
error
;
goto
cleanup
;
}
VIR_FREE(tmp);
def->id = vcpuid;
if (!(vcpu = virDomainDefGetVcpu(def, vcpuid)) ||
!vcpu->online) {
/* To avoid the regression when daemon loading domain confs, we can't
* simply error out if <vcpupin> nodes greater than current vcpus.
* Ignore them instead. */
VIR_WARN("Ignoring vcpupin for missing vcpus");
ret = 0;
goto cleanup;
}
if (!(tmp = virXMLPropString(node, "cpuset"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing cpuset for vcpupin"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing cpuset for vcpupin"));
goto cleanup;
}
goto error;
if (vcpu->cpumask) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("duplicate vcpupin for vcpu '%d'"), vcpuid);
goto cleanup;
}
if (virBitmapParse(tmp, 0, &
def
->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
goto
error
;
if (virBitmapParse(tmp, 0, &
vcpu
->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
goto
cleanup
;
if (virBitmapIsAllClear(
def
->cpumask)) {
if (virBitmapIsAllClear(
vcpu
->cpumask)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid value of 'cpuset': %s"), tmp);
goto
error
;
goto
cleanup
;
}
ret = 0;
cleanup:
VIR_FREE(tmp);
ctxt->node = oldnode;
return def;
error:
VIR_FREE(def);
goto cleanup;
return ret;
}
...
...
@@ -15142,34 +15135,9 @@ virDomainDefParseXML(xmlDocPtr xml,
if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0)
goto error;
if (n && VIR_ALLOC_N(def->cputune.vcpupin, n) < 0)
goto error;
for (i = 0; i < n; i++) {
virDomainPinDefPtr vcpupin;
if (!(vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt)))
if (virDomainVcpuPinDefParseXML(def, nodes[i]))
goto error;
if (virDomainPinIsDuplicate(def->cputune.vcpupin,
def->cputune.nvcpupin,
vcpupin->id)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("duplicate vcpupin for same vcpu"));
virDomainPinDefFree(vcpupin);
goto error;
}
if (vcpupin->id >= virDomainDefGetVcpus(def)) {
/* To avoid the regression when daemon loading
* domain confs, we can't simply error out if
* <vcpupin> nodes greater than current vcpus,
* ignoring them instead.
*/
VIR_WARN("Ignore vcpupin for missing vcpus");
virDomainPinDefFree(vcpupin);
} else {
def->cputune.vcpupin[def->cputune.nvcpupin++] = vcpupin;
}
}
VIR_FREE(nodes);
...
...
@@ -21845,15 +21813,19 @@ virDomainDefFormatInternal(virDomainDefPtr def,
"</emulator_quota>\n",
def->cputune.emulator_quota);
for (i = 0; i < def->
cputune.nvcpupin
; i++) {
for (i = 0; i < def->
maxvcpus
; i++) {
char *cpumask;
virBufferAsprintf(&childrenBuf, "<vcpupin vcpu='%u' ",
def->cputune.vcpupin[i]->id);
virDomainVcpuInfoPtr vcpu = def->vcpus + i;
if (!(cpumask = virBitmapFormat(def->cputune.vcpupin[i]->cpumask)))
if (!vcpu->cpumask)
continue;
if (!(cpumask = virBitmapFormat(vcpu->cpumask)))
goto error;
virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
virBufferAsprintf(&childrenBuf,
"<vcpupin vcpu='%zu' cpuset='%s'/>\n", i, cpumask);
VIR_FREE(cpumask);
}
...
...
src/conf/domain_conf.h
浏览文件 @
d2a6fc79
...
...
@@ -2137,8 +2137,6 @@ struct _virDomainCputune {
long
long
quota
;
unsigned
long
long
emulator_period
;
long
long
emulator_quota
;
size_t
nvcpupin
;
virDomainPinDefPtr
*
vcpupin
;
virBitmapPtr
emulatorpin
;
size_t
nvcpusched
;
...
...
@@ -2153,6 +2151,7 @@ typedef virDomainVcpuInfo *virDomainVcpuInfoPtr;
struct
_virDomainVcpuInfo
{
bool
online
;
virBitmapPtr
cpumask
;
};
typedef
struct
_virDomainBlkiotune
virDomainBlkiotune
;
...
...
src/libxl/libxl_domain.c
浏览文件 @
d2a6fc79
...
...
@@ -821,7 +821,7 @@ int
libxlDomainSetVcpuAffinities
(
libxlDriverPrivatePtr
driver
,
virDomainObjPtr
vm
)
{
libxlDriverConfigPtr
cfg
=
libxlDriverConfigGet
(
driver
);
virDomain
PinDefPtr
pin
;
virDomain
VcpuInfoPtr
vcpu
;
libxl_bitmap
map
;
virBitmapPtr
cpumask
=
NULL
;
size_t
i
;
...
...
@@ -830,13 +830,12 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
libxl_bitmap_init
(
&
map
);
for
(
i
=
0
;
i
<
virDomainDefGetVcpus
(
vm
->
def
);
++
i
)
{
pin
=
virDomainPinFind
(
vm
->
def
->
cputune
.
vcpupin
,
vm
->
def
->
cputune
.
nvcpupin
,
i
);
vcpu
=
virDomainDefGetVcpu
(
vm
->
def
,
i
);
if
(
pin
&&
pin
->
cpumask
)
cpumask
=
pin
->
cpumask
;
else
if
(
!
vcpu
->
online
)
continue
;
if
(
!
(
cpumask
=
vcpu
->
cpumask
))
cpumask
=
vm
->
def
->
cpumask
;
if
(
!
cpumask
)
...
...
@@ -845,9 +844,9 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
if
(
virBitmapToData
(
cpumask
,
&
map
.
map
,
(
int
*
)
&
map
.
size
)
<
0
)
goto
cleanup
;
if
(
libxl_set_vcpuaffinity
(
cfg
->
ctx
,
vm
->
def
->
id
,
pin
->
id
,
&
map
)
!=
0
)
{
if
(
libxl_set_vcpuaffinity
(
cfg
->
ctx
,
vm
->
def
->
id
,
i
,
&
map
)
!=
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to pin vcpu '%
d' with libxenlight"
),
pin
->
id
);
_
(
"Failed to pin vcpu '%
zu' with libxenlight"
),
i
);
goto
cleanup
;
}
...
...
src/libxl/libxl_driver.c
浏览文件 @
d2a6fc79
...
...
@@ -2329,6 +2329,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
libxlDriverConfigPtr
cfg
=
libxlDriverConfigGet
(
driver
);
virDomainDefPtr
targetDef
=
NULL
;
virBitmapPtr
pcpumap
=
NULL
;
virDomainVcpuInfoPtr
vcpuinfo
;
virDomainObjPtr
vm
;
int
ret
=
-
1
;
...
...
@@ -2364,6 +2365,13 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
if
(
!
pcpumap
)
goto
endjob
;
if
(
!
(
vcpuinfo
=
virDomainDefGetVcpu
(
targetDef
,
vcpu
))
||
!
vcpuinfo
->
online
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"vcpu '%u' is not active"
),
vcpu
);
goto
endjob
;
}
if
(
flags
&
VIR_DOMAIN_AFFECT_LIVE
)
{
libxl_bitmap
map
=
{
.
size
=
maplen
,
.
map
=
cpumap
};
if
(
libxl_set_vcpuaffinity
(
cfg
->
ctx
,
vm
->
def
->
id
,
vcpu
,
&
map
)
!=
0
)
{
...
...
@@ -2374,20 +2382,9 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
}
}
if
(
!
targetDef
->
cputune
.
vcpupin
)
{
if
(
VIR_ALLOC
(
targetDef
->
cputune
.
vcpupin
)
<
0
)
goto
endjob
;
targetDef
->
cputune
.
nvcpupin
=
0
;
}
if
(
virDomainPinAdd
(
&
targetDef
->
cputune
.
vcpupin
,
&
targetDef
->
cputune
.
nvcpupin
,
cpumap
,
maplen
,
vcpu
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"failed to update or add vcpupin xml"
));
goto
endjob
;
}
virBitmapFree
(
vcpuinfo
->
cpumask
);
vcpuinfo
->
cpumask
=
pcpumap
;
pcpumap
=
NULL
;
ret
=
0
;
...
...
@@ -2463,15 +2460,14 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
memset
(
cpumaps
,
0x00
,
maplen
*
ncpumaps
);
for
(
vcpu
=
0
;
vcpu
<
ncpumaps
;
vcpu
++
)
{
virDomain
PinDefPtr
pininfo
;
virDomain
VcpuInfoPtr
vcpuinfo
=
virDomainDefGetVcpu
(
targetDef
,
vcpu
)
;
virBitmapPtr
bitmap
=
NULL
;
pininfo
=
virDomainPinFind
(
targetDef
->
cputune
.
vcpupin
,
targetDef
->
cputune
.
nvcpupin
,
vcpu
);
if
(
!
vcpuinfo
->
online
)
continue
;
if
(
pininfo
&&
pin
info
->
cpumask
)
bitmap
=
pin
info
->
cpumask
;
if
(
vcpu
info
->
cpumask
)
bitmap
=
vcpu
info
->
cpumask
;
else
if
(
targetDef
->
cpumask
)
bitmap
=
targetDef
->
cpumask
;
else
...
...
src/qemu/qemu_cgroup.c
浏览文件 @
d2a6fc79
...
...
@@ -1024,7 +1024,7 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)
virCgroupPtr
cgroup_vcpu
=
NULL
;
qemuDomainObjPrivatePtr
priv
=
vm
->
privateData
;
virDomainDefPtr
def
=
vm
->
def
;
size_t
i
,
j
;
size_t
i
;
unsigned
long
long
period
=
vm
->
def
->
cputune
.
period
;
long
long
quota
=
vm
->
def
->
cputune
.
quota
;
char
*
mem_mask
=
NULL
;
...
...
@@ -1082,20 +1082,13 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)
virCgroupSetCpusetMems
(
cgroup_vcpu
,
mem_mask
)
<
0
)
goto
cleanup
;
/* try to use the default cpu maps */
if
(
vm
->
def
->
placement_mode
==
VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO
)
if
(
vcpu
->
cpumask
)
cpumap
=
vcpu
->
cpumask
;
else
if
(
vm
->
def
->
placement_mode
==
VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO
)
cpumap
=
priv
->
autoCpuset
;
else
cpumap
=
vm
->
def
->
cpumask
;
/* lookup a more specific pinning info */
for
(
j
=
0
;
j
<
def
->
cputune
.
nvcpupin
;
j
++
)
{
if
(
def
->
cputune
.
vcpupin
[
j
]
->
id
==
i
)
{
cpumap
=
def
->
cputune
.
vcpupin
[
j
]
->
cpumask
;
break
;
}
}
if
(
cpumap
&&
qemuSetupCgroupCpusetCpus
(
cgroup_vcpu
,
cpumap
)
<
0
)
goto
cleanup
;
}
...
...
src/qemu/qemu_driver.c
浏览文件 @
d2a6fc79
...
...
@@ -4869,10 +4869,8 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
VIR_CGROUP_THREAD_VCPU, vcpu) < 0)
goto cleanup;
/* Free vcpupin setting */
virDomainPinDel(&vm->def->cputune.vcpupin,
&vm->def->cputune.nvcpupin,
vcpu);
virBitmapFree(vcpuinfo->cpumask);
vcpuinfo->cpumask = NULL;
ret = 0;
...
...
@@ -5033,10 +5031,15 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
if (persistentDef) {
/* remove vcpupin entries for vcpus that were unplugged */
if (nvcpus < virDomainDefGetVcpus(persistentDef)) {
for (i = virDomainDefGetVcpus(persistentDef) - 1; i >= nvcpus; i--)
virDomainPinDel(&persistentDef->cputune.vcpupin,
&persistentDef->cputune.nvcpupin,
i);
for (i = virDomainDefGetVcpus(persistentDef) - 1; i >= nvcpus; i--) {
virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(persistentDef,
i);
if (vcpu) {
virBitmapFree(vcpu->cpumask);
vcpu->cpumask = NULL;
}
}
}
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
...
...
@@ -5096,9 +5099,11 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
virCgroupPtr cgroup_vcpu = NULL;
int ret = -1;
qemuDomainObjPrivatePtr priv;
size_t newVcpuPinNum = 0;
virDomainPinDefPtr *newVcpuPin = NULL;
virBitmapPtr pcpumap = NULL;
virBitmapPtr pcpumaplive = NULL;
virBitmapPtr pcpumappersist = NULL;
virDomainVcpuInfoPtr vcpuinfolive = NULL;
virDomainVcpuInfoPtr vcpuinfopersist = NULL;
virQEMUDriverConfigPtr cfg = NULL;
virObjectEventPtr event = NULL;
char paramField[VIR_TYPED_PARAM_FIELD_LENGTH] = "";
...
...
@@ -5126,18 +5131,36 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
priv = vm->privateData;
if (def && vcpu >= virDomainDefGetVcpus(def)) {
virReportError(VIR_ERR_INVALID_ARG,
_("vcpu %d is out of range of live cpu count %d"),
vcpu, virDomainDefGetVcpus(def));
goto endjob;
if (def) {
if (!(vcpuinfolive = virDomainDefGetVcpu(def, vcpu))) {
virReportError(VIR_ERR_INVALID_ARG,
_("vcpu %d is out of range of live cpu count %d"),
vcpu, virDomainDefGetVcpus(def));
goto endjob;
}
if (!vcpuinfolive->online) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("setting cpu pinning for inactive vcpu '%d' is not "
"supported"), vcpu);
goto endjob;
}
}
if (persistentDef && vcpu >= virDomainDefGetVcpus(persistentDef)) {
virReportError(VIR_ERR_INVALID_ARG,
_("vcpu %d is out of range of persistent cpu count %d"),
vcpu, virDomainDefGetVcpus(persistentDef));
goto endjob;
if (persistentDef) {
if (!(vcpuinfopersist = virDomainDefGetVcpu(persistentDef, vcpu))) {
virReportError(VIR_ERR_INVALID_ARG,
_("vcpu %d is out of range of persistent cpu count %d"),
vcpu, virDomainDefGetVcpus(persistentDef));
goto endjob;
}
if (!vcpuinfopersist->online) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("setting cpu pinning for inactive vcpu '%d' is not "
"supported"), vcpu);
goto endjob;
}
}
if (!(pcpumap = virBitmapNewData(cpumap, maplen)))
...
...
@@ -5149,6 +5172,10 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
goto endjob;
}
if ((def && !(pcpumaplive = virBitmapNewCopy(pcpumap))) ||
(persistentDef && !(pcpumappersist = virBitmapNewCopy(pcpumap))))
goto endjob;
if (def) {
if (!qemuDomainHasVcpuPids(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
...
...
@@ -5156,26 +5183,6 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
goto endjob;
}
if (def->cputune.vcpupin) {
newVcpuPin = virDomainPinDefCopy(def->cputune.vcpupin,
def->cputune.nvcpupin);
if (!newVcpuPin)
goto endjob;
newVcpuPinNum = def->cputune.nvcpupin;
} else {
if (VIR_ALLOC(newVcpuPin) < 0)
goto endjob;
newVcpuPinNum = 0;
}
if (virDomainPinAdd(&newVcpuPin, &newVcpuPinNum,
cpumap, maplen, vcpu) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to update vcpupin"));
goto endjob;
}
/* Configure the corresponding cpuset cgroup before set affinity. */
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, vcpu,
...
...
@@ -5197,13 +5204,9 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
}
}
if (def->cputune.vcpupin)
virDomainPinDefArrayFree(def->cputune.vcpupin,
def->cputune.nvcpupin);
def->cputune.vcpupin = newVcpuPin;
def->cputune.nvcpupin = newVcpuPinNum;
newVcpuPin = NULL;
virBitmapFree(vcpuinfolive->cpumask);
vcpuinfolive->cpumask = pcpumaplive;
pcpumaplive = NULL;
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
goto endjob;
...
...
@@ -5222,21 +5225,9 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
}
if (persistentDef) {
if (!persistentDef->cputune.vcpupin) {
if (VIR_ALLOC(persistentDef->cputune.vcpupin) < 0)
goto endjob;
persistentDef->cputune.nvcpupin = 0;
}
if (virDomainPinAdd(&persistentDef->cputune.vcpupin,
&persistentDef->cputune.nvcpupin,
cpumap,
maplen,
vcpu) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to update or add vcpupin xml of "
"a persistent domain"));
goto endjob;
}
virBitmapFree(vcpuinfopersist->cpumask);
vcpuinfopersist->cpumask = pcpumappersist;
pcpumappersist = NULL;
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
goto endjob;
...
...
@@ -5248,14 +5239,14 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
qemuDomainObjEndJob(driver, vm);
cleanup:
if (newVcpuPin)
virDomainPinDefArrayFree(newVcpuPin, newVcpuPinNum);
if (cgroup_vcpu)
virCgroupFree(&cgroup_vcpu);
virDomainObjEndAPI(&vm);
qemuDomainEventQueue(driver, event);
VIR_FREE(str);
virBitmapFree(pcpumap);
virBitmapFree(pcpumaplive);
virBitmapFree(pcpumappersist);
virObjectUnref(cfg);
return ret;
}
...
...
@@ -5280,7 +5271,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
virDomainObjPtr vm = NULL;
virDomainDefPtr def;
int ret = -1;
int hostcpus, vcpu;
int hostcpus;
size_t i;
virBitmapPtr allcpumap = NULL;
qemuDomainObjPrivatePtr priv = NULL;
...
...
@@ -5312,16 +5304,15 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
if (ncpumaps < 1)
goto cleanup;
for (
vcpu = 0; vcpu < ncpumaps; vcpu
++) {
virDomain
PinDefPtr pininfo
;
for (
i = 0; i < ncpumaps; i
++) {
virDomain
VcpuInfoPtr vcpu = virDomainDefGetVcpu(def, i)
;
virBitmapPtr bitmap = NULL;
pininfo = virDomainPinFind(def->cputune.vcpupin,
def->cputune.nvcpupin,
vcpu);
if (!vcpu->online)
continue;
if (
pininfo && pininfo
->cpumask)
bitmap =
pininfo
->cpumask;
if (
vcpu
->cpumask)
bitmap =
vcpu
->cpumask;
else if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
priv->autoCpuset)
bitmap = priv->autoCpuset;
...
...
@@ -5330,7 +5321,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
else
bitmap = allcpumap;
virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen,
vcpu
), maplen);
virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen,
i
), maplen);
}
ret = ncpumaps;
...
...
src/qemu/qemu_process.c
浏览文件 @
d2a6fc79
...
...
@@ -2193,23 +2193,23 @@ static int
qemuProcessSetVcpuAffinities
(
virDomainObjPtr
vm
)
{
virDomainDefPtr
def
=
vm
->
def
;
virDomain
PinDefPtr
pininfo
;
int
n
;
virDomain
VcpuInfoPtr
vcpu
;
size_t
i
;
int
ret
=
-
1
;
VIR_DEBUG
(
"Setting affinity on CPUs nvcpupin=%zu nvcpus=%d hasVcpupids=%d"
,
def
->
cputune
.
nvcpupin
,
virDomainDefGetVcpus
(
def
),
qemuDomainHasVcpuPids
(
vm
));
if
(
!
def
->
cputune
.
nvcpupin
)
return
0
;
VIR_DEBUG
(
"Setting affinity on CPUs"
);
if
(
!
qemuDomainHasVcpuPids
(
vm
))
{
/* If any CPU has custom affinity that differs from the
* VM default affinity, we must reject it
*/
for
(
n
=
0
;
n
<
def
->
cputune
.
nvcpupin
;
n
++
)
{
if
(
def
->
cputune
.
vcpupin
[
n
]
->
cpumask
&&
!
virBitmapEqual
(
def
->
cpumask
,
def
->
cputune
.
vcpupin
[
n
]
->
cpumask
))
{
for
(
i
=
0
;
i
<
virDomainDefGetVcpusMax
(
def
);
i
++
)
{
vcpu
=
virDomainDefGetVcpu
(
def
,
i
);
if
(
!
vcpu
->
online
)
continue
;
if
(
vcpu
->
cpumask
&&
!
virBitmapEqual
(
def
->
cpumask
,
vcpu
->
cpumask
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"cpu affinity is not supported"
));
return
-
1
;
...
...
@@ -2218,19 +2218,19 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
return
0
;
}
for
(
n
=
0
;
n
<
virDomainDefGetVcpus
(
def
);
n
++
)
{
for
(
i
=
0
;
i
<
virDomainDefGetVcpusMax
(
def
);
i
++
)
{
virBitmapPtr
bitmap
;
/* set affinity only for existing vcpus */
if
(
!
(
pininfo
=
virDomainPinFind
(
def
->
cputune
.
vcpupin
,
def
->
cputune
.
nvcpupin
,
n
))
)
vcpu
=
virDomainDefGetVcpu
(
def
,
i
);
if
(
!
vcpu
->
online
)
continue
;
if
(
!
(
bitmap
=
pininfo
->
cpumask
)
&&
if
(
!
(
bitmap
=
vcpu
->
cpumask
)
&&
!
(
bitmap
=
def
->
cpumask
))
continue
;
if
(
virProcessSetAffinity
(
qemuDomainGetVcpuPid
(
vm
,
n
),
bitmap
)
<
0
)
if
(
virProcessSetAffinity
(
qemuDomainGetVcpuPid
(
vm
,
i
),
bitmap
)
<
0
)
goto
cleanup
;
}
...
...
src/test/test_driver.c
浏览文件 @
d2a6fc79
...
...
@@ -2455,15 +2455,14 @@ static int testDomainGetVcpus(virDomainPtr domain,
memset
(
cpumaps
,
0
,
maxinfo
*
maplen
);
for
(
i
=
0
;
i
<
maxinfo
;
i
++
)
{
virDomain
PinDefPtr
pininfo
;
virDomain
VcpuInfoPtr
vcpu
=
virDomainDefGetVcpu
(
def
,
i
)
;
virBitmapPtr
bitmap
=
NULL
;
pininfo
=
virDomainPinFind
(
def
->
cputune
.
vcpupin
,
def
->
cputune
.
nvcpupin
,
i
);
if
(
!
vcpu
->
online
)
continue
;
if
(
pininfo
&&
pininfo
->
cpumask
)
bitmap
=
pininfo
->
cpumask
;
if
(
vcpu
->
cpumask
)
bitmap
=
vcpu
->
cpumask
;
else
if
(
def
->
cpumask
)
bitmap
=
def
->
cpumask
;
else
...
...
@@ -2492,6 +2491,7 @@ static int testDomainPinVcpu(virDomainPtr domain,
unsigned
char
*
cpumap
,
int
maplen
)
{
virDomainVcpuInfoPtr
vcpuinfo
;
virDomainObjPtr
privdom
;
virDomainDefPtr
def
;
int
ret
=
-
1
;
...
...
@@ -2507,29 +2507,21 @@ static int testDomainPinVcpu(virDomainPtr domain,
goto
cleanup
;
}
if
(
vcpu
>
virDomainDefGetVcpus
(
privdom
->
def
))
{
if
(
!
(
vcpuinfo
=
virDomainDefGetVcpu
(
def
,
vcpu
))
||
!
vcpuinfo
->
online
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"requested vcpu '%d' is not present in the domain"
),
vcpu
);
goto
cleanup
;
}
if
(
!
def
->
cputune
.
vcpupin
)
{
if
(
VIR_ALLOC
(
def
->
cputune
.
vcpupin
)
<
0
)
goto
cleanup
;
def
->
cputune
.
nvcpupin
=
0
;
}
if
(
virDomainPinAdd
(
&
def
->
cputune
.
vcpupin
,
&
def
->
cputune
.
nvcpupin
,
cpumap
,
maplen
,
vcpu
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"failed to update or add vcpupin"
));
virBitmapFree
(
vcpuinfo
->
cpumask
);
if
(
!
(
vcpuinfo
->
cpumask
=
virBitmapNewData
(
cpumap
,
maplen
)))
goto
cleanup
;
}
ret
=
0
;
cleanup:
virDomainObjEndAPI
(
&
privdom
);
return
ret
;
...
...
@@ -2566,15 +2558,14 @@ testDomainGetVcpuPinInfo(virDomainPtr dom,
ncpumaps
=
virDomainDefGetVcpus
(
def
);
for
(
vcpu
=
0
;
vcpu
<
ncpumaps
;
vcpu
++
)
{
virDomain
PinDefPtr
pininfo
;
virDomain
VcpuInfoPtr
vcpuinfo
=
virDomainDefGetVcpu
(
def
,
vcpu
)
;
virBitmapPtr
bitmap
=
NULL
;
pininfo
=
virDomainPinFind
(
def
->
cputune
.
vcpupin
,
def
->
cputune
.
nvcpupin
,
vcpu
);
if
(
!
vcpuinfo
->
online
)
continue
;
if
(
pininfo
&&
pin
info
->
cpumask
)
bitmap
=
pin
info
->
cpumask
;
if
(
vcpu
info
->
cpumask
)
bitmap
=
vcpu
info
->
cpumask
;
else
if
(
def
->
cpumask
)
bitmap
=
def
->
cpumask
;
else
...
...
src/vz/vz_sdk.c
浏览文件 @
d2a6fc79
...
...
@@ -1957,14 +1957,14 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDomainDefPtr def)
return
-
1
;
}
if
(
def
->
cputune
.
vcpupin
)
{
for
(
i
=
0
;
i
<
def
->
cputune
.
nvcpupin
;
i
++
)
{
if
(
def
->
cputune
.
vcpupin
[
i
]
->
cpumask
&&
!
virBitmapEqual
(
def
->
cpumask
,
def
->
cputune
.
vcpupin
[
i
]
->
cpumask
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"vcpupin cpumask differs from default cpumask"
));
return
-
1
;
}
for
(
i
=
0
;
i
<
virDomainDefGetVcpusMax
(
def
);
i
++
)
{
virDomainVcpuInfoPtr
vcpu
=
virDomainDefGetVcpu
(
def
,
i
);
if
(
vcpu
->
cpumask
&&
!
virBitmapEqual
(
def
->
cpumask
,
vcpu
->
cpumask
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"vcpupin cpumask differs from default cpumask"
))
;
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录