mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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.
This commit is contained in:
@@ -2240,10 +2240,8 @@ qemuProcessDetectVcpuPIDs(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjExitMonitor(driver, vm);
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
|
|
||||||
priv->nvcpupids = 1;
|
priv->nvcpupids = 0;
|
||||||
if (VIR_ALLOC_N(priv->vcpupids, priv->nvcpupids) < 0)
|
priv->vcpupids = NULL;
|
||||||
return -1;
|
|
||||||
priv->vcpupids[0] = vm->pid;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
@@ -2462,7 +2460,8 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
|
|||||||
virDomainVcpuPinDefPtr pininfo;
|
virDomainVcpuPinDefPtr pininfo;
|
||||||
int n;
|
int n;
|
||||||
int ret = -1;
|
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)
|
if (!def->cputune.nvcpupin)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -399,6 +399,7 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
bool set = false;
|
bool set = false;
|
||||||
|
VIR_DEBUG("Set process affinity on %lld\n", (long long)pid);
|
||||||
# ifdef CPU_ALLOC
|
# ifdef CPU_ALLOC
|
||||||
/* New method dynamically allocates cpu mask, allowing unlimted cpus */
|
/* New method dynamically allocates cpu mask, allowing unlimted cpus */
|
||||||
int numcpus = 1024;
|
int numcpus = 1024;
|
||||||
|
|||||||
Reference in New Issue
Block a user