[libvirt] [PATCH 2/3] virhostcpu: Expose virHostCPUGetOnline on non-Linux

Martin Kletzander posted 3 patches 8 years, 10 months ago
[libvirt] [PATCH 2/3] virhostcpu: Expose virHostCPUGetOnline on non-Linux
Posted by Martin Kletzander 8 years, 10 months ago
Previously, this function must've been called only on Linux in order
to fail gracefully.  That lead to #ifdef mess in callers, so the
function was redesigned so it failed gracefully on non-existing
files.  However that commit forgot to define the function outside the
__linux__ ifdef.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 src/util/virhostcpu.c | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 47f930cdbf3c..02b9fc8eb94f 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -262,24 +262,6 @@ virHostCPUGetCore(unsigned int cpu, unsigned int *core)
     return 0;
 }

-int
-virHostCPUGetOnline(unsigned int cpu, bool *online)
-{
-    unsigned int tmp = 0;
-    int ret = virSysfsGetCpuValueUint(cpu, "online", &tmp);
-
-
-    /* If the file is not there, it's online (doesn't support offlining) */
-    if (ret == -2)
-        tmp = 1;
-    else if (ret < 0)
-        return -1;
-
-    *online = tmp;
-
-    return 0;
-}
-
 virBitmapPtr
 virHostCPUGetSiblingsList(unsigned int cpu)
 {
@@ -880,6 +862,23 @@ virHostCPUParseCountLinux(void)
 }
 #endif

+int
+virHostCPUGetOnline(unsigned int cpu, bool *online)
+{
+    unsigned int tmp = 0;
+    int ret = virSysfsGetCpuValueUint(cpu, "online", &tmp);
+
+
+    /* If the file is not there, it's online (doesn't support offlining) */
+    if (ret == -2)
+        tmp = 1;
+    else if (ret < 0)
+        return -1;
+
+    *online = tmp;
+
+    return 0;
+}

 int
 virHostCPUStatsAssign(virNodeCPUStatsPtr param,
-- 
2.12.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/3] virhostcpu: Expose virHostCPUGetOnline on non-Linux
Posted by Pavel Hrdina 8 years, 10 months ago
On Mon, Mar 27, 2017 at 04:21:09PM +0200, Martin Kletzander wrote:
> Previously, this function must've been called only on Linux in order
> to fail gracefully.  That lead to #ifdef mess in callers, so the
> function was redesigned so it failed gracefully on non-existing
> files.  However that commit forgot to define the function outside the
> __linux__ ifdef.

It would be nice to mention the commit id in the commit message.

> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
> ---
>  src/util/virhostcpu.c | 35 +++++++++++++++++------------------
>  1 file changed, 17 insertions(+), 18 deletions(-)

ACK

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