提交 b07f3d82 编写于 作者: D Daniel P. Berrange

Don't setup fake CPU pids for old QEMU

The code assumes that def->vcpus == nvcpupids, so when we setup
fake CPU pids for old QEMU with nvcpupids == 1, we cause the
later code to read off the end of the array. This has fun results
like sche_setaffinity(0, ...) which changes libvirtd's own CPU
affinity, or even better sched_setaffinity($RANDOM, ...) which
changes the affinity of a random OS process.
上级 f309db1f
......@@ -2240,10 +2240,8 @@ qemuProcessDetectVcpuPIDs(virQEMUDriverPtr driver,
qemuDomainObjExitMonitor(driver, vm);
virResetLastError();
priv->nvcpupids = 1;
if (VIR_ALLOC_N(priv->vcpupids, priv->nvcpupids) < 0)
return -1;
priv->vcpupids[0] = vm->pid;
priv->nvcpupids = 0;
priv->vcpupids = NULL;
return 0;
}
qemuDomainObjExitMonitor(driver, vm);
......@@ -2462,7 +2460,8 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
virDomainVcpuPinDefPtr pininfo;
int n;
int ret = -1;
VIR_DEBUG("Setting affinity on CPUs nvcpupin=%zu nvcpus=%d nvcpupids=%d",
def->cputune.nvcpupin, def->vcpus, priv->nvcpupids);
if (!def->cputune.nvcpupin)
return 0;
......
......@@ -399,6 +399,7 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
{
size_t i;
bool set = false;
VIR_DEBUG("Set process affinity on %lld\n", (long long)pid);
# ifdef CPU_ALLOC
/* New method dynamically allocates cpu mask, allowing unlimted cpus */
int numcpus = 1024;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册