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