]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu: Introduce virCPUDataAddFeature
authorJiri Denemark <jdenemar@redhat.com>
Tue, 18 Jun 2019 08:09:31 +0000 (10:09 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 19 Jun 2019 22:22:39 +0000 (00:22 +0200)
This is a generic replacement for the former virCPUx86DataAddFeature,
which worked on the generic virCPUDataPtr anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu.c
src/cpu/cpu.h
src/cpu/cpu_x86.c
src/cpu/cpu_x86.h
src/libvirt_private.syms
src/qemu/qemu_capabilities.c

index a223ff06e8d985d10aa1f2a285f13ba5fc215156..b89462cc0c74ce66f5a2c831bf2296e9b4de5e2e 100644 (file)
@@ -1075,3 +1075,36 @@ virCPUValidateFeatures(virArch arch,
     else
         return 0;
 }
+
+
+/**
+ * virCPUDataAddFeature:
+ *
+ * @cpuData: CPU data
+ * @name: feature to be added to @cpuData
+ *
+ * Adds a feature called @name to @cpuData.
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int
+virCPUDataAddFeature(virCPUDataPtr cpuData,
+                     const char *name)
+{
+    struct cpuArchDriver *driver;
+
+    VIR_DEBUG("arch=%s, cpuData=%p, name=%s",
+              virArchToString(cpuData->arch), cpuData, name);
+
+    if (!(driver = cpuGetSubDriver(cpuData->arch)))
+        return -1;
+
+    if (!driver->dataAddFeature) {
+        virReportError(VIR_ERR_NO_SUPPORT,
+                       _("cannot add guest CPU feature for %s architecture"),
+                       virArchToString(cpuData->arch));
+        return -1;
+    }
+
+    return driver->dataAddFeature(cpuData, name);
+}
index 7cc9e7d9db4728130ac6d48b01586fb87c1d4e76..13909bb7a44558972cb99166cb2c0b7a65cb72dc 100644 (file)
@@ -117,6 +117,10 @@ typedef virCPUDefPtr
 typedef int
 (*virCPUArchValidateFeatures)(virCPUDefPtr cpu);
 
+typedef int
+(*virCPUArchDataAddFeature)(virCPUDataPtr cpuData,
+                            const char *name);
+
 struct cpuArchDriver {
     const char *name;
     const virArch *arch;
@@ -139,6 +143,7 @@ struct cpuArchDriver {
     virCPUArchExpandFeatures expandFeatures;
     virCPUArchCopyMigratable copyMigratable;
     virCPUArchValidateFeatures validateFeatures;
+    virCPUArchDataAddFeature dataAddFeature;
 };
 
 
@@ -256,6 +261,10 @@ virCPUValidateFeatures(virArch arch,
                        virCPUDefPtr cpu)
     ATTRIBUTE_NONNULL(2);
 
+int
+virCPUDataAddFeature(virCPUDataPtr cpuData,
+                     const char *name);
+
 /* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
  * have no real-life usage
  */
index 689b6cdaf56c91d650191433606ae1aefef6c43b..b6a94d483afd72bdbf9cd4733d0fb6eb6e43284c 100644 (file)
@@ -3326,7 +3326,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
 }
 
 
-int
+static int
 virCPUx86DataAddFeature(virCPUDataPtr cpuData,
                         const char *name)
 {
@@ -3371,4 +3371,5 @@ struct cpuArchDriver cpuDriverX86 = {
     .expandFeatures = virCPUx86ExpandFeatures,
     .copyMigratable = virCPUx86CopyMigratable,
     .validateFeatures = virCPUx86ValidateFeatures,
+    .dataAddFeature = virCPUx86DataAddFeature,
 };
index 29037d4afad73dd2a0b2f8e93e93f032c714907b..28ae46647a0f2d294ba417b85d62f664ad7fa12e 100644 (file)
@@ -40,6 +40,3 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
 
 int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
                            const char *vendor);
-
-int virCPUx86DataAddFeature(virCPUDataPtr cpuData,
-                            const char *name);
index 228cd929b4d379f7a3ee9356f2afa545873f3d33..ab2e4bc6fe9b06fdbb25073066af6afa6005a3b3 100644 (file)
@@ -1245,6 +1245,7 @@ virCPUCompare;
 virCPUCompareXML;
 virCPUConvertLegacy;
 virCPUCopyMigratable;
+virCPUDataAddFeature;
 virCPUDataCheckFeature;
 virCPUDataFormat;
 virCPUDataFree;
@@ -1263,7 +1264,6 @@ virCPUValidateFeatures;
 
 # cpu/cpu_x86.h
 virCPUx86DataAdd;
-virCPUx86DataAddFeature;
 virCPUx86DataGetSignature;
 virCPUx86DataSetSignature;
 virCPUx86DataSetVendor;
index 9ef1eabc954db85727ef4f2333ac3c2505f0d098..4134f319acd33ab1b3e8be983c3de37901b11ece 100644 (file)
@@ -3009,7 +3009,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
                 (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
                 continue;
 
-            if (virCPUx86DataAddFeature(data, name) < 0)
+            if (virCPUDataAddFeature(data, name) < 0)
                 goto cleanup;
 
             break;