提交 856f254e 编写于 作者: P Peter Krempa

conf: Don't copy def->cpumask into cpu pinning info

This step can be omitted, so that drivers can decide what to do when the
user requests to use default vcpu pinning.
上级 d0d341a3
......@@ -15173,34 +15173,6 @@ virDomainDefParseXML(xmlDocPtr xml,
}
VIR_FREE(nodes);
/* Initialize the pinning policy for vcpus which doesn't has
* the policy specified explicitly as def->cpuset.
*/
if (def->cpumask) {
if (VIR_REALLOC_N(def->cputune.vcpupin, virDomainDefGetVcpus(def)) < 0)
goto error;
for (i = 0; i < virDomainDefGetVcpus(def); i++) {
if (virDomainPinIsDuplicate(def->cputune.vcpupin,
def->cputune.nvcpupin,
i))
continue;
virDomainPinDefPtr vcpupin = NULL;
if (VIR_ALLOC(vcpupin) < 0)
goto error;
if (!(vcpupin->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN))) {
VIR_FREE(vcpupin);
goto error;
}
virBitmapCopy(vcpupin->cpumask, def->cpumask);
vcpupin->id = i;
def->cputune.vcpupin[def->cputune.nvcpupin++] = vcpupin;
}
}
if ((n = virXPathNodeSet("./cputune/emulatorpin", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract emulatorpin nodes"));
......@@ -21875,10 +21847,6 @@ virDomainDefFormatInternal(virDomainDefPtr def,
for (i = 0; i < def->cputune.nvcpupin; i++) {
char *cpumask;
/* Ignore the vcpupin which inherit from "cpuset of "<vcpu>." */
if (virBitmapEqual(def->cpumask, def->cputune.vcpupin[i]->cpumask))
continue;
virBufferAsprintf(&childrenBuf, "<vcpupin vcpu='%u' ",
def->cputune.vcpupin[i]->id);
......
......@@ -829,9 +829,18 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
libxl_bitmap_init(&map);
for (i = 0; i < vm->def->cputune.nvcpupin; ++i) {
pin = vm->def->cputune.vcpupin[i];
for (i = 0; i < virDomainDefGetVcpus(vm->def); ++i) {
pin = virDomainPinFind(vm->def->cputune.vcpupin,
vm->def->cputune.nvcpupin,
i);
if (pin && pin->cpumask)
cpumask = pin->cpumask;
else
cpumask = vm->def->cpumask;
if (!cpumask)
continue;
if (virBitmapToData(cpumask, &map.map, (int *)&map.size) < 0)
goto cleanup;
......
......@@ -2472,6 +2472,8 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
if (pininfo && pininfo->cpumask)
bitmap = pininfo->cpumask;
else if (targetDef->cpumask)
bitmap = targetDef->cpumask;
else
bitmap = allcpumap;
......
......@@ -4682,33 +4682,6 @@ qemuDomainAddCgroupForThread(virCgroupPtr cgroup,
return NULL;
}
static int
qemuDomainHotplugAddPin(virBitmapPtr cpumask,
int idx,
virDomainPinDefPtr **pindef_list,
size_t *npin)
{
int ret = -1;
virDomainPinDefPtr pindef = NULL;
if (VIR_ALLOC(pindef) < 0)
goto cleanup;
if (!(pindef->cpumask = virBitmapNewCopy(cpumask))) {
VIR_FREE(pindef);
goto cleanup;
}
pindef->id = idx;
if (VIR_APPEND_ELEMENT_COPY(*pindef_list, *npin, pindef) < 0) {
virBitmapFree(pindef->cpumask);
VIR_FREE(pindef);
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
static int
qemuDomainHotplugPinThread(virBitmapPtr cpumask,
......@@ -4825,11 +4798,6 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
/* Inherit def->cpuset */
if (vm->def->cpumask) {
if (qemuDomainHotplugAddPin(vm->def->cpumask, vcpu,
&vm->def->cputune.vcpupin,
&vm->def->cputune.nvcpupin) < 0)
goto cleanup;
if (qemuDomainHotplugPinThread(vm->def->cpumask, vcpu, vcpupid,
cgroup_vcpu) < 0) {
goto cleanup;
......@@ -5357,6 +5325,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
else if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
priv->autoCpuset)
bitmap = priv->autoCpuset;
else if (def->cpumask)
bitmap = def->cpumask;
else
bitmap = allcpumap;
......
......@@ -2207,7 +2207,8 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
* VM default affinity, we must reject it
*/
for (n = 0; n < def->cputune.nvcpupin; n++) {
if (!virBitmapEqual(def->cpumask,
if (def->cputune.vcpupin[n]->cpumask &&
!virBitmapEqual(def->cpumask,
def->cputune.vcpupin[n]->cpumask)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cpu affinity is not supported"));
......@@ -2218,17 +2219,20 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
}
for (n = 0; n < virDomainDefGetVcpus(def); n++) {
virBitmapPtr bitmap;
/* set affinity only for existing vcpus */
if (!(pininfo = virDomainPinFind(def->cputune.vcpupin,
def->cputune.nvcpupin,
n)))
continue;
if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, n),
pininfo->cpumask) < 0) {
if (!(bitmap = pininfo->cpumask) &&
!(bitmap = def->cpumask))
continue;
if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, n), bitmap) < 0)
goto cleanup;
}
}
ret = 0;
cleanup:
......
......@@ -2575,6 +2575,8 @@ testDomainGetVcpuPinInfo(virDomainPtr dom,
if (pininfo && pininfo->cpumask)
bitmap = pininfo->cpumask;
else if (def->cpumask)
bitmap = def->cpumask;
else
bitmap = allcpumap;
......
......@@ -1959,8 +1959,8 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDomainDefPtr def)
if (def->cputune.vcpupin) {
for (i = 0; i < def->cputune.nvcpupin; i++) {
if (!virBitmapEqual(def->cpumask,
def->cputune.vcpupin[i]->cpumask)) {
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册