From nobody Sat May 18 07:09:13 2024 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=1661516418; cv=none; d=zohomail.com; s=zohoarc; b=cwsqYj7oN1RVM477eGhnqLYF0XIFxIuu7R6x/yt+ozltiK0Q0K/QDE17LRMIJ3UL9VexqcbMJbUuS6/ZrHwXsQ7t/JjDl86B6wZSzUNM8CRcgq2gAzi1K2dOz40uH5X89nzEebJ/xl1Vgn2YKLVdiW3hm2m+v0JNhtc7XYmnq0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516418; 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=hGVNmLq9KTmjUEgIehDQvP7j92X1iC2CPSX+4acSJHc=; b=gYLcRBSDpocWZ2TMppnO4TNbt4UayzkX260NkVb/lOBSO8pRxDY4/eaKjHn3iT15Kt+QQIF7v6l9Jc22N7ZhZZBzRS/9t7wyxLWzfB89ZOoOh2pcU1/dwV75Dq57+HBTY3jI+zG6TKHOV7PfXVYdEKDfTEZrYTNGTkGxHOGGTac= 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 1661516418912814.7169882890007; Fri, 26 Aug 2022 05:20:18 -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-635-Vii6q3CdOwWoXZADT8fgGg-1; Fri, 26 Aug 2022 08:20:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D17AC101E9BA; Fri, 26 Aug 2022 12:20:11 +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 2822C2166B26; Fri, 26 Aug 2022 12:20:11 +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 7F38A1946A51; Fri, 26 Aug 2022 12:20:10 +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 E7A541946A43 for ; Fri, 26 Aug 2022 12:20:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D95FC40B40CB; Fri, 26 Aug 2022 12:20:08 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A22D40E7F28 for ; Fri, 26 Aug 2022 12:20:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516417; 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=hGVNmLq9KTmjUEgIehDQvP7j92X1iC2CPSX+4acSJHc=; b=JLaAwsmMnMH8TVr8RyvZ+R4xYS1HiB5Ip7G0HBVSxio37JdN5Wdmc1eYU7DXRqU2V2nnbi YNC1mlSoVPgwQ8WpAHAAwrJd2FXqwQDMbwMuM9xmX66kBeZuhPTY0Tzd+rlkY2B2uTGHqZ J4Eu0cLQoviHa0k1LjimyS5TuIG9Bmk= X-MC-Unique: Vii6q3CdOwWoXZADT8fgGg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/10] virDomainControllerDefValidate: Un-break lines in error messages Date: Fri, 26 Aug 2022 14:19:56 +0200 Message-Id: <1969ae9efe72c12a3efb21faef3e4b7792cf8d22.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.78 on 10.11.54.6 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: 1661516420455100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_validate.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 1c78a3d31c..6ecf6d1c11 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1129,8 +1129,7 @@ virDomainControllerDefValidate(const virDomainControl= lerDef *controller) controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT= ) { if (controller->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_= NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("pci-root and pcie-root controllers " - "should not have an address")); + _("pci-root and pcie-root controllers shoul= d not have an address")); return -1; } } @@ -1147,8 +1146,7 @@ virDomainControllerDefValidate(const virDomainControl= lerDef *controller) if (opts->targetIndex < 0 || opts->targetIndex > 30) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller target index '%d' out of " - "range - must be 0-30"), + _("PCI controller target index '%d' out of = range - must be 0-30"), opts->targetIndex); return -1; } @@ -1156,8 +1154,7 @@ virDomainControllerDefValidate(const virDomainControl= lerDef *controller) if ((controller->idx =3D=3D 0 && opts->targetIndex !=3D 0) || (controller->idx !=3D 0 && opts->targetIndex =3D=3D 0)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only the PCI controller with index 0 can= " - "have target index 0, and vice versa")); + _("Only the PCI controller with index 0 can= have target index 0, and vice versa")); return -1; } } @@ -1165,8 +1162,7 @@ virDomainControllerDefValidate(const virDomainControl= lerDef *controller) if (opts->chassisNr !=3D -1) { if (opts->chassisNr < 1 || opts->chassisNr > 255) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller chassisNr '%d' out of ran= ge " - "- must be 1-255"), + _("PCI controller chassisNr '%d' out of ran= ge - must be 1-255"), opts->chassisNr); return -1; } @@ -1175,8 +1171,7 @@ virDomainControllerDefValidate(const virDomainControl= lerDef *controller) if (opts->chassis !=3D -1) { if (opts->chassis < 0 || opts->chassis > 255) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller chassis '%d' out of range= " - "- must be 0-255"), + _("PCI controller chassis '%d' out of range= - must be 0-255"), opts->chassis); return -1; } @@ -1185,8 +1180,7 @@ virDomainControllerDefValidate(const virDomainControl= lerDef *controller) if (opts->port !=3D -1) { if (opts->port < 0 || opts->port > 255) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller port '%d' out of range " - "- must be 0-255"), + _("PCI controller port '%d' out of range - = must be 0-255"), opts->port); return -1; } @@ -1195,8 +1189,7 @@ virDomainControllerDefValidate(const virDomainControl= lerDef *controller) if (opts->busNr !=3D -1) { if (opts->busNr < 1 || opts->busNr > 254) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller busNr '%d' out of range " - "- must be 1-254"), + _("PCI controller busNr '%d' out of range -= must be 1-254"), opts->busNr); return -1; } @@ -1204,8 +1197,7 @@ virDomainControllerDefValidate(const virDomainControl= lerDef *controller) if (opts->numaNode >=3D 0 && controller->idx =3D=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("The PCI controller with index=3D0 can't " - "be associated with a NUMA node")); + _("The PCI controller with index=3D0 can't be a= ssociated with a NUMA node")); return -1; } } --=20 2.37.1 From nobody Sat May 18 07:09:13 2024 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=1661516465; cv=none; d=zohomail.com; s=zohoarc; b=ZVO7sYicg4uCsOltD+xnDRi2o6uYdpjgqKiUEJfmEDwvVhiM2vKC132k+CjIRXiul+4J9XFzP5P7QpdJIBROS8elbqge2pPu9vFa/Ifwv8gDzi5AH0vpyxFYRec1xH/V+6vPJV3/RO8UhqOdzRbn8ifSXwafFckU7JiPpb5Jo8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516465; 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=HAEKxcq3oJ4kgir4/oOjiBr+h61Z7inEXiD8DULdMXg=; b=YzuKxX5oaHz3cG13PlXuvXBO56+Pb8UiRBBVz05K/2W7LGyuLhlh2rgevP9Lz/mNfDitC+0r9QGau8omx+DuMiF1U4MgUls63hUD7dJmQM4CFnx6NeDGkEFJfBcnjAmCvW0wiaqYTrAZavsTyLp/lAB/G6PMMLCqg44pL66qNL8= 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 1661516465840427.35440642359856; Fri, 26 Aug 2022 05:21:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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-145-9EODiI-UPq-oVoVacf5_2Q-1; Fri, 26 Aug 2022 08:20:14 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF6F2280EA43; Fri, 26 Aug 2022 12:20:11 +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 84CF1C15BC5; Fri, 26 Aug 2022 12:20:11 +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 E44F91946A78; Fri, 26 Aug 2022 12:20:10 +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 D94FE1946A67 for ; Fri, 26 Aug 2022 12:20:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CDAE4400EA8F; Fri, 26 Aug 2022 12:20:09 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A63E40CF916 for ; Fri, 26 Aug 2022 12:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516463; 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=HAEKxcq3oJ4kgir4/oOjiBr+h61Z7inEXiD8DULdMXg=; b=MBGvF9ajZTzK35bUcoH78ngfnwTJnjwaua8vRWQXjVCvPa18HTAKyltHD8tVpAHPYThNay HLiGqXvn265vngFySh/OZNKZZeCed/40VxyY419a6aaJRgUmPBrg8duBrswr7XrHB9Rp7v 8YGWbQZavI/QN4IahM667FajYuKopUU= X-MC-Unique: 9EODiI-UPq-oVoVacf5_2Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/10] virDomainControllerDefFormat: Use proper type for enum Date: Fri, 26 Aug 2022 14:19:57 +0200 Message-Id: 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.85 on 10.11.54.8 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: 1661516466637100003 Content-Type: text/plain; charset="utf-8" Typecast the controller type variable and add all cases to the switch statement. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6950f7ec1d..673e8a77c3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22684,7 +22684,7 @@ virDomainControllerDefFormat(virBuffer *buf, if (model) virBufferEscapeString(&attrBuf, " model=3D'%s'", model); - switch (def->type) { + switch ((virDomainControllerType) def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: if (def->opts.vioserial.ports !=3D -1) { virBufferAsprintf(&attrBuf, " ports=3D'%d'", @@ -22714,7 +22714,14 @@ virDomainControllerDefFormat(virBuffer *buf, } break; - default: + case VIR_DOMAIN_CONTROLLER_TYPE_IDE: + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: + case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: + case VIR_DOMAIN_CONTROLLER_TYPE_SATA: + case VIR_DOMAIN_CONTROLLER_TYPE_CCID: + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + case VIR_DOMAIN_CONTROLLER_TYPE_ISA: + case VIR_DOMAIN_CONTROLLER_TYPE_LAST: break; } --=20 2.37.1 From nobody Sat May 18 07:09:13 2024 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=1661516423; cv=none; d=zohomail.com; s=zohoarc; b=aVInpsILp7mcILPP1ZGNEAq2QTjiSMKLbyCUqkNHs5L1js1auRsh+97Xj55A1ed1db5KC2+KRDv9FedtqtgSzT3ua4JcCJY6ivB9LS9yqhHkPUpX0bMbdVi5cQzDBEiLwOVt7B96520etV2Z7OrmpiKOukgdbdXXpkLK1m/+Vnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516423; 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=yanH+zoecFJTsNculMG2JfZec/MXAe4888CKM71XUXg=; b=IRfu+HYa7v0VAeYjCoAyvlIzx09L9TH6Nji0rY1/BxitxpcnNJSKPPbkSAhVpvsJWhqcxI9zM9rWngS0zhae23tUgL6NplgRDa9UFmwTOfvqmisyptNUwYPaSYF12V0ss09mVBwVMwzdVelgDYILP4hta5GCQWMvw9husf4E7Uo= 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 1661516423109239.46866666648862; Fri, 26 Aug 2022 05:20:23 -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-609-d1WzMhzPOpKj8irOOaZH1A-1; Fri, 26 Aug 2022 08:20:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71A7D8037AC; Fri, 26 Aug 2022 12:20:12 +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 5EDC92026D4C; Fri, 26 Aug 2022 12:20:12 +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 477801946A4E; Fri, 26 Aug 2022 12:20:12 +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 2BD591947040 for ; Fri, 26 Aug 2022 12:20:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 117AF401014C; Fri, 26 Aug 2022 12:20:11 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46FF44010E6E for ; Fri, 26 Aug 2022 12:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516422; 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=yanH+zoecFJTsNculMG2JfZec/MXAe4888CKM71XUXg=; b=iJvaVWn0tZPvM6zEQL+Lgpct0l5Nirpbpybth65+h9rFu3qDHWky07toenCy0KZnBdvxdk XKRMdkEbLV5mRriZgNMg+fsU3D+MWNtBUmoTyGXug3g0xh+Cyqr8cvaLhqamgZ9oKdNaiM pp5Jk2DI5ZY1NagJib+H6kQsLy2LXC0= X-MC-Unique: d1WzMhzPOpKj8irOOaZH1A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/10] virDomainControllerDefFormat: Split out formatting of PCI controller Date: Fri, 26 Aug 2022 14:19:58 +0200 Message-Id: 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.78 on 10.11.54.4 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: 1661516424577100003 Content-Type: text/plain; charset="utf-8" Move the PCI controller code into virDomainControllerDefFormatPCI. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 162 ++++++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 76 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 673e8a77c3..b2ee4d5979 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22650,6 +22650,88 @@ virDomainControllerDriverFormat(virBuffer *buf, } +static int +virDomainControllerDefFormatPCI(virBuffer *buf, + virDomainControllerDef *def, + unsigned int flags) +{ + bool formatModelName =3D true; + + if (def->opts.pciopts.modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL= _NAME_NONE) + formatModelName =3D false; + + /* Historically, libvirt didn't support specifying a model name for + * pci-root controllers; starting from 3.6.0, however, pSeries guests + * use pci-root controllers with model name spapr-pci-host-bridge to + * represent all PHBs, including the default one. + * + * In order to allow migration of pSeries guests from older libvirt + * versions and back, we don't format the model name in the migratable + * XML if it's spapr-pci-host-bridge, thus making "no model name" and + * "spapr-pci-host-bridge model name" basically equivalent. + * + * The spapr-pci-host-bridge device is specific to pSeries. + */ + if (def->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT && + def->opts.pciopts.modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL= _NAME_SPAPR_PCI_HOST_BRIDGE && + flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) { + formatModelName =3D false; + } + + if (formatModelName) { + const char *modelName =3D virDomainControllerPCIModelNameTypeToStr= ing(def->opts.pciopts.modelName); + if (!modelName) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected model name value %d"), + def->opts.pciopts.modelName); + return -1; + } + virBufferAsprintf(buf, "\n", modelName); + } + + if (def->opts.pciopts.chassisNr !=3D -1 || + def->opts.pciopts.chassis !=3D -1 || + def->opts.pciopts.port !=3D -1 || + def->opts.pciopts.busNr !=3D -1 || + def->opts.pciopts.targetIndex !=3D -1 || + def->opts.pciopts.numaNode !=3D -1 || + def->opts.pciopts.hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAddLit(buf, "opts.pciopts.chassisNr !=3D -1) + virBufferAsprintf(buf, " chassisNr=3D'%d'", + def->opts.pciopts.chassisNr); + if (def->opts.pciopts.chassis !=3D -1) + virBufferAsprintf(buf, " chassis=3D'%d'", + def->opts.pciopts.chassis); + if (def->opts.pciopts.port !=3D -1) + virBufferAsprintf(buf, " port=3D'0x%x'", + def->opts.pciopts.port); + if (def->opts.pciopts.busNr !=3D -1) + virBufferAsprintf(buf, " busNr=3D'%d'", + def->opts.pciopts.busNr); + if (def->opts.pciopts.targetIndex !=3D -1) + virBufferAsprintf(buf, " index=3D'%d'", + def->opts.pciopts.targetIndex); + if (def->opts.pciopts.hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(buf, " hotplug=3D'%s'", + virTristateSwitchTypeToString(def->opts.pcio= pts.hotplug)); + } + if (def->opts.pciopts.numaNode =3D=3D -1) { + virBufferAddLit(buf, "/>\n"); + } else { + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "%d\n", + def->opts.pciopts.numaNode); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + } + + return 0; +} + + static int virDomainControllerDefFormat(virBuffer *buf, virDomainControllerDef *def, @@ -22657,7 +22739,6 @@ virDomainControllerDefFormat(virBuffer *buf, { const char *type =3D virDomainControllerTypeToString(def->type); const char *model =3D NULL; - const char *modelName =3D NULL; g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); @@ -22714,91 +22795,20 @@ virDomainControllerDefFormat(virBuffer *buf, } break; + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + if (virDomainControllerDefFormatPCI(&childBuf, def, flags) < 0) + return -1; + case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: case VIR_DOMAIN_CONTROLLER_TYPE_SATA: case VIR_DOMAIN_CONTROLLER_TYPE_CCID: - case VIR_DOMAIN_CONTROLLER_TYPE_PCI: case VIR_DOMAIN_CONTROLLER_TYPE_ISA: case VIR_DOMAIN_CONTROLLER_TYPE_LAST: break; } - if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { - bool formatModelName =3D true; - - if (def->opts.pciopts.modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_M= ODEL_NAME_NONE) - formatModelName =3D false; - - /* Historically, libvirt didn't support specifying a model name for - * pci-root controllers; starting from 3.6.0, however, pSeries gue= sts - * use pci-root controllers with model name spapr-pci-host-bridge = to - * represent all PHBs, including the default one. - * - * In order to allow migration of pSeries guests from older libvirt - * versions and back, we don't format the model name in the migrat= able - * XML if it's spapr-pci-host-bridge, thus making "no model name" = and - * "spapr-pci-host-bridge model name" basically equivalent. - * - * The spapr-pci-host-bridge device is specific to pSeries. - */ - if (def->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT && - def->opts.pciopts.modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_M= ODEL_NAME_SPAPR_PCI_HOST_BRIDGE && - flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) { - formatModelName =3D false; - } - - if (formatModelName) { - modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected model name value %d"), - def->opts.pciopts.modelName); - return -1; - } - virBufferAsprintf(&childBuf, "\n", modelNa= me); - } - - if (def->opts.pciopts.chassisNr !=3D -1 || - def->opts.pciopts.chassis !=3D -1 || - def->opts.pciopts.port !=3D -1 || - def->opts.pciopts.busNr !=3D -1 || - def->opts.pciopts.targetIndex !=3D -1 || - def->opts.pciopts.numaNode !=3D -1 || - def->opts.pciopts.hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAddLit(&childBuf, "opts.pciopts.chassisNr !=3D -1) - virBufferAsprintf(&childBuf, " chassisNr=3D'%d'", - def->opts.pciopts.chassisNr); - if (def->opts.pciopts.chassis !=3D -1) - virBufferAsprintf(&childBuf, " chassis=3D'%d'", - def->opts.pciopts.chassis); - if (def->opts.pciopts.port !=3D -1) - virBufferAsprintf(&childBuf, " port=3D'0x%x'", - def->opts.pciopts.port); - if (def->opts.pciopts.busNr !=3D -1) - virBufferAsprintf(&childBuf, " busNr=3D'%d'", - def->opts.pciopts.busNr); - if (def->opts.pciopts.targetIndex !=3D -1) - virBufferAsprintf(&childBuf, " index=3D'%d'", - def->opts.pciopts.targetIndex); - if (def->opts.pciopts.hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT)= { - virBufferAsprintf(&childBuf, " hotplug=3D'%s'", - virTristateSwitchTypeToString(def->opts.= pciopts.hotplug)); - } - if (def->opts.pciopts.numaNode =3D=3D -1) { - virBufferAddLit(&childBuf, "/>\n"); - } else { - virBufferAddLit(&childBuf, ">\n"); - virBufferAdjustIndent(&childBuf, 2); - virBufferAsprintf(&childBuf, "%d\n", - def->opts.pciopts.numaNode); - virBufferAdjustIndent(&childBuf, -2); - virBufferAddLit(&childBuf, "\n"); - } - } - } virDomainControllerDriverFormat(&childBuf, def); --=20 2.37.1 From nobody Sat May 18 07:09:13 2024 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=1661516423; cv=none; d=zohomail.com; s=zohoarc; b=SOj1SfG05A3uTY3zvWMGetq8YAWShUq0MZAMOyvi+VmIkrI9prCwyQfaHpy1yhCb/cDv+ZaX8Dh+/GXgd7lLNtrImmyHDJV3QFENZEva1dv0b6CWEfSUcSyHJq2MMd7dax56obSUnMnOVDlOC9wi5DhulKl30FpggeMbrsWhtG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516423; 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=+Njkf1TLJSFmuL0JcSx2z93SeGaD5pEThlGGpGw//po=; b=XYWHS34ucVRKoxtXjwXweT/YPHU8QrIFlmXsVqJ+z4h3KVIFf4RdHrQX2K/icsMp3lodGhfEDDEuxwckHr7RmJqiHU39glzaA6vPktqACIQ83/BXCcufAWhLDwwRl9yNnOEfrdY5heb+RZAMfg9wqNZnBEzFSd1BxSq+rdlwRaA= 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 1661516422982660.1593991827841; Fri, 26 Aug 2022 05:20:22 -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-225-BSj4yWLnN8y4NQGuUvsmlA-1; Fri, 26 Aug 2022 08:20:18 -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 E7C8D185A794; Fri, 26 Aug 2022 12:20:15 +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 D3E7C141510F; Fri, 26 Aug 2022 12:20:15 +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 C3F3A1946A4E; Fri, 26 Aug 2022 12:20:15 +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 135FD1946A43 for ; Fri, 26 Aug 2022 12:20:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 08B9C4010E6E; Fri, 26 Aug 2022 12:20:12 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7241A4042F02 for ; Fri, 26 Aug 2022 12:20:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516421; 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=+Njkf1TLJSFmuL0JcSx2z93SeGaD5pEThlGGpGw//po=; b=igTVFPki3fDlzpXUMMKowYAREEOCP7cQRI62hiJjYpwCCuSGpO3zfVyvUhUAR82HmoctJ6 JcY0hQNfkRA2t54p5sNr6lSJU+YBqm1Vm5agYyRr+XC1NKMQEvHPhzgcrhj8BuAK33Z4yG mYhde9S0EKhZN8foxSGJcF9WCVJnbnA= X-MC-Unique: BSj4yWLnN8y4NQGuUvsmlA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/10] virDomainControllerDefFormatPCI: Refactor formatting of '' subelement Date: Fri, 26 Aug 2022 14:19:59 +0200 Message-Id: <48e79013aba6678bd8a9f14c11ab58e0efcebc28.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.85 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: 1661516424558100002 Content-Type: text/plain; charset="utf-8" Rewrite the code to use virXMLFormat element so that we can avoid a bunch of unnecessary checks. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 56 ++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b2ee4d5979..8573be36d0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22655,6 +22655,8 @@ virDomainControllerDefFormatPCI(virBuffer *buf, virDomainControllerDef *def, unsigned int flags) { + g_auto(virBuffer) targetAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) targetChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); bool formatModelName =3D true; if (def->opts.pciopts.modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL= _NAME_NONE) @@ -22689,45 +22691,25 @@ virDomainControllerDefFormatPCI(virBuffer *buf, virBufferAsprintf(buf, "\n", modelName); } - if (def->opts.pciopts.chassisNr !=3D -1 || - def->opts.pciopts.chassis !=3D -1 || - def->opts.pciopts.port !=3D -1 || - def->opts.pciopts.busNr !=3D -1 || - def->opts.pciopts.targetIndex !=3D -1 || - def->opts.pciopts.numaNode !=3D -1 || - def->opts.pciopts.hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAddLit(buf, "opts.pciopts.chassisNr !=3D -1) - virBufferAsprintf(buf, " chassisNr=3D'%d'", - def->opts.pciopts.chassisNr); - if (def->opts.pciopts.chassis !=3D -1) - virBufferAsprintf(buf, " chassis=3D'%d'", - def->opts.pciopts.chassis); - if (def->opts.pciopts.port !=3D -1) - virBufferAsprintf(buf, " port=3D'0x%x'", - def->opts.pciopts.port); - if (def->opts.pciopts.busNr !=3D -1) - virBufferAsprintf(buf, " busNr=3D'%d'", - def->opts.pciopts.busNr); - if (def->opts.pciopts.targetIndex !=3D -1) - virBufferAsprintf(buf, " index=3D'%d'", - def->opts.pciopts.targetIndex); - if (def->opts.pciopts.hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, " hotplug=3D'%s'", - virTristateSwitchTypeToString(def->opts.pcio= pts.hotplug)); - } - if (def->opts.pciopts.numaNode =3D=3D -1) { - virBufferAddLit(buf, "/>\n"); - } else { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, "%d\n", - def->opts.pciopts.numaNode); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + if (def->opts.pciopts.chassisNr !=3D -1) + virBufferAsprintf(&targetAttrBuf, " chassisNr=3D'%d'", def->opts.p= ciopts.chassisNr); + if (def->opts.pciopts.chassis !=3D -1) + virBufferAsprintf(&targetAttrBuf, " chassis=3D'%d'", def->opts.pci= opts.chassis); + if (def->opts.pciopts.port !=3D -1) + virBufferAsprintf(&targetAttrBuf, " port=3D'0x%x'", def->opts.pcio= pts.port); + if (def->opts.pciopts.busNr !=3D -1) + virBufferAsprintf(&targetAttrBuf, " busNr=3D'%d'", def->opts.pciop= ts.busNr); + if (def->opts.pciopts.targetIndex !=3D -1) + virBufferAsprintf(&targetAttrBuf, " index=3D'%d'", def->opts.pciop= ts.targetIndex); + if (def->opts.pciopts.hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&targetAttrBuf, " hotplug=3D'%s'", + virTristateSwitchTypeToString(def->opts.pciopts.= hotplug)); } + if (def->opts.pciopts.numaNode !=3D -1) + virBufferAsprintf(&targetChildBuf, "%d\n", def->opts.= pciopts.numaNode); + + virXMLFormatElement(buf, "target", &targetAttrBuf, &targetChildBuf); return 0; } --=20 2.37.1 From nobody Sat May 18 07:09:13 2024 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=1661516467; cv=none; d=zohomail.com; s=zohoarc; b=RKwRg2GCqdS1j2fk6lQGs6CP4/Xn9juUzEuyiRFD0yzjPD7Uc3XY+U2HdsLh6ntVwRAi0YkwSem4HTW1VH+MHXbAN2tYE5Xxiow2H+Rj1wUbP1E3lz+FppJjCOFbzHBKeM+veQRukHQrj5H73Iek7yThKLmfjI/zZ/EWh3VebVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516467; 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=ff3k15CRgnw+IbbWsDdnfc4CpHC/pWDtvZ3J5c+gls0=; b=OSXoX7WwvzYfs21aI03EodoLRQQSro4FhUkjbTlOJZUQTo/rOkUqJ86f7r4++N5BnukIa5MS8EGW1gPfITWi6Pcd99SeXsa9vuQUlCTHGMv6jdmZ9SW+oYr7SJK7Zd3Nb6Z2qPYNcGoOp0z46gQbHFviFlf+SrbC0cp2VgjufwI= 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 1661516467513630.4158093345981; Fri, 26 Aug 2022 05:21:07 -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-558-Nx0AI2-nOmC41JymJNi9eA-1; Fri, 26 Aug 2022 08:20:17 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3CE9185A7B2; Fri, 26 Aug 2022 12:20:14 +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 A1340403349; Fri, 26 Aug 2022 12:20:14 +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 852941946A4E; Fri, 26 Aug 2022 12:20:14 +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 79E041946A43 for ; Fri, 26 Aug 2022 12:20:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4DD6240E7F29; Fri, 26 Aug 2022 12:20:13 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA1AD40E7F28 for ; Fri, 26 Aug 2022 12:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516466; 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=ff3k15CRgnw+IbbWsDdnfc4CpHC/pWDtvZ3J5c+gls0=; b=Cw2H0mKGYm5yF0d2GOUYNgTfK/y3rW63ZKiTgTTocVdBTOy4ERimP/9u2ajqGU3oUtBtkm nCre5GfOPBWyp9LyNSYTDFAsmUal32Bz1bVIu3PLwcGQqklmBEcb4P1gnYq1AFgarFroIe aH6t1CcShw3KYgvTLJ7hHclKIKSiVGM= X-MC-Unique: Nx0AI2-nOmC41JymJNi9eA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/10] virDomainControllerDefParseXML: Fix broken code indentation when parsing PCI contoller target Date: Fri, 26 Aug 2022 14:20:00 +0200 Message-Id: <9a5a6cfe08bce400912ce6e5369bd2338038a59a.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.85 on 10.11.54.10 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: 1661516468686100001 Content-Type: text/plain; charset="utf-8" Code was not indented properly for one of the nested conditions. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 56 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8573be36d0..3ff9fffba8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8208,40 +8208,40 @@ virDomainControllerDefParseXML(virDomainXMLOption *= xmlopt, ntargetNodes =3D virXPathNodeSet("./target", ctxt, &targetNodes); if (ntargetNodes =3D=3D 1) { if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { - if (virXMLPropInt(targetNodes[0], "chassisNr", 0, VIR_XML_PROP_NON= E, - &def->opts.pciopts.chassisNr, - def->opts.pciopts.chassisNr) < 0) - return NULL; + if (virXMLPropInt(targetNodes[0], "chassisNr", 0, VIR_XML_PROP= _NONE, + &def->opts.pciopts.chassisNr, + def->opts.pciopts.chassisNr) < 0) + return NULL; - if (virXMLPropInt(targetNodes[0], "chassis", 0, VIR_XML_PROP_NONE, - &def->opts.pciopts.chassis, - def->opts.pciopts.chassis) < 0) - return NULL; + if (virXMLPropInt(targetNodes[0], "chassis", 0, VIR_XML_PROP_N= ONE, + &def->opts.pciopts.chassis, + def->opts.pciopts.chassis) < 0) + return NULL; - if (virXMLPropInt(targetNodes[0], "port", 0, VIR_XML_PROP_NONE, - &def->opts.pciopts.port, - def->opts.pciopts.port) < 0) - return NULL; + if (virXMLPropInt(targetNodes[0], "port", 0, VIR_XML_PROP_NONE, + &def->opts.pciopts.port, + def->opts.pciopts.port) < 0) + return NULL; - if (virXMLPropInt(targetNodes[0], "busNr", 0, VIR_XML_PROP_NONE, - &def->opts.pciopts.busNr, - def->opts.pciopts.busNr) < 0) - return NULL; + if (virXMLPropInt(targetNodes[0], "busNr", 0, VIR_XML_PROP_NON= E, + &def->opts.pciopts.busNr, + def->opts.pciopts.busNr) < 0) + return NULL; - if (virXMLPropTristateSwitch(targetNodes[0], "hotplug", - VIR_XML_PROP_NONE, - &def->opts.pciopts.hotplug) < 0) - return NULL; + if (virXMLPropTristateSwitch(targetNodes[0], "hotplug", + VIR_XML_PROP_NONE, + &def->opts.pciopts.hotplug) < 0) + return NULL; - if ((rc =3D virXMLPropInt(targetNodes[0], "index", 0, VIR_XML_PROP= _NONE, - &def->opts.pciopts.targetIndex, - def->opts.pciopts.targetIndex)) < 0) - return NULL; + if ((rc =3D virXMLPropInt(targetNodes[0], "index", 0, VIR_XML_= PROP_NONE, + &def->opts.pciopts.targetIndex, + def->opts.pciopts.targetIndex)) < 0) + return NULL; - if ((rc =3D=3D 1) && def->opts.pciopts.targetIndex =3D=3D -1) - virReportError(VIR_ERR_XML_ERROR, - _("Invalid target index '%i' in PCI controller"= ), - def->opts.pciopts.targetIndex); + if ((rc =3D=3D 1) && def->opts.pciopts.targetIndex =3D=3D -1) + virReportError(VIR_ERR_XML_ERROR, + _("Invalid target index '%i' in PCI control= ler"), + def->opts.pciopts.targetIndex); } } else if (ntargetNodes > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", --=20 2.37.1 From nobody Sat May 18 07:09:13 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=1661516423; cv=none; d=zohomail.com; s=zohoarc; b=gqO13RBe5bh29kHSvifKiAAfqg18qGcuBMdmaMWL/z+OHbDUhk3EdBWy1v258pRtV1uOyW8I7BCN2+LH1p8deoAdo8mK1a8QahtzuhAX9xdGpZwJ5vc07CshnHweWA29ayrJLJn2RTWZeZUhXLpUcmad+t6m3gBmu1WWT7FeU/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516423; 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=9U4F7rxKPpUGAEjEYpzjaCp2J4y2tesjSPymK1zMtVY=; b=Y/JR/lkQx8uWRV1txdnVlB3y1To5UK4VGkJe7A5qp6YIL/aCvD2jbt9cmGGjzCRHAE4vEM0BEIqxmjFIiErMsp4R99FCRcLlCL+EKF4phJf/qB3HnebzX/fUK/j08YkTi/bqOdI+uA7IZimjBPYF6DZCEKv066z73ZPoWqFxqrc= 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 16615164236481017.6604919338729; Fri, 26 Aug 2022 05:20:23 -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-672-7QKjmo4JM8WefxXVO7_h5A-1; Fri, 26 Aug 2022 08:20:18 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F28F3811E76; Fri, 26 Aug 2022 12:20:15 +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 DFFEA492C3B; Fri, 26 Aug 2022 12:20:15 +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 D16751946A5B; Fri, 26 Aug 2022 12:20:15 +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 57BBF1946A43 for ; Fri, 26 Aug 2022 12:20:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 48AAC400EA8F; Fri, 26 Aug 2022 12:20:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB89B40E7F28 for ; Fri, 26 Aug 2022 12:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516422; 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=9U4F7rxKPpUGAEjEYpzjaCp2J4y2tesjSPymK1zMtVY=; b=XmTd8H7m28SisgcIpvhUAbYWW7Jem13ZsJoSuC32FqEynfdFJ8V9aiTuUqpWZkXYCTHhMf DLzFWg6OZu6u3hzEDRHAJo1S0zqeo621Zzu/msD/YuWvXMgJaTaeYBWnJ97omOY4YT4kn+ 2mWPl8ZHVdr4yCmiNixRNSFxtKz6C7I= X-MC-Unique: 7QKjmo4JM8WefxXVO7_h5A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/10] virDomainControllerDefParseXML: Fix broken error reporting when parsing 'index' Date: Fri, 26 Aug 2022 14:20:01 +0200 Message-Id: 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.85 on 10.11.54.10 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: 1661516424538100001 Content-Type: text/plain; charset="utf-8" The code attempted to report an error if the user added the 'index' attribute to the 'target' element, but neglected to actually return an error code. Fix it by using the VIR_XML_PROP_NONNEGATIVE flag for virXMLPropInt which refuses user passed negative numbers. Fixes: 020dd80ecbd Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3ff9fffba8..a9a2afc7f1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8233,15 +8233,10 @@ virDomainControllerDefParseXML(virDomainXMLOption *= xmlopt, &def->opts.pciopts.hotplug) < 0) return NULL; - if ((rc =3D virXMLPropInt(targetNodes[0], "index", 0, VIR_XML_= PROP_NONE, - &def->opts.pciopts.targetIndex, - def->opts.pciopts.targetIndex)) < 0) + if (virXMLPropInt(targetNodes[0], "index", 0, VIR_XML_PROP_NON= NEGATIVE, + &def->opts.pciopts.targetIndex, + def->opts.pciopts.targetIndex) < 0) return NULL; - - if ((rc =3D=3D 1) && def->opts.pciopts.targetIndex =3D=3D -1) - virReportError(VIR_ERR_XML_ERROR, - _("Invalid target index '%i' in PCI control= ler"), - def->opts.pciopts.targetIndex); } } else if (ntargetNodes > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", --=20 2.37.1 From nobody Sat May 18 07:09:13 2024 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=1661516472; cv=none; d=zohomail.com; s=zohoarc; b=MCdK7/qMYAAselTgUBrBK5cHtf7dABOmTGaO+yFiC06DoBmPZNrGTZ6/DompCtif4ncYkQMsliHY6N9NjTgt97LZtBITcEVz7xmtgGqRS9A+jBadjf5rrfCd8ENxOTZUAr27ISopWe7l+t57PNYXuvyD0oKNsRWTIdONH6iMiZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516472; 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=q1xiujUfMXWyiZNBwt1AnOBPe79qu+JfTmjnIcnNaAk=; b=lvtpYhUjfs8A8ruoCD88oZrbs7VLcG0Ng6NTPQpkPuw43/6xBylphomMQqSHvuh1s0c4BCTzBw4ENCS1aVdKR5sWAX2CSK27uKGv0F1o6CmwzfWDiSlCObR2sCgacWd9sJcXmXV9xKydIpvVZTToIqWW8H/6PK8tr9OAxrJMyQA= 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 1661516472380523.1405121313855; Fri, 26 Aug 2022 05:21:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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-587-xZHtgNdROty-xvQZlpbzxw-1; Fri, 26 Aug 2022 08:20:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 047151C05B0A; Fri, 26 Aug 2022 12:20:19 +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 D8403C15D67; Fri, 26 Aug 2022 12:20:18 +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 C5E2B1946A5A; Fri, 26 Aug 2022 12:20:18 +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 64D531946A43 for ; Fri, 26 Aug 2022 12:20:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5BC1A40E7F28; Fri, 26 Aug 2022 12:20:15 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A634340B40CB for ; Fri, 26 Aug 2022 12:20:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516471; 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=q1xiujUfMXWyiZNBwt1AnOBPe79qu+JfTmjnIcnNaAk=; b=Uwqs4qkiA8oKxvJn+gV0yhIkJI0k8246t/KlXqiD03Z6/zaX4OJ8LzmBKU5ahWuYiWuznu yedTL0sqCdRdcxdHeDGkflAO34tUhVkU+9+kxQylAgOdCHQTM/vQZOU1YIwirip1wc0ux1 8Unplgf/vyGZ2Kz45RVxEW9Gng90yzk= X-MC-Unique: xZHtgNdROty-xvQZlpbzxw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/10] virDomainControllerDefParseXML: Remove explicit checks for negative value Date: Fri, 26 Aug 2022 14:20:02 +0200 Message-Id: <4dc479bbb1961adab6c502c9337463d9f55aec3e.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.85 on 10.11.54.8 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: 1661516472664100005 Content-Type: text/plain; charset="utf-8" Refactor all cases which use virXMLPropInt and then subsequently check that the parsed value is not '-1'/negative by using the VIR_XML_PROP_NONNEG= ATIVE flag for virXMLPropInt. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 46 +++++++++--------------------------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a9a2afc7f1..77cb5f1456 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8263,27 +8263,15 @@ virDomainControllerDefParseXML(virDomainXMLOption *= xmlopt, return NULL; } - if ((rc =3D virXMLPropInt(node, "ports", 10, VIR_XML_PROP_NONE, &ports= , -1)) < 0) + if (virXMLPropInt(node, "ports", 10, VIR_XML_PROP_NONNEGATIVE, &ports,= -1) < 0) return NULL; - if ((rc =3D=3D 1) && ports < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid ports: %i"), ports); - return NULL; - } switch (def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: { - if ((rc =3D virXMLPropInt(node, "vectors", 10, VIR_XML_PROP_NONE, - &def->opts.vioserial.vectors, - def->opts.vioserial.vectors)) < 0) - return NULL; - - if ((rc =3D=3D 1) && def->opts.vioserial.vectors < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid vectors: %i"), - def->opts.vioserial.vectors); + if (virXMLPropInt(node, "vectors", 10, VIR_XML_PROP_NONNEGATIVE, + &def->opts.vioserial.vectors, + def->opts.vioserial.vectors) < 0) return NULL; - } def->opts.vioserial.ports =3D ports; break; @@ -8345,29 +8333,15 @@ virDomainControllerDefParseXML(virDomainXMLOption *= xmlopt, break; case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: { - if ((rc =3D virXMLPropInt(node, "maxGrantFrames", 10, VIR_XML_PROP= _NONE, - &def->opts.xenbusopts.maxGrantFrames, - def->opts.xenbusopts.maxGrantFrames)) < 0) + if (virXMLPropInt(node, "maxGrantFrames", 10, VIR_XML_PROP_NONNEGA= TIVE, + &def->opts.xenbusopts.maxGrantFrames, + def->opts.xenbusopts.maxGrantFrames) < 0) return NULL; - if ((rc =3D=3D 1) && def->opts.xenbusopts.maxGrantFrames < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid maxGrantFrames: %i"), - def->opts.xenbusopts.maxGrantFrames); + if (virXMLPropInt(node, "maxEventChannels", 10, VIR_XML_PROP_NONNE= GATIVE, + &def->opts.xenbusopts.maxEventChannels, + def->opts.xenbusopts.maxEventChannels) < 0) return NULL; - } - - if ((rc =3D virXMLPropInt(node, "maxEventChannels", 10, VIR_XML_PR= OP_NONE, - &def->opts.xenbusopts.maxEventChannels, - def->opts.xenbusopts.maxEventChannels)) < = 0) - return NULL; - - if ((rc =3D=3D 1) && def->opts.xenbusopts.maxEventChannels < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid maxEventChannels: %i"), - def->opts.xenbusopts.maxEventChannels); - return NULL; - } break; } --=20 2.37.1 From nobody Sat May 18 07:09:13 2024 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 Reviewed-by: J=C3=A1n Tomko --- 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 From nobody Sat May 18 07:09:13 2024 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=1661516433; cv=none; d=zohomail.com; s=zohoarc; b=JquqRsp5p51REr7cunRmaHKVVIWW5rmhGEjOAtJeY7o8dKhkFfMlRKHRoPd1CKZGXULviz1Y2n6c0bzh3gL32awe7KnFEYcdga56DIczwU4JJHQwnQSKuoJdNtFVCiDOl/LfQFjAAAuEuKHgfYGnvQGlQ/uItz1jYIrIsg3MuNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516433; 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=tBI8NAR0LlX7ZL8KsqJNELO4t618CjK61HsxTG9q1hc=; b=WTyL5DACo+H3qA7mIQN6iId1MD/gjx5tOprv7E5ZkwpMCWd6fVLEJA8Q/AyyqGn2fUdYszgUauECdGRRvhfCRqlLXE5/wSC0GMQ4SghDi7XhyyBlptt8pLd3cVPYB4n0dLjb8InOAqVZvcdrlEzNz/IEJaAPqslfOoO3kvXI14s= 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 1661516433802312.97578095874576; Fri, 26 Aug 2022 05:20:33 -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-437-LDFa7N-SPXqKRApw4YpqPQ-1; Fri, 26 Aug 2022 08:20:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6A6180231E; Fri, 26 Aug 2022 12:20:18 +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 91B202166B29; Fri, 26 Aug 2022 12:20:18 +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 72D861946A4E; Fri, 26 Aug 2022 12:20:18 +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 65FDC1946A43 for ; Fri, 26 Aug 2022 12:20:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5CA0F400EA8F; Fri, 26 Aug 2022 12:20:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA9C540CF916 for ; Fri, 26 Aug 2022 12:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516432; 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=tBI8NAR0LlX7ZL8KsqJNELO4t618CjK61HsxTG9q1hc=; b=Pmlfw2aisoUr5yQyuqO94gMwhDXDSQWxKEimSxYLsQN1nRqDkaFKgv8foVim8nzOHwrFuw irLOEWygenjIsEsBlUQIs9RFPvkvbFuP7RrU+deYZPyZScrcxAHMutCACjjOgswzFC+5wF v0W8nOjS5LFlMu5KFnV90Sl2idoUXzE= X-MC-Unique: LDFa7N-SPXqKRApw4YpqPQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/10] virDomainControllerDefParseXML: Return early if there's unexpectedly many elements Date: Fri, 26 Aug 2022 14:20:04 +0200 Message-Id: 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.78 on 10.11.54.6 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: 1661516434772100001 Content-Type: text/plain; charset="utf-8" Move some checks earlier so that they are not tucked at the back of the block of code doing the actual parsing. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 70672c83ce..a4384f9d13 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8181,7 +8181,12 @@ virDomainControllerDefParseXML(virDomainXMLOption *x= mlopt, return NULL; } - nmodelNodes =3D virXPathNodeSet("./model", ctxt, &modelNodes); + if ((nmodelNodes =3D virXPathNodeSet("./model", ctxt, &modelNodes)) > = 1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Multiple elements in controller definiti= on not allowed")); + return NULL; + } + if (nmodelNodes =3D=3D 1) { if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { if (virXMLPropEnum(modelNodes[0], "name", @@ -8190,14 +8195,14 @@ virDomainControllerDefParseXML(virDomainXMLOption *= xmlopt, &def->opts.pciopts.modelName) < 0) return NULL; } - } else if (nmodelNodes > 1) { + } + + if ((ntargetNodes =3D virXPathNodeSet("./target", ctxt, &targetNodes))= > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("Multiple elements in " - "controller definition not allowed")); + _("Multiple elements in controller definit= ion not allowed")); return NULL; } - ntargetNodes =3D virXPathNodeSet("./target", ctxt, &targetNodes); if (ntargetNodes =3D=3D 1) { if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { if (virXMLPropInt(targetNodes[0], "chassisNr", 0, VIR_XML_PROP= _NONE, @@ -8230,11 +8235,6 @@ virDomainControllerDefParseXML(virDomainXMLOption *x= mlopt, def->opts.pciopts.targetIndex) < 0) return NULL; } - } else if (ntargetNodes > 1) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Multiple elements in " - "controller definition not allowed")); - return NULL; } /* node is parsed differently from target attributes because --=20 2.37.1 From nobody Sat May 18 07:09:13 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=1661516464; cv=none; d=zohomail.com; s=zohoarc; b=fI7loInA6y0w+b0e+KSrkGpqTkJRjM/FXpxatFhAKjU1QZ3eqqWQm5MIxwbWtCRktSI525L8gJ8TXKZlHpajJKgm6S0HXNHk7unu0fIJ/uD2t2XcBSVlKhoXu7kq+hpzlW9JK+TIGkXVtEll9lbBKBZPsFMhlM+idYBzL9/kMQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661516464; 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=HjnqPGbYD1SFmiozocdTws3eV65NHPB9Z4DuTkJISXc=; b=LvFqonBW7fTyH5uhjU48vQeoAZudwcNJbJ4EgqyQJTsTkrPTizIZyKqxxsZKXZx5f5F3+Aq9OQ7NaoTC7htQkiLiV82qHMt5vG4xkBl8BhVaM18/8y+vZvlZBPo8ae2otW67e38bmtm7R+xglf2PEWlNaI0E0FS4c5FAlBMVRa8= 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 1661516464049135.496472844531; Fri, 26 Aug 2022 05:21:04 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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-448-YqsSUhwgMkqskjmun4gbnA-1; Fri, 26 Aug 2022 08:20:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 608CD3800C20; Fri, 26 Aug 2022 12:20:21 +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 4DE172166B29; Fri, 26 Aug 2022 12:20:21 +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 3CB631946A4E; Fri, 26 Aug 2022 12:20:21 +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 5ECAD1946A43 for ; Fri, 26 Aug 2022 12:20:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5514240E7F28; Fri, 26 Aug 2022 12:20:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B820640CF916 for ; Fri, 26 Aug 2022 12:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661516463; 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=HjnqPGbYD1SFmiozocdTws3eV65NHPB9Z4DuTkJISXc=; b=N1s2fOO4cZ16Fyrz69otofN+nOMsRgvcyJpiHRLbaqoX4I3eWxgoWm2Qd/Of0ZrHKbsZQ/ DJFEiuhK6FHCoKwBWHN6uHBYL+GEE9/BvZI4B36PRvkBEKzW1P/laAUeQlaoQHiVP9AM9L vbCvxE2Z8i3fF2fwGz72CdoCL16eWu0= X-MC-Unique: YqsSUhwgMkqskjmun4gbnA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/10] virDomainControllerDefParseXML: Reject '-1' for PCI controller target properties Date: Fri, 26 Aug 2022 14:20:05 +0200 Message-Id: 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.78 on 10.11.54.6 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: 1661516464637100001 Content-Type: text/plain; charset="utf-8" All of the properties use '-1' as default and the code omits formatting them when the property is '-1'. Additionally subsequent validation code rejects all other negative values anyways. Since we've never formatted '-1' into an XML formatted by libvirt we can make the parser more strict, as we will never fail to parse existing on-disk libvirt-owned XMLs. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2121627 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a4384f9d13..65afebbfde 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8205,22 +8205,22 @@ virDomainControllerDefParseXML(virDomainXMLOption *= xmlopt, if (ntargetNodes =3D=3D 1) { if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { - if (virXMLPropInt(targetNodes[0], "chassisNr", 0, VIR_XML_PROP= _NONE, + if (virXMLPropInt(targetNodes[0], "chassisNr", 0, VIR_XML_PROP= _NONNEGATIVE, &def->opts.pciopts.chassisNr, def->opts.pciopts.chassisNr) < 0) return NULL; - if (virXMLPropInt(targetNodes[0], "chassis", 0, VIR_XML_PROP_N= ONE, + if (virXMLPropInt(targetNodes[0], "chassis", 0, VIR_XML_PROP_N= ONNEGATIVE, &def->opts.pciopts.chassis, def->opts.pciopts.chassis) < 0) return NULL; - if (virXMLPropInt(targetNodes[0], "port", 0, VIR_XML_PROP_NONE, + if (virXMLPropInt(targetNodes[0], "port", 0, VIR_XML_PROP_NONN= EGATIVE, &def->opts.pciopts.port, def->opts.pciopts.port) < 0) return NULL; - if (virXMLPropInt(targetNodes[0], "busNr", 0, VIR_XML_PROP_NON= E, + if (virXMLPropInt(targetNodes[0], "busNr", 0, VIR_XML_PROP_NON= NEGATIVE, &def->opts.pciopts.busNr, def->opts.pciopts.busNr) < 0) return NULL; --=20 2.37.1