|
|
c313de |
From 992af2f6564b899142a2be5f342e0cdbdd13eadc Mon Sep 17 00:00:00 2001
|
|
|
c313de |
Message-Id: <992af2f6564b899142a2be5f342e0cdbdd13eadc@dist-git>
|
|
|
c313de |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c313de |
Date: Fri, 21 Jun 2019 09:25:59 +0200
|
|
|
c313de |
Subject: [PATCH] cpu: Introduce virCPUDataAddFeature
|
|
|
c313de |
MIME-Version: 1.0
|
|
|
c313de |
Content-Type: text/plain; charset=UTF-8
|
|
|
c313de |
Content-Transfer-Encoding: 8bit
|
|
|
c313de |
|
|
|
c313de |
This is a generic replacement for the former virCPUx86DataAddFeature,
|
|
|
c313de |
which worked on the generic virCPUDataPtr anyway.
|
|
|
c313de |
|
|
|
c313de |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c313de |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c313de |
(cherry picked from commit df73078c612a70e48aa76e889a7026e2daa47b16)
|
|
|
c313de |
|
|
|
c313de |
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
|
|
|
c313de |
|
|
|
c313de |
Conflicts:
|
|
|
c313de |
src/cpu/cpu_x86.h
|
|
|
c313de |
- downstream did not switch to #pragma once
|
|
|
c313de |
|
|
|
c313de |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c313de |
Message-Id: <4e946f702092fe5eb4c8235dbb98402b30876a5f.1561068591.git.jdenemar@redhat.com>
|
|
|
c313de |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c313de |
---
|
|
|
c313de |
src/cpu/cpu.c | 33 +++++++++++++++++++++++++++++++++
|
|
|
c313de |
src/cpu/cpu.h | 9 +++++++++
|
|
|
c313de |
src/cpu/cpu_x86.c | 3 ++-
|
|
|
c313de |
src/cpu/cpu_x86.h | 3 ---
|
|
|
c313de |
src/libvirt_private.syms | 2 +-
|
|
|
c313de |
src/qemu/qemu_capabilities.c | 2 +-
|
|
|
c313de |
6 files changed, 46 insertions(+), 6 deletions(-)
|
|
|
c313de |
|
|
|
c313de |
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
|
|
|
c313de |
index cc93c49418..a2d143c94a 100644
|
|
|
c313de |
--- a/src/cpu/cpu.c
|
|
|
c313de |
+++ b/src/cpu/cpu.c
|
|
|
c313de |
@@ -1078,3 +1078,36 @@ virCPUValidateFeatures(virArch arch,
|
|
|
c313de |
else
|
|
|
c313de |
return 0;
|
|
|
c313de |
}
|
|
|
c313de |
+
|
|
|
c313de |
+
|
|
|
c313de |
+/**
|
|
|
c313de |
+ * virCPUDataAddFeature:
|
|
|
c313de |
+ *
|
|
|
c313de |
+ * @cpuData: CPU data
|
|
|
c313de |
+ * @name: feature to be added to @cpuData
|
|
|
c313de |
+ *
|
|
|
c313de |
+ * Adds a feature called @name to @cpuData.
|
|
|
c313de |
+ *
|
|
|
c313de |
+ * Returns 0 on success, -1 on error.
|
|
|
c313de |
+ */
|
|
|
c313de |
+int
|
|
|
c313de |
+virCPUDataAddFeature(virCPUDataPtr cpuData,
|
|
|
c313de |
+ const char *name)
|
|
|
c313de |
+{
|
|
|
c313de |
+ struct cpuArchDriver *driver;
|
|
|
c313de |
+
|
|
|
c313de |
+ VIR_DEBUG("arch=%s, cpuData=%p, name=%s",
|
|
|
c313de |
+ virArchToString(cpuData->arch), cpuData, name);
|
|
|
c313de |
+
|
|
|
c313de |
+ if (!(driver = cpuGetSubDriver(cpuData->arch)))
|
|
|
c313de |
+ return -1;
|
|
|
c313de |
+
|
|
|
c313de |
+ if (!driver->dataAddFeature) {
|
|
|
c313de |
+ virReportError(VIR_ERR_NO_SUPPORT,
|
|
|
c313de |
+ _("cannot add guest CPU feature for %s architecture"),
|
|
|
c313de |
+ virArchToString(cpuData->arch));
|
|
|
c313de |
+ return -1;
|
|
|
c313de |
+ }
|
|
|
c313de |
+
|
|
|
c313de |
+ return driver->dataAddFeature(cpuData, name);
|
|
|
c313de |
+}
|
|
|
c313de |
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
|
|
|
c313de |
index 81119b6aeb..e5fae31e30 100644
|
|
|
c313de |
--- a/src/cpu/cpu.h
|
|
|
c313de |
+++ b/src/cpu/cpu.h
|
|
|
c313de |
@@ -121,6 +121,10 @@ typedef virCPUDefPtr
|
|
|
c313de |
typedef int
|
|
|
c313de |
(*virCPUArchValidateFeatures)(virCPUDefPtr cpu);
|
|
|
c313de |
|
|
|
c313de |
+typedef int
|
|
|
c313de |
+(*virCPUArchDataAddFeature)(virCPUDataPtr cpuData,
|
|
|
c313de |
+ const char *name);
|
|
|
c313de |
+
|
|
|
c313de |
struct cpuArchDriver {
|
|
|
c313de |
const char *name;
|
|
|
c313de |
const virArch *arch;
|
|
|
c313de |
@@ -143,6 +147,7 @@ struct cpuArchDriver {
|
|
|
c313de |
virCPUArchExpandFeatures expandFeatures;
|
|
|
c313de |
virCPUArchCopyMigratable copyMigratable;
|
|
|
c313de |
virCPUArchValidateFeatures validateFeatures;
|
|
|
c313de |
+ virCPUArchDataAddFeature dataAddFeature;
|
|
|
c313de |
};
|
|
|
c313de |
|
|
|
c313de |
|
|
|
c313de |
@@ -260,6 +265,10 @@ virCPUValidateFeatures(virArch arch,
|
|
|
c313de |
virCPUDefPtr cpu)
|
|
|
c313de |
ATTRIBUTE_NONNULL(2);
|
|
|
c313de |
|
|
|
c313de |
+int
|
|
|
c313de |
+virCPUDataAddFeature(virCPUDataPtr cpuData,
|
|
|
c313de |
+ const char *name);
|
|
|
c313de |
+
|
|
|
c313de |
/* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
|
|
|
c313de |
* have no real-life usage
|
|
|
c313de |
*/
|
|
|
c313de |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
c313de |
index 3c1bd623db..ead962ae06 100644
|
|
|
c313de |
--- a/src/cpu/cpu_x86.c
|
|
|
c313de |
+++ b/src/cpu/cpu_x86.c
|
|
|
c313de |
@@ -3316,7 +3316,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
|
|
|
c313de |
-int
|
|
|
c313de |
+static int
|
|
|
c313de |
virCPUx86DataAddFeature(virCPUDataPtr cpuData,
|
|
|
c313de |
const char *name)
|
|
|
c313de |
{
|
|
|
c313de |
@@ -3361,4 +3361,5 @@ struct cpuArchDriver cpuDriverX86 = {
|
|
|
c313de |
.expandFeatures = virCPUx86ExpandFeatures,
|
|
|
c313de |
.copyMigratable = virCPUx86CopyMigratable,
|
|
|
c313de |
.validateFeatures = virCPUx86ValidateFeatures,
|
|
|
c313de |
+ .dataAddFeature = virCPUx86DataAddFeature,
|
|
|
c313de |
};
|
|
|
c313de |
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
|
|
|
c313de |
index 8b51cef9c1..519024b7c0 100644
|
|
|
c313de |
--- a/src/cpu/cpu_x86.h
|
|
|
c313de |
+++ b/src/cpu/cpu_x86.h
|
|
|
c313de |
@@ -45,7 +45,4 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
|
|
|
c313de |
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
|
|
|
c313de |
const char *vendor);
|
|
|
c313de |
|
|
|
c313de |
-int virCPUx86DataAddFeature(virCPUDataPtr cpuData,
|
|
|
c313de |
- const char *name);
|
|
|
c313de |
-
|
|
|
c313de |
#endif /* __VIR_CPU_X86_H__ */
|
|
|
c313de |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
c313de |
index 57508de0c1..a20e0593f0 100644
|
|
|
c313de |
--- a/src/libvirt_private.syms
|
|
|
c313de |
+++ b/src/libvirt_private.syms
|
|
|
c313de |
@@ -1187,6 +1187,7 @@ virCPUCompare;
|
|
|
c313de |
virCPUCompareXML;
|
|
|
c313de |
virCPUConvertLegacy;
|
|
|
c313de |
virCPUCopyMigratable;
|
|
|
c313de |
+virCPUDataAddFeature;
|
|
|
c313de |
virCPUDataCheckFeature;
|
|
|
c313de |
virCPUDataFormat;
|
|
|
c313de |
virCPUDataFree;
|
|
|
c313de |
@@ -1205,7 +1206,6 @@ virCPUValidateFeatures;
|
|
|
c313de |
|
|
|
c313de |
# cpu/cpu_x86.h
|
|
|
c313de |
virCPUx86DataAdd;
|
|
|
c313de |
-virCPUx86DataAddFeature;
|
|
|
c313de |
virCPUx86DataGetSignature;
|
|
|
c313de |
virCPUx86DataSetSignature;
|
|
|
c313de |
virCPUx86DataSetVendor;
|
|
|
c313de |
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
|
|
c313de |
index 78be2d35f4..4be0ec305f 100644
|
|
|
c313de |
--- a/src/qemu/qemu_capabilities.c
|
|
|
c313de |
+++ b/src/qemu/qemu_capabilities.c
|
|
|
c313de |
@@ -2916,7 +2916,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
|
|
|
c313de |
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
- if (virCPUx86DataAddFeature(data, name) < 0)
|
|
|
c313de |
+ if (virCPUDataAddFeature(data, name) < 0)
|
|
|
c313de |
goto cleanup;
|
|
|
c313de |
|
|
|
c313de |
break;
|
|
|
c313de |
--
|
|
|
c313de |
2.22.0
|
|
|
c313de |
|