6d3351
From 401cbf50f18234b0631b4b0e01b9e403137fee95 Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <401cbf50f18234b0631b4b0e01b9e403137fee95@dist-git>
6d3351
From: Jiri Denemark <jdenemar@redhat.com>
6d3351
Date: Tue, 11 Apr 2017 20:45:07 +0200
6d3351
Subject: [PATCH] cpu: Introduce virCPUGetHostIsSupported
6d3351
6d3351
Sometimes we want to call virCPUGetHost only when it is implemented for
6d3351
a given architecture to avoid logging expected and possibly misleading
6d3351
errors. The new virCPUGetHostIsSupported API may be used to guard such
6d3351
calls to virCPUGetHost.
6d3351
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
(cherry picked from commit bf1a881715c905c67f7d38dcd5bd6c2afbff1f9b)
6d3351
6d3351
https://bugzilla.redhat.com/show_bug.cgi?id=1444421
6d3351
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 src/cpu/cpu.c            | 20 ++++++++++++++++++++
6d3351
 src/cpu/cpu.h            |  3 +++
6d3351
 src/libvirt_private.syms |  1 +
6d3351
 3 files changed, 24 insertions(+)
6d3351
6d3351
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
6d3351
index 8a407ac18..702b14dbb 100644
6d3351
--- a/src/cpu/cpu.c
6d3351
+++ b/src/cpu/cpu.c
6d3351
@@ -358,6 +358,26 @@ virCPUDataFree(virCPUDataPtr data)
6d3351
 
6d3351
 
6d3351
 /**
6d3351
+ * virCPUGetHostIsSupported:
6d3351
+ *
6d3351
+ * @arch: CPU architecture
6d3351
+ *
6d3351
+ * Check whether virCPUGetHost is supported for @arch.
6d3351
+ *
6d3351
+ * Returns true if virCPUGetHost is supported, false otherwise.
6d3351
+ */
6d3351
+bool
6d3351
+virCPUGetHostIsSupported(virArch arch)
6d3351
+{
6d3351
+    struct cpuArchDriver *driver;
6d3351
+
6d3351
+    VIR_DEBUG("arch=%s", virArchToString(arch));
6d3351
+
6d3351
+    return (driver = cpuGetSubDriver(arch)) && driver->getHost;
6d3351
+}
6d3351
+
6d3351
+
6d3351
+/**
6d3351
  * virCPUGetHost:
6d3351
  *
6d3351
  * @arch: CPU architecture
6d3351
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
6d3351
index 352445c40..c6ca111e9 100644
6d3351
--- a/src/cpu/cpu.h
6d3351
+++ b/src/cpu/cpu.h
6d3351
@@ -183,6 +183,9 @@ virCPUDataNew(virArch arch);
6d3351
 void
6d3351
 virCPUDataFree(virCPUDataPtr data);
6d3351
 
6d3351
+bool
6d3351
+virCPUGetHostIsSupported(virArch arch);
6d3351
+
6d3351
 virCPUDefPtr
6d3351
 virCPUGetHost(virArch arch,
6d3351
               virCPUType type,
6d3351
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
6d3351
index cc78c5975..d802e7598 100644
6d3351
--- a/src/libvirt_private.syms
6d3351
+++ b/src/libvirt_private.syms
6d3351
@@ -1026,6 +1026,7 @@ virCPUDataNew;
6d3351
 virCPUDataParse;
6d3351
 virCPUExpandFeatures;
6d3351
 virCPUGetHost;
6d3351
+virCPUGetHostIsSupported;
6d3351
 virCPUGetModels;
6d3351
 virCPUProbeHost;
6d3351
 virCPUTranslate;
6d3351
-- 
6d3351
2.12.2
6d3351