From nobody Tue May 14 17:40:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1621350552; cv=none; d=zohomail.com; s=zohoarc; b=Q0QvbBca6HTIHGx6bL0i+hYqXocMIhQZ1tvxfRpeY/uIojOPw2JBGqTtxf8vV0aSIYX4rbebP89ZFiQwa5xeBK5hbH9dy2d8efeeWuxIX4dmZN+RcJM78hHzzGQQQDZ2o3J3o+uNIlpUcx0AwDOV2mrDNgZfwymrPZZi2YaPmxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350552; 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=z1A+WCdsWoJEwts+8O67s82Anp2v8Z71NWRpRumDpPA=; b=gGwPIivQwi1rQzM4m5ZGgkBnmjaJtULUknNIJtyQ/HeFLNxWLs8y0B4R4ERL1UnZNEmqvX2gPqofYem49dNRJoki3P2129OfFmuD+foEoEJwFA010qylBvMNT1NpS437XzDDOTnfaGepmZlaVLn+5BrZ+/PMTVSZ8Cd7jDJdXYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1621350552469696.1545380890099; Tue, 18 May 2021 08:09:12 -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-261-22TV_V7BNH-zpUTP6TsKTg-1; Tue, 18 May 2021 11:05:06 -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 BEE0BE7B4C; Tue, 18 May 2021 15:04:59 +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 370FA1007625; Tue, 18 May 2021 15:04:59 +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 6AB081801028; Tue, 18 May 2021 15:04:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF4skU019236 for ; Tue, 18 May 2021 11:04:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1D7DE19D9F; Tue, 18 May 2021 15:04:54 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 647463CC7; Tue, 18 May 2021 15:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350308; 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=z1A+WCdsWoJEwts+8O67s82Anp2v8Z71NWRpRumDpPA=; b=P7ysdvyoybhXd7Th77YtJQtsjSD/ZIfVIdYZ7OtcTVCZL455cNWRITyb3bOLozfHeFGBM6 2aYOGTaCut6AIINIWCBZbLq5fAcujbLFFNIrLmCDwd0X31gSk2dSwmYaAYSHcOxnVtlCYw 8x2Ok+NFMJSe3sjoyJ4p279EQsYNPwQ= X-MC-Unique: 22TV_V7BNH-zpUTP6TsKTg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 01/10] virDomainHostdevDef: Change type of startupPolicy to virDomainStartupPolicy Date: Tue, 18 May 2021 17:04:42 +0200 Message-Id: <20210518150451.79954-2-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 6 +++--- src/conf/domain_conf.h | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7044701fac..734fa584a4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6704,14 +6704,14 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr nod= e, ctxt->node =3D node; =20 if ((startupPolicy =3D virXMLPropString(node, "startupPolicy"))) { - def->startupPolicy =3D - virDomainStartupPolicyTypeFromString(startupPolicy); - if (def->startupPolicy <=3D 0) { + int value =3D virDomainStartupPolicyTypeFromString(startupPolicy); + if (value <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown startup policy '%s'"), startupPolicy); return -1; } + def->startupPolicy =3D value; } =20 if ((autoAddress =3D virXMLPropString(node, "autoAddress"))) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2d5462bb55..41e570765e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -332,6 +332,15 @@ struct _virDomainHostdevCaps { }; =20 =20 +typedef enum { + VIR_DOMAIN_STARTUP_POLICY_DEFAULT =3D 0, + VIR_DOMAIN_STARTUP_POLICY_MANDATORY, + VIR_DOMAIN_STARTUP_POLICY_REQUISITE, + VIR_DOMAIN_STARTUP_POLICY_OPTIONAL, + + VIR_DOMAIN_STARTUP_POLICY_LAST +} virDomainStartupPolicy; + /* basic device for direct passthrough */ struct _virDomainHostdevDef { /* If 'parentnet' is non-NULL it means this host dev was @@ -343,7 +352,7 @@ struct _virDomainHostdevDef { virDomainNetDef *parentnet; =20 int mode; /* enum virDomainHostdevMode */ - int startupPolicy; /* enum virDomainStartupPolicy */ + virDomainStartupPolicy startupPolicy; bool managed; bool missing; bool readonly; @@ -432,16 +441,6 @@ typedef enum { VIR_DOMAIN_DISK_IO_LAST } virDomainDiskIo; =20 -typedef enum { - VIR_DOMAIN_STARTUP_POLICY_DEFAULT =3D 0, - VIR_DOMAIN_STARTUP_POLICY_MANDATORY, - VIR_DOMAIN_STARTUP_POLICY_REQUISITE, - VIR_DOMAIN_STARTUP_POLICY_OPTIONAL, - - VIR_DOMAIN_STARTUP_POLICY_LAST -} virDomainStartupPolicy; - - typedef enum { VIR_DOMAIN_DEVICE_SGIO_DEFAULT =3D 0, VIR_DOMAIN_DEVICE_SGIO_FILTERED, --=20 2.26.3 From nobody Tue May 14 17:40:09 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=1621350323; cv=none; d=zohomail.com; s=zohoarc; b=PPr+cPA9uxDWZYYqbys6mdn5KF3rMGLrywodcQLzV+rYwWyugjwNvHaFZt39i4ae9gfCsKXTX2cH62dJY6tohH4fe4EWdmw7Gf08zpkbvVTZbhmdJiyf/oEoXYFdzGXIMpGk6+w1znaXk5AVCPkN26x8oA8ADDqDph8NaqUKJDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350323; 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=h7PawXWDeKgZZXkQiD43MDnVngC4SRC7xx4ezaxsSxQ=; b=ReOwCe/PoBzxSMG1AP8HsMg827MXbQgsn7CTTsUtF8rCEDkbiclOplHyQjjTL4c7qHzlwhzh/pZDd6BttOa0J4KpV22ffU4r+xVNDIajIQ7q4Z6LKlN6K/eSDrwEm+MLz4WFqMI68H3SCsxK2hz6hOQ6BbkmjnevnhrSVXwEp34= 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 1621350323647917.4270161419086; Tue, 18 May 2021 08:05:23 -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-160-R2Er4ITmOgKp95EArgTTOg-1; Tue, 18 May 2021 11:05:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 997F7801107; Tue, 18 May 2021 15:05:13 +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 756B51349A; Tue, 18 May 2021 15:05:13 +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 35120180B463; Tue, 18 May 2021 15:05:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF4tAA019250 for ; Tue, 18 May 2021 11:04:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 303963CC7; Tue, 18 May 2021 15:04:55 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71DD619D7C; Tue, 18 May 2021 15:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350321; 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=h7PawXWDeKgZZXkQiD43MDnVngC4SRC7xx4ezaxsSxQ=; b=Fh2lnwKx2G0Zegj6k/YkbTm4wRTDB+uEOxDIqqV0qirDVCUaGb6K7LxHR5ixaXjO/abYOg zk7GWCLbKylWzBg2002y6LoiCRSG773DUJIDupNs1aN3VliMsS7dPdukQxu+BI+Sh0ZjLO GuVI3H9IuRVLiP8FXIxNqUuvo28oCwA= X-MC-Unique: R2Er4ITmOgKp95EArgTTOg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 02/10] virDomainHostdevSubsysUSBDefParseXML: Use virXMLProp* Date: Tue, 18 May 2021 17:04:43 +0200 Message-Id: <20210518150451.79954-3-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 734fa584a4..661fa53206 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6694,28 +6694,23 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr nod= e, virDomainHostdevDef *def) { virDomainHostdevSubsysUSB *usbsrc =3D &def->source.subsys.u.usb; - g_autofree char *startupPolicy =3D NULL; - g_autofree char *autoAddress =3D NULL; xmlNodePtr vendorNode; xmlNodePtr productNode; xmlNodePtr addressNode; + virTristateBool autoAddress; VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 ctxt->node =3D node; =20 - if ((startupPolicy =3D virXMLPropString(node, "startupPolicy"))) { - int value =3D virDomainStartupPolicyTypeFromString(startupPolicy); - if (value <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown startup policy '%s'"), - startupPolicy); - return -1; - } - def->startupPolicy =3D value; - } + if (virXMLPropEnum(node, "startupPolicy", + virDomainStartupPolicyTypeFromString, + VIR_XML_PROP_NONZERO, &def->startupPolicy) < 0) + return -1; =20 - if ((autoAddress =3D virXMLPropString(node, "autoAddress"))) - ignore_value(virStringParseYesNo(autoAddress, &usbsrc->autoAddress= )); + if (virXMLPropTristateBool(node, "autoAddress", VIR_XML_PROP_NONE, + &autoAddress) < 0) + return -1; + usbsrc->autoAddress =3D autoAddress =3D=3D VIR_TRISTATE_BOOL_YES; =20 /* Product can validly be 0, so we need some extra help to determine * if it is uninitialized */ --=20 2.26.3 From nobody Tue May 14 17:40:09 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=1621350331; cv=none; d=zohomail.com; s=zohoarc; b=hF68bFGrfVUBD8+X+nYnSHKVU3oV+XfGUCm8c8py6osIYYNxAF1KaKYJkAj1sMZAAFBTkVs0m9GJtXJi3EnQeNwIPpjKp1+FlPnUMghQvOTml+c0H2DaxCcTZF4hJe4qoHQ8LJd77Sno42/SzDI4s4dI/Y+b3CwLtRLMmlAC+xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350331; 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=3buQowNC8dqMJ73XyRSabPAp/KIDGijhiEYROzqnaMU=; b=cE1VV8NxYq67m2uVxLaatmIe5Xf42YgZrqbICahVqDtQ72zU14J2LA6AGndY33NFQrNR01qCMceqAzmeh73RJDJmnWP329LI23KrleoPlSOBSw1gWHn05LZ6O5CBFs0NZ784Q+8ycH684DgnfCH47mY1poZmzufv18PyjSd3bLk= 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 1621350331226584.2981824096557; Tue, 18 May 2021 08:05:31 -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-408-_IlzH5jYM0aiXiBfqnsGbg-1; Tue, 18 May 2021 11:05:21 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9BA77801106; Tue, 18 May 2021 15:05:16 +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 7E8D61349A; Tue, 18 May 2021 15:05:16 +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 34B04180B464; Tue, 18 May 2021 15:05:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF4uao019256 for ; Tue, 18 May 2021 11:04:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C33C3CC7; Tue, 18 May 2021 15:04:56 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81EE319D7C; Tue, 18 May 2021 15:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350326; 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=3buQowNC8dqMJ73XyRSabPAp/KIDGijhiEYROzqnaMU=; b=iFAD9XrZtIJCO1mZ3lLgH7yXo1yvSytei5dw6TBZUKeTFHFY/VXuS0BurFqvqFvKX+iG8Q P1cl9RM7DBNfOT1peLRJTDD2Q9GOUXntmEn9vgKJkIHPvZMVgR6Hv8XVrps1AMssTqHkYM UkNZ9be63Ojg5Oz/QJhnJxUz4TsmQPk= X-MC-Unique: _IlzH5jYM0aiXiBfqnsGbg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 03/10] virDomainDeviceUSBMasterParseXML: Use virXMLProp* Date: Tue, 18 May 2021 17:04:44 +0200 Message-Id: <20210518150451.79954-4-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `startport`. Allowing negative numbers to be interpreted this way makes no sense for this attribute. Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 661fa53206..86680e0cdb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6439,18 +6439,11 @@ static int virDomainDeviceUSBMasterParseXML(xmlNodePtr node, virDomainDeviceUSBMaster *master) { - g_autofree char *startport =3D NULL; - memset(master, 0, sizeof(*master)); =20 - startport =3D virXMLPropString(node, "startport"); - - if (startport && - virStrToLong_ui(startport, NULL, 10, &master->startport) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse 'startport' attribute")); + if (virXMLPropUInt(node, "startport", 10, VIR_XML_PROP_NONE, + &master->startport) < 0) return -1; - } =20 return 0; } --=20 2.26.3 From nobody Tue May 14 17:40:09 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=1621350344; cv=none; d=zohomail.com; s=zohoarc; b=Rh73hcpX9BrWOZd21Hif1kH96oNV9J6yIbtjx8oGkXAnRJ/we+IhRXk5xGfHYtYqo/uZF2D3TCET1KEYNc3zxlHdEFGKQm4InszbgwcA6OrX30gjccNNzVtwEKh8lRs6LZxZ0i41ZGSxtGmdjqNpwo5im1+i85wEgL9pVtx8p0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350344; 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=o3Pj6Za212wm4/6brQK2P2Lz7V+p1ayaZjDy8FYUoVk=; b=blVPwzf8X80e8N5QuB/RfVWp7ZmUe/1yuVMaQntJbG4D9BPfU+Q6/fcc4n1oj6OsyCtBql3zj7b6rTqhiTYtLfEgCINQnsVlZPVzWn7TeC/hfE9R8O4Ndp9T4QROxIxT18yw/XJyOo+b8ttU19cPvLtivr72039sreYeTio1fX8= 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 1621350344400842.0767266677346; Tue, 18 May 2021 08:05:44 -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-448-xUZ6uFsgPhqtXqN4bb5Rlw-1; Tue, 18 May 2021 11:05:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9E798049CC; Tue, 18 May 2021 15:05:23 +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 A8FC35C1CF; Tue, 18 May 2021 15:05:23 +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 75721180102C; Tue, 18 May 2021 15:05:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF4vqW019264 for ; Tue, 18 May 2021 11:04:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 480DF19D9F; Tue, 18 May 2021 15:04:57 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 907011A868; Tue, 18 May 2021 15:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350341; 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=o3Pj6Za212wm4/6brQK2P2Lz7V+p1ayaZjDy8FYUoVk=; b=RPeFxREHLuLrm4kq+nt3nUhnwOc27s/VeC9inTlGMdMW+5GIK99WGdMHFl+rPCpVGOprtd vENzEXCnJGIdptXyu2sK1n1E15XVV8mnrIfg8SdV/Ftwwf9OnoX+ZFv02KNGyoIps5/u+T FLgKgd4WApWTK4KWGCUAYRU+2pQXtkM= X-MC-Unique: xUZ6uFsgPhqtXqN4bb5Rlw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 04/10] virDomainDiskDef: Change type of geometry.trans to virDomainDiskGeometryTrans Date: Tue, 18 May 2021 17:04:45 +0200 Message-Id: <20210518150451.79954-5-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 5 +++-- src/conf/domain_conf.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 86680e0cdb..f55117e849 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8845,13 +8845,14 @@ virDomainDiskDefGeometryParse(virDomainDiskDef *def, } =20 if ((tmp =3D virXMLPropString(cur, "trans"))) { - def->geometry.trans =3D virDomainDiskGeometryTransTypeFromString(t= mp); - if (def->geometry.trans <=3D 0) { + int value; + if ((value =3D virDomainDiskGeometryTransTypeFromString(tmp)) <=3D= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid translation value '%s'"), tmp); return -1; } + def->geometry.trans =3D value; } =20 return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 41e570765e..cf8481f1f6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -549,7 +549,7 @@ struct _virDomainDiskDef { unsigned int cylinders; unsigned int heads; unsigned int sectors; - int trans; /* enum virDomainDiskGeometryTrans */ + virDomainDiskGeometryTrans trans; } geometry; =20 struct { --=20 2.26.3 From nobody Tue May 14 17:40:09 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=1621350344; cv=none; d=zohomail.com; s=zohoarc; b=BeHw01QSVmW9Nq3eEm33mUrOYwfhGEsgof7mB1N+RvnZ12CynK6HGwGPaxuH4f5NIVWHLqBgjUZmQhNyBLWL06f5oLmL6yVoNEXhp+yiQ0o5pzm2ddSrpPjFye5oh88hdj9nZbmN21zSvaBUuny9AhP/tvN+nwG/vC7bUkZNjwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350344; 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=OpiW+X7OaTaDI4S2QMwHARRdSuaIL10zyrSG/mL+3+s=; b=nEcIB4Zs3bAiIK7xZM1oDpfi6rN1EMHi7Ujp3S58U0rkloaRb8StBntzaLRvgKjz35Lx0XgXorjDM1rCoMkgNsJg0EQWoQFm+QEo2jPnfvRKJgFQPQWeJkGLUjVHfiHJOtf1XEDN8xTD6My4srDZhubNo8WovPvz20YKWsb+/2M= 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 1621350344401615.0940663890219; Tue, 18 May 2021 08:05:44 -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-170-sp4AbmGfNWalyXzPJ6Gfcw-1; Tue, 18 May 2021 11:05:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98A41E7B4C; Tue, 18 May 2021 15:05:26 +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 7D02D18A50; Tue, 18 May 2021 15:05:26 +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 437E01801265; Tue, 18 May 2021 15:05:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF4w0Y019279 for ; Tue, 18 May 2021 11:04:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 536893CC7; Tue, 18 May 2021 15:04:58 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C3A619D7C; Tue, 18 May 2021 15:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350341; 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=OpiW+X7OaTaDI4S2QMwHARRdSuaIL10zyrSG/mL+3+s=; b=fEKIM5qC1D/rW0jCCxJf5U5zky3MU3TwefbHu34pbmxjLsAU4Y9vzEalnv1NO/3/XoDnn1 Lgc7w/wfO/5EZdcPMc/AZHgYvtHBgs8DhLo6HIZ3GgLDT905zufuflW8Neb2RhdoQeEaQU B9tOaE+rgCWOYy9dTkM1YQo9rsTx8Lw= X-MC-Unique: sp4AbmGfNWalyXzPJ6Gfcw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 05/10] virDomainDiskDefGeometryParse: Use virXMLProp* Date: Tue, 18 May 2021 17:04:46 +0200 Message-Id: <20210518150451.79954-6-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attributes `cyls`, `heads` and `secs`. Allowing negative numbers to be interpreted this way makes no sense for these attributes. Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 48 +++++++++++------------------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f55117e849..bfcc56ca9e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8815,45 +8815,21 @@ static int virDomainDiskDefGeometryParse(virDomainDiskDef *def, xmlNodePtr cur) { - g_autofree char *tmp =3D NULL; - - if ((tmp =3D virXMLPropString(cur, "cyls"))) { - if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.cylinders) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("invalid geometry settings (cyls)")); - return -1; - } - VIR_FREE(tmp); - } + if (virXMLPropUInt(cur, "cyls", 10, VIR_XML_PROP_NONE, + &def->geometry.cylinders) < 0) + return -1; =20 - if ((tmp =3D virXMLPropString(cur, "heads"))) { - if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.heads) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("invalid geometry settings (heads)")); - return -1; - } - VIR_FREE(tmp); - } + if (virXMLPropUInt(cur, "heads", 10, VIR_XML_PROP_NONE, + &def->geometry.heads) < 0) + return -1; =20 - if ((tmp =3D virXMLPropString(cur, "secs"))) { - if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.sectors) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("invalid geometry settings (secs)")); - return -1; - } - VIR_FREE(tmp); - } + if (virXMLPropUInt(cur, "secs", 10, VIR_XML_PROP_NONE, + &def->geometry.sectors) < 0) + return -1; =20 - if ((tmp =3D virXMLPropString(cur, "trans"))) { - int value; - if ((value =3D virDomainDiskGeometryTransTypeFromString(tmp)) <=3D= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid translation value '%s'"), - tmp); - return -1; - } - def->geometry.trans =3D value; - } + if (virXMLPropEnum(cur, "trans", virDomainDiskGeometryTransTypeFromStr= ing, + VIR_XML_PROP_NONZERO, &def->geometry.trans) < 0) + return -1; =20 return 0; } --=20 2.26.3 From nobody Tue May 14 17:40:09 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=1621350354; cv=none; d=zohomail.com; s=zohoarc; b=JnMPhR3gpfNsL8f/J1EGl4xCVwgQRJCjF+QWr/XvUpbtsdGrq7Sy5EEKwcaW+CORc1KHN2GMsp0kLd7SING7wkL4M3gV7SiBmpse9FXhLNyogAC7yrOTlObOqnUZv4CsPeR183tos3EEiSncbuHdVNpSpWgOgO1cSz6HWj5oJHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350354; 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=7Kwf8rfRNzpBSqUwgKjNythv7UHmA+qtTaIyKBqudgk=; b=GItM2JD91CLnPpbGWVNqk5ORhHyrgWsdM3l3qJqF/aDqPvTn2XHwBa4S6Y8cVjAzGNnidGxXkcLJRNJwPnCdfX10cmT6EDchLwCCnq6V9L+XeLo5UPDYvhODJE0qJYqmuTcwMh7M+lDVaN6qtNN2J+8aKaLWMePQ2eb2AYf6Wdg= 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 1621350354380883.8556818440474; Tue, 18 May 2021 08:05:54 -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-290-8sigygxWMtyFJSnLyyDS9Q-1; Tue, 18 May 2021 11:05:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82DD88049D6; Tue, 18 May 2021 15:05:44 +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 6405F687DC; Tue, 18 May 2021 15:05:44 +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 2CFCD55353; Tue, 18 May 2021 15:05:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF54FC019321 for ; Tue, 18 May 2021 11:05:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id CDF38E2E0; Tue, 18 May 2021 15:05:04 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76B79E152; Tue, 18 May 2021 15:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350351; 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=7Kwf8rfRNzpBSqUwgKjNythv7UHmA+qtTaIyKBqudgk=; b=MywaHNPo9R60Fd/Zdkzp5aPjSgmQWWVyYzBANS1pMBOn83RHbzWIvX2DtAzWcoR1o8BB8V efXQ+bbJip/BXo7hju7L1C1/Xuyxu6wR0iPRRJPb8gkP+FhWfiQMA0ljC/fc2Z6pCcY9Qj hW2k9orWVbKmZ8YkmXdxUcrmYB+6tW4= X-MC-Unique: 8sigygxWMtyFJSnLyyDS9Q-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 06/10] virDomainChrSourceReconnectDefParseXML: Use virXMLProp* Date: Tue, 18 May 2021 17:04:47 +0200 Message-Id: <20210518150451.79954-7-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `timeout`. Allowing negative numbers to be interpreted this way makes no sense for this attribute. Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bfcc56ca9e..a5514660cc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10093,39 +10093,20 @@ virDomainChrSourceReconnectDefParseXML(virDomainC= hrSourceReconnectDef *def, xmlNodePtr node, xmlXPathContextPtr ctxt) { - int tmpVal; VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr cur; - g_autofree char *tmp =3D NULL; =20 ctxt->node =3D node; =20 if ((cur =3D virXPathNode("./reconnect", ctxt))) { - if ((tmp =3D virXMLPropString(cur, "enabled"))) { - if ((tmpVal =3D virTristateBoolTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid reconnect enabled value: '%s'"), - tmp); - return -1; - } - def->enabled =3D tmpVal; - VIR_FREE(tmp); - } + if (virXMLPropTristateBool(cur, "enabled", VIR_XML_PROP_NONE, + &def->enabled) < 0) + return -1; =20 if (def->enabled =3D=3D VIR_TRISTATE_BOOL_YES) { - if ((tmp =3D virXMLPropString(cur, "timeout"))) { - if (virStrToLong_ui(tmp, NULL, 10, &def->timeout) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid reconnect timeout value: '%s= '"), - tmp); - return -1; - } - } else { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing timeout for chardev with " - "reconnect enabled")); + if (virXMLPropUInt(cur, "timeout", 10, VIR_XML_PROP_REQUIRED, + &def->timeout) < 0) return -1; - } } } =20 --=20 2.26.3 From nobody Tue May 14 17:40:09 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=1621350952; cv=none; d=zohomail.com; s=zohoarc; b=GoTUtq8zHNb46FxP5rWZRprfKYu5CU+CpRN4yfKmMOZyp/XvcFf9Kn3nsaF/N50LMz6PxTAtUXCmF3qV9bRnqYcvlM7dBDYSBhf1HFISO7YmR+oWD1CZqOis0r5U8xWPpcYI4Ud7FZzP2WgtMKtBIPO74B9BvNZ93lAXrsPJ/9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350952; 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=XFMrp0uxXzBeDcySGU9u05P4bCZgw93UWD1+PGl3SVU=; b=krQ/Vl4bXkZzWtS/zBpEnAZemxKh/xQKDhWJE4MQKHEijmc7Lgc41J7gT1fwb8e/NmxHbVxbey47mABx6IDnQ7vbp6MR9Hd1LyHpL898SbLWlKDdL/TWXdIYdamLEWnAQ12JJE4IEsTISdbBkUwGpqc32T989LQuvrjPJLAMbco= 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 1621350952018170.90032335842284; Tue, 18 May 2021 08:15:52 -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-430-A3vmnPyGNC2wKcNuXM9sNw-1; Tue, 18 May 2021 11:05:46 -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 4117D802575; Tue, 18 May 2021 15:05: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 1914B1037F22; Tue, 18 May 2021 15:05:29 +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 D60971801268; Tue, 18 May 2021 15:05:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF570E019337 for ; Tue, 18 May 2021 11:05:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3FABDE171; Tue, 18 May 2021 15:05:07 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BA7919D9F; Tue, 18 May 2021 15:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350349; 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=XFMrp0uxXzBeDcySGU9u05P4bCZgw93UWD1+PGl3SVU=; b=S+eXgZLckY1Zg88iTgj4BOQwR2ep/Ql12zUbdR/wHGqmEJw6+7g4Upx2A19KxGY4tWxZw7 TfrEuE/IdU5vAjtWXUbs6QZnS8je2kwpfeWvTIx9ynywUL/F6+OoBpKU2jgyZXmGMRlfIt /99v44i/FpiDqUDGObwcNPL34telM/s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350950; 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=XFMrp0uxXzBeDcySGU9u05P4bCZgw93UWD1+PGl3SVU=; b=C1Qhdsf8I8p/Vd9dX1QPS4SQ2BJEMah026nQobeCQJSosVDfG9dJvLiBAOhFxcsQopZp7f /HtbLZ8JeC6Pleji6wGlBobimsEgkAxLTJYH5RNf2k9lTR+yY3yGQREQLnF5HzRlRVTrRk ud6qiNAfB3Ae+9XYnIBBL0TVQM7huK8= X-MC-Unique: A3vmnPyGNC2wKcNuXM9sNw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 07/10] virDomainChrDefParseTargetXML: Use virXMLProp* Date: Tue, 18 May 2021 17:04:48 +0200 Message-Id: <20210518150451.79954-8-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `port`. Allowing negative numbers to be interpreted this way makes no sense for this attribute. Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a5514660cc..57a54f12ef 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10977,7 +10977,6 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def, g_autofree char *targetModel =3D NULL; g_autofree char *addrStr =3D NULL; g_autofree char *portStr =3D NULL; - g_autofree char *stateStr =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 ctxt->node =3D cur; @@ -11007,7 +11006,6 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def, switch (def->targetType) { case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: addrStr =3D virXMLPropString(cur, "address"); - portStr =3D virXMLPropString(cur, "port"); =20 def->target.addr =3D g_new0(virSocketAddr, 1); =20 @@ -11028,19 +11026,8 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def, return -1; } =20 - if (portStr =3D=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("guestfwd channel does " - "not define a target port")); - return -1; - } - - if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid port number: %s"), - portStr); + if (virXMLPropUInt(cur, "port", 10, VIR_XML_PROP_REQUIRED, &po= rt) < 0) return -1; - } =20 virSocketAddrSetPort(def->target.addr, port); break; @@ -11050,18 +11037,12 @@ virDomainChrDefParseTargetXML(virDomainChrDef *de= f, def->target.name =3D virXMLPropString(cur, "name"); =20 if (def->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_= VIRTIO && - !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - (stateStr =3D virXMLPropString(cur, "state"))) { - int tmp; + !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { =20 - if ((tmp =3D virDomainChrDeviceStateTypeFromString(stateSt= r)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid channel state value '%s'"), - stateStr); + if (virXMLPropEnum(cur, "state", + virDomainChrDeviceStateTypeFromString, + VIR_XML_PROP_NONZERO, &def->state) < 0) return -1; - } - - def->state =3D tmp; } break; } --=20 2.26.3 From nobody Tue May 14 17:40:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1621350377; cv=none; d=zohomail.com; s=zohoarc; b=Ig+QhyJGqYXFAhoJNnsPBQWQIueqJha1Rj8qI7w+W47E6TX8kPUCqweeDmWz2VZ57HTOMPKIUwYQctjxiEIOJC5EKllpPf+wc8UMDo8MS6Top2q07zfUuRCwnNbWpLmrVOEJnBnUkR19DdnGLiBPwU0+s+5jpq0hm0/kZVlxu7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350377; 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=devuoPVXFMx2EDoatfFc0fNKKXGc9iWsYVeUU64b+wg=; b=FPJ7cY6OZ9P2agPY4q0kdIqgYph306zcKVDj3P0LB6vzM2eg+/tOvjahx75M5F4UBwi/sLf4y5Wlt8hlJKR1wlKTnP8GPqW6VHipozXIDqlacRNKWKg/jiugl5odmqItVfMYBFN2VXX/QcFW8ll2ZYRkl8c+of/iw40Cb83/uN4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1621350377513640.5431105750312; Tue, 18 May 2021 08:06:17 -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-204-vqjWmdouOrqPX3qVIRN3fw-1; Tue, 18 May 2021 11:05:42 -0400 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 2AC17107ACF7; Tue, 18 May 2021 15:05:32 +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 F336D19D9F; Tue, 18 May 2021 15:05:31 +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 B573355347; Tue, 18 May 2021 15:05:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF58qT019344 for ; Tue, 18 May 2021 11:05:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B2D33CC7; Tue, 18 May 2021 15:05:08 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9148C19D9F; Tue, 18 May 2021 15:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350374; 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=devuoPVXFMx2EDoatfFc0fNKKXGc9iWsYVeUU64b+wg=; b=c6N1zCXD7dB8XIDVUa/u/MWoIU+Gt9UBRcP1jyy9ZQC4oz78oHknEYMeILVo1ICD7iqEM8 WArmpvOBZ0eCMyRpBCgdSUdKfMtN1ITmcJ23pmVyG32TCsb5DwQFRs9bbuyMwnIUzTWPx/ QD2moRrRGQSfj5/aZpMFGC4qTR8kJyQ= X-MC-Unique: vqjWmdouOrqPX3qVIRN3fw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 08/10] virDomainAudioCoreAudioParse: Use virXMLProp* Date: Tue, 18 May 2021 17:04:49 +0200 Message-Id: <20210518150451.79954-9-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `bufferCount`. Allowing negative numbers to be interpreted this way makes no sense for this attribute. Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 57a54f12ef..a46e64c64a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13046,15 +13046,9 @@ static int virDomainAudioCoreAudioParse(virDomainAudioIOCoreAudio *def, xmlNodePtr node) { - g_autofree char *bufferCount =3D virXMLPropString(node, "bufferCount"); - - if (bufferCount && - virStrToLong_ui(bufferCount, NULL, 10, - &def->bufferCount) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse 'bufferCount' value '%s'"), bufferC= ount); + if (virXMLPropUInt(node, "bufferCount", 10, VIR_XML_PROP_NONE, + &def->bufferCount) < 0) return -1; - } =20 return 0; } --=20 2.26.3 From nobody Tue May 14 17:40:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1621350355; cv=none; d=zohomail.com; s=zohoarc; b=Ets98AMbEKvJnDIRXlfdPkqdMKtMGRJtvEcGDK05XFDhhMNhs2sKGCieG+QfNKlVMuQroI1Iehd5h7AOvr/hlb96EnbfzCYL+kSXyoJ5n91NkiCUqG8vLgXxxx4iErikx0GQ4ZS2ZgUvNBjjhd/PtjN4liAjIwlXQUUmXKqUg54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350355; 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=9IYg1sIOuSnhz0baNLf/tZYl4mofblCcDFFwDQFrHQY=; b=VRrhjMaX0Io79LkT6eZ07+jc3ogOZqdoJF60eSgeky00pJZ8RLvXszV/UVHEXTgAkrjyLOxkgNCwsWoPYv8drZEsB9ZK0mt+9zhohlsAEF1IDugcW+oQfvbghqaPDvov3osv0ZdZf/S7e38jiEGLL+IvnVudGKt58ay7wmOTdUc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1621350354689507.67930574460297; Tue, 18 May 2021 08:05:54 -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-113-FYW-VlRcOBqmwaTUNoK1iw-1; Tue, 18 May 2021 11:05:49 -0400 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 47B1B106BB2D; Tue, 18 May 2021 15:05:41 +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 24F7518506; Tue, 18 May 2021 15:05:41 +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 DEA71180B464; Tue, 18 May 2021 15:05:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF59CL019354 for ; Tue, 18 May 2021 11:05:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 51E9A19D9F; Tue, 18 May 2021 15:05:09 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C06A1A868; Tue, 18 May 2021 15:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350352; 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=9IYg1sIOuSnhz0baNLf/tZYl4mofblCcDFFwDQFrHQY=; b=LfIJTcKXl/yuNGh2Wmqq7vcOSvSTvB4a+2KI6CBLC9iTmjlCgI1ce/k5mmcqhQhSWO8fcP i1Y+bsY3nJPG0Qa4AK5RUYYPg4dxwHTAoVVzfc9bbKFV6jcI7PrAXKnR3hRVfpc62okcj7 eKcdgywN3aMnoP1TgOgYIRfJRBYYp3I= X-MC-Unique: FYW-VlRcOBqmwaTUNoK1iw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 09/10] virDomainAudioOSSParse: Use virXMLProp* Date: Tue, 18 May 2021 17:04:50 +0200 Message-Id: <20210518150451.79954-10-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `bufferCount`. Allowing negative numbers to be interpreted this way makes no sense for this attribute. Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a46e64c64a..b3ed3a9c5a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13074,26 +13074,15 @@ static int virDomainAudioOSSParse(virDomainAudioIOOSS *def, xmlNodePtr node) { - g_autofree char *tryPoll =3D virXMLPropString(node, "tryPoll"); - g_autofree char *bufferCount =3D virXMLPropString(node, "bufferCount"); - def->dev =3D virXMLPropString(node, "dev"); =20 - if (tryPoll && - ((def->tryPoll =3D - virTristateBoolTypeFromString(tryPoll)) <=3D 0)) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown 'tryPoll' value '%s'"), tryPoll); + if (virXMLPropTristateBool(node, "tryPoll", VIR_XML_PROP_NONE, + &def->tryPoll) < 0) return -1; - } =20 - if (bufferCount && - virStrToLong_ui(bufferCount, NULL, 10, - &def->bufferCount) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse 'bufferCount' value '%s'"), bufferC= ount); + if (virXMLPropUInt(node, "bufferCount", 10, VIR_XML_PROP_NONE, + &def->bufferCount) < 0) return -1; - } =20 return 0; } --=20 2.26.3 From nobody Tue May 14 17:40:09 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=1621350348; cv=none; d=zohomail.com; s=zohoarc; b=iNSHrQICEuqXYGpl90mwi3JrnHz/imQn/VRmaJmMYKwaw8M1PE6UqlyTrjZeGq487n6JlTrWsk/qABGa4eSvofrnNa0I+tCma1YY/krSMEQRAvN79phaYY+U1cMVM24TlS1XGp7q3tv2KWXD/JIq09/Ah6XszpKyvO3xFkoNR+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350348; 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=+TdRffC47d9sGWSprKRAD8Dc98cIhESN9OIZxKT5i3U=; b=mNBdYu0BSu9IZkKMbZJIcY8cfXOKQ5tjD5evs0eZGe3yPhRRdostFfSgfAWlJj8xsxXDQHNbhcBtLPYcBc65qFcP4nEVUKzkKtyJy0Vsp0RVlEojXBsYWGc1sAaLHvZjydebsdM8HE+BEpYUFjxoiBzDJZn+onkf7SJOnjIvqsg= 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 16213503480061008.0425177984044; Tue, 18 May 2021 08:05:48 -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-228-spCTnXNkMruFg9HV1z5_rQ-1; Tue, 18 May 2021 11:05:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49C60195D56D; Tue, 18 May 2021 15:05:36 +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 0B2135D71D; Tue, 18 May 2021 15:05:36 +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 C3FF01801267; Tue, 18 May 2021 15:05:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF5Atx019364 for ; Tue, 18 May 2021 11:05:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 580CEE152; Tue, 18 May 2021 15:05:10 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3D383CC7; Tue, 18 May 2021 15:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350345; 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=+TdRffC47d9sGWSprKRAD8Dc98cIhESN9OIZxKT5i3U=; b=aZ4jvVdB+yKaXSjcuZo/+xPpjhEFfeMz7q8d0Dxbr+0xYevPhsdyuu9e8PmqludX0op42P +0iBJVGfz996fdExx5r/jAtr2YED5OMWMiAfcEvtsvcYIAO7ZotHOb3XnDeUKlx+g2u6HX D9Txw54F9DUJGpoFpSHjRHYqfQDh+hw= X-MC-Unique: spCTnXNkMruFg9HV1z5_rQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 10/10] virNodeDevCapPCIDevIommuGroupParseXML: Use virXMLProp* Date: Tue, 18 May 2021 17:04:51 +0200 Message-Id: <20210518150451.79954-11-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.15 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `number`. Allowing negative numbers to be interpreted this way makes no sense for this attribute. Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/node_device_conf.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 861f43f6c4..332b12f997 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1557,25 +1557,14 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathConte= xtPtr ctxt, { VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree xmlNodePtr *addrNodes =3D NULL; - g_autofree char *numberStr =3D NULL; int nAddrNodes; size_t i; =20 ctxt->node =3D iommuGroupNode; =20 - numberStr =3D virXMLPropString(iommuGroupNode, "number"); - if (!numberStr) { - virReportError(VIR_ERR_XML_ERROR, - "%s", _("missing iommuGroup number attribute")); + if (virXMLPropUInt(iommuGroupNode, "number", 10, VIR_XML_PROP_REQUIRED, + &pci_dev->iommuGroupNumber) < 0) return -1; - } - if (virStrToLong_ui(numberStr, NULL, 10, - &pci_dev->iommuGroupNumber) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid iommuGroup number attribute '%s'"), - numberStr); - return -1; - } =20 if ((nAddrNodes =3D virXPathNodeSet("./address", ctxt, &addrNodes)) < = 0) return -1; --=20 2.26.3