From nobody Sun Feb 8 23:04:03 2026 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=1614795542; cv=none; d=zohomail.com; s=zohoarc; b=IWJuEq/2UwJPw4ZlZywShhaxSMMaGewe2J0YmgXREBQt1ozlRgcDGZkt70pkTZz7Lz+iFrtsMU4WNL6UUdqZUISJsxRghiNE9EObnb2hL/YfB4X1KT/E8Qvb8L254p6HNGR9bl146mucUiMsjGPtGfU83zHHd1PnK1vQ96k63C8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614795542; 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=/+JhV/czoEXwQWvho7ZRtdRAx/c1gYx8yahsFwn1WY8=; b=irYpCIRiM/+kBBnbm+lTtaUF/Lrvsn3maY1DRyDeOr5pwlpYMUJS7WERkK+T04uXTPzj0t521zKj15A/XtLjvvCepZnUDnUuijJcjIn7aBjJZ9SYinj8mUV4NcX14AG6LDwMjGm1AgxGRypbB6vv+aK3IGKKRdUHKAt68gUtZKw= 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) header.from= 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 1614795542394336.76596703960195; Wed, 3 Mar 2021 10:19:02 -0800 (PST) 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-44-n2DCk3mXPyKwbJyf2YTR8A-1; Wed, 03 Mar 2021 13:18:58 -0500 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 6204E18C35BF; Wed, 3 Mar 2021 18:18:53 +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 13A135D9C6; Wed, 3 Mar 2021 18:18:53 +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 D4F9D18095CB; Wed, 3 Mar 2021 18:18:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 123IImD0032355 for ; Wed, 3 Mar 2021 13:18:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9E96560C13; Wed, 3 Mar 2021 18:18:48 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-145.ams2.redhat.com [10.36.115.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBAED60BFA; Wed, 3 Mar 2021 18:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614795541; 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=/+JhV/czoEXwQWvho7ZRtdRAx/c1gYx8yahsFwn1WY8=; b=GcxNQhSf5YsI8JB76kYwxep4Ea9iaiCC/1yR0L6cX1ADJROnBzb+LXetN7t85K714qGm6G NYJJ8CbFJ1vvbObp0hSA6hi6YDD7Ocnw4EOb/lUZ4MpJ+kgDXJYQiYo8VoY4VAOW19d0Kr 1+0DPv4XE+mU8Mu/tBTXfP4m2Bpsy+Y= X-MC-Unique: n2DCk3mXPyKwbJyf2YTR8A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 02/18] conf: stronger error reporting when parsing audio related params Date: Wed, 3 Mar 2021 18:18:18 +0000 Message-Id: <20210303181834.1578756-3-berrange@redhat.com> In-Reply-To: <20210303181834.1578756-1-berrange@redhat.com> References: <20210303181834.1578756-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Check for varuous mandatory elements and improve error message clarity Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b731744f04..d30ca627aa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13794,6 +13794,11 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xm= lopt, if (audioNode) { g_autofree char *tmp =3D NULL; tmp =3D virXMLPropString(audioNode, "id"); + if (!tmp) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing audio 'id' attribute")); + goto error; + } if (virStrToLong_ui(tmp, NULL, 10, &def->audioId) < 0 || def->audioId =3D=3D 0) { virReportError(VIR_ERR_XML_ERROR, @@ -13867,6 +13872,12 @@ virDomainAudioDefParseXML(virDomainXMLOptionPtr xm= lopt G_GNUC_UNUSED, ctxt->node =3D node; =20 type =3D virXMLPropString(node, "type"); + if (!type) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing audio 'type' attribute")); + goto error; + } + if ((def->type =3D virDomainAudioTypeTypeFromString(type)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown audio type '%s'"), type); @@ -13874,6 +13885,11 @@ virDomainAudioDefParseXML(virDomainXMLOptionPtr xm= lopt G_GNUC_UNUSED, } =20 tmp =3D virXMLPropString(node, "id"); + if (!tmp) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("missing audio 'id' attribute")); + goto error; + } if (virStrToLong_ui(tmp, NULL, 10, &def->id) < 0 || def->id =3D=3D 0) { virReportError(VIR_ERR_XML_ERROR, --=20 2.29.2