From nobody Tue Feb 10 16:18:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1547341079133682.5023606028612; Sat, 12 Jan 2019 16:57:59 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D44F5F; Sun, 13 Jan 2019 00:57:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4696C8176B; Sun, 13 Jan 2019 00:57:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9B400184B54D; Sun, 13 Jan 2019 00:57:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0D0vrDm002192 for ; Sat, 12 Jan 2019 19:57:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id EEA2581753; Sun, 13 Jan 2019 00:57:53 +0000 (UTC) Received: from cv1.lan (ovpn-126-68.rdu2.redhat.com [10.10.126.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE4C081747; Sun, 13 Jan 2019 00:57:49 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Sat, 12 Jan 2019 18:50:30 -0600 Message-Id: <20190113005032.17880-32-cventeic@redhat.com> In-Reply-To: <20190113005032.17880-1-cventeic@redhat.com> References: <20190113005032.17880-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com, mprivozn@redhat.com, jdenemar@redhat.com, chris@venteicher.org Subject: [libvirt] [PATCH v6 31/33] qemu_driver: Support baseline calculation using QEMU X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 13 Jan 2019 00:57:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add capability to calculate hypervisor baseline using QMP message exchanges with QEMU in addition to existing capability to calculate baseline using libvirt utility functions. A new utility function encapsulates the core logic for interacting with QEMU using QMP baseline messages. The QMP messages only allow two cpu models to be evaluated at a time so a sequence of QMP baseline messages must be used to include all the models in the baseline when more than 2 cpu models are input. A QEMU process must be started prior to sending the series of QEMU messages to compute baseline. The QEMU process is started and maintained in the main hypervisor baseline function and only a pointer to the QEMU process monitor is passed to the baseline utility function. The QEMU process is maintained in the main hypervisor baseline function because the process will also be used for feature expansion (via QEMU) in a later patch. Signed-off-by: Chris Venteicher --- src/qemu/qemu_driver.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e9f5686dbe..5068805f51 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13696,6 +13696,78 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUT= E_UNUSED, } =20 =20 +/* in: + * cpus[0]->model =3D "z14"; + * cpus[0]->features[0].name =3D "xxx"; + * cpus[0]->features[1].name =3D "yyy"; + * *** + * cpus[n]->model =3D "z13"; + * cpus[n]->features[0].name =3D "xxx"; + * cpus[n]->features[1].name =3D "yyy"; + * + * out: + * *baseline->model =3D "z13-base"; + * *baseline->features[0].name =3D "yyy"; + */ +static int +qemuConnectBaselineHypervisorCPUViaQEMU(qemuMonitorPtr mon, + virCPUDefPtr *cpus, + virCPUDefPtr *baseline) +{ + qemuMonitorCPUModelInfoPtr model_baseline =3D NULL; + qemuMonitorCPUModelInfoPtr new_model_baseline =3D NULL; + qemuMonitorCPUModelInfoPtr next_model =3D NULL; + bool migratable =3D true; + int ret =3D -1; + size_t i; + + *baseline =3D NULL; + + if (!cpus || !cpus[0]) { + virReportError(VIR_ERR_INVALID_ARG, "%s", _("no cpus")); + goto cleanup; + } + + for (i =3D 0; cpus[i]; i++) { /* cpus terminated by NULL element = */ + virCPUDefPtr cpu =3D cpus[i]; + + VIR_DEBUG("cpu[%lu]->model =3D %s", i, NULLSTR(cpu->model)); + + if (!(next_model =3D virQEMUCapsCPUModelInfoFromCPUDef(cpu))) + goto cleanup; + + if (i =3D=3D 0) { + model_baseline =3D next_model; + continue; + } + + if (qemuMonitorGetCPUModelBaseline(mon, model_baseline, + next_model, &new_model_baseline= ) < 0) + goto cleanup; + + qemuMonitorCPUModelInfoFree(model_baseline); + qemuMonitorCPUModelInfoFree(next_model); + + next_model =3D NULL; + + model_baseline =3D new_model_baseline; + } + + if (!(*baseline =3D virQEMUCapsCPUModelInfoToCPUDef(model_baseline, mi= gratable))) + goto cleanup; + + VIR_DEBUG("baseline->model =3D %s", (*baseline)->model); + + ret =3D 0; + + cleanup: + qemuMonitorCPUModelInfoFree(model_baseline); + qemuMonitorCPUModelInfoFree(next_model); + + return ret; +} + + static int qemuConnectBaselineHypervisorCPUViaLibvirt( virQEMUCapsPtr qemuCaps, @@ -13764,6 +13836,11 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, virCPUDefPtr cpu =3D NULL; char *cpustr =3D NULL; bool useLibvirt =3D false; + bool useQemu =3D false; + bool forceTCG =3D false; + qemuMonitorCPUModelInfoPtr modelInfo =3D NULL; + qemuMonitorCPUModelInfoPtr expansion =3D NULL; + qemuProcessQMPPtr proc =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -13784,6 +13861,7 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, goto cleanup; =20 useLibvirt =3D ARCH_IS_X86(arch); + useQemu =3D ARCH_IS_S390(arch); =20 if (useLibvirt) { migratable =3D !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); @@ -13792,6 +13870,21 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, virttype, arch, cpus, ncpus, &cpu) = < 0) goto cleanup; + + } else if (useQemu) { + const char *binary =3D virQEMUCapsGetBinary(qemuCaps); + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + + if (!(proc =3D qemuProcessQMPNew(binary, cfg->libDir, + cfg->user, cfg->group, forceTCG))) + goto cleanup; + + if (qemuProcessQMPStart(proc) < 0) + goto cleanup; + + if ((qemuConnectBaselineHypervisorCPUViaQEMU(proc->mon, cpus, &cpu= ) < 0) || !cpu) + goto cleanup; + } else { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("computing baseline hypervisor CPU is not support= ed " @@ -13819,6 +13912,10 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, virCPUDefListFree(cpus); virCPUDefFree(cpu); virObjectUnref(qemuCaps); + qemuMonitorCPUModelInfoFree(modelInfo); + qemuMonitorCPUModelInfoFree(expansion); + qemuProcessQMPStop(proc); + qemuProcessQMPFree(proc); =20 return cpustr; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list