render / rpms / libvirt

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