mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
Do not report error when setting affinity is allowed to fail
Suggested-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7afc99ae2d
commit
9514e24984
@ -775,7 +775,7 @@ static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
|
||||
* so use '0' to indicate our own process ID. No threads are
|
||||
* running at this point
|
||||
*/
|
||||
if (virProcessSetAffinity(0 /* Self */, cpumapToSet) < 0) {
|
||||
if (virProcessSetAffinity(0 /* Self */, cpumapToSet, false) < 0) {
|
||||
virBitmapFree(cpumap);
|
||||
return -1;
|
||||
}
|
||||
|
@ -4559,7 +4559,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, vcpu), cpumap) < 0)
|
||||
if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, vcpu),
|
||||
cpumap, false) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -4777,7 +4778,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
|
||||
}
|
||||
}
|
||||
|
||||
if (virProcessSetAffinity(vm->pid, pcpumap) < 0)
|
||||
if (virProcessSetAffinity(vm->pid, pcpumap, false) < 0)
|
||||
goto endjob;
|
||||
|
||||
virBitmapFree(def->cputune.emulatorpin);
|
||||
@ -5252,7 +5253,7 @@ qemuDomainPinIOThread(virDomainPtr dom,
|
||||
}
|
||||
}
|
||||
|
||||
if (virProcessSetAffinity(iothrid->thread_id, pcpumap) < 0)
|
||||
if (virProcessSetAffinity(iothrid->thread_id, pcpumap, false) < 0)
|
||||
goto endjob;
|
||||
|
||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
||||
|
@ -2570,7 +2570,7 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
|
||||
}
|
||||
|
||||
if (cpumapToSet &&
|
||||
virProcessSetAffinity(vm->pid, cpumapToSet) < 0) {
|
||||
virProcessSetAffinity(vm->pid, cpumapToSet, false) < 0) {
|
||||
/*
|
||||
* We only want to error out if we failed to set the affinity to
|
||||
* user-requested mapping. If we are just trying to reset the affinity
|
||||
@ -2740,7 +2740,8 @@ qemuProcessSetupPid(virDomainObjPtr vm,
|
||||
affinity_cpumask = use_cpumask;
|
||||
|
||||
/* Setup legacy affinity. */
|
||||
if (affinity_cpumask && virProcessSetAffinity(pid, affinity_cpumask) < 0) {
|
||||
if (affinity_cpumask &&
|
||||
virProcessSetAffinity(pid, affinity_cpumask, false) < 0) {
|
||||
/*
|
||||
* We only want to error out if we failed to set the affinity to
|
||||
* user-requested mapping. If we are just trying to reset the affinity
|
||||
|
@ -441,7 +441,7 @@ int virProcessKillPainfully(pid_t pid, bool force)
|
||||
|
||||
#if WITH_SCHED_GETAFFINITY
|
||||
|
||||
int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
|
||||
int virProcessSetAffinity(pid_t pid, virBitmapPtr map, bool quiet)
|
||||
{
|
||||
size_t i;
|
||||
int numcpus = 1024;
|
||||
@ -479,9 +479,14 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
|
||||
numcpus = numcpus << 2;
|
||||
goto realloc;
|
||||
}
|
||||
virReportSystemError(errno,
|
||||
_("cannot set CPU affinity on process %d"), pid);
|
||||
return -1;
|
||||
if (quiet) {
|
||||
VIR_DEBUG("cannot set CPU affinity on process %d: %s",
|
||||
pid, g_strerror(errno));
|
||||
} else {
|
||||
virReportSystemError(errno,
|
||||
_("cannot set CPU affinity on process %d"), pid);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
CPU_FREE(mask);
|
||||
|
||||
@ -533,7 +538,8 @@ virProcessGetAffinity(pid_t pid)
|
||||
#elif defined(WITH_BSD_CPU_AFFINITY)
|
||||
|
||||
int virProcessSetAffinity(pid_t pid,
|
||||
virBitmapPtr map)
|
||||
virBitmapPtr map,
|
||||
bool quiet)
|
||||
{
|
||||
size_t i;
|
||||
cpuset_t mask;
|
||||
@ -546,9 +552,14 @@ int virProcessSetAffinity(pid_t pid,
|
||||
|
||||
if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid,
|
||||
sizeof(mask), &mask) != 0) {
|
||||
virReportSystemError(errno,
|
||||
_("cannot set CPU affinity on process %d"), pid);
|
||||
return -1;
|
||||
if (quiet) {
|
||||
VIR_DEBUG("cannot set CPU affinity on process %d: %s",
|
||||
pid, g_strerror(errno));
|
||||
} else {
|
||||
virReportSystemError(errno,
|
||||
_("cannot set CPU affinity on process %d"), pid);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -582,8 +593,11 @@ virProcessGetAffinity(pid_t pid)
|
||||
#else /* WITH_SCHED_GETAFFINITY */
|
||||
|
||||
int virProcessSetAffinity(pid_t pid G_GNUC_UNUSED,
|
||||
virBitmapPtr map G_GNUC_UNUSED)
|
||||
virBitmapPtr map G_GNUC_UNUSED,
|
||||
bool quiet G_GNUC_UNUSED)
|
||||
{
|
||||
/* The @quiet parameter is ignored here, it is used only for silencing
|
||||
* actual failures. */
|
||||
virReportSystemError(ENOSYS, "%s",
|
||||
_("Process CPU affinity is not supported on this platform"));
|
||||
return -1;
|
||||
|
@ -58,7 +58,7 @@ int virProcessKillPainfullyDelay(pid_t pid,
|
||||
bool force,
|
||||
unsigned int extradelay);
|
||||
|
||||
int virProcessSetAffinity(pid_t pid, virBitmapPtr map);
|
||||
int virProcessSetAffinity(pid_t pid, virBitmapPtr map, bool quiet);
|
||||
|
||||
virBitmapPtr virProcessGetAffinity(pid_t pid);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user