Blame SOURCES/libvirt-Revert-report-error-when-virProcessGetStatInfo-is-unable-to-parse-data.patch

1b5f1d
From 732113455fb7eadeea178c71cc77f0ffdf639f24 Mon Sep 17 00:00:00 2001
1b5f1d
Message-Id: <732113455fb7eadeea178c71cc77f0ffdf639f24@dist-git>
1b5f1d
From: Michal Privoznik <mprivozn@redhat.com>
1b5f1d
Date: Tue, 18 Jan 2022 12:40:09 +0100
1b5f1d
Subject: [PATCH] Revert "report error when virProcessGetStatInfo() is unable
1b5f1d
 to parse data"
1b5f1d
1b5f1d
This reverts commit 938382b60ae5bd1f83b5cb09e1ce68b9a88f679a.
1b5f1d
1b5f1d
Turns out, the commit did more harm than good. It changed
1b5f1d
semantics on some public APIs. For instance, while
1b5f1d
qemuDomainGetInfo() previously did not returned an error it does
1b5f1d
now. While the calls to virProcessGetStatInfo() is guarded with
1b5f1d
virDomainObjIsActive() it doesn't necessarily mean that QEMU's
1b5f1d
PID is still alive. QEMU might be gone but we just haven't
1b5f1d
realized it (e.g. because the eof handler thread is waiting for a
1b5f1d
job).
1b5f1d
1b5f1d
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2041610
1b5f1d
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
1b5f1d
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
1b5f1d
(cherry picked from commit 105dace22cc7b5b18d72a4dcad4a2cf386ce5c99)
1b5f1d
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
1b5f1d
---
1b5f1d
 src/ch/ch_driver.c     | 2 ++
1b5f1d
 src/qemu/qemu_driver.c | 7 ++++++-
1b5f1d
 src/util/virprocess.c  | 8 ++------
1b5f1d
 3 files changed, 10 insertions(+), 7 deletions(-)
1b5f1d
1b5f1d
diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c
1b5f1d
index 3cbc668489..53e0872207 100644
1b5f1d
--- a/src/ch/ch_driver.c
1b5f1d
+++ b/src/ch/ch_driver.c
1b5f1d
@@ -1073,6 +1073,8 @@ chDomainHelperGetVcpus(virDomainObj *vm,
1b5f1d
             if (virProcessGetStatInfo(&vcpuinfo->cpuTime,
1b5f1d
                                       &vcpuinfo->cpu, NULL,
1b5f1d
                                       vm->pid, vcpupid) < 0) {
1b5f1d
+                virReportSystemError(errno, "%s",
1b5f1d
+                                      _("cannot get vCPU placement & pCPU time"));
1b5f1d
                 return -1;
1b5f1d
             }
1b5f1d
         }
1b5f1d
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
1b5f1d
index 65ac5ef367..d3d76c003f 100644
1b5f1d
--- a/src/qemu/qemu_driver.c
1b5f1d
+++ b/src/qemu/qemu_driver.c
1b5f1d
@@ -1359,6 +1359,8 @@ qemuDomainHelperGetVcpus(virDomainObj *vm,
1b5f1d
             if (virProcessGetStatInfo(&vcpuinfo->cpuTime,
1b5f1d
                                       &vcpuinfo->cpu, NULL,
1b5f1d
                                       vm->pid, vcpupid) < 0) {
1b5f1d
+                virReportSystemError(errno, "%s",
1b5f1d
+                                     _("cannot get vCPU placement & pCPU time"));
1b5f1d
                 return -1;
1b5f1d
             }
1b5f1d
         }
1b5f1d
@@ -2519,6 +2521,8 @@ qemuDomainGetInfo(virDomainPtr dom,
1b5f1d
     if (virDomainObjIsActive(vm)) {
1b5f1d
         if (virProcessGetStatInfo(&(info->cpuTime), NULL, NULL,
1b5f1d
                                   vm->pid, 0) < 0) {
1b5f1d
+            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
1b5f1d
+                           _("cannot read cputime for domain"));
1b5f1d
             goto cleanup;
1b5f1d
         }
1b5f1d
     }
1b5f1d
@@ -10526,7 +10530,8 @@ qemuDomainMemoryStatsInternal(virQEMUDriver *driver,
1b5f1d
     }
1b5f1d
 
1b5f1d
     if (virProcessGetStatInfo(NULL, NULL, &rss, vm->pid, 0) < 0) {
1b5f1d
-        virResetLastError();
1b5f1d
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
1b5f1d
+                       _("cannot get RSS for domain"));
1b5f1d
     } else {
1b5f1d
         stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_RSS;
1b5f1d
         stats[ret].val = rss;
1b5f1d
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
1b5f1d
index 85d8c8e747..b559a4257e 100644
1b5f1d
--- a/src/util/virprocess.c
1b5f1d
+++ b/src/util/virprocess.c
1b5f1d
@@ -1784,10 +1784,7 @@ virProcessGetStatInfo(unsigned long long *cpuTime,
1b5f1d
         virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_STIME], NULL, 10, &systime) < 0 ||
1b5f1d
         virStrToLong_l(proc_stat[VIR_PROCESS_STAT_RSS], NULL, 10, &rss) < 0 ||
1b5f1d
         virStrToLong_i(proc_stat[VIR_PROCESS_STAT_PROCESSOR], NULL, 10, &cpu) < 0) {
1b5f1d
-        virReportError(VIR_ERR_INTERNAL_ERROR,
1b5f1d
-                       _("cannot parse process status data for pid '%d/%d'"),
1b5f1d
-                       (int) pid, (int) tid);
1b5f1d
-        return -1;
1b5f1d
+        VIR_WARN("cannot parse process status data");
1b5f1d
     }
1b5f1d
 
1b5f1d
     /* We got jiffies
1b5f1d
@@ -1884,8 +1881,7 @@ virProcessGetStatInfo(unsigned long long *cpuTime G_GNUC_UNUSED,
1b5f1d
                       pid_t pid G_GNUC_UNUSED,
1b5f1d
                       pid_t tid G_GNUC_UNUSED)
1b5f1d
 {
1b5f1d
-    virReportSystemError(ENOSYS, "%s",
1b5f1d
-                         _("Process statistics data is not supported on this platform"));
1b5f1d
+    errno = ENOSYS;
1b5f1d
     return -1;
1b5f1d
 }
1b5f1d
 
1b5f1d
-- 
1b5f1d
2.35.0
1b5f1d