[libvirt PATCH v2 04/14] domain_capabilities: Add vendor attribute for CPU models

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Even though several CPU models from various vendors are reported as
usable on a given host, user may still want to use only those that match
the host vendor. Currently the only place where users can check the
vendor of each CPU model is our CPU map, which is considered internal
and users should not really be using it directly. So to allow for such
filtering we now advertise the vendor of each CPU model in domain
capabilities.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>
---

Notes:
    Version 2:
    - no change

 docs/formatdomaincaps.rst                     |  12 +-
 src/conf/domain_capabilities.c                |  13 +-
 src/conf/domain_capabilities.h                |   4 +-
 src/conf/schemas/domaincaps.rng               |   3 +
 src/qemu/qemu_capabilities.c                  |   2 +-
 tests/cputest.c                               |   5 +-
 .../domaincapsdata/qemu_4.2.0-q35.x86_64.xml  | 104 ++++++------
 .../domaincapsdata/qemu_4.2.0-tcg.x86_64.xml  | 104 ++++++------
 .../qemu_4.2.0-virt.aarch64.xml               |  72 ++++-----
 tests/domaincapsdata/qemu_4.2.0.aarch64.xml   |  72 ++++-----
 tests/domaincapsdata/qemu_4.2.0.ppc64.xml     |   6 +-
 tests/domaincapsdata/qemu_4.2.0.s390x.xml     | 148 +++++++++---------
 tests/domaincapsdata/qemu_4.2.0.x86_64.xml    | 104 ++++++------
 .../domaincapsdata/qemu_5.0.0-q35.x86_64.xml  | 108 ++++++-------
 .../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml  | 108 ++++++-------
 .../qemu_5.0.0-virt.aarch64.xml               |  74 ++++-----
 tests/domaincapsdata/qemu_5.0.0.aarch64.xml   |  74 ++++-----
 tests/domaincapsdata/qemu_5.0.0.ppc64.xml     |   8 +-
 tests/domaincapsdata/qemu_5.0.0.x86_64.xml    | 108 ++++++-------
 .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml  | 108 ++++++-------
 .../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml  | 108 ++++++-------
 tests/domaincapsdata/qemu_5.1.0.x86_64.xml    | 108 ++++++-------
 .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml  | 108 ++++++-------
 .../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml  | 108 ++++++-------
 .../qemu_5.2.0-virt.aarch64.xml               |  74 ++++-----
 tests/domaincapsdata/qemu_5.2.0.aarch64.xml   |  74 ++++-----
 tests/domaincapsdata/qemu_5.2.0.ppc64.xml     |   8 +-
 tests/domaincapsdata/qemu_5.2.0.s390x.xml     | 148 +++++++++---------
 tests/domaincapsdata/qemu_5.2.0.x86_64.xml    | 108 ++++++-------
 .../domaincapsdata/qemu_6.0.0-q35.x86_64.xml  | 110 ++++++-------
 .../domaincapsdata/qemu_6.0.0-tcg.x86_64.xml  | 110 ++++++-------
 .../qemu_6.0.0-virt.aarch64.xml               |  76 ++++-----
 tests/domaincapsdata/qemu_6.0.0.aarch64.xml   |  76 ++++-----
 tests/domaincapsdata/qemu_6.0.0.s390x.xml     | 148 +++++++++---------
 tests/domaincapsdata/qemu_6.0.0.x86_64.xml    | 110 ++++++-------
 .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml  | 110 ++++++-------
 .../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml  | 110 ++++++-------
 tests/domaincapsdata/qemu_6.1.0.x86_64.xml    | 110 ++++++-------
 .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml  | 110 ++++++-------
 .../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml  | 110 ++++++-------
 .../qemu_6.2.0-virt.aarch64.xml               |  78 ++++-----
 tests/domaincapsdata/qemu_6.2.0.aarch64.xml   |  78 ++++-----
 tests/domaincapsdata/qemu_6.2.0.ppc64.xml     |   8 +-
 tests/domaincapsdata/qemu_6.2.0.x86_64.xml    | 110 ++++++-------
 .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml  | 110 ++++++-------
 .../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml  | 110 ++++++-------
 .../qemu_7.0.0-virt.aarch64.xml               |  78 ++++-----
 tests/domaincapsdata/qemu_7.0.0.aarch64.xml   |  78 ++++-----
 tests/domaincapsdata/qemu_7.0.0.ppc64.xml     |   8 +-
 tests/domaincapsdata/qemu_7.0.0.x86_64.xml    | 110 ++++++-------
 .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml  | 106 ++++++-------
 .../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml  | 106 ++++++-------
 tests/domaincapsdata/qemu_7.1.0.x86_64.xml    | 106 ++++++-------
 53 files changed, 2183 insertions(+), 2164 deletions(-)

diff --git a/docs/formatdomaincaps.rst b/docs/formatdomaincaps.rst
index 70f46b972a..6ce780fb69 100644
--- a/docs/formatdomaincaps.rst
+++ b/docs/formatdomaincaps.rst
@@ -191,9 +191,10 @@ CPUs <formatdomain.html#cpu-model-and-topology>`__.
          <feature policy='require' name='vmx'/>
        </mode>
        <mode name='custom' supported='yes'>
-         <model usable='no' deprecated='no'>Broadwell</model>
-         <model usable='yes' deprecated='no'>Broadwell-noTSX</model>
-         <model usable='no' deprecated='yes'>Haswell</model>
+         <model usable='no' deprecated='no' vendor='Intel'>Broadwell</model>
+         <model usable='yes' deprecated='no' vendor='Intel'>Broadwell-noTSX</model>
+         <model usable='no' deprecated='yes' vendor='Intel'>Haswell</model>
+         <model usable='no' deprecated='no' vendor='AMD'>EPYC-Milan</model>
          ...
        </mode>
      </cpu>
@@ -226,7 +227,10 @@ more details about it:
    CPU of such model is expected to have. A special value ``unknown`` indicates
    libvirt does not have enough information to provide the usability data. The
    ``deprecated`` attribute reflects the hypervisor's policy on usage of this
-   model :since:`(since 7.1.0)` .
+   model :since:`(since 7.1.0)`. The ``vendor`` attribute :since:`(since 8.9.0)`
+   contains the vendor of the CPU model for users who want to use CPU models
+   with specific vendors only. CPU models with undefined vendor will be listed
+   with ``vendor='unkwnown'``.
 
 I/O Threads
 ~~~~~~~~~~~
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 123c80a560..b5d8288982 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -105,6 +105,7 @@ virDomainCapsCPUModelsDispose(void *obj)
     for (i = 0; i < cpuModels->nmodels; i++) {
         g_free(cpuModels->models[i].name);
         g_strfreev(cpuModels->models[i].blockers);
+        g_free(cpuModels->models[i].vendor);
     }
 
     g_free(cpuModels->models);
@@ -166,7 +167,8 @@ virDomainCapsCPUModelsCopy(virDomainCapsCPUModels *old)
                                   old->models[i].name,
                                   old->models[i].usable,
                                   old->models[i].blockers,
-                                  old->models[i].deprecated);
+                                  old->models[i].deprecated,
+                                  old->models[i].vendor);
     }
 
     return cpuModels;
@@ -178,7 +180,8 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModels *cpuModels,
                           const char *name,
                           virDomainCapsCPUUsable usable,
                           char **blockers,
-                          bool deprecated)
+                          bool deprecated,
+                          const char *vendor)
 {
     virDomainCapsCPUModel *cpu;
 
@@ -192,6 +195,7 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModels *cpuModels,
     cpu->name = g_strdup(name);
     cpu->blockers = g_strdupv(blockers);
     cpu->deprecated = deprecated;
+    cpu->vendor = g_strdup(vendor);
 }
 
 
@@ -377,6 +381,11 @@ virDomainCapsCPUCustomFormat(virBuffer *buf,
         if (model->deprecated)
             virBufferAddLit(buf, " deprecated='yes'");
 
+        if (model->vendor)
+            virBufferAsprintf(buf, " vendor='%s'", model->vendor);
+        else
+            virBufferAddLit(buf, " vendor='unknown'");
+
         virBufferAsprintf(buf, ">%s</model>\n", model->name);
     }
 
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index 7333276231..f5fa1fb8e3 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -159,6 +159,7 @@ struct _virDomainCapsCPUModel {
     virDomainCapsCPUUsable usable;
     char **blockers; /* NULL-terminated list of usability blockers */
     bool deprecated;
+    char *vendor;
 };
 
 typedef struct _virDomainCapsCPUModels virDomainCapsCPUModels;
@@ -249,7 +250,8 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModels *cpuModels,
                           const char *name,
                           virDomainCapsCPUUsable usable,
                           char **blockers,
-                          bool deprecated);
+                          bool deprecated,
+                          const char *vendor);
 virDomainCapsCPUModel *
 virDomainCapsCPUModelsGet(virDomainCapsCPUModels *cpuModels,
                           const char *name);
diff --git a/src/conf/schemas/domaincaps.rng b/src/conf/schemas/domaincaps.rng
index 9cbc2467ab..c4cb9afeba 100644
--- a/src/conf/schemas/domaincaps.rng
+++ b/src/conf/schemas/domaincaps.rng
@@ -159,6 +159,9 @@
               <ref name="virYesNo"/>
             </attribute>
           </optional>
+          <attribute name='vendor'>
+            <text/>
+          </attribute>
           <text/>
         </element>
       </zeroOrMore>
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f366e6797c..5af5de8fc5 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2195,7 +2195,7 @@ virQEMUCapsCPUDefsToModels(qemuMonitorCPUDefs *defs,
             continue;
 
         virDomainCapsCPUModelsAdd(cpuModels, cpu->name, cpu->usable,
-                                  cpu->blockers, cpu->deprecated);
+                                  cpu->blockers, cpu->deprecated, NULL);
     }
 
     return cpuModels;
diff --git a/tests/cputest.c b/tests/cputest.c
index 9d24b9d0f5..52e0022ac3 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -824,7 +824,7 @@ cpuTestUpdateLive(const void *arg)
         }
 
         virDomainCapsCPUModelsAdd(models, expected->model,
-                                  usable, blockers, false);
+                                  usable, blockers, false, expected->vendor);
 
         cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
         ignore_value(virCPUTranslate(data->arch, cpu, models));
@@ -902,7 +902,8 @@ cpuTestInitModels(const char **list)
 
     for (model = list; *model; model++) {
         virDomainCapsCPUModelsAdd(cpus, *model,
-                                  VIR_DOMCAPS_CPU_USABLE_UNKNOWN, NULL, false);
+                                  VIR_DOMCAPS_CPU_USABLE_UNKNOWN,
+                                  NULL, false, NULL);
     }
 
     return cpus;
diff --git a/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml
index 0ec4c570ac..fa86554892 100644
--- a/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml
@@ -61,58 +61,58 @@
       <feature policy='require' name='pschange-mc-no'/>
     </mode>
     <mode name='custom' supported='yes'>
-      <model usable='yes'>qemu64</model>
-      <model usable='yes'>qemu32</model>
-      <model usable='no'>phenom</model>
-      <model usable='yes'>pentium3</model>
-      <model usable='yes'>pentium2</model>
-      <model usable='yes'>pentium</model>
-      <model usable='yes'>n270</model>
-      <model usable='yes'>kvm64</model>
-      <model usable='yes'>kvm32</model>
-      <model usable='yes'>coreduo</model>
-      <model usable='yes'>core2duo</model>
-      <model usable='no'>athlon</model>
-      <model usable='yes'>Westmere-IBRS</model>
-      <model usable='yes'>Westmere</model>
-      <model usable='no'>Snowridge</model>
-      <model usable='no'>Skylake-Server-noTSX-IBRS</model>
-      <model usable='no'>Skylake-Server-IBRS</model>
-      <model usable='no'>Skylake-Server</model>
-      <model usable='yes'>Skylake-Client-noTSX-IBRS</model>
-      <model usable='yes'>Skylake-Client-IBRS</model>
-      <model usable='yes'>Skylake-Client</model>
-      <model usable='yes'>SandyBridge-IBRS</model>
-      <model usable='yes'>SandyBridge</model>
-      <model usable='yes'>Penryn</model>
-      <model usable='no'>Opteron_G5</model>
-      <model usable='no'>Opteron_G4</model>
-      <model usable='no'>Opteron_G3</model>
-      <model usable='yes'>Opteron_G2</model>
-      <model usable='yes'>Opteron_G1</model>
-      <model usable='yes'>Nehalem-IBRS</model>
-      <model usable='yes'>Nehalem</model>
-      <model usable='yes'>IvyBridge-IBRS</model>
-      <model usable='yes'>IvyBridge</model>
-      <model usable='no'>Icelake-Server-noTSX</model>
-      <model usable='no'>Icelake-Server</model>
-      <model usable='no'>Icelake-Client-noTSX</model>
-      <model usable='no'>Icelake-Client</model>
-      <model usable='yes'>Haswell-noTSX-IBRS</model>
-      <model usable='yes'>Haswell-noTSX</model>
-      <model usable='yes'>Haswell-IBRS</model>
-      <model usable='yes'>Haswell</model>
-      <model usable='no'>EPYC-IBPB</model>
-      <model usable='no'>EPYC</model>
-      <model usable='no'>Dhyana</model>
-      <model usable='yes'>Conroe</model>
-      <model usable='no'>Cascadelake-Server-noTSX</model>
-      <model usable='no'>Cascadelake-Server</model>
-      <model usable='yes'>Broadwell-noTSX-IBRS</model>
-      <model usable='yes'>Broadwell-noTSX</model>
-      <model usable='yes'>Broadwell-IBRS</model>
-      <model usable='yes'>Broadwell</model>
-      <model usable='yes'>486</model>
+      <model usable='yes' vendor='unknown'>qemu64</model>
+      <model usable='yes' vendor='unknown'>qemu32</model>
+      <model usable='no' vendor='unknown'>phenom</model>
+      <model usable='yes' vendor='unknown'>pentium3</model>
+      <model usable='yes' vendor='unknown'>pentium2</model>
+      <model usable='yes' vendor='unknown'>pentium</model>
+      <model usable='yes' vendor='unknown'>n270</model>
+      <model usable='yes' vendor='unknown'>kvm64</model>
+      <model usable='yes' vendor='unknown'>kvm32</model>
+      <model usable='yes' vendor='unknown'>coreduo</model>
+      <model usable='yes' vendor='unknown'>core2duo</model>
+      <model usable='no' vendor='unknown'>athlon</model>
+      <model usable='yes' vendor='unknown'>Westmere-IBRS</model>
+      <model usable='yes' vendor='unknown'>Westmere</model>
+      <model usable='no' vendor='unknown'>Snowridge</model>
+      <model usable='no' vendor='unknown'>Skylake-Server-noTSX-IBRS</model>
+      <model usable='no' vendor='unknown'>Skylake-Server-IBRS</model>
+      <model usable='no' vendor='unknown'>Skylake-Server</model>
+      <model usable='yes' vendor='unknown'>Skylake-Client-noTSX-IBRS</model>
+      <model usable='yes' vendor='unknown'>Skylake-Client-IBRS</model>
+      <model usable='yes' vendor='unknown'>Skylake-Client</model>
+      <model usable='yes' vendor='unknown'>SandyBridge-IBRS</model>
+      <model usable='yes' vendor='unknown'>SandyBridge</model>
+      <model usable='yes' vendor='unknown'>Penryn</model>
+      <model usable='no' vendor='unknown'>Opteron_G5</model>
+      <model usable='no' vendor='unknown'>Opteron_G4</model>
+      <model usable='no' vendor='unknown'>Opteron_G3</model>
+      <model usable='yes' vendor='unknown'>Opteron_G2</model>
+      <model usable='yes' vendor='unknown'>Opteron_G1</model>
+      <model usable='yes' vendor='unknown'>Nehalem-IBRS</model>
+      <model usable='yes' vendor='unknown'>Nehalem</model>
+      <model usable='yes' vendor='unknown'>IvyBridge-IBRS</model>
+      <model usable='yes' vendor='unknown'>IvyBridge</model>
+      <model usable='no' vendor='unknown'>Icelake-Server-noTSX</model>
+      <model usable='no' vendor='unknown'>Icelake-Server</model>
+      <model usable='no' vendor='unknown'>Icelake-Client-noTSX</model>
+      <model usable='no' vendor='unknown'>Icelake-Client</model>
+      <model usable='yes' vendor='unknown'>Haswell-noTSX-IBRS</model>
+      <model usable='yes' vendor='unknown'>Haswell-noTSX</model>
+      <model usable='yes' vendor='unknown'>Haswell-IBRS</model>
+      <model usable='yes' vendor='unknown'>Haswell</model>
+      <model usable='no' vendor='unknown'>EPYC-IBPB</model>
+      <model usable='no' vendor='unknown'>EPYC</model>
+      <model usable='no' vendor='unknown'>Dhyana</model>
+      <model usable='yes' vendor='unknown'>Conroe</model>
+      <model usable='no' vendor='unknown'>Cascadelake-Server-noTSX</model>
+      <model usable='no' vendor='unknown'>Cascadelake-Server</model>
+      <model usable='yes' vendor='unknown'>Broadwell-noTSX-IBRS</model>
+      <model usable='yes' vendor='unknown'>Broadwell-noTSX</model>
+      <model usable='yes' vendor='unknown'>Broadwell-IBRS</model>
+      <model usable='yes' vendor='unknown'>Broadwell</model>
+      <model usable='yes' vendor='unknown'>486</model>
     </mode>
   </cpu>
   <memoryBacking supported='yes'>
...
-- 
2.38.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux