Blame SOURCES/libvirt-src-Don-t-use-virReportSystemError-on-virProcessGetStatInfo-failure.patch

735c6b
From a967747fcdf7d78425d218625ddb42606451c2ab Mon Sep 17 00:00:00 2001
735c6b
Message-Id: <a967747fcdf7d78425d218625ddb42606451c2ab@dist-git>
735c6b
From: Michal Privoznik <mprivozn@redhat.com>
735c6b
Date: Wed, 18 Jan 2023 09:03:29 +0100
735c6b
Subject: [PATCH] src: Don't use virReportSystemError() on
735c6b
 virProcessGetStatInfo() failure
735c6b
735c6b
Firstly, the virProcessGetStatInfo() does not fail really. But
735c6b
even if it did, it sets correct errno only sometimes (and even
735c6b
that is done in a helper it's calling - virProcessGetStat() and
735c6b
even there it's the case only in very few error paths).
735c6b
735c6b
Therefore, using virReportSystemError() to report errors is very
735c6b
misleading. Use plain virReportError() instead. Luckily, there
735c6b
are only two places where the former was used:
735c6b
chDomainHelperGetVcpus() and qemuDomainHelperGetVcpus() (not a
735c6b
big surprise since CH driver is heavily inspired by QEMU driver).
735c6b
735c6b
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
735c6b
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
735c6b
(cherry picked from commit 818c9717c53446ca7abbaa7b3fd7925e1c5ab663)
735c6b
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2148266
735c6b
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
735c6b
---
735c6b
 src/ch/ch_driver.c     | 4 ++--
735c6b
 src/qemu/qemu_driver.c | 4 ++--
735c6b
 2 files changed, 4 insertions(+), 4 deletions(-)
735c6b
735c6b
diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c
735c6b
index db2a66d131..12fbe31c24 100644
735c6b
--- a/src/ch/ch_driver.c
735c6b
+++ b/src/ch/ch_driver.c
735c6b
@@ -1079,8 +1079,8 @@ chDomainHelperGetVcpus(virDomainObj *vm,
735c6b
                                       NULL, NULL,
735c6b
                                       &vcpuinfo->cpu, NULL,
735c6b
                                       vm->pid, vcpupid) < 0) {
735c6b
-                virReportSystemError(errno, "%s",
735c6b
-                                      _("cannot get vCPU placement & pCPU time"));
735c6b
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
735c6b
+                               _("cannot get vCPU placement & pCPU time"));
735c6b
                 return -1;
735c6b
             }
735c6b
         }
735c6b
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
735c6b
index d6879175fe..c576c601ad 100644
735c6b
--- a/src/qemu/qemu_driver.c
735c6b
+++ b/src/qemu/qemu_driver.c
735c6b
@@ -1355,8 +1355,8 @@ qemuDomainHelperGetVcpus(virDomainObj *vm,
735c6b
                                       NULL, NULL,
735c6b
                                       &vcpuinfo->cpu, NULL,
735c6b
                                       vm->pid, vcpupid) < 0) {
735c6b
-                virReportSystemError(errno, "%s",
735c6b
-                                     _("cannot get vCPU placement & pCPU time"));
735c6b
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
735c6b
+                               _("cannot get vCPU placement & pCPU time"));
735c6b
                 return -1;
735c6b
             }
735c6b
         }
735c6b
-- 
735c6b
2.39.1
735c6b