From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364648; cv=none; d=zohomail.com; s=zohoarc; b=UarbGiO2eyv3jwtGF1HxxSf3ZhqZtiAAM6YuYFWs6ym8mENitGThzQ+ieLA47B8ZnrCNFwfx1gJguLuMffEV5BRT17YP+Zk0iKO1hqyqKKvGPaiKeCyjY1sUQql3AS/NNfmfHhjTXFm7QG47Vwm+RivNLeffuvabfPuM+kTF+/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364648; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lYlgxHNEAD8JAUhjNS0NdBNY3WC3mhoTPmaXMhlaSCI=; b=miP0QBKCeXv3Y/c7LKTbfk5+XUZMSLHTPfN/eI/k3y6EL6JVv+tQHo/JqDpEiZU/mbJhSTRc1eczbCg3v7ostJ+cVrrWxvjglYYCtDW3YFezzHKecxKyPLSLZcYGczlzrzjvTX55WtoRkhbr6spJw+xQqqAL2pspudMScTq2bBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1624364648415802.7686642293188; Tue, 22 Jun 2021 05:24:08 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-VxwsRSdKMeakma-WEajZnA-1; Tue, 22 Jun 2021 08:24:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D17F818414AC; Tue, 22 Jun 2021 12:23:57 +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 AAD145D6AD; Tue, 22 Jun 2021 12:23: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 7345E4EA37; Tue, 22 Jun 2021 12:23:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCN5FE005118 for ; Tue, 22 Jun 2021 08:23:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E12B19C66; Tue, 22 Jun 2021 12:23:05 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F44B19D9B; Tue, 22 Jun 2021 12:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364647; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lYlgxHNEAD8JAUhjNS0NdBNY3WC3mhoTPmaXMhlaSCI=; b=hiUmfiup6ARyoA0nwW2sG6oJmBuNnFsesypP7z+uwTdzjjdALQwTM6wZHcedOV57ALY+U1 koWg7zt4zogY4oV+xfKCeM8Sw4eo7N38YkzFsuKjO3nVvkdZDztpyi5DOrG+aYhiB1qn1T vPQLaaRloESNLoq0NGyTgYIWqc27ZtA= X-MC-Unique: VxwsRSdKMeakma-WEajZnA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 01/16] virDomainFeaturesDefParse: Factor out HyperV parsing into separate function Date: Tue, 22 Jun 2021 14:22:42 +0200 Message-Id: <20210622122257.12528-2-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Only moving code, cleanup to follow. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 236 ++++++++++++++++++++++------------------- 1 file changed, 127 insertions(+), 109 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f65509d8ec..8cf57db7ba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17286,6 +17286,128 @@ virDomainResourceDefParse(xmlNodePtr node, } =20 =20 +static int +virDomainFeaturesHyperVDefParse(virDomainDef *def, + xmlXPathContext *ctxt) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + size_t i; + int n; + + def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D VIR_TRISTATE_SWITCH_ON; + + if (def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D=3D VIR_TRISTATE_SWITC= H_ON) { + int feature; + virTristateSwitch value; + if ((n =3D virXPathNodeSet("./features/hyperv/*", ctxt, &nodes)) <= 0) + return -1; + + for (i =3D 0; i < n; i++) { + feature =3D virDomainHypervTypeFromString((const char *)nodes[= i]->name); + if (feature < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported HyperV Enlightenment feature= : %s"), + nodes[i]->name); + return -1; + } + + if (virXMLPropTristateSwitch(nodes[i], "state", + VIR_XML_PROP_REQUIRED, &value) < = 0) + return -1; + + def->hyperv_features[feature] =3D value; + + switch ((virDomainHyperv) feature) { + case VIR_DOMAIN_HYPERV_RELAXED: + case VIR_DOMAIN_HYPERV_VAPIC: + case VIR_DOMAIN_HYPERV_VPINDEX: + case VIR_DOMAIN_HYPERV_RUNTIME: + case VIR_DOMAIN_HYPERV_SYNIC: + case VIR_DOMAIN_HYPERV_STIMER: + case VIR_DOMAIN_HYPERV_RESET: + case VIR_DOMAIN_HYPERV_FREQUENCIES: + case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: + case VIR_DOMAIN_HYPERV_TLBFLUSH: + case VIR_DOMAIN_HYPERV_IPI: + case VIR_DOMAIN_HYPERV_EVMCS: + break; + + case VIR_DOMAIN_HYPERV_SPINLOCKS: + if (value !=3D VIR_TRISTATE_SWITCH_ON) + break; + + if (virXMLPropUInt(nodes[i], "retries", 0, + VIR_XML_PROP_REQUIRED, + &def->hyperv_spinlocks) < 0) + return -1; + + if (def->hyperv_spinlocks < 0xFFF) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("HyperV spinlock retry count must be " + "at least 4095")); + return -1; + } + break; + + case VIR_DOMAIN_HYPERV_VENDOR_ID: + if (value !=3D VIR_TRISTATE_SWITCH_ON) + break; + + if (!(def->hyperv_vendor_id =3D virXMLPropString(nodes[i], + "value"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing 'value' attribute for " + "HyperV feature 'vendor_id'")); + return -1; + } + + if (strlen(def->hyperv_vendor_id) > VIR_DOMAIN_HYPERV_VEND= OR_ID_MAX) { + virReportError(VIR_ERR_XML_ERROR, + _("HyperV vendor_id value must not be m= ore " + "than %d characters."), + VIR_DOMAIN_HYPERV_VENDOR_ID_MAX); + return -1; + } + + /* ensure that the string can be passed to qemu */ + if (strchr(def->hyperv_vendor_id, ',')) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("HyperV vendor_id value is invalid")); + return -1; + } + break; + + case VIR_DOMAIN_HYPERV_LAST: + break; + } + } + VIR_FREE(nodes); + } + + if (def->hyperv_features[VIR_DOMAIN_HYPERV_STIMER] =3D=3D VIR_TRISTATE= _SWITCH_ON) { + if ((n =3D virXPathNodeSet("./features/hyperv/stimer/*", ctxt, &no= des)) < 0) + return -1; + + for (i =3D 0; i < n; i++) { + if (STRNEQ((const char *)nodes[i]->name, "direct")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported Hyper-V stimer feature: %s"), + nodes[i]->name); + return -1; + } + + if (virXMLPropTristateSwitch(nodes[i], "state", + VIR_XML_PROP_REQUIRED, + &def->hyperv_stimer_direct) < 0) + return -1; + } + VIR_FREE(nodes); + } + + return 0; +} + + static int virDomainFeaturesDefParse(virDomainDef *def, xmlXPathContextPtr ctxt) @@ -17323,13 +17445,17 @@ virDomainFeaturesDefParse(virDomainDef *def, case VIR_DOMAIN_FEATURE_PAE: case VIR_DOMAIN_FEATURE_VIRIDIAN: case VIR_DOMAIN_FEATURE_PRIVNET: - case VIR_DOMAIN_FEATURE_HYPERV: case VIR_DOMAIN_FEATURE_KVM: case VIR_DOMAIN_FEATURE_MSRS: case VIR_DOMAIN_FEATURE_XEN: def->features[val] =3D VIR_TRISTATE_SWITCH_ON; break; =20 + case VIR_DOMAIN_FEATURE_HYPERV: + if (virDomainFeaturesHyperVDefParse(def, ctxt) < 0) + return -1; + break; + case VIR_DOMAIN_FEATURE_CAPABILITIES: { virDomainCapabilitiesPolicy policy; =20 @@ -17463,114 +17589,6 @@ virDomainFeaturesDefParse(virDomainDef *def, } VIR_FREE(nodes); =20 - if (def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D=3D VIR_TRISTATE_SWITC= H_ON) { - int feature; - virTristateSwitch value; - if ((n =3D virXPathNodeSet("./features/hyperv/*", ctxt, &nodes)) <= 0) - return -1; - - for (i =3D 0; i < n; i++) { - feature =3D virDomainHypervTypeFromString((const char *)nodes[= i]->name); - if (feature < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported HyperV Enlightenment feature= : %s"), - nodes[i]->name); - return -1; - } - - if (virXMLPropTristateSwitch(nodes[i], "state", - VIR_XML_PROP_REQUIRED, &value) < = 0) - return -1; - - def->hyperv_features[feature] =3D value; - - switch ((virDomainHyperv) feature) { - case VIR_DOMAIN_HYPERV_RELAXED: - case VIR_DOMAIN_HYPERV_VAPIC: - case VIR_DOMAIN_HYPERV_VPINDEX: - case VIR_DOMAIN_HYPERV_RUNTIME: - case VIR_DOMAIN_HYPERV_SYNIC: - case VIR_DOMAIN_HYPERV_STIMER: - case VIR_DOMAIN_HYPERV_RESET: - case VIR_DOMAIN_HYPERV_FREQUENCIES: - case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: - case VIR_DOMAIN_HYPERV_TLBFLUSH: - case VIR_DOMAIN_HYPERV_IPI: - case VIR_DOMAIN_HYPERV_EVMCS: - break; - - case VIR_DOMAIN_HYPERV_SPINLOCKS: - if (value !=3D VIR_TRISTATE_SWITCH_ON) - break; - - if (virXMLPropUInt(nodes[i], "retries", 0, - VIR_XML_PROP_REQUIRED, - &def->hyperv_spinlocks) < 0) - return -1; - - if (def->hyperv_spinlocks < 0xFFF) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("HyperV spinlock retry count must be " - "at least 4095")); - return -1; - } - break; - - case VIR_DOMAIN_HYPERV_VENDOR_ID: - if (value !=3D VIR_TRISTATE_SWITCH_ON) - break; - - if (!(def->hyperv_vendor_id =3D virXMLPropString(nodes[i], - "value"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing 'value' attribute for " - "HyperV feature 'vendor_id'")); - return -1; - } - - if (strlen(def->hyperv_vendor_id) > VIR_DOMAIN_HYPERV_VEND= OR_ID_MAX) { - virReportError(VIR_ERR_XML_ERROR, - _("HyperV vendor_id value must not be m= ore " - "than %d characters."), - VIR_DOMAIN_HYPERV_VENDOR_ID_MAX); - return -1; - } - - /* ensure that the string can be passed to qemu */ - if (strchr(def->hyperv_vendor_id, ',')) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("HyperV vendor_id value is invalid")); - return -1; - } - break; - - case VIR_DOMAIN_HYPERV_LAST: - break; - } - } - VIR_FREE(nodes); - } - - if (def->hyperv_features[VIR_DOMAIN_HYPERV_STIMER] =3D=3D VIR_TRISTATE= _SWITCH_ON) { - if ((n =3D virXPathNodeSet("./features/hyperv/stimer/*", ctxt, &no= des)) < 0) - return -1; - - for (i =3D 0; i < n; i++) { - if (STRNEQ((const char *)nodes[i]->name, "direct")) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported Hyper-V stimer feature: %s"), - nodes[i]->name); - return -1; - } - - if (virXMLPropTristateSwitch(nodes[i], "state", - VIR_XML_PROP_REQUIRED, - &def->hyperv_stimer_direct) < 0) - return -1; - } - VIR_FREE(nodes); - } - if (def->features[VIR_DOMAIN_FEATURE_KVM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { int feature; virTristateSwitch value; --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364758; cv=none; d=zohomail.com; s=zohoarc; b=HIbZqCEDGBP81mW7alHlgUnFgkOEBcGonjIiBTsNbaeN1m5yLYN910GQLndqm4RZtkONLThpt+hEx0BvqcVmX56oRwGUTJsnWMZwU6cBa7VhPnS3/Fo7Hr7u25HvsqRfEduzxMn0knjGIbo1/VgVft9sE+mmuQVFR2aH0QhMvac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364758; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3tcroNUhJs4XQiXAghpRoyszH9ZzNyY23s8aUzd7k8Q=; b=lRhtd1BcP0iYx7hF+wDC2oeQ7b38Rpg4Om0VkuDTFUG3nKCjwQjcDT8BfK8h3uB9RwgGIGWnQn2yJlLooBs8YF2kQLO1dpgDP6pWRlnmvqER21XHdy48rDlWAQWxmLEttShlUP2tK9cleGDgP6OL/CFfM2pSwZbiiYuxrVMsfAk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1624364758724325.1404120322427; Tue, 22 Jun 2021 05:25:58 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-I5JrKiBzPfirmABqi0ZLrA-1; Tue, 22 Jun 2021 08:25:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 08FF7804147; Tue, 22 Jun 2021 12:25:51 +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 D52ED10016FE; Tue, 22 Jun 2021 12:25:50 +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 9FFDA1800FDB; Tue, 22 Jun 2021 12:25:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCN6bl005125 for ; Tue, 22 Jun 2021 08:23:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 11D683AE1; Tue, 22 Jun 2021 12:23:06 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FFB519C46; Tue, 22 Jun 2021 12:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364757; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3tcroNUhJs4XQiXAghpRoyszH9ZzNyY23s8aUzd7k8Q=; b=BJRoiEMXGNzSX+EsXpSPYVs+jl5Um5KhblKS3BHwLxsv5zvZkXIqI7hNpOrUDE5pGAbS8g SQRD0FAaP3+ZEjmzZIrzyzbmYTHCvEo52qm0ttjGAK4Vdy2HYtV1me5SzpPXB/vmMu6dtm rAeBVKmtu8U0sDiUNxnIt4bE9AswOxo= X-MC-Unique: I5JrKiBzPfirmABqi0ZLrA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 02/16] virDomainFeaturesHyperVDefParse: Inline hyperv/stimer parsing Date: Tue, 22 Jun 2021 14:22:43 +0200 Message-Id: <20210622122257.12528-3-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Iterating over all child elements of a node does not require xpath. By doing away with xpath for this code, the code can be inlined and simplified. This also removes the re-use of `nodes`, elimininating two VIR_FREEs. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 46 ++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8cf57db7ba..4ec5557eba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17303,6 +17303,8 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, return -1; =20 for (i =3D 0; i < n; i++) { + xmlNodePtr child; + feature =3D virDomainHypervTypeFromString((const char *)nodes[= i]->name); if (feature < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -17323,7 +17325,6 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, case VIR_DOMAIN_HYPERV_VPINDEX: case VIR_DOMAIN_HYPERV_RUNTIME: case VIR_DOMAIN_HYPERV_SYNIC: - case VIR_DOMAIN_HYPERV_STIMER: case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: @@ -17332,6 +17333,28 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, case VIR_DOMAIN_HYPERV_EVMCS: break; =20 + case VIR_DOMAIN_HYPERV_STIMER: + if (value !=3D VIR_TRISTATE_SWITCH_ON) + break; + + child =3D xmlFirstElementChild(nodes[i]); + while (child) { + if (STRNEQ((const char *)child->name, "direct")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported Hyper-V stimer featu= re: %s"), + child->name); + return -1; + } + + if (virXMLPropTristateSwitch(child, "state", + VIR_XML_PROP_REQUIRED, + &def->hyperv_stimer_direc= t) < 0) + return -1; + + child =3D xmlNextElementSibling(child); + } + break; + case VIR_DOMAIN_HYPERV_SPINLOCKS: if (value !=3D VIR_TRISTATE_SWITCH_ON) break; @@ -17381,27 +17404,6 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, break; } } - VIR_FREE(nodes); - } - - if (def->hyperv_features[VIR_DOMAIN_HYPERV_STIMER] =3D=3D VIR_TRISTATE= _SWITCH_ON) { - if ((n =3D virXPathNodeSet("./features/hyperv/stimer/*", ctxt, &no= des)) < 0) - return -1; - - for (i =3D 0; i < n; i++) { - if (STRNEQ((const char *)nodes[i]->name, "direct")) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported Hyper-V stimer feature: %s"), - nodes[i]->name); - return -1; - } - - if (virXMLPropTristateSwitch(nodes[i], "state", - VIR_XML_PROP_REQUIRED, - &def->hyperv_stimer_direct) < 0) - return -1; - } - VIR_FREE(nodes); } =20 return 0; --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364763; cv=none; d=zohomail.com; s=zohoarc; b=emnFuO8fX82lh39Q5UG/jufbCUjKi5xztjB/YN2bKFSIjW8HvCfV4apne+3/5lyjE2izxZ9az9cfJ1YbVrwH6JW9eOjOvpUZ+BME6mG5cGQXQkjSQMlxKntMC9p358zvKvSalKl9uERH69si9bmhM0GmedkXCOxB4dI2slw1CNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364763; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ustvmf9jo2Fn/XHHztAnHkTJoEOMd/oP+gTnQHMD2wE=; b=DCoXY3BNYUSJst2sjomjsdKM74yWJF2hhgPhrqEwaRagJptN45c1Tl6kVgZjhkSp/cXGsuro4AuFt85raXvWSOrHEtA/n6Es626sXfcZMaDNTyDCZRthiuDtzv54wd5VPq+RzD7LCimKLSacfYL+B4IUb664i0/afN27O2bu8Fs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1624364763501523.8630424800012; Tue, 22 Jun 2021 05:26:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-497-dVfYsQQ0PC-7iJdai1nvbg-1; Tue, 22 Jun 2021 08:26:00 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 76F281084F4C; Tue, 22 Jun 2021 12:25:54 +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 59C6B608BA; Tue, 22 Jun 2021 12:25:54 +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 19A1B1819AC2; Tue, 22 Jun 2021 12:25:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCN7Uk005135 for ; Tue, 22 Jun 2021 08:23:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1514419C79; Tue, 22 Jun 2021 12:23:07 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63CA319C46; Tue, 22 Jun 2021 12:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364762; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ustvmf9jo2Fn/XHHztAnHkTJoEOMd/oP+gTnQHMD2wE=; b=YQjVIcdAX6CImLAPN76Vn6DtQeu4JCULydGNpNswbupkfP8PjvdhNH8gJPedO4KckON+t3 hwLKsehRf9QJkCigo57XIbR3NZccIh1w5J/J00IFuzwOirdT3VCnKHptJUeKPZKiKbrAbu PjzRgZj9Css4+YlNNdmXrZ/s24z9DiQ= X-MC-Unique: dVfYsQQ0PC-7iJdai1nvbg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 03/16] virDomainFeaturesHyperVDefParse: Remove ctxt Date: Tue, 22 Jun 2021 14:22:44 +0200 Message-Id: <20210622122257.12528-4-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Iterating over all child elements of a node does not require xpath. By doing away with xpath for this code, the code can be simplified. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4ec5557eba..b778dfe463 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17288,32 +17288,27 @@ virDomainResourceDefParse(xmlNodePtr node, =20 static int virDomainFeaturesHyperVDefParse(virDomainDef *def, - xmlXPathContext *ctxt) + xmlNodePtr node) { - g_autofree xmlNodePtr *nodes =3D NULL; - size_t i; - int n; - def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D VIR_TRISTATE_SWITCH_ON; =20 if (def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D=3D VIR_TRISTATE_SWITC= H_ON) { int feature; virTristateSwitch value; - if ((n =3D virXPathNodeSet("./features/hyperv/*", ctxt, &nodes)) <= 0) - return -1; =20 - for (i =3D 0; i < n; i++) { + node =3D xmlFirstElementChild(node); + while (node !=3D NULL) { xmlNodePtr child; =20 - feature =3D virDomainHypervTypeFromString((const char *)nodes[= i]->name); + feature =3D virDomainHypervTypeFromString((const char *)node->= name); if (feature < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported HyperV Enlightenment feature= : %s"), - nodes[i]->name); + node->name); return -1; } =20 - if (virXMLPropTristateSwitch(nodes[i], "state", + if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUIRED, &value) < = 0) return -1; =20 @@ -17337,7 +17332,7 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, if (value !=3D VIR_TRISTATE_SWITCH_ON) break; =20 - child =3D xmlFirstElementChild(nodes[i]); + child =3D xmlFirstElementChild(node); while (child) { if (STRNEQ((const char *)child->name, "direct")) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -17359,7 +17354,7 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, if (value !=3D VIR_TRISTATE_SWITCH_ON) break; =20 - if (virXMLPropUInt(nodes[i], "retries", 0, + if (virXMLPropUInt(node, "retries", 0, VIR_XML_PROP_REQUIRED, &def->hyperv_spinlocks) < 0) return -1; @@ -17376,7 +17371,7 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, if (value !=3D VIR_TRISTATE_SWITCH_ON) break; =20 - if (!(def->hyperv_vendor_id =3D virXMLPropString(nodes[i], + if (!(def->hyperv_vendor_id =3D virXMLPropString(node, "value"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing 'value' attribute for " @@ -17403,6 +17398,8 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, case VIR_DOMAIN_HYPERV_LAST: break; } + + node =3D xmlNextElementSibling(node); } } =20 @@ -17454,7 +17451,7 @@ virDomainFeaturesDefParse(virDomainDef *def, break; =20 case VIR_DOMAIN_FEATURE_HYPERV: - if (virDomainFeaturesHyperVDefParse(def, ctxt) < 0) + if (virDomainFeaturesHyperVDefParse(def, nodes[i]) < 0) return -1; break; =20 --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364622; cv=none; d=zohomail.com; s=zohoarc; b=fGaTtLTSFPBQCmL1PlUwNM9lFiOKGr6ngkBBGdcOPmmo7N1KkIZQhHJMTMiTbVxD8rlu+/sygs5mwPcIIyzZINPHxxmY9ARNl0poI96WPmabKw03q7YHJXvihU4qFJ5d1AntOCrJDdJuHl9BHJObfs/S4Xz1FRTSyNOIBTijVQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364622; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sDj36OI02Xa7ZGg/TMhDhbDU8vy9NgLpkhXDW8CRPVQ=; b=jB3wH8zgNomYEwC/GU5aBRl5OFl9rflyFvv20XAUH46cMEQngINQpDLHxnyGxJfEQZ7TsHfU4a3kCia+M5lEM5XT55ibnR4B075cH4TxQox4+2Yv1J76eUEwz1m+CByv2gUiBTWFhEd0xf6bz8GNx8HZ6PHl2eAKV/qzZ+VXqvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1624364622557468.2851593926748; Tue, 22 Jun 2021 05:23:42 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-168-laOHO9xSPGGxJ3kcBD9G6A-1; Tue, 22 Jun 2021 08:23:39 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCF72800D55; Tue, 22 Jun 2021 12:23:33 +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 486BF10016FE; Tue, 22 Jun 2021 12:23:31 +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 2B3861809C98; Tue, 22 Jun 2021 12:23:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCN8uC005140 for ; Tue, 22 Jun 2021 08:23:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1921D19C46; Tue, 22 Jun 2021 12:23:08 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66B5C19C79; Tue, 22 Jun 2021 12:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364621; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sDj36OI02Xa7ZGg/TMhDhbDU8vy9NgLpkhXDW8CRPVQ=; b=RXZHS/tU64W5/3hC3ee2Zri8NGjYuwXn5+bDy2TPZlNrm7zXRuQ4eh6hGrzSjPnk2ak6MK YHXQelDeHYTQitCA81XQ7bGP5VCiBpVz4Vs1OP1IKIrwOJ4kNthPtKVNt7E8df4kD8JWwh eApSLudOlvH9TODZZho+3Bsma9hu16o= X-MC-Unique: laOHO9xSPGGxJ3kcBD9G6A-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 04/16] virDomainFeaturesHyperVDefParse: Remove tautological "if" Date: Tue, 22 Jun 2021 14:22:45 +0200 Message-Id: <20210622122257.12528-5-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Fix some line wrapping in the process. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 163 +++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 86 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b778dfe463..3ba41869ec 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17292,115 +17292,106 @@ virDomainFeaturesHyperVDefParse(virDomainDef *d= ef, { def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D VIR_TRISTATE_SWITCH_ON; =20 - if (def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D=3D VIR_TRISTATE_SWITC= H_ON) { + node =3D xmlFirstElementChild(node); + while (node !=3D NULL) { int feature; virTristateSwitch value; + xmlNodePtr child; =20 - node =3D xmlFirstElementChild(node); - while (node !=3D NULL) { - xmlNodePtr child; + feature =3D virDomainHypervTypeFromString((const char *)node->name= ); + if (feature < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported HyperV Enlightenment feature: %s= "), + node->name); + return -1; + } =20 - feature =3D virDomainHypervTypeFromString((const char *)node->= name); - if (feature < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported HyperV Enlightenment feature= : %s"), - node->name); - return -1; - } + if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUIRED, + &value) < 0) + return -1; =20 - if (virXMLPropTristateSwitch(node, "state", - VIR_XML_PROP_REQUIRED, &value) < = 0) - return -1; + def->hyperv_features[feature] =3D value; =20 - def->hyperv_features[feature] =3D value; + switch ((virDomainHyperv) feature) { + case VIR_DOMAIN_HYPERV_RELAXED: + case VIR_DOMAIN_HYPERV_VAPIC: + case VIR_DOMAIN_HYPERV_VPINDEX: + case VIR_DOMAIN_HYPERV_RUNTIME: + case VIR_DOMAIN_HYPERV_SYNIC: + case VIR_DOMAIN_HYPERV_RESET: + case VIR_DOMAIN_HYPERV_FREQUENCIES: + case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: + case VIR_DOMAIN_HYPERV_TLBFLUSH: + case VIR_DOMAIN_HYPERV_IPI: + case VIR_DOMAIN_HYPERV_EVMCS: + break; =20 - switch ((virDomainHyperv) feature) { - case VIR_DOMAIN_HYPERV_RELAXED: - case VIR_DOMAIN_HYPERV_VAPIC: - case VIR_DOMAIN_HYPERV_VPINDEX: - case VIR_DOMAIN_HYPERV_RUNTIME: - case VIR_DOMAIN_HYPERV_SYNIC: - case VIR_DOMAIN_HYPERV_RESET: - case VIR_DOMAIN_HYPERV_FREQUENCIES: - case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: - case VIR_DOMAIN_HYPERV_TLBFLUSH: - case VIR_DOMAIN_HYPERV_IPI: - case VIR_DOMAIN_HYPERV_EVMCS: + case VIR_DOMAIN_HYPERV_STIMER: + if (value !=3D VIR_TRISTATE_SWITCH_ON) break; =20 - case VIR_DOMAIN_HYPERV_STIMER: - if (value !=3D VIR_TRISTATE_SWITCH_ON) - break; + child =3D xmlFirstElementChild(node); + while (child) { + if (STRNEQ((const char *)child->name, "direct")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported Hyper-V stimer feature: = %s"), + child->name); + return -1; + } =20 - child =3D xmlFirstElementChild(node); - while (child) { - if (STRNEQ((const char *)child->name, "direct")) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported Hyper-V stimer featu= re: %s"), - child->name); - return -1; - } + if (virXMLPropTristateSwitch(child, "state", VIR_XML_PROP_= REQUIRED, + &def->hyperv_stimer_direct) <= 0) + return -1; =20 - if (virXMLPropTristateSwitch(child, "state", - VIR_XML_PROP_REQUIRED, - &def->hyperv_stimer_direc= t) < 0) - return -1; + child =3D xmlNextElementSibling(child); + } + break; =20 - child =3D xmlNextElementSibling(child); - } + case VIR_DOMAIN_HYPERV_SPINLOCKS: + if (value !=3D VIR_TRISTATE_SWITCH_ON) break; =20 - case VIR_DOMAIN_HYPERV_SPINLOCKS: - if (value !=3D VIR_TRISTATE_SWITCH_ON) - break; + if (virXMLPropUInt(node, "retries", 0, VIR_XML_PROP_REQUIRED, + &def->hyperv_spinlocks) < 0) + return -1; =20 - if (virXMLPropUInt(node, "retries", 0, - VIR_XML_PROP_REQUIRED, - &def->hyperv_spinlocks) < 0) - return -1; + if (def->hyperv_spinlocks < 0xFFF) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("HyperV spinlock retry count must be at l= east 4095")); + return -1; + } + break; =20 - if (def->hyperv_spinlocks < 0xFFF) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("HyperV spinlock retry count must be " - "at least 4095")); - return -1; - } + case VIR_DOMAIN_HYPERV_VENDOR_ID: + if (value !=3D VIR_TRISTATE_SWITCH_ON) break; =20 - case VIR_DOMAIN_HYPERV_VENDOR_ID: - if (value !=3D VIR_TRISTATE_SWITCH_ON) - break; - - if (!(def->hyperv_vendor_id =3D virXMLPropString(node, - "value"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing 'value' attribute for " - "HyperV feature 'vendor_id'")); - return -1; - } - - if (strlen(def->hyperv_vendor_id) > VIR_DOMAIN_HYPERV_VEND= OR_ID_MAX) { - virReportError(VIR_ERR_XML_ERROR, - _("HyperV vendor_id value must not be m= ore " - "than %d characters."), - VIR_DOMAIN_HYPERV_VENDOR_ID_MAX); - return -1; - } + if (!(def->hyperv_vendor_id =3D virXMLPropString(node, "value"= ))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing 'value' attribute for HyperV fea= ture 'vendor_id'")); + return -1; + } =20 - /* ensure that the string can be passed to qemu */ - if (strchr(def->hyperv_vendor_id, ',')) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("HyperV vendor_id value is invalid")); - return -1; - } - break; + if (strlen(def->hyperv_vendor_id) > VIR_DOMAIN_HYPERV_VENDOR_I= D_MAX) { + virReportError(VIR_ERR_XML_ERROR, + _("HyperV vendor_id value must not be more = than %d characters."), + VIR_DOMAIN_HYPERV_VENDOR_ID_MAX); + return -1; + } =20 - case VIR_DOMAIN_HYPERV_LAST: - break; + /* ensure that the string can be passed to qemu */ + if (strchr(def->hyperv_vendor_id, ',')) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("HyperV vendor_id value is invalid")); + return -1; } + break; =20 - node =3D xmlNextElementSibling(node); + case VIR_DOMAIN_HYPERV_LAST: + break; } + + node =3D xmlNextElementSibling(node); } =20 return 0; --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364650; cv=none; d=zohomail.com; s=zohoarc; b=aJfCnsqNKSfIS2wB3KrIuIFiU4UBZ3QYhH8lUk/KI7dG9d44ATMitskPl0bCJZgjtKqiK1SAJqv+Ci78bBGL3Ko+oIhQNDlFWAEWe4pfYIdGMzB/uQgtWUCv3Gh1VNduVBS6uoHIoA+26y+rn5kLGvgsXOaazPP088R6+anU8uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364650; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NnOnRekUSQxe1RD2RrZY2rXo6tdqDFmPGZayLrC/+5c=; b=FHf4i7eYKpKEBNmJ8P+JmQQF5oKcDdK3gsj2jXrHLMg+/5bRgl8yEQStmAScd4nboqAcK3NF6v2g3xG4VpkB0fuHyL4uPFnZDutKeGMRrwo8XiPGWvDMX9iHfsuJMthV2QS7zFcSakf2VRq5gUcngncur80WWXrZu3QGsD2wvwc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1624364650792375.35523241262126; Tue, 22 Jun 2021 05:24:10 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-3PQ6eeHgN7mNjf7l_7fQsQ-1; Tue, 22 Jun 2021 08:24:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B298C804152; Tue, 22 Jun 2021 12:24:00 +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 94B981346F; Tue, 22 Jun 2021 12:24:00 +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 5FF9F1809CB5; Tue, 22 Jun 2021 12:24:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCN9ok005149 for ; Tue, 22 Jun 2021 08:23:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1BB2319C79; Tue, 22 Jun 2021 12:23:09 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AC4519C46; Tue, 22 Jun 2021 12:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364649; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NnOnRekUSQxe1RD2RrZY2rXo6tdqDFmPGZayLrC/+5c=; b=CymOkVW0MXtcZMdWSlk4kfK6X1aKJOEYj6aJESlQJi77ELKSPNBB9HEqLaThFS2i5RcpuZ tME+hq13/vDaXdgnwhM59BMcuOpRJskP3ziL29/LehVTMe3W6RJ/umjDuGH6DgZYeXF8v8 zM/fZ2ej2MTxRbp03NiwApdHrle7Xe0= X-MC-Unique: 3PQ6eeHgN7mNjf7l_7fQsQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 05/16] virDomainFeaturesDefParse: Factor out KVM parsing into separate function Date: Tue, 22 Jun 2021 14:22:46 +0200 Message-Id: <20210622122257.12528-6-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Only moving code, cleanup to follow. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 88 +++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3ba41869ec..384740c364 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17398,6 +17398,54 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, } =20 =20 +static int +virDomainFeaturesKVMDefParse(virDomainDef *def, + xmlXPathContext *ctxt) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + size_t i; + int n; + + def->features[VIR_DOMAIN_FEATURE_KVM] =3D VIR_TRISTATE_SWITCH_ON; + + if (def->features[VIR_DOMAIN_FEATURE_KVM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { + int feature; + virTristateSwitch value; + if ((n =3D virXPathNodeSet("./features/kvm/*", ctxt, &nodes)) < 0) + return -1; + + for (i =3D 0; i < n; i++) { + feature =3D virDomainKVMTypeFromString((const char *)nodes[i]-= >name); + if (feature < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported KVM feature: %s"), + nodes[i]->name); + return -1; + } + + switch ((virDomainKVM) feature) { + case VIR_DOMAIN_KVM_HIDDEN: + case VIR_DOMAIN_KVM_DEDICATED: + case VIR_DOMAIN_KVM_POLLCONTROL: + if (virXMLPropTristateSwitch(nodes[i], "state", + VIR_XML_PROP_REQUIRED, + &value) < 0) + return -1; + + def->kvm_features[feature] =3D value; + break; + + case VIR_DOMAIN_KVM_LAST: + break; + } + } + VIR_FREE(nodes); + } + + return 0; +} + + static int virDomainFeaturesDefParse(virDomainDef *def, xmlXPathContextPtr ctxt) @@ -17435,7 +17483,6 @@ virDomainFeaturesDefParse(virDomainDef *def, case VIR_DOMAIN_FEATURE_PAE: case VIR_DOMAIN_FEATURE_VIRIDIAN: case VIR_DOMAIN_FEATURE_PRIVNET: - case VIR_DOMAIN_FEATURE_KVM: case VIR_DOMAIN_FEATURE_MSRS: case VIR_DOMAIN_FEATURE_XEN: def->features[val] =3D VIR_TRISTATE_SWITCH_ON; @@ -17446,6 +17493,11 @@ virDomainFeaturesDefParse(virDomainDef *def, return -1; break; =20 + case VIR_DOMAIN_FEATURE_KVM: + if (virDomainFeaturesKVMDefParse(def, ctxt) < 0) + return -1; + break; + case VIR_DOMAIN_FEATURE_CAPABILITIES: { virDomainCapabilitiesPolicy policy; =20 @@ -17579,40 +17631,6 @@ virDomainFeaturesDefParse(virDomainDef *def, } VIR_FREE(nodes); =20 - if (def->features[VIR_DOMAIN_FEATURE_KVM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { - int feature; - virTristateSwitch value; - if ((n =3D virXPathNodeSet("./features/kvm/*", ctxt, &nodes)) < 0) - return -1; - - for (i =3D 0; i < n; i++) { - feature =3D virDomainKVMTypeFromString((const char *)nodes[i]-= >name); - if (feature < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported KVM feature: %s"), - nodes[i]->name); - return -1; - } - - switch ((virDomainKVM) feature) { - case VIR_DOMAIN_KVM_HIDDEN: - case VIR_DOMAIN_KVM_DEDICATED: - case VIR_DOMAIN_KVM_POLLCONTROL: - if (virXMLPropTristateSwitch(nodes[i], "state", - VIR_XML_PROP_REQUIRED, - &value) < 0) - return -1; - - def->kvm_features[feature] =3D value; - break; - - case VIR_DOMAIN_KVM_LAST: - break; - } - } - VIR_FREE(nodes); - } - if (def->features[VIR_DOMAIN_FEATURE_XEN] =3D=3D VIR_TRISTATE_SWITCH_O= N) { int feature; virTristateSwitch value; --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364706; cv=none; d=zohomail.com; s=zohoarc; b=AjNwi1XsVMYnO+rR1rYwZnZCrVMe5UolsVz3jMt4a6sTqDErgYX4B7BacTPI20uyv46zhbpSZM9oRFIvyMXERYQjVutU9TQs+grePQMTqv5rZHXED70PsggUsYhjHrZiNati6o6t9Ks0Fbg9bF9ZNeNVxPGN0T50Wz29D8O4JZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364706; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9X6iz+fo4PKLYPusWG4bVYCdXglm8YMLh1w34Ikx85M=; b=hO7U/G1Pl1jodbEQGjKEeUepluCpIQNfOT0zXi1ubGODMX8CnhV1ebzZ+OnHe/fyjumzyAJR2ePlszlpxa0libs1cIOAXE7xifgOCS99lGTz2yt/8+F8RJZbW9/bNidEp+W86RvK3ZcZgLObBKYKw12acFA4b0us+Ztp+gEvizs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1624364706385755.5654934427731; Tue, 22 Jun 2021 05:25:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-350-dfPlQr0EOmqAsb2WSl-FPw-1; Tue, 22 Jun 2021 08:24:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B03AF18414A0; Tue, 22 Jun 2021 12:24:03 +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 81D4E5D703; Tue, 22 Jun 2021 12:24:03 +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 487741800C8D; Tue, 22 Jun 2021 12:24:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNAn2005161 for ; Tue, 22 Jun 2021 08:23:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3207019C46; Tue, 22 Jun 2021 12:23:10 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 702EA19C79; Tue, 22 Jun 2021 12:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364705; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9X6iz+fo4PKLYPusWG4bVYCdXglm8YMLh1w34Ikx85M=; b=NLeEPHAagaa4FoNT3xqeec73XJRP4T3GN1nSRN+gi40A/pCUXsjM/0aLfR0ArnukepeiQn oHIM7xD9yFoi081awiWWOuE3/YOR7ANJcmv35Mf4+md+xks5ZZxhQajXCdT6YZ018b5Gl+ FlEby4n42tw5zHN4ziv7gG/9Bv4kB1E= X-MC-Unique: dfPlQr0EOmqAsb2WSl-FPw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 06/16] virDomainFeaturesKVMDefParse: Remove ctxt Date: Tue, 22 Jun 2021 14:22:47 +0200 Message-Id: <20210622122257.12528-7-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Iterating over all child elements of a node does not require xpath. By doing away with xpath for this code, the code can be simplified. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 384740c364..2ad4cbc5a3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17400,26 +17400,21 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, =20 static int virDomainFeaturesKVMDefParse(virDomainDef *def, - xmlXPathContext *ctxt) + xmlNodePtr node) { - g_autofree xmlNodePtr *nodes =3D NULL; - size_t i; - int n; - def->features[VIR_DOMAIN_FEATURE_KVM] =3D VIR_TRISTATE_SWITCH_ON; =20 if (def->features[VIR_DOMAIN_FEATURE_KVM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { int feature; virTristateSwitch value; - if ((n =3D virXPathNodeSet("./features/kvm/*", ctxt, &nodes)) < 0) - return -1; =20 - for (i =3D 0; i < n; i++) { - feature =3D virDomainKVMTypeFromString((const char *)nodes[i]-= >name); + node =3D xmlFirstElementChild(node); + while (node) { + feature =3D virDomainKVMTypeFromString((const char *)node->nam= e); if (feature < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported KVM feature: %s"), - nodes[i]->name); + node->name); return -1; } =20 @@ -17427,7 +17422,7 @@ virDomainFeaturesKVMDefParse(virDomainDef *def, case VIR_DOMAIN_KVM_HIDDEN: case VIR_DOMAIN_KVM_DEDICATED: case VIR_DOMAIN_KVM_POLLCONTROL: - if (virXMLPropTristateSwitch(nodes[i], "state", + if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUIRED, &value) < 0) return -1; @@ -17438,8 +17433,9 @@ virDomainFeaturesKVMDefParse(virDomainDef *def, case VIR_DOMAIN_KVM_LAST: break; } + + node =3D xmlNextElementSibling(node); } - VIR_FREE(nodes); } =20 return 0; @@ -17494,7 +17490,7 @@ virDomainFeaturesDefParse(virDomainDef *def, break; =20 case VIR_DOMAIN_FEATURE_KVM: - if (virDomainFeaturesKVMDefParse(def, ctxt) < 0) + if (virDomainFeaturesKVMDefParse(def, nodes[i]) < 0) return -1; break; =20 --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364757; cv=none; d=zohomail.com; s=zohoarc; b=JvaUY/yxAYhOKjtd/lmKyWZZQ5cPOtcRiKAnKWb23l8hXRJeTAJdM3E6zsG6NjuA4I6ehFpLOhw0Lv1/SDdPOBgR0ID0fUTdEoaw0i23Az+DPsgoVho8TaU3Xf/wQJBoibRrzZ8/sU1L/xK75X0PY9y/eg+ynNUTNlOKmZcljc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364757; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8mTJ8xolaonXHXVoICpgaAu/hs8XmjPy8EFCFfnOBwo=; b=Wgj0Dbx977NtFhFWtA5LQJgmz6JSebW1d2QFsg7nn56O/hUp18dS2U2uCqFCvtF0jAQlvB5O+5xzazWJ7GKn45s8orl3Fo3vYr164YmX8fbPdhoQa5YqrrHewRfRpIConxxeGFp/6dGUQOiFQNuXJuioRcagqrKtLbuHnLcKwTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1624364757595493.949119541094; Tue, 22 Jun 2021 05:25:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-243-PuBJ2MYYPDWaj3uJ8_LpyA-1; Tue, 22 Jun 2021 08:24:12 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id F22E38042FE; Tue, 22 Jun 2021 12:24:06 +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 D3D71608BA; Tue, 22 Jun 2021 12:24:06 +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 98F341801258; Tue, 22 Jun 2021 12:24:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNBxl005169 for ; Tue, 22 Jun 2021 08:23:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3731619D9B; Tue, 22 Jun 2021 12:23:11 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83AD119C46; Tue, 22 Jun 2021 12:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364755; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8mTJ8xolaonXHXVoICpgaAu/hs8XmjPy8EFCFfnOBwo=; b=dF035WYRK63m3XhsPEvFQswJXbLbBpINev0Uk0MQij3Vy8fPueDMIDsOti2kk+vfxvEFSd eY9P/Iv/Kmo9apaEHesP11wRBUKGMNqPhXH1L3C7BHp2t7T+i/pQ9f+kTWS5WuZ0der4/2 9/yq/Rxvl6hMGnmclUu/YVfaAtR89ao= X-MC-Unique: PuBJ2MYYPDWaj3uJ8_LpyA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 07/16] virDomainFeaturesKVMDefParse: Remove tautological "switch" Date: Tue, 22 Jun 2021 14:22:48 +0200 Message-Id: <20210622122257.12528-8-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" `feature` is always one of the values listed in the switch, ensured by `virDomainKVMTypeFromString` above. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2ad4cbc5a3..62565601ab 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17418,21 +17418,11 @@ virDomainFeaturesKVMDefParse(virDomainDef *def, return -1; } =20 - switch ((virDomainKVM) feature) { - case VIR_DOMAIN_KVM_HIDDEN: - case VIR_DOMAIN_KVM_DEDICATED: - case VIR_DOMAIN_KVM_POLLCONTROL: - if (virXMLPropTristateSwitch(node, "state", - VIR_XML_PROP_REQUIRED, - &value) < 0) - return -1; - - def->kvm_features[feature] =3D value; - break; + if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUI= RED, + &value) < 0) + return -1; =20 - case VIR_DOMAIN_KVM_LAST: - break; - } + def->kvm_features[feature] =3D value; =20 node =3D xmlNextElementSibling(node); } --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364639; cv=none; d=zohomail.com; s=zohoarc; b=LyfO5AHVsl0wcOtjRjLPF8F2KyK34w7WLrQMXJC6ZEngWFDnPq2mdepPQXaDWVBouYJu1prqU8jmm3EKEAU6vpZLI1lQIu4/W0sYBl8kfgqffJd8QaV+P/SNxjDO+xfbch7uP4dhtZv6e8Q84QnaG6nN2gdzRR3IVtHrElewN8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364639; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AtPTe1T7INb4vVSZIDBFWqskE/IZyt1B+qb31VnosnM=; b=CDxK3JuvJVr9dvqvOu/MuUMe3GGpzWjiyOoEFXOHVhNDIAldvuxP5P4L4G0yybGdMdYerle8tk5cqSwr+fIHE3DR4BrpE3pUhB2xJoL9qGlky5JSeTCA6rk81hC0jkmnB+2XL75b/BFsri/080z8U48XWtQtuqRC4w+fhDh+UmQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1624364639855335.81307283861395; Tue, 22 Jun 2021 05:23:59 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-388-ttV2rrf4NtSd2sa2NvyNWg-1; Tue, 22 Jun 2021 08:23:56 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73E00804142; Tue, 22 Jun 2021 12:23:51 +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 45B565C1D1; Tue, 22 Jun 2021 12:23:51 +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 DAAFF4EA29; Tue, 22 Jun 2021 12:23:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNCSX005185 for ; Tue, 22 Jun 2021 08:23:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A61719D7C; Tue, 22 Jun 2021 12:23:12 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 886D519C46; Tue, 22 Jun 2021 12:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364638; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AtPTe1T7INb4vVSZIDBFWqskE/IZyt1B+qb31VnosnM=; b=himIGI/z3CHvBeCpnJhWuezsKSkqbpo7Y+J9ZNzboQFT+BfZEVj6sY5QV5FUigFJfnPgR+ eeXBaqZOHtQRQr3gbR/jl4itrE3cG6/IEPv053txL6aelznIo2U9aasPf7/DduZKWWp/Li oI+KGB9C6whk9cSh5Uam7tepXWNsOBE= X-MC-Unique: ttV2rrf4NtSd2sa2NvyNWg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 08/16] virDomainFeaturesKVMDefParse: Remove tautological "if" Date: Tue, 22 Jun 2021 14:22:49 +0200 Message-Id: <20210622122257.12528-9-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 62565601ab..24529f3093 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17404,28 +17404,26 @@ virDomainFeaturesKVMDefParse(virDomainDef *def, { def->features[VIR_DOMAIN_FEATURE_KVM] =3D VIR_TRISTATE_SWITCH_ON; =20 - if (def->features[VIR_DOMAIN_FEATURE_KVM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { + node =3D xmlFirstElementChild(node); + while (node) { int feature; virTristateSwitch value; =20 - node =3D xmlFirstElementChild(node); - while (node) { - feature =3D virDomainKVMTypeFromString((const char *)node->nam= e); - if (feature < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported KVM feature: %s"), - node->name); - return -1; - } + feature =3D virDomainKVMTypeFromString((const char *)node->name); + if (feature < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported KVM feature: %s"), + node->name); + return -1; + } =20 - if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUI= RED, - &value) < 0) - return -1; + if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUIRED, + &value) < 0) + return -1; =20 - def->kvm_features[feature] =3D value; + def->kvm_features[feature] =3D value; =20 - node =3D xmlNextElementSibling(node); - } + node =3D xmlNextElementSibling(node); } =20 return 0; --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364643; cv=none; d=zohomail.com; s=zohoarc; b=CD88U6jQNVbVIKzlC2RfkGHIOa5Yjk/p4/1vZvkdGSnf/zOwh96sMGqjtS/g2jMidRCnW33ad5Nan9fBgvr+92CYsumRLRbUoIN43WTvfAalsnG0vnVSVXxF9B7597EzKfoWBzCWRBuoW+6ladXAUUSXBTOdcLrJX2SVFC7777I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364643; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=H2IOgOUpjRUsbza7/GMHJQ9HbkTs0NZDHEAaJ2BXCuk=; b=SN8aPQfpUn6GN+OR0Ucd/q2O6IEQn3MUoAJ7PfKBbYvmITKlPPUzP3B6Z2G1pdhdVOlpJP5JyZnRRgP8bGYaoe883kL4WNCT3ZG1sBIyQw/ortaTlm5zR/pJHgf+JLxyfkBlpKZQosEdTesOyVoG331427ZIbaDf0C5rt6hfkkw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1624364643497782.9485170322033; Tue, 22 Jun 2021 05:24:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-0CR7bbpqOHeLF8dSq3T7Lw-1; Tue, 22 Jun 2021 08:24:00 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE5748042A8; Tue, 22 Jun 2021 12:23:55 +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 981D619C66; Tue, 22 Jun 2021 12:23:55 +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 635D91809CB3; Tue, 22 Jun 2021 12:23:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNGAl005209 for ; Tue, 22 Jun 2021 08:23:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A81E19C46; Tue, 22 Jun 2021 12:23:16 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7ADE19C66; Tue, 22 Jun 2021 12:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364642; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=H2IOgOUpjRUsbza7/GMHJQ9HbkTs0NZDHEAaJ2BXCuk=; b=ZccLqg7iAa/JX1bCSraKO3BfSgRKFdRytiMrm3CGz45wA8CBc25J8+HlPMrXeb20bsfiXE lhlDXyn3gbG18ScYmSGZT4eaHFg5ikdlzxxy5jWd4yDzH48fJpVdu0OiqbIHx45P5ib1ci Ud2EBNZ1frLa92byM6yIWHqPjYSOjC0= X-MC-Unique: 0CR7bbpqOHeLF8dSq3T7Lw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 09/16] virDomainFeaturesDefParse: Factor out XEN parsing into separate function Date: Tue, 22 Jun 2021 14:22:50 +0200 Message-Id: <20210622122257.12528-10-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Only moving code, cleanup to follow. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 108 ++++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 24529f3093..e687f18afe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17430,6 +17430,64 @@ virDomainFeaturesKVMDefParse(virDomainDef *def, } =20 =20 +static int +virDomainFeaturesXENDefParse(virDomainDef *def, + xmlXPathContext *ctxt) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + size_t i; + int n; + + def->features[VIR_DOMAIN_FEATURE_XEN] =3D VIR_TRISTATE_SWITCH_ON; + + if (def->features[VIR_DOMAIN_FEATURE_XEN] =3D=3D VIR_TRISTATE_SWITCH_O= N) { + int feature; + virTristateSwitch value; + + if ((n =3D virXPathNodeSet("./features/xen/*", ctxt, &nodes)) < 0) + return -1; + + for (i =3D 0; i < n; i++) { + feature =3D virDomainXenTypeFromString((const char *)nodes[i]-= >name); + if (feature < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported Xen feature: %s"), + nodes[i]->name); + return -1; + } + + if (virXMLPropTristateSwitch(nodes[i], "state", + VIR_XML_PROP_REQUIRED, &value) < = 0) + return -1; + + def->xen_features[feature] =3D value; + + switch ((virDomainXen) feature) { + case VIR_DOMAIN_XEN_E820_HOST: + break; + + case VIR_DOMAIN_XEN_PASSTHROUGH: + if (value !=3D VIR_TRISTATE_SWITCH_ON) + break; + + if (virXMLPropEnum(nodes[i], "mode", + virDomainXenPassthroughModeTypeFromStri= ng, + VIR_XML_PROP_NONZERO, + &def->xen_passthrough_mode) < 0) + return -1; + break; + + case VIR_DOMAIN_XEN_LAST: + break; + } + } + VIR_FREE(nodes); + } + + return 0; +} + + static int virDomainFeaturesDefParse(virDomainDef *def, xmlXPathContextPtr ctxt) @@ -17468,7 +17526,6 @@ virDomainFeaturesDefParse(virDomainDef *def, case VIR_DOMAIN_FEATURE_VIRIDIAN: case VIR_DOMAIN_FEATURE_PRIVNET: case VIR_DOMAIN_FEATURE_MSRS: - case VIR_DOMAIN_FEATURE_XEN: def->features[val] =3D VIR_TRISTATE_SWITCH_ON; break; =20 @@ -17482,6 +17539,11 @@ virDomainFeaturesDefParse(virDomainDef *def, return -1; break; =20 + case VIR_DOMAIN_FEATURE_XEN: + if (virDomainFeaturesXENDefParse(def, ctxt) < 0) + return -1; + break; + case VIR_DOMAIN_FEATURE_CAPABILITIES: { virDomainCapabilitiesPolicy policy; =20 @@ -17615,50 +17677,6 @@ virDomainFeaturesDefParse(virDomainDef *def, } VIR_FREE(nodes); =20 - if (def->features[VIR_DOMAIN_FEATURE_XEN] =3D=3D VIR_TRISTATE_SWITCH_O= N) { - int feature; - virTristateSwitch value; - - if ((n =3D virXPathNodeSet("./features/xen/*", ctxt, &nodes)) < 0) - return -1; - - for (i =3D 0; i < n; i++) { - feature =3D virDomainXenTypeFromString((const char *)nodes[i]-= >name); - if (feature < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported Xen feature: %s"), - nodes[i]->name); - return -1; - } - - if (virXMLPropTristateSwitch(nodes[i], "state", - VIR_XML_PROP_REQUIRED, &value) < = 0) - return -1; - - def->xen_features[feature] =3D value; - - switch ((virDomainXen) feature) { - case VIR_DOMAIN_XEN_E820_HOST: - break; - - case VIR_DOMAIN_XEN_PASSTHROUGH: - if (value !=3D VIR_TRISTATE_SWITCH_ON) - break; - - if (virXMLPropEnum(nodes[i], "mode", - virDomainXenPassthroughModeTypeFromStri= ng, - VIR_XML_PROP_NONZERO, - &def->xen_passthrough_mode) < 0) - return -1; - break; - - case VIR_DOMAIN_XEN_LAST: - break; - } - } - VIR_FREE(nodes); - } - if (def->features[VIR_DOMAIN_FEATURE_SMM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { int rv =3D virParseScaledValue("string(./features/smm/tseg)", "string(./features/smm/tseg/@unit)", --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364769; cv=none; d=zohomail.com; s=zohoarc; b=OjoxR/YZBISuczUYB0luzj3gPJyiSITBjYzMvXkqJXFLx/4RIaGSTYRrcbP3oIN/G+rJOdekvej0ZL+8sitngDZgzwZtPUrdCrSrzdWwBYWFFGRmgSTN/CBtqBLAkolmLFhpfpb1iFG46SJBrEl78K110Xg8oR2asSSCAzrkSUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364769; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YIgizyMBpbHceLwKKhQ4TF5UOz7jDrvT7KpJ17yRsj8=; b=H8H1jPTt2Xu89S8Q6m0U/GGSFQ1dzDzxsFxGaP96tflbiV3AsF7cQ1zW4lrgjzhdM1qlHnrcXy15rME0YrIv0bicxo4TZCxP5Lj39mxVWxpxCBGUh2lXq1YlBU4FRR73bJXu+IiENB/9OXtQ11E2fkeKfJl/fz9HB5+E+CCc+to= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1624364769097488.15575359390436; Tue, 22 Jun 2021 05:26:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-579-gDiGTzCGN1qkX842H3Wzqw-1; Tue, 22 Jun 2021 08:26:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A4F91882FA7; Tue, 22 Jun 2021 12:25:58 +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 30BD819C66; Tue, 22 Jun 2021 12:25:58 +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 EDCA84EA39; Tue, 22 Jun 2021 12:25:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNHum005214 for ; Tue, 22 Jun 2021 08:23:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6EC1319C66; Tue, 22 Jun 2021 12:23:17 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBE9919C46; Tue, 22 Jun 2021 12:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364766; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YIgizyMBpbHceLwKKhQ4TF5UOz7jDrvT7KpJ17yRsj8=; b=PqQLfk4kWVqTJxsHNOzv6n6LjbfIqATkTtnKiDvR1MNjT4tPXHy9+tfFjy3THiWVzzF4xW YfFO+vWKpdBk4BO4ea/REw62ExOig1+bu9I6jwShrtaL1naulhEY/bDc/FhlewohCPcFQr d3t3cTKQjNhc40Wo2ESk5G6tLLuvcvo= X-MC-Unique: gDiGTzCGN1qkX842H3Wzqw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 10/16] virDomainFeaturesXENDefParse: Remove ctxt Date: Tue, 22 Jun 2021 14:22:51 +0200 Message-Id: <20210622122257.12528-11-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Iterating over all child elements of a node does not require xpath. By doing away with xpath for this code, the code can be simplified. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e687f18afe..45c4b9cedf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17432,31 +17432,25 @@ virDomainFeaturesKVMDefParse(virDomainDef *def, =20 static int virDomainFeaturesXENDefParse(virDomainDef *def, - xmlXPathContext *ctxt) + xmlNodePtr node) { - g_autofree xmlNodePtr *nodes =3D NULL; - size_t i; - int n; - def->features[VIR_DOMAIN_FEATURE_XEN] =3D VIR_TRISTATE_SWITCH_ON; =20 if (def->features[VIR_DOMAIN_FEATURE_XEN] =3D=3D VIR_TRISTATE_SWITCH_O= N) { int feature; virTristateSwitch value; =20 - if ((n =3D virXPathNodeSet("./features/xen/*", ctxt, &nodes)) < 0) - return -1; - - for (i =3D 0; i < n; i++) { - feature =3D virDomainXenTypeFromString((const char *)nodes[i]-= >name); + node =3D xmlFirstElementChild(node); + while (node) { + feature =3D virDomainXenTypeFromString((const char *)node->nam= e); if (feature < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported Xen feature: %s"), - nodes[i]->name); + node->name); return -1; } =20 - if (virXMLPropTristateSwitch(nodes[i], "state", + if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUIRED, &value) < = 0) return -1; =20 @@ -17470,7 +17464,7 @@ virDomainFeaturesXENDefParse(virDomainDef *def, if (value !=3D VIR_TRISTATE_SWITCH_ON) break; =20 - if (virXMLPropEnum(nodes[i], "mode", + if (virXMLPropEnum(node, "mode", virDomainXenPassthroughModeTypeFromStri= ng, VIR_XML_PROP_NONZERO, &def->xen_passthrough_mode) < 0) @@ -17480,8 +17474,9 @@ virDomainFeaturesXENDefParse(virDomainDef *def, case VIR_DOMAIN_XEN_LAST: break; } + + node =3D xmlNextElementSibling(node); } - VIR_FREE(nodes); } =20 return 0; @@ -17540,7 +17535,7 @@ virDomainFeaturesDefParse(virDomainDef *def, break; =20 case VIR_DOMAIN_FEATURE_XEN: - if (virDomainFeaturesXENDefParse(def, ctxt) < 0) + if (virDomainFeaturesXENDefParse(def, nodes[i]) < 0) return -1; break; =20 --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364769; cv=none; d=zohomail.com; s=zohoarc; b=YaXDtnkUG49DY+ULFdBnEOKzSPuT7xZQ3xLwJ6DUs797LdVgPkkDQbEFWoJAsuocf/HFJXTdAPfoH5B7ZWIyW5R0s4jo5ZT/VA1OCw1i3vPiZVwksTZDiq4VBm7m0SU9+GJf+mRdCngBOVoDclsz237BrKo+r5kUnQSm/lHjlRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364769; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XVfTB+VgAgon6SLiKd3ji6dmLT1oq0oO4ye4iqBFyfg=; b=KrfutHENYUaTAIPxLv1FP57aqVv3vLH1LFpKiegtYsCncg7sgHE2EHd397HFceBjG8jgTdir0GEHVKbbeIrx3otmyi8ZmkOLZIGj0QClnVMIkQDBDpEqzKhlzufAsl/BJhDFyRExbRLfZdqHK3k07DL5lf8tzuWKgBZf1xoQlvE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1624364769005583.7774115800644; Tue, 22 Jun 2021 05:26:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-94-tArecQ5lMMq42oAWesx-Zg-1; Tue, 22 Jun 2021 08:26:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BEF8180C96C; Tue, 22 Jun 2021 12:26:01 +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 065765DEFB; Tue, 22 Jun 2021 12:26:01 +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 C07984EA3D; Tue, 22 Jun 2021 12:26:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNLIc005234 for ; Tue, 22 Jun 2021 08:23:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id B1EBE19C66; Tue, 22 Jun 2021 12:23:21 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BACF19C46; Tue, 22 Jun 2021 12:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364768; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XVfTB+VgAgon6SLiKd3ji6dmLT1oq0oO4ye4iqBFyfg=; b=FsYPSKZqnJU67yBKO5mtAtpYEWBLHKRuQAU2R82fxTmQcD56d0aTi2fKSEEpTOuTO87bx8 EKbFeBFyvUy08/18O+btln+2CqG62peTVgX6w56Rm+QbnyRk7ycOvdlqjSnRPmpT1SgxdS iG6gfpFwuKHrtXO+aE4Aqd01UggsHk4= X-MC-Unique: tArecQ5lMMq42oAWesx-Zg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 11/16] virDomainFeaturesXENDefParse: Remove tautological "if" Date: Tue, 22 Jun 2021 14:22:52 +0200 Message-Id: <20210622122257.12528-12-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 58 ++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 45c4b9cedf..02c06d5ab9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17436,47 +17436,45 @@ virDomainFeaturesXENDefParse(virDomainDef *def, { def->features[VIR_DOMAIN_FEATURE_XEN] =3D VIR_TRISTATE_SWITCH_ON; =20 - if (def->features[VIR_DOMAIN_FEATURE_XEN] =3D=3D VIR_TRISTATE_SWITCH_O= N) { + node =3D xmlFirstElementChild(node); + while (node) { int feature; virTristateSwitch value; =20 - node =3D xmlFirstElementChild(node); - while (node) { - feature =3D virDomainXenTypeFromString((const char *)node->nam= e); - if (feature < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported Xen feature: %s"), - node->name); - return -1; - } - - if (virXMLPropTristateSwitch(node, "state", - VIR_XML_PROP_REQUIRED, &value) < = 0) - return -1; + feature =3D virDomainXenTypeFromString((const char *)node->name); + if (feature < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported Xen feature: %s"), + node->name); + return -1; + } =20 - def->xen_features[feature] =3D value; + if (virXMLPropTristateSwitch(node, "state", + VIR_XML_PROP_REQUIRED, &value) < 0) + return -1; =20 - switch ((virDomainXen) feature) { - case VIR_DOMAIN_XEN_E820_HOST: - break; + def->xen_features[feature] =3D value; =20 - case VIR_DOMAIN_XEN_PASSTHROUGH: - if (value !=3D VIR_TRISTATE_SWITCH_ON) - break; + switch ((virDomainXen) feature) { + case VIR_DOMAIN_XEN_E820_HOST: + break; =20 - if (virXMLPropEnum(node, "mode", - virDomainXenPassthroughModeTypeFromStri= ng, - VIR_XML_PROP_NONZERO, - &def->xen_passthrough_mode) < 0) - return -1; + case VIR_DOMAIN_XEN_PASSTHROUGH: + if (value !=3D VIR_TRISTATE_SWITCH_ON) break; =20 - case VIR_DOMAIN_XEN_LAST: - break; - } + if (virXMLPropEnum(node, "mode", + virDomainXenPassthroughModeTypeFromString, + VIR_XML_PROP_NONZERO, + &def->xen_passthrough_mode) < 0) + return -1; + break; =20 - node =3D xmlNextElementSibling(node); + case VIR_DOMAIN_XEN_LAST: + break; } + + node =3D xmlNextElementSibling(node); } =20 return 0; --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364650; cv=none; d=zohomail.com; s=zohoarc; b=ARr1Tse5Mq6m/mrA6cOCPjP+WV3uPG7wRQVV8SPjnWVc/tIUVPsclYw97M94vRWjsy4k1GIUpFgdVsaxyWp/UUWYf7kGklUChLMktK9QaFGajg5hTC+k8E5k0mj29y0T3nUm0fbbyYdTehb2Hhj3kIA0LeKaJWSD/WUl/RkbWZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364650; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=suIdPU1SPYuDZl+yiHC7z+ZWWg+Fu06Sv7G7rfnEfZE=; b=WbVtv2aJCMRjprnRH1RW7yxmKMvgZX9GDQHzYLU6MlvIen4dYqYK55IMvskTPNWSkbTAVFw7e0kCEhhVZDdhODLG57nsWmY8G0a7Q97ewKK4KqP5lAgrU83JWa9jS3wRInRqVpfHZJ2AcRJJ/me/eL5sGzaKGMEC4ClyCkdKlyM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162436465006047.644808586610225; Tue, 22 Jun 2021 05:24:10 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-TisDr_EgOIuVz2t2erUQSg-1; Tue, 22 Jun 2021 08:24:07 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4536A1084F58; Tue, 22 Jun 2021 12:24:01 +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 1FAE35C1D1; Tue, 22 Jun 2021 12:24:01 +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 DBF614EA39; Tue, 22 Jun 2021 12:24:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNMTr005240 for ; Tue, 22 Jun 2021 08:23:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id B6BC019C79; Tue, 22 Jun 2021 12:23:22 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F37219C66; Tue, 22 Jun 2021 12:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364649; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=suIdPU1SPYuDZl+yiHC7z+ZWWg+Fu06Sv7G7rfnEfZE=; b=O+Gc8Fw5+szH82DvOnMrFEDf8VF8jW2StgV1ZmVkG0TZArWABTfcyCOiti8rX+aQlc6XNq u7DQm/Z/wo4zTgpTcZaXX7NcuWNdfLu2F2TCYkTBAOS4MdoeF2zgxyXGWt/SZTylDO45// zfmbeDfwFe+Vr9ltVRClheMRTb2UxJI= X-MC-Unique: TisDr_EgOIuVz2t2erUQSg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 12/16] virDomainFeaturesDefParse: Inline SMM parsing Date: Tue, 22 Jun 2021 14:22:53 +0200 Message-Id: <20210622122257.12528-13-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 02c06d5ab9..b411c1fb8c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17554,8 +17554,7 @@ virDomainFeaturesDefParse(virDomainDef *def, case VIR_DOMAIN_FEATURE_HAP: case VIR_DOMAIN_FEATURE_PMU: case VIR_DOMAIN_FEATURE_PVSPINLOCK: - case VIR_DOMAIN_FEATURE_VMPORT: - case VIR_DOMAIN_FEATURE_SMM: { + case VIR_DOMAIN_FEATURE_VMPORT: { virTristateSwitch state; =20 if (virXMLPropTristateSwitch(nodes[i], "state", @@ -17569,6 +17568,31 @@ virDomainFeaturesDefParse(virDomainDef *def, break; } =20 + case VIR_DOMAIN_FEATURE_SMM: { + virTristateSwitch state; + + if (virXMLPropTristateSwitch(nodes[i], "state", + VIR_XML_PROP_NONE, &state) < 0) + return -1; + + if ((state =3D=3D VIR_TRISTATE_SWITCH_ABSENT) || + (state =3D=3D VIR_TRISTATE_SWITCH_ON)) { + int rv =3D virParseScaledValue("string(./features/smm/tseg= )", + "string(./features/smm/tseg/@= unit)", + ctxt, + &def->tseg_size, + 1024 * 1024, /* Defaults to m= ebibytes */ + ULLONG_MAX, + false); + if (rv < 0) + return -1; + + def->features[val] =3D VIR_TRISTATE_SWITCH_ON; + def->tseg_specified =3D rv !=3D 0; + } + break; + } + case VIR_DOMAIN_FEATURE_GIC: if (virXMLPropEnum(nodes[i], "version", virGICVersionTypeFromS= tring, VIR_XML_PROP_NONZERO, &def->gic_version) < = 0) @@ -17670,19 +17694,6 @@ virDomainFeaturesDefParse(virDomainDef *def, } VIR_FREE(nodes); =20 - if (def->features[VIR_DOMAIN_FEATURE_SMM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { - int rv =3D virParseScaledValue("string(./features/smm/tseg)", - "string(./features/smm/tseg/@unit)", - ctxt, - &def->tseg_size, - 1024 * 1024, /* Defaults to mebibytes= */ - ULLONG_MAX, - false); - if (rv < 0) - return -1; - def->tseg_specified =3D rv; - } - if (def->features[VIR_DOMAIN_FEATURE_MSRS] =3D=3D VIR_TRISTATE_SWITCH_= ON) { virDomainMsrsUnknown unknown; xmlNodePtr node =3D NULL; --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364791; cv=none; d=zohomail.com; s=zohoarc; b=eg93dJvnQKaItp2agismZ8j+ZoWm+yshHvMsOI8sDeI+ovOgZTDV6DVZcApbvN0NO6JmBRnPWUhXVKeDVjw09IuFoTS3hAx812DRewD6Ul1YuxpYksVnbrnw+sGcWWD+AfC0PK/gulC5cgH8mLQ1zftyUeYikCEEN9nYAvOYw/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364791; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BCmllfsmvypy146sNRXdcS3tmWoS9T6gMf6pFKEYBf0=; b=W+XcU+NiDUYJBGIixLZ3/NMU9m8XyWF0uVzaoZBOCex5FedeMuawo/6CtGkRxi44DSKd6EEkpDRwyGkvwwvkg20ShWMUhEftzm9Lkw9NQaKjQYbND9TRctg602MBNaVpGc/rpZiT1iSDyFA9WIUpbi12hnE3vsVqloOAAP6E7/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1624364791832331.6372525093144; Tue, 22 Jun 2021 05:26:31 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-whAqUdLoPYulDc3dEk7D8g-1; Tue, 22 Jun 2021 08:26:09 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF33C1084F5A; Tue, 22 Jun 2021 12:26:03 +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 A447560936; Tue, 22 Jun 2021 12:26:03 +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 6FDED181A6EB; Tue, 22 Jun 2021 12:26:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNNtE005250 for ; Tue, 22 Jun 2021 08:23:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id B9DD219C66; Tue, 22 Jun 2021 12:23:23 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13CC819C46; Tue, 22 Jun 2021 12:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364771; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BCmllfsmvypy146sNRXdcS3tmWoS9T6gMf6pFKEYBf0=; b=BhbAOhuipo2C0Ernqoz4JNyF/XQsJPW9EMMgTO1uwB7hhTk7Jp68TNOwpAVy0CtfaTVOSQ wVXGzt06g9AmqyMG/7jXcxrnkcb4JbT2MBz5sqyFb0EsNA90nYJK9tNczVHEF9zktclSFC JT+lG4iFQqOTxmLtVbD3fk9jdreK5XA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364791; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BCmllfsmvypy146sNRXdcS3tmWoS9T6gMf6pFKEYBf0=; b=ZmrmPcSqDZy1deLc0srlRPf+HfUb8jVs31o9fnQuE3D9UMInqfkmvvG/uZrSziyLooNJFR bCQyoLj+LlNuyWv6TBu+ZhgZMqntbfYDy2LvHJ3N5/THtoEOrclizbt5FbS9Y/N3cWnDMr cpRbSa6OV0pTMYlzpzjjM7tAoHYWVX0= X-MC-Unique: whAqUdLoPYulDc3dEk7D8g-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 13/16] virDomainFeaturesDefParse: Inline MSRS parsing Date: Tue, 22 Jun 2021 14:22:54 +0200 Message-Id: <20210622122257.12528-14-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b411c1fb8c..915303adcd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17518,10 +17518,21 @@ virDomainFeaturesDefParse(virDomainDef *def, case VIR_DOMAIN_FEATURE_PAE: case VIR_DOMAIN_FEATURE_VIRIDIAN: case VIR_DOMAIN_FEATURE_PRIVNET: - case VIR_DOMAIN_FEATURE_MSRS: def->features[val] =3D VIR_TRISTATE_SWITCH_ON; break; =20 + case VIR_DOMAIN_FEATURE_MSRS: { + virDomainMsrsUnknown unknown; + if (virXMLPropEnum(nodes[i], "unknown", + virDomainMsrsUnknownTypeFromString, + VIR_XML_PROP_REQUIRED, &unknown) < 0) + return -1; + + def->features[val] =3D VIR_TRISTATE_SWITCH_ON; + def->msrs_features[VIR_DOMAIN_MSRS_UNKNOWN] =3D unknown; + break; + } + case VIR_DOMAIN_FEATURE_HYPERV: if (virDomainFeaturesHyperVDefParse(def, nodes[i]) < 0) return -1; @@ -17694,19 +17705,6 @@ virDomainFeaturesDefParse(virDomainDef *def, } VIR_FREE(nodes); =20 - if (def->features[VIR_DOMAIN_FEATURE_MSRS] =3D=3D VIR_TRISTATE_SWITCH_= ON) { - virDomainMsrsUnknown unknown; - xmlNodePtr node =3D NULL; - if ((node =3D virXPathNode("./features/msrs", ctxt)) =3D=3D NULL) - return -1; - - if (virXMLPropEnum(node, "unknown", virDomainMsrsUnknownTypeFromSt= ring, - VIR_XML_PROP_REQUIRED, &unknown) < 0) - return -1; - - def->msrs_features[VIR_DOMAIN_MSRS_UNKNOWN] =3D unknown; - } - if ((n =3D virXPathNodeSet("./features/capabilities/*", ctxt, &nodes))= < 0) return -1; =20 --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364709; cv=none; d=zohomail.com; s=zohoarc; b=Es1skJrkeeHOYTSiW8mTTVMU+bRlR3SZG2HKNT7mayPBiwl0WrYoCy5l1246UjZHrGuZ3ie/TTZ0GfBIKud60h4TL+gkLzDSO8HkbJc5oTigLbhUzpBlTQL7lN7HBtUlIx5EsfFyy1VJmcE+pfKHQpm42ikvRJROGIBfIyXtXm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364709; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/f3lQ9aw6qSpoTj75KIV8+WgNvI0sC+QLsjv0jHQjUQ=; b=ZwCpTLczxXwltumfiP7+QbznJCG3/9oOA63oGRHOyZCsQIvDWlpQ/bkQ1YOPhJy2HTdG/lcvaq401rQlfzUEuBRjRJ7zax0ZYPUIugvPaVOKZewHCPg2i/HHvQKo+B4ORcxTGwSJj/DOqtsAi4KKRX/hEQy381eGUX5qPwGAX3Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1624364709421646.4609294894196; Tue, 22 Jun 2021 05:25:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-435-8pxxy06rMUKuIGdcIdzqhg-1; Tue, 22 Jun 2021 08:24:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1790E1084F53; Tue, 22 Jun 2021 12:24:04 +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 E13A11000320; Tue, 22 Jun 2021 12:24:03 +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 A6BD94EA3D; Tue, 22 Jun 2021 12:24:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNOtC005255 for ; Tue, 22 Jun 2021 08:23:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF19B19C66; Tue, 22 Jun 2021 12:23:24 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1771A19C46; Tue, 22 Jun 2021 12:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364708; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/f3lQ9aw6qSpoTj75KIV8+WgNvI0sC+QLsjv0jHQjUQ=; b=PYh/6vWWOGkeXc5BDNBGaAyzt21I6zndMv743RCxlxjO6/jd/B85tBoGPs54MLX0A8qw7M jQuxwvmlEjmq/+IqMp6UvUghit3miq6xK/lm9zsFLAL4hNHCfH/miktP+WvvWCfzhhQT0u kRy2gdPYgZLizrZpdYss1NNg+mkQGMw= X-MC-Unique: 8pxxy06rMUKuIGdcIdzqhg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 14/16] virDomainFeaturesDefParse: Factor out capabilities parsing into separate function Date: Tue, 22 Jun 2021 14:22:55 +0200 Message-Id: <20210622122257.12528-15-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Cleanup to follow. This removes the last re-use of `nodes` in this function, eliminating two VIR_FREEs. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 78 +++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 915303adcd..84c684b004 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17481,6 +17481,51 @@ virDomainFeaturesXENDefParse(virDomainDef *def, } =20 =20 +static int +virDomainFeaturesCapabilitiesDefParse(virDomainDef *def, + xmlNodePtr node, + xmlXPathContext *ctxt) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + size_t i; + int n; + virDomainCapabilitiesPolicy policy; + + if (virXMLPropEnumDefault(node, "policy", + virDomainCapabilitiesPolicyTypeFromString, + VIR_XML_PROP_NONE, &policy, + VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT) < 0) + return -1; + + def->features[VIR_DOMAIN_FEATURE_CAPABILITIES] =3D policy; + + if ((n =3D virXPathNodeSet("./features/capabilities/*", ctxt, &nodes))= < 0) + return -1; + + for (i =3D 0; i < n; i++) { + virTristateSwitch state; + int val =3D virDomainProcessCapsFeatureTypeFromString((const char = *)nodes[i]->name); + if (val < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unexpected capability feature '%s'"), nodes[= i]->name); + return -1; + } + + + if (virXMLPropTristateSwitch(nodes[i], "state", VIR_XML_PROP_NONE, + &state) < 0) + return -1; + + if (state =3D=3D VIR_TRISTATE_SWITCH_ABSENT) + state =3D VIR_TRISTATE_SWITCH_ON; + + def->caps_features[val] =3D state; + } + + return 0; +} + + static int virDomainFeaturesDefParse(virDomainDef *def, xmlXPathContextPtr ctxt) @@ -17549,15 +17594,8 @@ virDomainFeaturesDefParse(virDomainDef *def, break; =20 case VIR_DOMAIN_FEATURE_CAPABILITIES: { - virDomainCapabilitiesPolicy policy; - - if (virXMLPropEnumDefault(nodes[i], "policy", - virDomainCapabilitiesPolicyTypeFromS= tring, - VIR_XML_PROP_NONE, &policy, - VIR_DOMAIN_CAPABILITIES_POLICY_DEFAU= LT) < 0) + if (virDomainFeaturesCapabilitiesDefParse(def, nodes[i], ctxt)= < 0) return -1; - - def->features[val] =3D policy; break; } =20 @@ -17703,31 +17741,7 @@ virDomainFeaturesDefParse(virDomainDef *def, break; } } - VIR_FREE(nodes); =20 - if ((n =3D virXPathNodeSet("./features/capabilities/*", ctxt, &nodes))= < 0) - return -1; - - for (i =3D 0; i < n; i++) { - virTristateSwitch state; - int val =3D virDomainProcessCapsFeatureTypeFromString((const char = *)nodes[i]->name); - if (val < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unexpected capability feature '%s'"), nodes[= i]->name); - return -1; - } - - - if (virXMLPropTristateSwitch(nodes[i], "state", VIR_XML_PROP_NONE, - &state) < 0) - return -1; - - if (state =3D=3D VIR_TRISTATE_SWITCH_ABSENT) - state =3D VIR_TRISTATE_SWITCH_ON; - - def->caps_features[val] =3D state; - } - VIR_FREE(nodes); return 0; } =20 --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364723; cv=none; d=zohomail.com; s=zohoarc; b=HKS/LHkHjjriEyvl52GtSXbvuYdjM+hnp1X7BnYYOiJCdWIIISJVnq054bTHZrC66eo2QmTvXZXsYM6PwidebozDjRQ/9CR41Yln5GOiH/PONeXeRk41o0Ih1QHihakILjQ3neIdjMq307rpbwAcldpA7rKP9KD1b4dF4U4PFTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364723; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fVZP4zM8wc/KhF4UNM/Qz2Arx8IrHDbqOrhpxECiOAQ=; b=lpQ8N+ROrPTiEjRG55KrM5bad4lO/QDlTIORd2/hurEL7O1BOEtJ6jruZm88SBFj7grcrlQ3dtsWgqvgbXp8acQ7wf9mQ8ZW5oTvac1YKurqgiOoo3q+FHKbdGdYZotcFA6kmN3V1z2wKhXPmfL1yZHV4mHpQaaNXTbDrQdTta8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1624364723055591.8685803002456; Tue, 22 Jun 2021 05:25:23 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-rbthnIzsPnenmeah0ild-w-1; Tue, 22 Jun 2021 08:24:15 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F07F0100C666; Tue, 22 Jun 2021 12:24:09 +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 C9FD410023B5; Tue, 22 Jun 2021 12:24:09 +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 954DA180101F; Tue, 22 Jun 2021 12:24:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNPKE005277 for ; Tue, 22 Jun 2021 08:23:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id C49C419D7C; Tue, 22 Jun 2021 12:23:25 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CF2219C66; Tue, 22 Jun 2021 12:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364710; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fVZP4zM8wc/KhF4UNM/Qz2Arx8IrHDbqOrhpxECiOAQ=; b=Ay/fmKKkzLcVcK7HfXohaEoUY8Ouunl4ALOq5Sg/6NIdcTa8IjuIvWxfZb045t9x86N+Jn lLtjxHdmSfRoqbSvr44T5+eptrMH/8SVoSjlaseu+St0iWxc0w+qodWmoti5w/57w9ua6S wFwLLpPKs+Str3RZXLz5KiJ1QUpI4iY= X-MC-Unique: rbthnIzsPnenmeah0ild-w-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 15/16] virDomainFeaturesCapabilitiesDefParse: Remove ctxt Date: Tue, 22 Jun 2021 14:22:56 +0200 Message-Id: <20210622122257.12528-16-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Iterating over all child elements of a node does not require xpath. By doing away with xpath for this code, the code can be simplified. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 84c684b004..50717c4f44 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17483,12 +17483,8 @@ virDomainFeaturesXENDefParse(virDomainDef *def, =20 static int virDomainFeaturesCapabilitiesDefParse(virDomainDef *def, - xmlNodePtr node, - xmlXPathContext *ctxt) + xmlNodePtr node) { - g_autofree xmlNodePtr *nodes =3D NULL; - size_t i; - int n; virDomainCapabilitiesPolicy policy; =20 if (virXMLPropEnumDefault(node, "policy", @@ -17499,27 +17495,25 @@ virDomainFeaturesCapabilitiesDefParse(virDomainDe= f *def, =20 def->features[VIR_DOMAIN_FEATURE_CAPABILITIES] =3D policy; =20 - if ((n =3D virXPathNodeSet("./features/capabilities/*", ctxt, &nodes))= < 0) - return -1; - - for (i =3D 0; i < n; i++) { + node =3D xmlFirstElementChild(node); + while (node) { virTristateSwitch state; - int val =3D virDomainProcessCapsFeatureTypeFromString((const char = *)nodes[i]->name); + int val =3D virDomainProcessCapsFeatureTypeFromString((const char = *)node->name); if (val < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unexpected capability feature '%s'"), nodes[= i]->name); + _("unexpected capability feature '%s'"), node->= name); return -1; } =20 =20 - if (virXMLPropTristateSwitch(nodes[i], "state", VIR_XML_PROP_NONE, - &state) < 0) + if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_NONE, &st= ate) < 0) return -1; =20 if (state =3D=3D VIR_TRISTATE_SWITCH_ABSENT) state =3D VIR_TRISTATE_SWITCH_ON; =20 def->caps_features[val] =3D state; + node =3D xmlNextElementSibling(node); } =20 return 0; @@ -17594,7 +17588,7 @@ virDomainFeaturesDefParse(virDomainDef *def, break; =20 case VIR_DOMAIN_FEATURE_CAPABILITIES: { - if (virDomainFeaturesCapabilitiesDefParse(def, nodes[i], ctxt)= < 0) + if (virDomainFeaturesCapabilitiesDefParse(def, nodes[i]) < 0) return -1; break; } --=20 2.31.1 From nobody Thu Nov 14 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1624364803; cv=none; d=zohomail.com; s=zohoarc; b=QNHBK+H6VblBOn4lRkBANQ7/Zdwj1aLguaK9vS+oJFRWhXwWgcgy4FZ+zVCv7ImUfIFC/evc4isiO10ajx6EpFoQbw+sPfAbyW0CnWMpr09oGZegnlmYh/GVhseNVuzisz/uVt1MXQzHJgIdf6B7jsUjF2Jvc2mDHFuwjaqg7LA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624364803; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fxGXziu1iA4qO5KLJHwiu+eIM0clbkiTP3zwBQE50Ys=; b=K1QsNQtaKYZy7ZoPAVYZViQKyYcXdrvPHSYhKyR4scoNCqrHMchc1CfQE5BzPQDG+qVRhhwcofgPf1VZpMdCeE+FnxWvcrNahWFXLh8gJAlXLS3zbZhbV+9sHWGNdp8YUGjTgK8S+CcM0hltmnEJ0vKIyAspIs2eZkol9ux586A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162436480374919.7060305034679; Tue, 22 Jun 2021 05:26:43 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-558-78Mcw00rPG-q2Im3IAKYFA-1; Tue, 22 Jun 2021 08:26:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 232FD8030D6; Tue, 22 Jun 2021 12:26:07 +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 EEFFF1000320; Tue, 22 Jun 2021 12:26:06 +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 B7AA51826D29; Tue, 22 Jun 2021 12:26:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15MCNQfb005289 for ; Tue, 22 Jun 2021 08:23:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id CEF8F19C46; Tue, 22 Jun 2021 12:23:26 +0000 (UTC) Received: from work.redhat.com (ovpn-113-16.ams2.redhat.com [10.36.113.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23B8619D7C; Tue, 22 Jun 2021 12:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624364773; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fxGXziu1iA4qO5KLJHwiu+eIM0clbkiTP3zwBQE50Ys=; b=Qq5TsVI0OPkzVF/k8DPFn2TFJpWCLBR6g/qZcpzpqf6yO9VyrS0/QBUTrPaihcBq+ax85M oKfPiMnHc0mTE4rF3f4n7rYarVIWRjhLGtN4SdJYAwy5fh/2ySdUCkH28hkyhsCmeTVYCY 7ijgd7CPLiuknYr8gidbXTzT6JC9ok4= X-MC-Unique: 78Mcw00rPG-q2Im3IAKYFA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 16/16] virDomainFeaturesDefParse: Simplify APIC parsing Date: Tue, 22 Jun 2021 14:22:57 +0200 Message-Id: <20210622122257.12528-17-twiederh@redhat.com> In-Reply-To: <20210622122257.12528-1-twiederh@redhat.com> References: <20210622122257.12528-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 50717c4f44..d78f846a52 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17532,7 +17532,6 @@ virDomainFeaturesDefParse(virDomainDef *def, return -1; =20 for (i =3D 0; i < n; i++) { - g_autofree char *tmp =3D NULL; int val =3D virDomainFeatureTypeFromString((const char *)nodes[i]-= >name); if (val < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -17541,18 +17540,6 @@ virDomainFeaturesDefParse(virDomainDef *def, } =20 switch ((virDomainFeature) val) { - case VIR_DOMAIN_FEATURE_APIC: - if ((tmp =3D virXPathString("string(./features/apic/@eoi)", ct= xt))) { - int eoi; - if ((eoi =3D virTristateSwitchTypeFromString(tmp)) <=3D 0)= { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown value for attribute eoi: '%s= '"), - tmp); - return -1; - } - def->apic_eoi =3D eoi; - } - G_GNUC_FALLTHROUGH; case VIR_DOMAIN_FEATURE_ACPI: case VIR_DOMAIN_FEATURE_PAE: case VIR_DOMAIN_FEATURE_VIRIDIAN: @@ -17560,6 +17547,16 @@ virDomainFeaturesDefParse(virDomainDef *def, def->features[val] =3D VIR_TRISTATE_SWITCH_ON; break; =20 + case VIR_DOMAIN_FEATURE_APIC: { + virTristateSwitch eoi; + if (virXMLPropTristateSwitch(nodes[i], "eoi", VIR_XML_PROP_NON= E, &eoi) < 0) + return -1; + + def->features[val] =3D VIR_TRISTATE_SWITCH_ON; + def->apic_eoi =3D eoi; + break; + } + case VIR_DOMAIN_FEATURE_MSRS: { virDomainMsrsUnknown unknown; if (virXMLPropEnum(nodes[i], "unknown", --=20 2.31.1