From nobody Mon Feb 9 02:52:03 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=1661516426; cv=none; d=zohomail.com; s=zohoarc; b=CvW/TPZx/KZvYJvjVcfsdJwuw9tSvlQUpqlN0VvqLnJfBS1XzxhFfJCi/4bTsQ1wm4nRiHXqtDWcBbD2S8bTBiWwJ1gPcwd9eJjpgC2rO7KLMQtEjFFBk881GdVSkC+x0YBW7Y1qw5E9Z3FPe2U2RLw7ge19jCi5Qy0IYtMK9Ec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516426; 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=P8liX4jCkTDMt8TRjIX3G+3b6gL8QKu6lVj8fBiVOL0=; b=WOGAxGZz/EQ8eedgtybI4dndyWgpMehIzTyLGmtl7TGMYxFLQmwl6Poq344kg3UnlG5jczTvXw2s3kXg7Ph82Duy8W8riqpWjzyQ3y/LA8zyvlTxU86WHbBxhAMbcpnVmdcJFHBsUN3/SvcIroMJz6m/xNXpMgxqn5vPsZbtsrU= 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 1661516426922460.288733402546; Fri, 26 Aug 2022 05:20:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-449-Adot5ZtzMd-7946KNuYAfw-1; Fri, 26 Aug 2022 08:20:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BBCF580A0C3; Fri, 26 Aug 2022 12:20:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A95E940C141D; Fri, 26 Aug 2022 12:20:17 +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 8B1091946A4E; Fri, 26 Aug 2022 12:20:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6B6A61946A67 for ; Fri, 26 Aug 2022 12:20:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5BDD440E7F2A; Fri, 26 Aug 2022 12:20:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B216440E7F28 for ; Fri, 26 Aug 2022 12:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516424; 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=P8liX4jCkTDMt8TRjIX3G+3b6gL8QKu6lVj8fBiVOL0=; b=QmnRGn1a5WjKcs9YcgKnujhSIR9Lu+iEwMKt+r/zFicwuZlHou35CCvew4tJA6UvX8j7il fp5HFQCM8Caw0HrROKhgCiuYHkZvUnay1GnZrp1LdScAsshONqr+4K1p9vpocNg3h9XNek eBf0K9X9OhTC4BbL8c671ev8RFQkERg= X-MC-Unique: Adot5ZtzMd-7946KNuYAfw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/10] virDomainControllerDefParseXML: Parse 'index' by virXMLPropInt Date: Fri, 26 Aug 2022 14:20:03 +0200 Message-Id: <97b066352e2f4b9d41205abd7d9072251dbc1b00.1661516306.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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 2.84 on 10.11.54.2 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: 1661516428477100001 Content-Type: text/plain; charset="utf-8" 'index' is parsed to fit into a signed int but not have negative values. virXMLPropInt can do that internally. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 14 +++----------- .../pci-bridge-negative-index-invalid.err | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 77cb5f1456..70672c83ce 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8132,7 +8132,6 @@ virDomainControllerDefParseXML(virDomainXMLOption *xm= lopt, int ports; VIR_XPATH_NODE_AUTORESTORE(ctxt) int rc; - g_autofree char *idx =3D NULL; g_autofree char *model =3D NULL; ctxt->node =3D node; @@ -8152,16 +8151,9 @@ virDomainControllerDefParseXML(virDomainXMLOption *x= mlopt, } } - idx =3D virXMLPropString(node, "index"); - if (idx) { - unsigned int idxVal; - if (virStrToLong_ui(idx, NULL, 10, &idxVal) < 0 || idxVal > INT_MA= X) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse controller index %s"), idx); - return NULL; - } - def->idx =3D idxVal; - } + if (virXMLPropInt(node, "index", 10, VIR_XML_PROP_NONNEGATIVE, + &def->idx, def->idx) < 0) + return NULL; if ((driver =3D virXPathNode("./driver", ctxt))) { if (virXMLPropUInt(driver, "queues", 10, VIR_XML_PROP_NONE, diff --git a/tests/qemuxml2argvdata/pci-bridge-negative-index-invalid.err b= /tests/qemuxml2argvdata/pci-bridge-negative-index-invalid.err index e258bcbee5..24a7d817e1 100644 --- a/tests/qemuxml2argvdata/pci-bridge-negative-index-invalid.err +++ b/tests/qemuxml2argvdata/pci-bridge-negative-index-invalid.err @@ -1 +1 @@ -internal error: Cannot parse controller index -1 +XML error: Invalid value for attribute 'index' in element 'controller': '-= 1'. Expected non-negative value --=20 2.37.1