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