]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu: Introduce virCPUGetHostIsSupported
authorJiri Denemark <jdenemar@redhat.com>
Tue, 11 Apr 2017 18:45:07 +0000 (20:45 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 19 Apr 2017 14:36:38 +0000 (16:36 +0200)
Sometimes we want to call virCPUGetHost only when it is implemented for
a given architecture to avoid logging expected and possibly misleading
errors. The new virCPUGetHostIsSupported API may be used to guard such
calls to virCPUGetHost.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/cpu/cpu.c
src/cpu/cpu.h
src/libvirt_private.syms

index 8a407ac18c34f2fe0c2b18f48536f8addaf1f961..702b14dbb76556b5eeba5fb55d30eaa2c9459723 100644 (file)
@@ -357,6 +357,26 @@ virCPUDataFree(virCPUDataPtr data)
 }
 
 
+/**
+ * virCPUGetHostIsSupported:
+ *
+ * @arch: CPU architecture
+ *
+ * Check whether virCPUGetHost is supported for @arch.
+ *
+ * Returns true if virCPUGetHost is supported, false otherwise.
+ */
+bool
+virCPUGetHostIsSupported(virArch arch)
+{
+    struct cpuArchDriver *driver;
+
+    VIR_DEBUG("arch=%s", virArchToString(arch));
+
+    return (driver = cpuGetSubDriver(arch)) && driver->getHost;
+}
+
+
 /**
  * virCPUGetHost:
  *
index 352445c40b21dc84353284b25b3f55f4231d33ac..c6ca111e972280abbfcdf79f73339983e23f7123 100644 (file)
@@ -183,6 +183,9 @@ virCPUDataNew(virArch arch);
 void
 virCPUDataFree(virCPUDataPtr data);
 
+bool
+virCPUGetHostIsSupported(virArch arch);
+
 virCPUDefPtr
 virCPUGetHost(virArch arch,
               virCPUType type,
index ba6b05d4bec783ff4457ca06b8bff751fab58fa0..181e178753a4fa6fffd3071d213b72bfdfb44e73 100644 (file)
@@ -1039,6 +1039,7 @@ virCPUDataNew;
 virCPUDataParse;
 virCPUExpandFeatures;
 virCPUGetHost;
+virCPUGetHostIsSupported;
 virCPUGetModels;
 virCPUProbeHost;
 virCPUTranslate;