[PATCH] virProcessGetStatInfo: add a comment describing why we can not report error

Ani Sinha posted 1 patch 2 years, 3 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20220121144305.929938-1-ani@anisinha.ca
There is a newer version of this series
src/util/virprocess.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] virProcessGetStatInfo: add a comment describing why we can not report error
Posted by Ani Sinha 2 years, 3 months ago
virProcessGetStatInfo() currently is unable to report error conditions because
that breaks libvirt's public best effort APIs. We add a comment in the function
to indicate this. Adding comment here prevents others from going down the path
of reporting error conditions in this functions in the future. It also reminds
us that at some point in the future we need to fix the code so that this
limitations no longer exists.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 src/util/virprocess.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index b559a4257e..9422829b8b 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -1784,6 +1784,12 @@ 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) {
+        /* This function can not report error at present. Reporting error here
+         * causes some of libvirt's best effort public APIs to fail. This
+         * resuts in external API behavior change. Until we can fix this in
+         * a way so that public API behavior remains unchanged, we can only
+         * write a warning log here.
+         */
         VIR_WARN("cannot parse process status data");
     }
 
-- 
2.25.1