From nobody Thu May 15 02:18:42 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516722548486665.5258771522792; Tue, 23 Jan 2018 07:49:08 -0800 (PST) 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 537F8C070E30; Tue, 23 Jan 2018 15:49:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2034DBA75; Tue, 23 Jan 2018 15:49:07 +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 DB9F03FC75; Tue, 23 Jan 2018 15:49:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0NFjgXp023521 for ; Tue, 23 Jan 2018 10:45:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 905B8176C0; Tue, 23 Jan 2018 15:45:42 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF138176C9 for ; Tue, 23 Jan 2018 15:45:37 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 23 Jan 2018 16:45:01 +0100 Message-Id: <20180123154504.9541-3-abologna@redhat.com> In-Reply-To: <20180123154504.9541-1-abologna@redhat.com> References: <20180123154504.9541-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] conf: Add pSeries features 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.31]); Tue, 23 Jan 2018 15:49:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We're going to introduce a number of optional, pSeries-specific features, so we want to have a dedicated sub-element to avoid cluttering the element. Along with the generic framework, we also introduce the first actual feature: HPT (Hash Page Table) tuning. This will replace the existing feature later on, but right now they simply co-exist without interfering with each other. Signed-off-by: Andrea Bolognani --- docs/formatdomain.html.in | 20 +++++++++ docs/schemas/domaincommon.rng | 16 +++++++ src/conf/domain_conf.c | 102 ++++++++++++++++++++++++++++++++++++++= ++++ src/conf/domain_conf.h | 11 +++++ src/libvirt_private.syms | 2 + src/qemu/qemu_command.c | 93 ++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.c | 7 +++ 7 files changed, 251 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index d272cc1ba..b2584fbb0 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1768,6 +1768,9 @@ <kvm> <hidden state=3D'on'/> </kvm> + <pseries> + <hpt resizing=3D'required'/> + </pseries> <pvspinlock state=3D'on'/> <gic version=3D'2'/> <ioapic driver=3D'qemu'/> @@ -1904,6 +1907,23 @@ +
pseries
+
Various features to change the behavior of pSeries guests. + + + + + + + + + + + + + +
FeatureDescriptionValueSince
hptConfigure HPT (Hash Page Table)resizing: enabled, disabled, required4.1.0 (QEMU 2.10)
+
pmu
Depending on the state attribute (values on, off, default on) enable or disable the diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 75838b581..fead6e7cc 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4703,6 +4703,9 @@ + + + @@ -5526,6 +5529,19 @@ =20 + + + + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a1c25060f..577a804df 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -152,6 +152,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, "ioapic", "hpt", "vmcoreinfo", + "pseries", ); =20 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_= LAST, @@ -173,6 +174,11 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST, VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST, "hidden") =20 +VIR_ENUM_IMPL(virDomainPSeries, + VIR_DOMAIN_PSERIES_LAST, + "hpt", +); + VIR_ENUM_IMPL(virDomainCapsFeature, VIR_DOMAIN_CAPS_FEATURE_LAST, "audit_control", "audit_write", @@ -18879,6 +18885,7 @@ virDomainDefParseXML(xmlDocPtr xml, case VIR_DOMAIN_FEATURE_HYPERV: case VIR_DOMAIN_FEATURE_VMCOREINFO: case VIR_DOMAIN_FEATURE_KVM: + case VIR_DOMAIN_FEATURE_PSERIES: def->features[val] =3D VIR_TRISTATE_SWITCH_ON; break; =20 @@ -19114,6 +19121,54 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); } =20 + if (def->features[VIR_DOMAIN_FEATURE_PSERIES] =3D=3D VIR_TRISTATE_SWIT= CH_ON) { + int feature; + int value; + + if ((n =3D virXPathNodeSet("./features/pseries/*", ctxt, &nodes)) = < 0) + goto error; + + for (i =3D 0; i < n; i++) { + feature =3D virDomainPSeriesTypeFromString((const char *) node= s[i]->name); + + if (feature < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown '%s' pSeries feature"), + nodes[i]->name); + goto error; + } + + switch ((virDomainPSeries) feature) { + case VIR_DOMAIN_PSERIES_HPT: + if (!(tmp =3D virXMLPropString(nodes[i], "resizing"))) { + virReportError(VIR_ERR_XML_ERROR, + _("Missing '%s' attribute for " + "'%s' pSeries feature"), + "resizing", nodes[i]->name); + goto error; + } + + if ((value =3D virDomainHPTResizingTypeFromString(tmp)) < = 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid value '%s' for '%s' " + "attribute of '%s' pSeries feature"), + tmp, "resizing", nodes[i]->name); + goto error; + } + + def->pseries_features[feature] =3D VIR_TRISTATE_SWITCH_ON; + def->pseries_hpt_resizing =3D value; + + VIR_FREE(tmp); + break; + + case VIR_DOMAIN_PSERIES_LAST: + break; + } + } + VIR_FREE(nodes); + } + if ((n =3D virXPathNodeSet("./features/capabilities/*", ctxt, &nodes))= < 0) goto error; =20 @@ -21140,6 +21195,29 @@ virDomainDefFeaturesCheckABIStability(virDomainDef= Ptr src, } } =20 + /* pSeries features */ + if (src->features[VIR_DOMAIN_FEATURE_PSERIES] =3D=3D VIR_TRISTATE_SWIT= CH_ON) { + for (i =3D 0; i < VIR_DOMAIN_PSERIES_LAST; i++) { + switch ((virDomainPSeries) i) { + case VIR_DOMAIN_PSERIES_HPT: + if (src->pseries_features[i] !=3D dst->pseries_features[i]= || + src->pseries_hpt_resizing !=3D dst->pseries_hpt_resizi= ng) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("State of '%s' pSeries feature differ= s: " + "source: '%s', destination: '%s'"), + virDomainPSeriesTypeToString(i), + virDomainHPTResizingTypeToString(src->p= series_hpt_resizing), + virDomainHPTResizingTypeToString(dst->p= series_hpt_resizing)); + return false; + } + break; + + case VIR_DOMAIN_PSERIES_LAST: + break; + } + } + } + /* ioapic */ if (src->ioapic !=3D dst->ioapic) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -26487,6 +26565,30 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferAddLit(buf, "\n"); break; =20 + case VIR_DOMAIN_FEATURE_PSERIES: + if (def->features[i] !=3D VIR_TRISTATE_SWITCH_ON) + break; + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + for (j =3D 0; j < VIR_DOMAIN_PSERIES_LAST; j++) { + switch ((virDomainPSeries) j) { + case VIR_DOMAIN_PSERIES_HPT: + if (def->pseries_features[j] !=3D VIR_TRISTATE_SWI= TCH_ON) + break; + + virBufferAsprintf(buf, "\n", + virDomainHPTResizingTypeToString= (def->pseries_hpt_resizing)); + break; + + case VIR_DOMAIN_PSERIES_LAST: + break; + } + } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + break; + case VIR_DOMAIN_FEATURE_CAPABILITIES: if (def->features[i] =3D=3D VIR_DOMAIN_CAPABILITIES_POLICY= _DEFAULT && !virDomainDefHasCapabilitiesFeatures(def)) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 6f7f96b3d..e4ae2a26c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1740,6 +1740,7 @@ typedef enum { VIR_DOMAIN_FEATURE_IOAPIC, VIR_DOMAIN_FEATURE_HPT, VIR_DOMAIN_FEATURE_VMCOREINFO, + VIR_DOMAIN_FEATURE_PSERIES, =20 VIR_DOMAIN_FEATURE_LAST } virDomainFeature; @@ -1766,6 +1767,14 @@ typedef enum { VIR_DOMAIN_KVM_LAST } virDomainKVM; =20 +typedef enum { + VIR_DOMAIN_PSERIES_HPT =3D 0, + + VIR_DOMAIN_PSERIES_LAST +} virDomainPSeries; + +VIR_ENUM_DECL(virDomainPSeries); + typedef enum { VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT =3D 0, VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW, @@ -2346,11 +2355,13 @@ struct _virDomainDef { int apic_eoi; int hyperv_features[VIR_DOMAIN_HYPERV_LAST]; int kvm_features[VIR_DOMAIN_KVM_LAST]; + int pseries_features[VIR_DOMAIN_PSERIES_LAST]; unsigned int hyperv_spinlocks; virGICVersion gic_version; char *hyperv_vendor_id; virDomainIOAPIC ioapic; virDomainHPTResizing hpt_resizing; + virDomainHPTResizing pseries_hpt_resizing; =20 /* These options are of type virTristateSwitch: ON =3D keep, OFF =3D d= rop */ int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST]; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bc8cc1fba..ae9eecb5d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -484,6 +484,8 @@ virDomainPausedReasonTypeFromString; virDomainPausedReasonTypeToString; virDomainPMSuspendedReasonTypeFromString; virDomainPMSuspendedReasonTypeToString; +virDomainPSeriesTypeFromString; +virDomainPSeriesTypeToString; virDomainRedirdevBusTypeFromString; virDomainRedirdevBusTypeToString; virDomainRedirdevDefFind; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b8aede32d..a053b597c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7360,6 +7360,79 @@ qemuBuildNameCommandLine(virCommandPtr cmd, return 0; } =20 +static int +virDomainPSeriesToQEMUCaps(int feature) +{ + switch ((virDomainPSeries) feature) { + case VIR_DOMAIN_PSERIES_HPT: + return QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT; + case VIR_DOMAIN_PSERIES_LAST: + break; + } + + return -1; +} + +static const char* +virDomainPSeriesToMachineOption(int feature) +{ + switch ((virDomainPSeries) feature) { + case VIR_DOMAIN_PSERIES_HPT: + return "resize-hpt"; + case VIR_DOMAIN_PSERIES_LAST: + break; + } + + return NULL; +} + +static int +qemuBuildMachineCommandLinePSeriesFeature(virBufferPtr buf, + virDomainPSeries feature, + const char *value, + virQEMUCapsPtr qemuCaps) +{ + const char *name =3D virDomainPSeriesTypeToString(feature); + const char *option =3D virDomainPSeriesToMachineOption(feature); + int cap; + int ret =3D -1; + + if (!option) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown QEMU option for '%s' pSeries feature"), + name); + goto cleanup; + } + + if (!value) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid value for '%s' pSeries feature"), + name); + goto cleanup; + } + + if ((cap =3D virDomainPSeriesToQEMUCaps(feature)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown QEMU capability for '%s' pSeries feature= "), + name); + goto cleanup; + } + + if (!virQEMUCapsGet(qemuCaps, cap)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("'%s' pSeries feature not supported by this QEMU = binary"), + name); + goto cleanup; + } + + virBufferAsprintf(buf, ",%s=3D%s", option, value); + + ret =3D 0; + + cleanup: + return ret; +} + static int qemuBuildMachineCommandLine(virCommandPtr cmd, virQEMUDriverConfigPtr cfg, @@ -7592,6 +7665,26 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, virBufferAsprintf(&buf, ",resize-hpt=3D%s", str); } =20 + if (def->features[VIR_DOMAIN_FEATURE_PSERIES] =3D=3D VIR_TRISTATE_= SWITCH_ON) { + const char *value; + + for (i =3D 0; i < VIR_DOMAIN_PSERIES_LAST; i++) { + switch ((virDomainPSeries) i) { + case VIR_DOMAIN_PSERIES_HPT: + if (def->pseries_features[i] !=3D VIR_TRISTATE_SWITCH_= ON) + break; + + value =3D virDomainHPTResizingTypeToString(def->pserie= s_hpt_resizing); + if (qemuBuildMachineCommandLinePSeriesFeature(&buf, i,= value, qemuCaps) < 0) + goto cleanup; + break; + + case VIR_DOMAIN_PSERIES_LAST: + goto cleanup; + } + } + } + if (cpu && cpu->model && cpu->mode =3D=3D VIR_CPU_MODE_HOST_MODEL && qemuDomainIsPSeries(def) && diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b4bd3cca..edef3838e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3125,6 +3125,13 @@ qemuDomainDefVerifyFeatures(const virDomainDef *def) return -1; } =20 + if (def->features[VIR_DOMAIN_FEATURE_PSERIES] =3D=3D VIR_TRISTATE_SWIT= CH_ON && + !qemuDomainIsPSeries(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("pSeries features are only supported for pSeries = guests")); + return -1; + } + if (def->features[VIR_DOMAIN_FEATURE_HPT] =3D=3D VIR_TRISTATE_SWITCH_O= N && !qemuDomainIsPSeries(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list