From nobody Sat Feb 7 14:15:52 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 1531195048438976.7692275572656; Mon, 9 Jul 2018 20:57:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2720D80F7B; Tue, 10 Jul 2018 03:57:27 +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 DD20A60BE4; Tue, 10 Jul 2018 03:57:26 +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 7A1F218037FC; Tue, 10 Jul 2018 03:57:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6A3v9WO003415 for ; Mon, 9 Jul 2018 23:57:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id A6D647C59; Tue, 10 Jul 2018 03:57:09 +0000 (UTC) Received: from cv1.lan (ovpn-120-63.rdu2.redhat.com [10.10.120.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29ED27C4D; Tue, 10 Jul 2018 03:57:09 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Mon, 9 Jul 2018 22:56:55 -0500 Message-Id: <20180710035655.24983-12-cventeic@redhat.com> In-Reply-To: <20180710035655.24983-1-cventeic@redhat.com> References: <20180710035655.24983-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCHv2 11/11] qemu_driver: BaselineHypervisorCPU supports S390 using QEMU/QMP 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 10 Jul 2018 03:57:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Transient S390 configurations require using QEMU to compute CPU Model Baseline and to do CPU Feature Expansion. Start and use a single QEMU instance to do both the baseline and expansion transactions required by BaselineHypervisorCPU. CPU Feature Expansion uses true / false to indicate if property is/isn't included in model. Baseline only returns property list where all enumerated properties are included. --- src/qemu/qemu_driver.c | 74 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9a35e04a85..6c6107f077 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13400,10 +13400,13 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr co= nn, virArch arch; virDomainVirtType virttype; virDomainCapsCPUModelsPtr cpuModels; - bool migratable; + bool migratable_only; virCPUDefPtr cpu =3D NULL; char *cpustr =3D NULL; char **features =3D NULL; + virQEMUCapsInitQMPCommandPtr cmd =3D NULL; + bool forceTCG =3D false; + qemuMonitorCPUModelInfoPtr modelInfo =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -13411,8 +13414,6 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, if (virConnectBaselineHypervisorCPUEnsureACL(conn) < 0) goto cleanup; =20 - migratable =3D !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); - if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_AUTO))) goto cleanup; =20 @@ -13425,6 +13426,19 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, if (!qemuCaps) goto cleanup; =20 + /* QEMU can enumerate non-migratable cpu model features for some archs= like x86 + * migratable_only =3D=3D true: ask for and include only migratable f= eatures + * migratable_only =3D=3D false: ask for and include all features + */ + migratable_only =3D !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); + + if (ARCH_IS_S390(arch)) { + /* QEMU for S390 arch only enumerates migratable features + * No reason to explicitly ask QEMU for or include non-migratable f= eatures + */ + migratable_only =3D true; + } + if (!(cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, virttype)) = || cpuModels->nmodels =3D=3D 0) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, @@ -13437,18 +13451,31 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr co= nn, =20 if (ARCH_IS_X86(arch)) { int rc =3D virQEMUCapsGetCPUFeatures(qemuCaps, virttype, - migratable, &features); + migratable_only, &features); if (rc < 0) goto cleanup; if (features && rc =3D=3D 0) { /* We got only migratable features from QEMU if we asked for t= hem, * no further filtering in virCPUBaseline is desired. */ - migratable =3D false; + migratable_only =3D false; } =20 if (!(cpu =3D virCPUBaseline(arch, cpus, ncpus, cpuModels, - (const char **)features, migratable))) + (const char **)features, migratable_onl= y))) goto cleanup; + } else if (ARCH_IS_S390(arch)) { + + const char *binary =3D virQEMUCapsGetBinary(qemuCaps); + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + + if (!(cmd =3D virQEMUCapsNewQMPCommandConnection(binary, cfg->libDi= r, + cfg->user, cfg->grou= p, + forceTCG))) + goto cleanup; + + if ((virQEMUCapsQMPBaselineCPUModel(cmd, cpus, &cpu) < 0) || !cpu) + goto cleanup; /* Content Error */ + } else { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("computing baseline hypervisor CPU is not support= ed " @@ -13458,9 +13485,36 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, =20 cpu->fallback =3D VIR_CPU_FALLBACK_FORBID; =20 - if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && - virCPUExpandFeatures(arch, cpu) < 0) - goto cleanup; + if (flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) { + if (ARCH_IS_X86(arch)) { + if (virCPUExpandFeatures(arch, cpu) < 0) + goto cleanup; + } else if (ARCH_IS_S390(arch)) { + + if (!(modelInfo =3D virQEMUCapsCPUModelInfoFromCPUDef(cpu))) + goto cleanup; + + virCPUDefFree(cpu); /* Null on failure, repopulated on success */ + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSIO= N)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Feature Expansion not supported with this Q= EMU binary")); + goto cleanup; + } + + if (qemuMonitorGetCPUModelExpansion(cmd->mon, + QEMU_MONITOR_CPU_MODEL_EXPAN= SION_FULL, + migratable_only, modelInfo) = < 0) + goto cleanup; + + /* Expansion enumerates all features + * Baseline reply enumerates only in-model (true) features */ + qemuMonitorCPUModelInfoRemovePropByBoolValue(modelInfo, false); + + if (!(cpu =3D virQEMUCapsCPUModelInfoToCPUDef(migratable_only, m= odelInfo))) + goto cleanup; + } + } =20 cpustr =3D virCPUDefFormat(cpu, NULL); =20 @@ -13469,6 +13523,8 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, virCPUDefFree(cpu); virObjectUnref(qemuCaps); virStringListFree(features); + virQEMUCapsInitQMPCommandFree(cmd); + qemuMonitorCPUModelInfoFree(modelInfo); =20 return cpustr; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list