cpu: Introduce virCPUGetHostIsSupported

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>
This commit is contained in:
Jiri Denemark 2017-04-11 20:45:07 +02:00
parent 232d87c7dd
commit bf1a881715
3 changed files with 24 additions and 0 deletions

View 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: * virCPUGetHost:
* *

View File

@ -183,6 +183,9 @@ virCPUDataNew(virArch arch);
void void
virCPUDataFree(virCPUDataPtr data); virCPUDataFree(virCPUDataPtr data);
bool
virCPUGetHostIsSupported(virArch arch);
virCPUDefPtr virCPUDefPtr
virCPUGetHost(virArch arch, virCPUGetHost(virArch arch,
virCPUType type, virCPUType type,

View File

@ -1039,6 +1039,7 @@ virCPUDataNew;
virCPUDataParse; virCPUDataParse;
virCPUExpandFeatures; virCPUExpandFeatures;
virCPUGetHost; virCPUGetHost;
virCPUGetHostIsSupported;
virCPUGetModels; virCPUGetModels;
virCPUProbeHost; virCPUProbeHost;
virCPUTranslate; virCPUTranslate;