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

Ani Sinha ani at anisinha.ca
Fri Jan 21 14:43:05 UTC 2022

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 at 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");

More information about the libvir-list mailing list