From nobody Sun May 5 23:56:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1573768770; cv=none; d=zoho.com; s=zohoarc; b=krsw4eoCrH/5xEIGIPh9KQLfeJtqSO3ap8wESvwDqZzwtqDfr/rTWqV2RyR/HiSbQkysPfN4rmJOJ2F9KEP7ehGucBPlsN2RresWqyFmfrUZe2SNy73U8UbDFQ1fE69NTE9jqRGir6Yz+MhNxcb6HbYPnG0hf6NCHX+ik0IDOUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573768770; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KTeTZGMQJdiXQduXKwavYSit8sIf8ODpcbYzZwrLbu8=; b=SjTF52udeFEU74jDFkNUCuGTWcSZik1vB4/6oNvJBpmtkZbvCEWmQLSWUmgiEQHfFKNYbHnq4qcUb/nlS3lFNrzIaZIV+1ELoVlF22aHo+TSTXa86+1m7788y8U7GqcCs+drdLt4lpJC8WHCTzJwMXAY/qtEvGA4lfPBFN16CUw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1573768770599636.8416309681639; Thu, 14 Nov 2019 13:59:30 -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-30-u6A8HS0oPgOlAF6BGHxbcg-1; Thu, 14 Nov 2019 16:59:28 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22031108BD12; Thu, 14 Nov 2019 21:59:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F236FA7E3; Thu, 14 Nov 2019 21:59:22 +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 B089B4BB78; Thu, 14 Nov 2019 21:59:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAELxL7g017627 for ; Thu, 14 Nov 2019 16:59:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 904AE10246F4; Thu, 14 Nov 2019 21:59:21 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 546C0101F967; Thu, 14 Nov 2019 21:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573768769; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=KTeTZGMQJdiXQduXKwavYSit8sIf8ODpcbYzZwrLbu8=; b=WCpKW/rLhgex31b0685Kv1mPZfM+d/o83mrfwNrZWxNRnugPOq6wyWkVcdYa+oEXKxZEHo nqYteNMy4z+C8+Km9iAU7Gqx92YPWiy8gjhicBuVBcsmvXZrXmuIacnebBNId6A3wtxdpN PD7d/NTfOVngCCsmmbyMApm4ZBuMfYE= From: Jonathon Jongsma To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 15:59:14 -0600 Message-Id: <20191114215917.25513-2-jjongsma@redhat.com> In-Reply-To: <20191114215917.25513-1-jjongsma@redhat.com> References: <20191114215917.25513-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: crobinso@redhat.com Subject: [libvirt] [PATCH v3 1/4] conf: iterate video model children in parent function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: u6A8HS0oPgOlAF6BGHxbcg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Previously, we were passing the video "model" node to the "acceleration" and "resolution" parsing functions and requiring them to iterate over the children to discover and parse the appropriate node. It makes more sense to move this responsibility up to the parent function and just pass these functions the node that needs to be parsed. Signed-off-by: Jonathon Jongsma Reviewed-by: Cole Robinson --- src/conf/domain_conf.c | 45 +++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 561e25ff6e..5c86729258 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15259,25 +15259,15 @@ virDomainVideoDefaultType(const virDomainDef *def) static virDomainVideoAccelDefPtr virDomainVideoAccelDefParseXML(xmlNodePtr node) { - xmlNodePtr cur; g_autofree virDomainVideoAccelDefPtr def =3D NULL; int val; g_autofree char *accel2d =3D NULL; g_autofree char *accel3d =3D NULL; g_autofree char *rendernode =3D NULL; =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (!accel3d && !accel2d && - virXMLNodeNameEqual(cur, "acceleration")) { - accel3d =3D virXMLPropString(cur, "accel3d"); - accel2d =3D virXMLPropString(cur, "accel2d"); - rendernode =3D virXMLPropString(cur, "rendernode"); - } - } - cur =3D cur->next; - } + accel3d =3D virXMLPropString(node, "accel3d"); + accel2d =3D virXMLPropString(node, "accel2d"); + rendernode =3D virXMLPropString(node, "rendernode"); =20 if (!accel3d && !accel2d && !rendernode) return NULL; @@ -15312,22 +15302,12 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) static virDomainVideoResolutionDefPtr virDomainVideoResolutionDefParseXML(xmlNodePtr node) { - xmlNodePtr cur; g_autofree virDomainVideoResolutionDefPtr def =3D NULL; g_autofree char *x =3D NULL; g_autofree char *y =3D NULL; =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (!x && !y && - virXMLNodeNameEqual(cur, "resolution")) { - x =3D virXMLPropString(cur, "x"); - y =3D virXMLPropString(cur, "y"); - } - } - cur =3D cur->next; - } + x =3D virXMLPropString(node, "x"); + y =3D virXMLPropString(node, "y"); =20 if (!x || !y) return NULL; @@ -15415,6 +15395,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml= opt, if (cur->type =3D=3D XML_ELEMENT_NODE) { if (!type && !vram && !ram && !heads && virXMLNodeNameEqual(cur, "model")) { + xmlNodePtr child; type =3D virXMLPropString(cur, "type"); ram =3D virXMLPropString(cur, "ram"); vram =3D virXMLPropString(cur, "vram"); @@ -15427,8 +15408,18 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm= lopt, VIR_FREE(primary); } =20 - def->accel =3D virDomainVideoAccelDefParseXML(cur); - def->res =3D virDomainVideoResolutionDefParseXML(cur); + child =3D cur->children; + while (child !=3D NULL) { + if (child->type =3D=3D XML_ELEMENT_NODE) { + if (def->accel =3D=3D NULL && + virXMLNodeNameEqual(child, "acceleration")) + def->accel =3D virDomainVideoAccelDefParseXML(= child); + if (def->res =3D=3D NULL && + virXMLNodeNameEqual(child, "resolution")) + def->res =3D virDomainVideoResolutionDefParseX= ML(child); + } + child =3D child->next; + } } if (virXMLNodeNameEqual(cur, "driver")) { if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:56:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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=1573768809; cv=none; d=zoho.com; s=zohoarc; b=hLF3xHWe5YPcQqkpeNWRrhXyqOhLgPhfuP8sgItTyHSd8aFQ+CFntArJ1iTWaliJNDqsGLEEus9wrZgJlHh7Op6q8cywjoYE+0yFeSXQ/UVLrrRHMc6lxSa7TpZc5u+pFJ/3gvc77SrOS3mBmveEKGe4zYiSlIAJEj/kzRuitSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573768809; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=spwMrzzI7eXCheS4PF7EGz7G0S6MWuNAW0RO7cNFeO0=; b=DHCgcQ6fit1O2FGsor6YjGu2/3Ki06m3L4HNqJcwyDWYni8sLgdYYpb/jUKcxtzZ/j4yAvwUtpas7xi6Lv39PDWwX2WeU9UOdn+17vxc4axcofESGI/lSGLUWDHxa37NWRoK6IjpptOlTRtz3ElOqzMrFKWU9EU2iDvmHptqLhI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573768809691542.1102442203309; Thu, 14 Nov 2019 14:00:09 -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-93-1nvtf7c0N72Q5L8K6OXLbg-1; Thu, 14 Nov 2019 17:00:06 -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 766951802CE3; Thu, 14 Nov 2019 21:59:57 +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 50B295E261; Thu, 14 Nov 2019 21:59:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1424A180887A; Thu, 14 Nov 2019 21:59:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAELxLrM017633 for ; Thu, 14 Nov 2019 16:59:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id E8B6410246F4; Thu, 14 Nov 2019 21:59:21 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD0BD101F967; Thu, 14 Nov 2019 21:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573768808; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=spwMrzzI7eXCheS4PF7EGz7G0S6MWuNAW0RO7cNFeO0=; b=RjxUH1szaPjFCbfxAlC4U30lXkgRrCN39aVS3gS9l1AerNHOYan/vylX04/GKLGXPb8U4I Le8c8wB2sRXROcr09E22Do3Z6AKhXbGggWV3/N8a9e87h0ArBHGMErMC9NHNVz/fu3WED/ 4dsRoZvo2PieDAf67+VpSv2zI57Z0ek= From: Jonathon Jongsma To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 15:59:15 -0600 Message-Id: <20191114215917.25513-3-jjongsma@redhat.com> In-Reply-To: <20191114215917.25513-1-jjongsma@redhat.com> References: <20191114215917.25513-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: crobinso@redhat.com Subject: [libvirt] [PATCH v3 2/4] conf: report errors when parsing video resolution 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 X-MC-Unique: 1nvtf7c0N72Q5L8K6OXLbg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The current code doesn't properly handle errors when parsing a video device's resolution. We were returning a NULL structure for the case where 'x' or 'y' were missing. But for the other error cases, we were logging an error (virReportError()), but still returning an under-specified structure. That under-specified structure was used by the calling function rather than properly reporting an error. This patch changes the parse function to return NULL on any parsing error and changes the calling function to report an error when NULL is returned. Signed-off-by: Jonathon Jongsma Reviewed-by: Cole Robinson --- src/conf/domain_conf.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5c86729258..b0599c7318 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15309,24 +15309,26 @@ virDomainVideoResolutionDefParseXML(xmlNodePtr no= de) x =3D virXMLPropString(node, "x"); y =3D virXMLPropString(node, "y"); =20 - if (!x || !y) + if (!x || !y) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("missing values for resolution")); return NULL; + } =20 def =3D g_new0(virDomainVideoResolutionDef, 1); =20 if (virStrToLong_uip(x, NULL, 10, &def->x) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot parse video x-resolution '%s'"), x); - goto cleanup; + return NULL; } =20 if (virStrToLong_uip(y, NULL, 10, &def->y) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot parse video y-resolution '%s'"), y); - goto cleanup; + return NULL; } =20 - cleanup: return g_steal_pointer(&def); } =20 @@ -15415,8 +15417,10 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm= lopt, virXMLNodeNameEqual(child, "acceleration")) def->accel =3D virDomainVideoAccelDefParseXML(= child); if (def->res =3D=3D NULL && - virXMLNodeNameEqual(child, "resolution")) - def->res =3D virDomainVideoResolutionDefParseX= ML(child); + virXMLNodeNameEqual(child, "resolution")) { + if ((def->res =3D virDomainVideoResolutionDefP= arseXML(child)) =3D=3D NULL) + goto error; + } } child =3D child->next; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:56:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1573768812; cv=none; d=zoho.com; s=zohoarc; b=OfcauxM1wAFCweFbUzsSiJqk7HZXD5mybABa9Il76wdxWiQXYodsMqf/h+ID4zdxK/dwaVg/bL86QNNI9NmEYDsI7QaJKiEyLVDGgWMktHSbehDPzoEfnBhYVIOfLH/hAsi5WWDImL/tu+ZKj8gcVvpMTTjByx/vgOSRYrQAGx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573768812; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kRhT/QabQHx3VxYo6bOqHEo952nXgvvB/56yrn2MsNM=; b=F8ReJ9mqIghrmWKekzpIB5uMUtD3UPMpt4beuDUVTD3NuczuaY16HhpAVCQVMM+OhMmYBjYQ/AGFnhhMlb8no5aMs1jgx3oWCaZqr12ybfWJl+kTTsxiWlV6/oyAPER6kI4ocz5/AYQ/X3wtUAGwNNkQbAewQMlO/uKPThHry/4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1573768812982849.6542478216388; Thu, 14 Nov 2019 14:00:12 -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-400-raOeIMhaOMmdjULVYfeBdg-1; Thu, 14 Nov 2019 17:00:06 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4960800EBE; Thu, 14 Nov 2019 22:00:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CB24A7E3; Thu, 14 Nov 2019 22:00:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 48C8D180880D; Thu, 14 Nov 2019 22:00:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAELxMDK017640 for ; Thu, 14 Nov 2019 16:59:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 54E571036C75; Thu, 14 Nov 2019 21:59:22 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1172410016EB; Thu, 14 Nov 2019 21:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573768810; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kRhT/QabQHx3VxYo6bOqHEo952nXgvvB/56yrn2MsNM=; b=PXC1o6Ki9pSLxTlja17JIDBbj5T8xHEFQAtW3vwu0r0pd0aFsO9Yp9T3VOpO6DniYE5Op0 sPQrdyb0ooafGDx/rj4c9pc1VjJsc5y0X6/wuC4NArgdulleFO8Wy9F23tdYwm6MBn6G4N p72dtLMd/4cmLz2oAUUEHXy69EcIeO8= From: Jonathon Jongsma To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 15:59:16 -0600 Message-Id: <20191114215917.25513-4-jjongsma@redhat.com> In-Reply-To: <20191114215917.25513-1-jjongsma@redhat.com> References: <20191114215917.25513-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: crobinso@redhat.com Subject: [libvirt] [PATCH v3 3/4] conf: report errors when parsing video acceleration X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: raOeIMhaOMmdjULVYfeBdg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since this function is now only called when an 'acceleration' element is present in the xml, any failure to parse the element will be considered an error. Previously, we detected some types of errors, but we would only log an error (virReportError()), but still return a partially-specified accel object to the caller. This patch returns NULL for all parsing errors and reports that error back up to the caller. Signed-off-by: Jonathon Jongsma Reviewed-by: Cole Robinson --- src/conf/domain_conf.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b0599c7318..c0f20c928f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15269,8 +15269,11 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) accel2d =3D virXMLPropString(node, "accel2d"); rendernode =3D virXMLPropString(node, "rendernode"); =20 - if (!accel3d && !accel2d && !rendernode) + if (!accel3d && !accel2d && !rendernode) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("missing values for acceleration")); return NULL; + } =20 def =3D g_new0(virDomainVideoAccelDef, 1); =20 @@ -15278,7 +15281,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) if ((val =3D virTristateBoolTypeFromString(accel3d)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown accel3d value '%s'"), accel3d); - goto cleanup; + return NULL; } def->accel3d =3D val; } @@ -15287,7 +15290,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) if ((val =3D virTristateBoolTypeFromString(accel2d)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown accel2d value '%s'"), accel2d); - goto cleanup; + return NULL; } def->accel2d =3D val; } @@ -15295,7 +15298,6 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) if (rendernode) def->rendernode =3D virFileSanitizePath(rendernode); =20 - cleanup: return g_steal_pointer(&def); } =20 @@ -15414,8 +15416,10 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm= lopt, while (child !=3D NULL) { if (child->type =3D=3D XML_ELEMENT_NODE) { if (def->accel =3D=3D NULL && - virXMLNodeNameEqual(child, "acceleration")) - def->accel =3D virDomainVideoAccelDefParseXML(= child); + virXMLNodeNameEqual(child, "acceleration")) { + if ((def->accel =3D virDomainVideoAccelDefPars= eXML(child)) =3D=3D NULL) + goto error; + } if (def->res =3D=3D NULL && virXMLNodeNameEqual(child, "resolution")) { if ((def->res =3D virDomainVideoResolutionDefP= arseXML(child)) =3D=3D NULL) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:56:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1573768777; cv=none; d=zoho.com; s=zohoarc; b=fzX6WYVflqDV/IwhjGclMTdY3oS8a6L96Q2ngverF22Kxb/kaSbHNWdgxsX2XntCfAdkpaxu0FeL9L4FdUGVKSrt8z3jpfxcjNkEWEKyjRXDkttc8l1MMdjN9ztfZrRMtdSKUFHtH2usors0RQ9nyVq/6s4CTvHtFB8CVszs6us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573768777; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fD4QApDWjZY9tr95k1/JA1eaWEMYzfXq5A2AZkf5yIc=; b=T4bv/3l7s/hIz/1gHuqdwzPthQG7Cs5qN3x5gYn6iHIFDNDBpSnWWWzn9H57A210vP0rKFEoeGqHReZPFzoSC+PXnCP8Us4AQzt1IcJnOJ2/8GZbzX5tOP0RDpuiCupwnB/8O+SZtXIH4NiAkmHHOzMnQLvpwQpD98C94Gdx2B0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1573768777050747.7874464658441; Thu, 14 Nov 2019 13:59:37 -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-22-AbmgIItkMb-QNygVZhrrhA-1; Thu, 14 Nov 2019 16:59:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 262E51802CE2; Thu, 14 Nov 2019 21:59:29 +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 F1FFD9302; Thu, 14 Nov 2019 21:59:28 +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 B21821808878; Thu, 14 Nov 2019 21:59:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAELxMob017647 for ; Thu, 14 Nov 2019 16:59:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id AFEDF10013A1; Thu, 14 Nov 2019 21:59:22 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 712851036C63; Thu, 14 Nov 2019 21:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573768775; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fD4QApDWjZY9tr95k1/JA1eaWEMYzfXq5A2AZkf5yIc=; b=YFjgTgkieTYjQFTX2gQGozk1fpNOKmkjbq+lHUGUHcRf2fInyViBOyoC9qKVLjlNdYiJS5 Lkqi39qL2kUlf5LdBxHE6hALB3SHTdkkqg6rSYEwf3UgIaVlCy7ikQfHgP773W7TPoT1dC Jz4vAa78Hvp9gt+xJ+KXT/3JIguW018= From: Jonathon Jongsma To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 15:59:17 -0600 Message-Id: <20191114215917.25513-5-jjongsma@redhat.com> In-Reply-To: <20191114215917.25513-1-jjongsma@redhat.com> References: <20191114215917.25513-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: crobinso@redhat.com Subject: [libvirt] [PATCH v3 4/4] conf: validate video resolution X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: AbmgIItkMb-QNygVZhrrhA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Ensure that both x and y are non-zero when resolution is specified for a video device. Signed-off-by: Jonathon Jongsma Reviewed-by: Cole Robinson --- src/conf/domain_conf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c0f20c928f..54d6ae297e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6319,6 +6319,12 @@ virDomainVideoDefValidate(const virDomainVideoDef *v= ideo, return -1; } =20 + if (video->res && (video->res->x =3D=3D 0 || video->res->y =3D=3D 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("video resolution values must be greater than 0")= ); + return -1; + } + return 0; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list