diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f569d24177d0767f691c2cfb6911302bdf6ed80d..7b1dc06c32b7cf6b77a8335d920a1c96ea9f2820 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2474,7 +2474,7 @@ void virDomainDefFree(virDomainDefPtr def)
virDomainPinDefArrayFree(def->cputune.vcpupin, def->cputune.nvcpupin);
- virDomainPinDefFree(def->cputune.emulatorpin);
+ virBitmapFree(def->cputune.emulatorpin);
for (i = 0; i < def->cputune.nvcpusched; i++)
virBitmapFree(def->cputune.vcpusched[i].ids);
@@ -13569,36 +13569,26 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
}
-
/* Parse the XML definition for emulatorpin.
* emulatorpin has the form of
*
*/
-static virDomainPinDefPtr
+static virBitmapPtr
virDomainEmulatorPinDefParseXML(xmlNodePtr node)
{
- virDomainPinDefPtr def;
+ virBitmapPtr def = NULL;
char *tmp = NULL;
- if (VIR_ALLOC(def) < 0)
- return NULL;
-
if (!(tmp = virXMLPropString(node, "cpuset"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing cpuset for emulatorpin"));
- goto error;
+ return NULL;
}
- if (virBitmapParse(tmp, 0, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
- goto error;
+ ignore_value(virBitmapParse(tmp, 0, &def, VIR_DOMAIN_CPUMASK_LEN));
VIR_FREE(tmp);
return def;
-
- error:
- VIR_FREE(tmp);
- VIR_FREE(def);
- return NULL;
}
@@ -17768,50 +17758,6 @@ virDomainPinDel(virDomainPinDefPtr **pindef_list,
}
}
-int
-virDomainEmulatorPinAdd(virDomainDefPtr def,
- unsigned char *cpumap,
- int maplen)
-{
- virDomainPinDefPtr emulatorpin = NULL;
-
- if (!def->cputune.emulatorpin) {
- /* No emulatorpin exists yet. */
- if (VIR_ALLOC(emulatorpin) < 0)
- return -1;
-
- emulatorpin->id = -1;
- emulatorpin->cpumask = virBitmapNewData(cpumap, maplen);
- if (!emulatorpin->cpumask) {
- virDomainPinDefFree(emulatorpin);
- return -1;
- }
-
- def->cputune.emulatorpin = emulatorpin;
- } else {
- /* Since there is only 1 emulatorpin for each vm,
- * juest replace the old one.
- */
- virBitmapFree(def->cputune.emulatorpin->cpumask);
- def->cputune.emulatorpin->cpumask = virBitmapNewData(cpumap, maplen);
- if (!def->cputune.emulatorpin->cpumask)
- return -1;
- }
-
- return 0;
-}
-
-int
-virDomainEmulatorPinDel(virDomainDefPtr def)
-{
- if (!def->cputune.emulatorpin)
- return 0;
-
- virDomainPinDefFree(def->cputune.emulatorpin);
- def->cputune.emulatorpin = NULL;
-
- return 0;
-}
static int
virDomainEventActionDefFormat(virBufferPtr buf,
@@ -21105,7 +21051,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
char *cpumask;
virBufferAddLit(buf, "cputune.emulatorpin->cpumask)))
+ if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin)))
goto error;
virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 924c4843e3067b13ad6f7c071ebb7a490aa80377..62e8435226571141ec450a023b6c88583fc9598f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2069,7 +2069,7 @@ struct _virDomainCputune {
long long emulator_quota;
size_t nvcpupin;
virDomainPinDefPtr *vcpupin;
- virDomainPinDefPtr emulatorpin;
+ virBitmapPtr emulatorpin;
size_t nvcpusched;
virDomainThreadSchedParamPtr vcpusched;
@@ -2674,12 +2674,6 @@ void virDomainPinDel(virDomainPinDefPtr **pindef_list,
size_t *npin,
int vcpu);
-int virDomainEmulatorPinAdd(virDomainDefPtr def,
- unsigned char *cpumap,
- int maplen);
-
-int virDomainEmulatorPinDel(virDomainDefPtr def);
-
void virDomainRNGDefFree(virDomainRNGDefPtr def);
bool virDomainDiskDefDstDuplicates(virDomainDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6a95fb991694f3bfd216e346e00ce9520309cb13..a90a1b76870c10d0a5bc134c35d1bae8338316fa 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -273,8 +273,6 @@ virDomainDiskSetFormat;
virDomainDiskSetSource;
virDomainDiskSetType;
virDomainDiskSourceIsBlockType;
-virDomainEmulatorPinAdd;
-virDomainEmulatorPinDel;
virDomainFSDefFree;
virDomainFSIndexByName;
virDomainFSInsert;
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 96677dd0403ecaca7ef00a7177b2fdef8a7a4cd1..7d1f0093aea6271623230a095bf2a83cbbb3e7fa 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -1114,7 +1114,7 @@ qemuSetupCgroupForEmulator(virDomainObjPtr vm)
goto cleanup;
if (def->cputune.emulatorpin)
- cpumask = def->cputune.emulatorpin->cpumask;
+ cpumask = def->cputune.emulatorpin;
else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)
cpumask = priv->autoCpuset;
else if (def->cpumask)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d1b00a2014ba4d672408e4ff564e767630e89e95..e34cb6c2ff80bbeb43e82d68d02d4553982cf554 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5374,23 +5374,19 @@ qemuDomainPinEmulator(virDomainPtr dom,
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
virCgroupPtr cgroup_emulator = NULL;
- pid_t pid;
virDomainDefPtr persistentDef = NULL;
int ret = -1;
qemuDomainObjPrivatePtr priv;
bool doReset = false;
- size_t newVcpuPinNum = 0;
- virDomainPinDefPtr *newVcpuPin = NULL;
virBitmapPtr pcpumap = NULL;
virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL;
virObjectEventPtr event = NULL;
- char * str = NULL;
+ char *str = NULL;
virTypedParameterPtr eventParams = NULL;
int eventNparams = 0;
int eventMaxparams = 0;
-
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -5436,65 +5432,33 @@ qemuDomainPinEmulator(virDomainPtr dom,
if (virBitmapIsAllSet(pcpumap))
doReset = true;
- pid = vm->pid;
-
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
-
- if (priv->vcpupids != NULL) {
- if (VIR_ALLOC(newVcpuPin) < 0)
+ if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
+ if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_EMULATOR,
+ 0, false, &cgroup_emulator) < 0)
goto endjob;
- if (virDomainPinAdd(&newVcpuPin, &newVcpuPinNum, cpumap, maplen, -1) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to update vcpupin"));
- virDomainPinDefArrayFree(newVcpuPin, newVcpuPinNum);
+ if (qemuSetupCgroupCpusetCpus(cgroup_emulator, pcpumap) < 0) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("failed to set cpuset.cpus in cgroup"
+ " for emulator threads"));
goto endjob;
}
-
- if (virCgroupHasController(priv->cgroup,
- VIR_CGROUP_CONTROLLER_CPUSET)) {
- /*
- * Configure the corresponding cpuset cgroup.
- */
- if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_EMULATOR,
- 0, false, &cgroup_emulator) < 0)
- goto endjob;
- if (qemuSetupCgroupCpusetCpus(cgroup_emulator,
- newVcpuPin[0]->cpumask) < 0) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("failed to set cpuset.cpus in cgroup"
- " for emulator threads"));
- goto endjob;
- }
- } else {
- if (virProcessSetAffinity(pid, pcpumap) < 0) {
- virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
- _("failed to set cpu affinity for "
- "emulator threads"));
- goto endjob;
- }
+ } else {
+ if (virProcessSetAffinity(vm->pid, pcpumap) < 0) {
+ virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+ _("failed to set cpu affinity for "
+ "emulator thread"));
+ goto endjob;
}
+ }
- if (doReset) {
- if (virDomainEmulatorPinDel(vm->def) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to delete emulatorpin xml of "
- "a running domain"));
- goto endjob;
- }
- } else {
- virDomainPinDefFree(vm->def->cputune.emulatorpin);
- vm->def->cputune.emulatorpin = newVcpuPin[0];
- VIR_FREE(newVcpuPin);
- }
+ virBitmapFree(vm->def->cputune.emulatorpin);
+ vm->def->cputune.emulatorpin = NULL;
- if (newVcpuPin)
- virDomainPinDefArrayFree(newVcpuPin, newVcpuPinNum);
- } else {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cpu affinity is not supported"));
+ if (!doReset &&
+ !(vm->def->cputune.emulatorpin = virBitmapNewCopy(pcpumap)))
goto endjob;
- }
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
goto endjob;
@@ -5510,22 +5474,12 @@ qemuDomainPinEmulator(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ virBitmapFree(persistentDef->cputune.emulatorpin);
+ persistentDef->cputune.emulatorpin = NULL;
- if (doReset) {
- if (virDomainEmulatorPinDel(persistentDef) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to delete emulatorpin xml of "
- "a persistent domain"));
- goto endjob;
- }
- } else {
- if (virDomainEmulatorPinAdd(persistentDef, cpumap, maplen) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to update or add emulatorpin xml "
- "of a persistent domain"));
- goto endjob;
- }
- }
+ if (!doReset &&
+ !(persistentDef->cputune.emulatorpin = virBitmapNewCopy(pcpumap)))
+ goto endjob;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
goto endjob;
@@ -5592,7 +5546,7 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
goto cleanup;
if (targetDef->cputune.emulatorpin) {
- cpumask = targetDef->cputune.emulatorpin->cpumask;
+ cpumask = targetDef->cputune.emulatorpin;
} else if (targetDef->cpumask) {
cpumask = targetDef->cpumask;
} else {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f2b22292f417f86e7fd71acb1cf2cd1233fa056b..cc588d72b9f0927c858a350adf75e16bbbac58c3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2414,7 +2414,7 @@ qemuProcessSetEmulatorAffinity(virDomainObjPtr vm)
int ret = -1;
if (def->cputune.emulatorpin)
- cpumask = def->cputune.emulatorpin->cpumask;
+ cpumask = def->cputune.emulatorpin;
else if (def->cpumask)
cpumask = def->cpumask;
else