Revert "report error when virProcessGetStatInfo() is unable to parse data"

This reverts commit 938382b60a.

Turns out, the commit did more harm than good. It changed
semantics on some public APIs. For instance, while
qemuDomainGetInfo() previously did not returned an error it does
now. While the calls to virProcessGetStatInfo() is guarded with
virDomainObjIsActive() it doesn't necessarily mean that QEMU's
PID is still alive. QEMU might be gone but we just haven't
realized it (e.g. because the eof handler thread is waiting for a
job).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2041610
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Michal Privoznik 2022-01-18 12:40:09 +01:00
parent add089d9f5
commit 105dace22c
3 changed files with 10 additions and 7 deletions

View File

@ -1073,6 +1073,8 @@ chDomainHelperGetVcpus(virDomainObj *vm,
if (virProcessGetStatInfo(&vcpuinfo->cpuTime,
&vcpuinfo->cpu, NULL,
vm->pid, vcpupid) < 0) {
virReportSystemError(errno, "%s",
_("cannot get vCPU placement & pCPU time"));
return -1;
}
}

View File

@ -1354,6 +1354,8 @@ qemuDomainHelperGetVcpus(virDomainObj *vm,
if (virProcessGetStatInfo(&vcpuinfo->cpuTime,
&vcpuinfo->cpu, NULL,
vm->pid, vcpupid) < 0) {
virReportSystemError(errno, "%s",
_("cannot get vCPU placement & pCPU time"));
return -1;
}
}
@ -2514,6 +2516,8 @@ qemuDomainGetInfo(virDomainPtr dom,
if (virDomainObjIsActive(vm)) {
if (virProcessGetStatInfo(&(info->cpuTime), NULL, NULL,
vm->pid, 0) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot read cputime for domain"));
goto cleanup;
}
}
@ -10513,7 +10517,8 @@ qemuDomainMemoryStatsInternal(virQEMUDriver *driver,
}
if (virProcessGetStatInfo(NULL, NULL, &rss, vm->pid, 0) < 0) {
virResetLastError();
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot get RSS for domain"));
} else {
stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_RSS;
stats[ret].val = rss;

View File

@ -1784,10 +1784,7 @@ virProcessGetStatInfo(unsigned long long *cpuTime,
virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_STIME], NULL, 10, &systime) < 0 ||
virStrToLong_l(proc_stat[VIR_PROCESS_STAT_RSS], NULL, 10, &rss) < 0 ||
virStrToLong_i(proc_stat[VIR_PROCESS_STAT_PROCESSOR], NULL, 10, &cpu) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse process status data for pid '%d/%d'"),
(int) pid, (int) tid);
return -1;
VIR_WARN("cannot parse process status data");
}
/* We got jiffies
@ -1884,8 +1881,7 @@ virProcessGetStatInfo(unsigned long long *cpuTime G_GNUC_UNUSED,
pid_t pid G_GNUC_UNUSED,
pid_t tid G_GNUC_UNUSED)
{
virReportSystemError(ENOSYS, "%s",
_("Process statistics data is not supported on this platform"));
errno = ENOSYS;
return -1;
}