[libvirt] [PATCH v6 30/33] qemu_driver: Identify using libvirt as a distinct way to compute baseline

Chris Venteicher cventeic at redhat.com
Sun Jan 13 00:50:29 UTC 2019


Hypervisor baseline cpu can be computed locally using libvirt utility
functions or remotely using QEMU QMP commands.

Likewise, cpu feature expansion can be computed locally using libvirt
utility functions or remotely using QEMU QMP commands.

This patch identifies using libvirt as a distinct case in the hypervisor
baseline logic and triggers that case when the X86 architecture is being
baselined.

There is one functionality change introduced by this patch.

Local libvirt functions are only used for feature expansion when the
local utility functions are used for CPU baseline and an error is
generated when no method is available to expand cpu featues.

The useQEMU option will be introduced in a future patch for using QEMU
to compute baseline rather than using libvirt.

Signed-off-by: Chris Venteicher <cventeic at redhat.com>
---
 src/qemu/qemu_driver.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2a030bed2f..e9f5686dbe 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13763,6 +13763,7 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn,
     bool migratable;
     virCPUDefPtr cpu = NULL;
     char *cpustr = NULL;
+    bool useLibvirt = false;
 
     virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
                   VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
@@ -13782,7 +13783,9 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn,
     if (!qemuCaps)
         goto cleanup;
 
-    if (ARCH_IS_X86(arch)) {
+    useLibvirt = ARCH_IS_X86(arch);
+
+    if (useLibvirt) {
         migratable = !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE);
 
         if (qemuConnectBaselineHypervisorCPUViaLibvirt(qemuCaps, migratable,
@@ -13798,9 +13801,17 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn,
 
     cpu->fallback = VIR_CPU_FALLBACK_FORBID;
 
-    if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
-        virCPUExpandFeatures(arch, cpu) < 0)
-        goto cleanup;
+    if (flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) {
+        if (useLibvirt && virCPUExpandFeatures(arch, cpu) < 0) {
+            goto cleanup;
+        } else {
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                           _("expand features while "
+                             "computing baseline hypervisor CPU is not supported "
+                             "for arch %s"), virArchToString(arch));
+            goto cleanup;
+        }
+    }
 
     cpustr = virCPUDefFormat(cpu, NULL);
 
-- 
2.17.1




More information about the libvir-list mailing list