[libvirt] [PATCH v2 20/33] cpu_x86: Introduce virCPUx86DataAddFeature

Jiri Denemark posted 33 patches 8 years, 11 months ago
There is a newer version of this series
[libvirt] [PATCH v2 20/33] cpu_x86: Introduce virCPUx86DataAddFeature
Posted by Jiri Denemark 8 years, 11 months ago
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---

Notes:
    Version 2:
    - no change

 src/cpu/cpu_x86.c        | 22 ++++++++++++++++++++++
 src/cpu/cpu_x86.h        |  3 +++
 src/libvirt_private.syms |  1 +
 3 files changed, 26 insertions(+)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index ab5e5257d..b3bccd176 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2756,6 +2756,28 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
 }
 
 
+int
+virCPUx86DataAddFeature(virCPUDataPtr cpuData,
+                        const char *name)
+{
+    virCPUx86FeaturePtr feature;
+    virCPUx86MapPtr map;
+
+    if (!(map = virCPUx86GetMap()))
+        return -1;
+
+    /* ignore unknown features */
+    if (!(feature = x86FeatureFind(map, name)) &&
+        !(feature = x86FeatureFindInternal(name)))
+        return 0;
+
+    if (x86DataAdd(&cpuData->data.x86, &feature->data) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 struct cpuArchDriver cpuDriverX86 = {
     .name = "x86",
     .arch = archs,
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index ab5394914..91ec43fea 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -39,4 +39,7 @@ int virCPUx86DataSetSignature(virCPUDataPtr cpuData,
 int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
                            const char *vendor);
 
+int virCPUx86DataAddFeature(virCPUDataPtr cpuData,
+                            const char *name);
+
 #endif /* __VIR_CPU_X86_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7338c31e7..1c071091d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1006,6 +1006,7 @@ virCPUUpdate;
 
 # cpu/cpu_x86.h
 virCPUx86DataAddCPUID;
+virCPUx86DataAddFeature;
 virCPUx86DataSetSignature;
 virCPUx86DataSetVendor;
 
-- 
2.11.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 20/33] cpu_x86: Introduce virCPUx86DataAddFeature
Posted by John Ferlan 8 years, 11 months ago
No commit message...


On 02/15/2017 11:44 AM, Jiri Denemark wrote:
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
> 
> Notes:
>     Version 2:
>     - no change
> 
>  src/cpu/cpu_x86.c        | 22 ++++++++++++++++++++++
>  src/cpu/cpu_x86.h        |  3 +++
>  src/libvirt_private.syms |  1 +
>  3 files changed, 26 insertions(+)
> 

ACK

John

> diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
> index ab5e5257d..b3bccd176 100644
> --- a/src/cpu/cpu_x86.c
> +++ b/src/cpu/cpu_x86.c
> @@ -2756,6 +2756,28 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
>  }
>  
>  
> +int
> +virCPUx86DataAddFeature(virCPUDataPtr cpuData,
> +                        const char *name)
> +{
> +    virCPUx86FeaturePtr feature;
> +    virCPUx86MapPtr map;
> +
> +    if (!(map = virCPUx86GetMap()))
> +        return -1;
> +
> +    /* ignore unknown features */

Looks like I'm not the only one with redundant comments ;-)


> +    if (!(feature = x86FeatureFind(map, name)) &&
> +        !(feature = x86FeatureFindInternal(name)))
> +        return 0;
> +
> +    if (x86DataAdd(&cpuData->data.x86, &feature->data) < 0)
> +        return -1;
> +
> +    return 0;
> +}
> +
> +
>  struct cpuArchDriver cpuDriverX86 = {
>      .name = "x86",
>      .arch = archs,
> diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
> index ab5394914..91ec43fea 100644
> --- a/src/cpu/cpu_x86.h
> +++ b/src/cpu/cpu_x86.h
> @@ -39,4 +39,7 @@ int virCPUx86DataSetSignature(virCPUDataPtr cpuData,
>  int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
>                             const char *vendor);
>  
> +int virCPUx86DataAddFeature(virCPUDataPtr cpuData,
> +                            const char *name);
> +
>  #endif /* __VIR_CPU_X86_H__ */
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 7338c31e7..1c071091d 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1006,6 +1006,7 @@ virCPUUpdate;
>  
>  # cpu/cpu_x86.h
>  virCPUx86DataAddCPUID;
> +virCPUx86DataAddFeature;
>  virCPUx86DataSetSignature;
>  virCPUx86DataSetVendor;
>  
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list