On 01/14/2016 11:27 AM, Peter Krempa wrote:
This step can be omitted, so that drivers can decide what to do when
the
user requests to use default vcpu pinning.
---
src/conf/domain_conf.c | 32 --------------------------------
src/libxl/libxl_domain.c | 15 ++++++++++++---
src/libxl/libxl_driver.c | 2 ++
src/qemu/qemu_driver.c | 34 ++--------------------------------
src/qemu/qemu_process.c | 8 +++++++-
src/test/test_driver.c | 2 ++
src/vz/vz_sdk.c | 4 ++--
7 files changed, 27 insertions(+), 70 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 36286d3..caf5334 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15149,34 +15149,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"));
@@ -21855,10 +21827,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);
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index cf5c9f6..37c92c6 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -824,9 +824,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];
- cpumask = pin->cpumask;
+ 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;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index d4e9c2a7..26c1a43 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2464,6 +2464,8 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
if (pininfo && pininfo->cpumask)
bitmap = pininfo->cpumask;
+ else if (targetDef->cpumask)
+ bitmap = targetDef->cpumask;
else
bitmap = allcpumap;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b377738..0a4de1b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4596,33 +4596,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,
@@ -4734,11 +4707,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;
@@ -5260,6 +5228,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;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a7c3094..64b58be 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2177,7 +2177,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"));
@@ -2188,12 +2189,17 @@ 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 (!(bitmap = pininfo->cpumask) &&
+ !(bitmap = def->cpumask))
+ continue;
+
if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, n),
pininfo->cpumask) < 0) {
It seems you meant to use 'bitmap' as the last param here and not
'pininfo->cpumask'... Otherwise, the setting of bitmap above is pointless.
John
goto cleanup;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 8d1402e..4d268de 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2574,6 +2574,8 @@ testDomainGetVcpuPinInfo(virDomainPtr dom,
if (pininfo && pininfo->cpumask)
bitmap = pininfo->cpumask;
+ else if (def->cpumask)
+ bitmap = def->cpumask;
else
bitmap = allcpumap;
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index d610979..7cc24d3 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -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;