From nobody Tue Nov 26 15:39:36 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=1571852854; cv=none; d=zoho.com; s=zohoarc; b=E+9TgPuSju2Ib8jtx6Bzef1WDiiYmGD2CX56syywQB8vtlGyPYSr2oXDoZrN3/327DOr3rk5Yvn48JY1W0CLBEkLin/k7E+GiHKqs/MoTaQv22EhZIOrpjoqn02jvYuKbfmFfTkVQXDsDpxfk4vojApxdTzxKW2OE8/fxQnT2TA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571852854; 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=x732BT/zKVfPMn46eZfnkxUHajHDApLwUkoC1aGxwZk=; b=npUeJy2dyxmu7bVvJjPNlRPfeC0PqGDPc9FwZ1D8VClg/gFQePgbbtqgM5tYr70yTurVEVAFjOj2NYlH59SkHsq1gnPd3KYvhanBBXH1TBDrHpUj07TfzRlxfrUsdkv3aZAYilLGRB/cOn/axRWDva1tXr04h28e5CQNT0lD/rA= 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 1571852854715492.05944973119904; Wed, 23 Oct 2019 10:47:34 -0700 (PDT) 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-350-vdcVMIdyOYOLsTvB-vDj2g-1; Wed, 23 Oct 2019 13:47:31 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 314C45E9; Wed, 23 Oct 2019 17:47:24 +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 0B13710027C3; Wed, 23 Oct 2019 17:47:24 +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 BA19D180B536; Wed, 23 Oct 2019 17:47:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9NHkt50008846 for ; Wed, 23 Oct 2019 13:46:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 530D26061E; Wed, 23 Oct 2019 17:46:55 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-117-228.phx2.redhat.com [10.3.117.228]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B05260624; Wed, 23 Oct 2019 17:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571852853; 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=x732BT/zKVfPMn46eZfnkxUHajHDApLwUkoC1aGxwZk=; b=dDO/XP7/S3uJ+jRwrFE9ivigcQ6tmBMWkqkV/2yLnbosQ9CX+Z4CaAtZTQbt3Ll4cUL0l7 DyWKxvI1rI3Ms7lTmMEd+8K65Vj9QDI1J58XJ6nElzsvmoPoH+OIW5AW5XJ3fqOc5loxts pFc81tMZyhv3N0bscwl2Gp+V1eACUjk= From: Jonathon Jongsma To: libvir-list@redhat.com Date: Wed, 23 Oct 2019 12:46:49 -0500 Message-Id: <20191023174649.28887-6-jjongsma@redhat.com> In-Reply-To: <20191023174649.28887-1-jjongsma@redhat.com> References: <20191023174649.28887-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: jtomko@redhat.com, crobinso@redhat.com Subject: [libvirt] [PATCH v2 5/5] 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.22 X-MC-Unique: vdcVMIdyOYOLsTvB-vDj2g-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" In order to differentiate between a configuration that does not specify any video acceleration and one that is incorrectly specified, change the signature of virDomainVideoAccelDefParseXML() to return an error response. If any of the values are invalid, report an error rather than returning a partially-specified accel object. If no 'acceleration' node is found, do not report an error since it is optional. Signed-off-by: Jonathon Jongsma --- src/conf/domain_conf.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b3f32d0b63..1c3fc5c4ce 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15285,8 +15285,8 @@ virDomainVideoDefaultType(const virDomainDef *def) } } =20 -static virDomainVideoAccelDefPtr -virDomainVideoAccelDefParseXML(xmlNodePtr node) +static int +virDomainVideoAccelDefParseXML(xmlNodePtr node, virDomainVideoAccelDefPtr = *accel) { xmlNodePtr cur; g_autofree virDomainVideoAccelDefPtr def =3D NULL; @@ -15295,21 +15295,25 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) g_autofree char *accel3d =3D NULL; g_autofree char *rendernode =3D NULL; =20 + *accel =3D NULL; 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"); - } + if ((cur->type =3D=3D XML_ELEMENT_NODE) && + virXMLNodeNameEqual(cur, "acceleration")) { + accel3d =3D virXMLPropString(cur, "accel3d"); + accel2d =3D virXMLPropString(cur, "accel2d"); + rendernode =3D virXMLPropString(cur, "rendernode"); + break; } cur =3D cur->next; } =20 + /* no acceleration node was specified */ + if (cur =3D=3D NULL) + return 0; + if (!accel3d && !accel2d && !rendernode) - return NULL; + return -1; =20 def =3D g_new0(virDomainVideoAccelDef, 1); =20 @@ -15317,7 +15321,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) if ((val =3D virTristateBoolTypeFromString(accel3d)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown accel3d value '%s'"), accel3d); - goto cleanup; + return -1; } def->accel3d =3D val; } @@ -15326,7 +15330,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) if ((val =3D virTristateBoolTypeFromString(accel2d)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown accel2d value '%s'"), accel2d); - goto cleanup; + return -1; } def->accel2d =3D val; } @@ -15334,8 +15338,8 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) if (rendernode) def->rendernode =3D virFileSanitizePath(rendernode); =20 - cleanup: - return g_steal_pointer(&def); + *accel =3D g_steal_pointer(&def); + return 0; } =20 static int @@ -15469,7 +15473,11 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm= lopt, VIR_FREE(primary); } =20 - def->accel =3D virDomainVideoAccelDefParseXML(cur); + if (virDomainVideoAccelDefParseXML(cur, &def->accel) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("Cannot parse video acceleratio= n")); + goto error; + } if (virDomainVideoResolutionDefParseXML(cur, &def->res) < = 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Cannot parse video resolution"= )); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list