From: Jiri Denemark <jdenemar(a)redhat.com>
With this new flag virConnectHypervisorBaselineCPU can be used on any
host (rather than being limited to hosts described by individual CPUs
passed to the API). Using the flag makes the API behave similarly to the
old virConnectBaselineCPU. The main difference is the CPU definition
accepted by both APIs: the old one only accepts host CPU definition,
i.e., without 'policy' attributes as seen in the host capabilities XML.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
include/libvirt/libvirt-host.h | 3 +++
src/libvirt-host.c | 8 +++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
index 91214ea21b..19043235b2 100644
--- a/include/libvirt/libvirt-host.h
+++ b/include/libvirt/libvirt-host.h
@@ -974,6 +974,9 @@ typedef enum {
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES = (1 << 0),
/* filter out non-migratable features (Since: 1.2.14) */
VIR_CONNECT_BASELINE_CPU_MIGRATABLE = (1 << 1),
+ /* when computing a baseline from several CPUs, do not make the result
+ * dependent on the current host (Since: 11.5.0) */
+ VIR_CONNECT_BASELINE_CPU_IGNORE_HOST = (1 << 2),
} virConnectBaselineCPUFlags;
char *virConnectBaselineCPU(virConnectPtr conn,
diff --git a/src/libvirt-host.c b/src/libvirt-host.c
index 8d2107fd62..da75f5f30b 100644
--- a/src/libvirt-host.c
+++ b/src/libvirt-host.c
@@ -1305,7 +1305,8 @@ virConnectBaselineCPU(virConnectPtr conn,
* it on another host results in an undefined behavior as the computed CPU
* model is influenced by the hypervisor (the result may use an unexpected CPU
* model or some features may disabled even though they are supported on all
- * input CPUs).
+ * input CPUs). The undefined behavior can be avoided using
+ * VIR_CONNECT_BASELINE_CPU_IGNORE_HOST flag (see below).
*
* This is different from virConnectBaselineCPU() which doesn't consider any
* hypervisor abilities when computing the best CPU.
@@ -1333,6 +1334,11 @@ virConnectBaselineCPU(virConnectPtr conn,
* If @flags includes VIR_CONNECT_BASELINE_CPU_MIGRATABLE, the resulting
* CPU will not include features that block migration.
*
+ * If @flags contains VIR_CONNECT_BASELINE_CPU_IGNORE_HOST and @ncpus > 1, the
+ * API will not consider hypervisor abilities when computing the baseline. With
+ * this flag baseline can be safely computed on any host (even those not
+ * described in @xmlCPUs).
+ *
* Returns XML description of the computed CPU (caller frees) or NULL on error.
*
* Since: 4.4.0
--
2.50.0