[libvirt] [PATCH] src: warn against virNodeGetInfo() API call due to inaccurate info

Daniel P. Berrangé posted 1 patch 4 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20191216103640.8690-1-berrange@redhat.com
include/libvirt/libvirt-host.h |  4 ++++
src/libvirt-host.c             | 16 ++++++++++++++++
2 files changed, 20 insertions(+)
[libvirt] [PATCH] src: warn against virNodeGetInfo() API call due to inaccurate info
Posted by Daniel P. Berrangé 4 years, 4 months ago
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 include/libvirt/libvirt-host.h |  4 ++++
 src/libvirt-host.c             | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
index be65b4686b..b87d634813 100644
--- a/include/libvirt/libvirt-host.h
+++ b/include/libvirt/libvirt-host.h
@@ -147,6 +147,10 @@ typedef virSecurityModel *virSecurityModelPtr;
  *
  * a virNodeInfo is a structure filled by virNodeGetInfo() and providing
  * the information for the Node.
+ *
+ * Note that the information in this struct is not guaranteed to be an
+ * accurate relection of the system hardware. See the virNodeGetInfo()
+ * API documentation for further guidance.
  */
 
 typedef struct _virNodeInfo virNodeInfo;
diff --git a/src/libvirt-host.c b/src/libvirt-host.c
index 94ba5a8e80..bc3d1d2803 100644
--- a/src/libvirt-host.c
+++ b/src/libvirt-host.c
@@ -399,6 +399,22 @@ virConnectGetMaxVcpus(virConnectPtr conn,
  *
  * Extract hardware information about the node.
  *
+ * Use of this API is strongly discouraged as the information provided
+ * is not guaranteed to be accurate on all hardware platforms.
+ *
+ * The mHZ value merely reflects the speed that the first CPU in the
+ * machine is currently running at. This speed may vary across CPUs
+ * and changes continually as the host OS throttles.
+ *
+ * The nodes/sockets/cores/threads data is potentially inaccurate as
+ * it assumes a symmetric installation. If one NUMA node has more
+ * sockets populated that another NUMA node this information will be
+ * wrong. It is also not able to report about CPU dies.
+ *
+ * Applications are recommended to use the virConnectGetCapabilities()
+ * call instead, which provides all the information except CPU mHZ,
+ * in a more accurate representation.
+ *
  * Returns 0 in case of success and -1 in case of failure.
  */
 int
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] src: warn against virNodeGetInfo() API call due to inaccurate info
Posted by Jiri Denemark 4 years, 4 months ago
On Mon, Dec 16, 2019 at 10:36:40 +0000, Daniel P. Berrangé wrote:
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  include/libvirt/libvirt-host.h |  4 ++++
>  src/libvirt-host.c             | 16 ++++++++++++++++
>  2 files changed, 20 insertions(+)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list