From nobody Sun Feb 8 23:41:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1693231064; cv=none; d=zohomail.com; s=zohoarc; b=Dk3wARbOLMfLH0WTi9D9oA0IT/dZFAig4cPlRMpYqJrymEENbFdH0xRPykVAMYHD+Xf349e1kySfr84XEmy8oO13cRoIP8PBGYgvv2eVqcbIMHtJfIOkSMFergICCDHik0CJbsRSNIqBsngicD/nzZlQ6qCghimnBIEYbFLiaLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693231064; h=Content-Type:Content-Transfer-Encoding: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=Pn59tgG8nCJFJefyFFMk16IhBK4OUOkQalroPcoZ4Xo=; b=EgQEl7gv00m0WpYgEsVDcIdAHTRN2oEgx/D/JuYW5pr6A59fporwdmWE/fYzSsDjNjSYlfScguIOfAmQMDD4/kBKW1iiX9SH+V5M8J3oDG/CcPChMZTPTQuoEPQd5JgwArqmQExvPjNCq7YrbQ0CpDdPz93RjMJz1ExWH8jLGBg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1693231064706689.5687757038901; Mon, 28 Aug 2023 06:57:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-507-unm4fibENUmxVRvgrsYszg-1; Mon, 28 Aug 2023 09:57:40 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 065531C06ECC; Mon, 28 Aug 2023 13:57:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E75F1140E964; Mon, 28 Aug 2023 13:57:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B8FBD1946588; Mon, 28 Aug 2023 13:57:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1A9541946587 for ; Mon, 28 Aug 2023 13:57:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E196B2026D76; Mon, 28 Aug 2023 13:57:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A8202026D4B for ; Mon, 28 Aug 2023 13:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693231063; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=Pn59tgG8nCJFJefyFFMk16IhBK4OUOkQalroPcoZ4Xo=; b=L1QIHuykamH6B7kBKDyzDb9MVoHLJkCd0PQVA/kYt3/2Y9qnvO/6H0oABbERMmSopr8ZE/ 4qJDGyq4vjI1MlYnY3HnN/dif7uDQqviCsDi03BNJuon7ocDGJWJS8VQ0hYg6s/DbbqLmb Im7WewA7rvNpiAr9Hkyg+GYT01udKOA= X-MC-Unique: unm4fibENUmxVRvgrsYszg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/5] virDomainFeaturesKVMDefParse: Use virXMLNodeGetSubelementList Date: Mon, 28 Aug 2023 15:57:26 +0200 Message-ID: <44f7d21c97019065249e240b0b1edab1a3544771.1693231019.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693231066383100001 Content-Type: text/plain; charset="utf-8" Rewrite the old-style parser to use virXMLNodeGetSubelementList Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d510279472..3a08034b9d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16355,24 +16355,24 @@ static int virDomainFeaturesKVMDefParse(virDomainDef *def, xmlNodePtr node) { - g_autofree virDomainFeatureKVM *kvm =3D NULL; - - kvm =3D g_new0(virDomainFeatureKVM, 1); + g_autofree virDomainFeatureKVM *kvm =3D g_new0(virDomainFeatureKVM, 1); + g_autofree xmlNodePtr *feats =3D NULL; + size_t nfeats =3D virXMLNodeGetSubelementList(node, NULL, &feats); + size_t i; - node =3D xmlFirstElementChild(node); - while (node) { + for (i =3D 0; i < nfeats; i++) { int feature; virTristateSwitch value; - feature =3D virDomainKVMTypeFromString((const char *)node->name); + feature =3D virDomainKVMTypeFromString((const char *)feats[i]->nam= e); if (feature < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported KVM feature: %1$s"), - node->name); + feats[i]->name); return -1; } - if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUIRED, + if (virXMLPropTristateSwitch(feats[i], "state", VIR_XML_PROP_REQUI= RED, &value) < 0) return -1; @@ -16382,7 +16382,7 @@ virDomainFeaturesKVMDefParse(virDomainDef *def, if (feature =3D=3D VIR_DOMAIN_KVM_DIRTY_RING && value =3D=3D VIR_TRISTATE_SWITCH_ON) { - if (virXMLPropUInt(node, "size", 0, VIR_XML_PROP_REQUIRED, + if (virXMLPropUInt(feats[i], "size", 0, VIR_XML_PROP_REQUIRED, &kvm->dirty_ring_size) < 0) { return -1; } @@ -16396,8 +16396,6 @@ virDomainFeaturesKVMDefParse(virDomainDef *def, return -1; } } - - node =3D xmlNextElementSibling(node); } def->features[VIR_DOMAIN_FEATURE_KVM] =3D VIR_TRISTATE_SWITCH_ON; --=20 2.41.0