From nobody Mon Feb 9 16:02:17 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 1517935438440194.91905005989076; Tue, 6 Feb 2018 08:43:58 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91B6F7EAA3; Tue, 6 Feb 2018 16:43: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 6C2765E1AB; Tue, 6 Feb 2018 16:43: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 314F618033F2; Tue, 6 Feb 2018 16:43:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w16GhtS1008610 for ; Tue, 6 Feb 2018 11:43:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5732A6046C; Tue, 6 Feb 2018 16:43:55 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D19245C7AC for ; Tue, 6 Feb 2018 16:43:38 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 6 Feb 2018 17:42:58 +0100 Message-Id: <20180206164300.13450-10-abologna@redhat.com> In-Reply-To: <20180206164300.13450-1-abologna@redhat.com> References: <20180206164300.13450-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/11] conf: Improve IOAPIC feature handling 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 06 Feb 2018 16:43:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of storing separately whether the feature is enabled or not and what driver should be used, store both of them in a single place. Signed-off-by: Andrea Bolognani Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 29 +++++++++++++---------------- src/conf/domain_conf.h | 11 ++++++----- src/qemu/qemu_command.c | 5 +++-- src/qemu/qemu_domain.c | 2 +- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 170c56665..19884ec13 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -900,6 +900,7 @@ VIR_ENUM_IMPL(virDomainLoader, =20 VIR_ENUM_IMPL(virDomainIOAPIC, VIR_DOMAIN_IOAPIC_LAST, + "none", "qemu", "kvm") =20 @@ -5913,8 +5914,7 @@ virDomainDefValidateInternal(const virDomainDef *def) =20 if (def->iommu && def->iommu->intremap =3D=3D VIR_TRISTATE_SWITCH_ON && - (def->features[VIR_DOMAIN_FEATURE_IOAPIC] !=3D VIR_TRISTATE_SWITCH= _ON || - def->ioapic !=3D VIR_DOMAIN_IOAPIC_QEMU)) { + def->features[VIR_DOMAIN_FEATURE_IOAPIC] !=3D VIR_DOMAIN_IOAPIC_QE= MU) { virReportError(VIR_ERR_XML_ERROR, "%s", _("IOMMU interrupt remapping requires split I/O API= C " "(ioapic driver=3D'qemu')")); @@ -19224,14 +19224,13 @@ virDomainDefParseXML(xmlDocPtr xml, tmp =3D virXMLPropString(nodes[i], "driver"); if (tmp) { int value =3D virDomainIOAPICTypeFromString(tmp); - if (value < 0) { + if (value < 0 || value =3D=3D VIR_DOMAIN_IOAPIC_NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown driver mode: %s"), tmp); goto error; } - def->ioapic =3D value; - def->features[val] =3D VIR_TRISTATE_SWITCH_ON; + def->features[val] =3D value; VIR_FREE(tmp); } break; @@ -21408,16 +21407,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDe= fPtr src, break; =20 case VIR_DOMAIN_FEATURE_IOAPIC: - if (src->features[i] !=3D dst->features[i] || - src->ioapic !=3D dst->ioapic) { + if (src->features[i] !=3D dst->features[i]) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("State of feature '%s:%s' differs: " - "source: '%s:%s', destination: '%s:%s'"), + "source: '%s', destination: '%s'"), featureName, "driver", - virTristateSwitchTypeToString(src->features= [i]), - virDomainIOAPICTypeToString(src->ioapic), - virTristateSwitchTypeToString(dst->features= [i]), - virDomainIOAPICTypeToString(dst->ioapic)); + virDomainIOAPICTypeToString(src->features[i= ]), + virDomainIOAPICTypeToString(dst->features[i= ])); return false; } break; @@ -26943,10 +26939,11 @@ virDomainDefFormatInternal(virDomainDefPtr def, break; =20 case VIR_DOMAIN_FEATURE_IOAPIC: - if (def->features[i] =3D=3D VIR_TRISTATE_SWITCH_ON) { - virBufferAsprintf(buf, "\n", - virDomainIOAPICTypeToString(def->ioa= pic)); - } + if (def->features[i] =3D=3D VIR_DOMAIN_IOAPIC_NONE) + break; + + virBufferAsprintf(buf, "\n", + virDomainIOAPICTypeToString(def->feature= s[i])); break; =20 case VIR_DOMAIN_FEATURE_HPT: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 21e004515..20f0efc36 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1861,7 +1861,8 @@ struct _virDomainLoaderDef { void virDomainLoaderDefFree(virDomainLoaderDefPtr loader); =20 typedef enum { - VIR_DOMAIN_IOAPIC_QEMU =3D 0, + VIR_DOMAIN_IOAPIC_NONE =3D 0, + VIR_DOMAIN_IOAPIC_QEMU, VIR_DOMAIN_IOAPIC_KVM, =20 VIR_DOMAIN_IOAPIC_LAST @@ -2352,9 +2353,10 @@ struct _virDomainDef { =20 virDomainOSDef os; char *emulator; - /* These three options are of type virTristateSwitch, - * except VIR_DOMAIN_FEATURE_CAPABILITIES that is of type - * virDomainCapabilitiesPolicy */ + /* Most of the values in {kvm_,hyperv_,}features are of type + * virTristateSwitch, but there are exceptions: for example, + * VIR_DOMAIN_FEATURE_CAPABILITIES is of type virDomainCapabilitiesPol= icy, + * VIR_DOMAIN_FEATURE_IOAPIC is of type virDomainIOAPIC and so on */ int features[VIR_DOMAIN_FEATURE_LAST]; int apic_eoi; int hyperv_features[VIR_DOMAIN_HYPERV_LAST]; @@ -2362,7 +2364,6 @@ struct _virDomainDef { unsigned int hyperv_spinlocks; virGICVersion gic_version; char *hyperv_vendor_id; - virDomainIOAPIC ioapic; virDomainHPTResizing hpt_resizing; =20 /* These options are of type virTristateSwitch: ON =3D keep, OFF =3D d= rop */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 529079be0..3aabdf7a2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7240,14 +7240,14 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, } } =20 - if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] =3D=3D VIR_TRISTATE_S= WITCH_ON) { + if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] !=3D VIR_DOMAIN_IOAPI= C_NONE) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP= )) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("I/O APIC tuning is not supported by this= " "QEMU binary")); goto cleanup; } - switch (def->ioapic) { + switch ((virDomainIOAPIC) def->features[VIR_DOMAIN_FEATURE_IOA= PIC]) { case VIR_DOMAIN_IOAPIC_QEMU: if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQ= CHIP_SPLIT)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -7260,6 +7260,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, case VIR_DOMAIN_IOAPIC_KVM: virBufferAddLit(&buf, ",kernel_irqchip=3Don"); break; + case VIR_DOMAIN_IOAPIC_NONE: case VIR_DOMAIN_IOAPIC_LAST: break; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ee720d328..cfea1f500 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3234,7 +3234,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def) =20 switch ((virDomainFeature) i) { case VIR_DOMAIN_FEATURE_IOAPIC: - if (def->features[i] =3D=3D VIR_TRISTATE_SWITCH_ON && + if (def->features[i] !=3D VIR_DOMAIN_IOAPIC_NONE && !ARCH_IS_X86(def->os.arch)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("The '%s' feature is only supported for %= s guests"), --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list