Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/cpu/cpu.c | 29 +++++++++++++++++++++++++++++
src/cpu/cpu.h | 9 +++++++++
src/libvirt_private.syms | 1 +
3 files changed, 39 insertions(+)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index b4965f3ee0..a3531dd665 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -1128,6 +1128,35 @@ virCPUDataAddFeature(virCPUData *cpuData,
}
+/**
+ * virCPUDataIsIdentical:
+ *
+ * Returns VIR_CPU_COMPARE_IDENTICAL if @a and @b are identical,
+ * VIR_CPU_COMPARE_INCOMPATIBLE if @a and @b are not identical, or
+ * VIR_CPU_COMPARE_ERROR on error.
+ */
+virCPUCompareResult
+virCPUDataIsIdentical(const virCPUData *a,
+ const virCPUData *b)
+{
+ struct cpuArchDriver *driver;
+
+ VIR_DEBUG("a=%p, b=%p", a, b);
+
+ if (!a || !b)
+ return VIR_CPU_COMPARE_ERROR;
+
+ if (!(driver = cpuGetSubDriver(a->arch)))
+ return VIR_CPU_COMPARE_ERROR;
+
+ if (!driver->dataIsIdentical) {
+ return VIR_CPU_COMPARE_ERROR;
+ }
+
+ return driver->dataIsIdentical(a, b);
+}
+
+
/**
* virCPUArchIsSupported:
*
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index d11d2641fc..e752126813 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -123,6 +123,10 @@ typedef int
(*virCPUArchDataAddFeature)(virCPUData *cpuData,
const char *name);
+typedef virCPUCompareResult
+(*virCPUArchDataIsIdentical)(const virCPUData *a,
+ const virCPUData *b);
+
struct cpuArchDriver {
const char *name;
const virArch *arch;
@@ -146,6 +150,7 @@ struct cpuArchDriver {
virCPUArchCopyMigratable copyMigratable;
virCPUArchValidateFeatures validateFeatures;
virCPUArchDataAddFeature dataAddFeature;
+ virCPUArchDataIsIdentical dataIsIdentical;
};
@@ -275,6 +280,10 @@ int
virCPUDataAddFeature(virCPUData *cpuData,
const char *name);
+virCPUCompareResult
+virCPUDataIsIdentical(const virCPUData *a,
+ const virCPUData *b);
+
bool
virCPUArchIsSupported(virArch arch);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fd0eea0777..b63165f354 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1459,6 +1459,7 @@ virCPUDataAddFeature;
virCPUDataCheckFeature;
virCPUDataFormat;
virCPUDataFree;
+virCPUDataIsIdentical;
virCPUDataNew;
virCPUDataParse;
virCPUExpandFeatures;
--
2.31.1