From nobody Thu Apr 25 06:32:16 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=1619535904; cv=none; d=zohomail.com; s=zohoarc; b=cUcKYRlf100ulKxVUQbNK+4cv/npegO8jPnd5GnR1A9Y9S0KnFG6l2RPHQE20q1ZYtsdwvDKfeBZ+cLdh+8EzGZlvsncmJGjNrgT9isijtLSt2N95pjPlmPCw1JMGQrxR4JOYk+eLGeHVphnzq3ZZiuhH6oFZ6TP75owaXEGnO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535904; 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=Dp3nqDTvLhMin9TYnRdsTjQXYXUrD8asinQXXRCQEvc=; b=OTFLdNYvJ8LIKqOeTtpjvFjtCC7yHHjPmjjRGveneEtJNBajmVvFlLTtfJuC9LnJsj1POWCmBnG6D+RnDZBv36oWqSL04fL/jA5BGhlO6ejlqJlM3660oiGEcp7bCciXEYXoCfZwsxyuJaHI4qKxsppR2mqaKwgrgvnXsefNIeM= 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 1619535904782710.3972163009569; Tue, 27 Apr 2021 08:05:04 -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-588-hDVzcXUMNJixwHtb6UKGHw-1; Tue, 27 Apr 2021 11:04:58 -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 D237AEC1A2; Tue, 27 Apr 2021 15:04:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33A7E60CFB; Tue, 27 Apr 2021 15:04:52 +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 C9C4D18095C9; Tue, 27 Apr 2021 15:04:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF4lai031848 for ; Tue, 27 Apr 2021 11:04:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id E05BA60CC9; Tue, 27 Apr 2021 15:04:47 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F57D60C0F; Tue, 27 Apr 2021 15:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535901; 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=Dp3nqDTvLhMin9TYnRdsTjQXYXUrD8asinQXXRCQEvc=; b=ZIOkdfNS4cZIMHgatM1S5IHJGfxkP+EjXjwmCP20I8mu/jMEhH2XrduQyScWFgCakyP0ku J9t4RXsInERxGpw00e+db5s6scbaanK/XjV+k2kHvjuBe9rFa7uJai0aiDQwCEj0CkqPsJ vvLL5Q4FHvSNExBlkvUv7lLl+WnSi6k= X-MC-Unique: hDVzcXUMNJixwHtb6UKGHw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 01/10] virDomainAudioIOCommon: Change type of format to virDomainAudioFormat Date: Tue, 27 Apr 2021 17:04:32 +0200 Message-Id: <20210427150441.206606-2-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" Signed-off-by: Tim Wiederhake Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 13 ++++++++----- src/conf/domain_conf.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9d98f487ea..d8e34e79b0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13495,11 +13495,14 @@ virDomainAudioCommonParse(virDomainAudioIOCommon = *def, return -1; } =20 - if (format && - (def->format =3D virDomainAudioFormatTypeFromString(format)) <= =3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse 'format' value '%s'"), format); - return -1; + if (format) { + int value; + if ((value =3D virDomainAudioFormatTypeFromString(format)) <= =3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("cannot parse 'format' value '%s'"), form= at); + return -1; + } + def->format =3D value; } } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 85c318d027..a694b434c6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1502,7 +1502,7 @@ struct _virDomainAudioIOCommon { unsigned int frequency; unsigned int channels; unsigned int voices; - int format; /* virDomainAudioFormat */ + virDomainAudioFormat format; unsigned int bufferLength; /* milliseconds */ }; =20 --=20 2.26.3 From nobody Thu Apr 25 06:32:16 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=1619535917; cv=none; d=zohomail.com; s=zohoarc; b=DnMnU4nmZ1Qv7gO6KNJ59jWVNMt3XCDQpgqcEBYWGh8B6bEd7Q0Or6BDwFvrBTsBnCY8nnBRxq99ul0tl+msWOv8uGZHiovtvWbxc/YWK2CVlo2c37DwYSO5K6e2uqqA6YZ+yZmGsuPRhCL3nHXeKODEHCSzsVpYy6fKbJju8G0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535917; 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=ps69jDyXzb2fkKNxw2U5m6lYU/0uljKwPF4R2ZczDm4=; b=l1nWtQGlD9f564pkUB6Lt4shSy5EnbZWeNy8CkGs9+RsasFPGdyc76fVz9hjVQEMmXV8/qT55jCKMBeaWo451mr527xAvXFj4M33KEgE6pZ754pL0xvBC8LlVyfPfH8riD7f/DSZrXqqzt+T3Kd7ra/TJaYlkBoDi9fnLhpkqYk= 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 1619535917174736.7663748553969; Tue, 27 Apr 2021 08:05: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-593-RdqMabWmM4iWNQf6f_M7kg-1; Tue, 27 Apr 2021 11:05:12 -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 74D3218B9ECB; Tue, 27 Apr 2021 15:05:06 +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 3E1791A865; Tue, 27 Apr 2021 15:05:06 +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 BF59344A60; Tue, 27 Apr 2021 15:05:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF4mjY031859 for ; Tue, 27 Apr 2021 11:04:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id EE03A60CC6; Tue, 27 Apr 2021 15:04:48 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42E9D60C0F; Tue, 27 Apr 2021 15:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535915; 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=ps69jDyXzb2fkKNxw2U5m6lYU/0uljKwPF4R2ZczDm4=; b=BhKtDr0GxVBeXUzEnywNS8cPaF28OgYwdv9SXa9dh88me/EZMYdXoMdEX1zmfig3LadBB5 nQIvN1b9l30oixV3uyEdJjlrWWkLagq+JfFpkbXtI+AMVPJdzvptRnL3z8y3bHGXLwALPL svNgdrmr3u+VGe2zk08dvJ6ksrZmIsM= X-MC-Unique: RdqMabWmM4iWNQf6f_M7kg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 02/10] virDomainAudioCommonParse: Use virXMLProp* Date: Tue, 27 Apr 2021 17:04:33 +0200 Message-Id: <20210427150441.206606-3-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 attributes `voices` (typically 1), `bufferLength` (measured in milliseconds), `frequency` (in Hz, typically 44100), and `channels` (typically 2 for stereo). None of these properties benefit from or have a sensible use-case for wrap-around behavior. Signed-off-by: Tim Wiederhake Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 73 ++++++++++++------------------------------ 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d8e34e79b0..371a9dead7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13419,31 +13419,19 @@ virDomainAudioCommonParse(virDomainAudioIOCommon = *def, xmlNodePtr node, xmlXPathContextPtr ctxt) { - g_autofree char *mixingEngine =3D virXMLPropString(node, "mixingEngine= "); - g_autofree char *fixedSettings =3D virXMLPropString(node, "fixedSettin= gs"); - g_autofree char *voices =3D virXMLPropString(node, "voices"); - g_autofree char *bufferLength =3D virXMLPropString(node, "bufferLength= "); xmlNodePtr settings; VIR_XPATH_NODE_AUTORESTORE(ctxt); =20 ctxt->node =3D node; settings =3D virXPathNode("./settings", ctxt); =20 - if (mixingEngine && - ((def->mixingEngine =3D - virTristateBoolTypeFromString(mixingEngine)) <=3D 0)) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown 'mixingEngine' value '%s'"), mixingEngin= e); + if (virXMLPropTristateBool(node, "mixingEngine", VIR_XML_PROP_NONE, + &def->mixingEngine) < 0) return -1; - } =20 - if (fixedSettings && - ((def->fixedSettings =3D - virTristateBoolTypeFromString(fixedSettings)) <=3D 0)) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown 'fixedSettings' value '%s'"), fixedSetti= ngs); + if (virXMLPropTristateBool(node, "fixedSettings", VIR_XML_PROP_NONE, + &def->fixedSettings) < 0) return -1; - } =20 if (def->fixedSettings =3D=3D VIR_TRISTATE_BOOL_YES && def->mixingEngine !=3D VIR_TRISTATE_BOOL_YES) { @@ -13452,58 +13440,37 @@ virDomainAudioCommonParse(virDomainAudioIOCommon = *def, return -1; } =20 - if (voices && - (virStrToLong_ui(voices, NULL, 10, &def->voices) < 0 || - !def->voices)) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse 'voices' value '%s'"), voices); + if (virXMLPropUInt(node, "voices", 10, + VIR_XML_PROP_NONE | VIR_XML_PROP_NONZERO, + &def->voices) < 0) return -1; - } =20 - if (bufferLength && - (virStrToLong_ui(bufferLength, NULL, 10, &def->bufferLength) < 0 || - !def->bufferLength)) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse 'bufferLength' value '%s'"), buffer= Length); + if (virXMLPropUInt(node, "bufferLength", 10, + VIR_XML_PROP_NONE | VIR_XML_PROP_NONZERO, + &def->bufferLength) < 0) return -1; - } =20 if (settings) { - g_autofree char *frequency =3D virXMLPropString(settings, "frequen= cy"); - g_autofree char *channels =3D virXMLPropString(settings, "channels= "); - g_autofree char *format =3D virXMLPropString(settings, "format"); - if (def->fixedSettings !=3D VIR_TRISTATE_BOOL_YES) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("audio settings specified without fixed setti= ngs flag")); return -1; } =20 - if (frequency && - (virStrToLong_ui(frequency, NULL, 10, &def->frequency) < 0 || - !def->frequency)) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse 'frequency' value '%s'"), frequ= ency); + if (virXMLPropUInt(settings, "frequency", 10, + VIR_XML_PROP_NONE | VIR_XML_PROP_NONZERO, + &def->frequency) < 0) return -1; - } =20 - if (channels && - (virStrToLong_ui(channels, NULL, 10, &def->channels) < 0 || - !def->channels)) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse 'channels' value '%s'"), channe= ls); + if (virXMLPropUInt(settings, "channels", 10, + VIR_XML_PROP_NONE | VIR_XML_PROP_NONZERO, + &def->channels) < 0) return -1; - } =20 - if (format) { - int value; - if ((value =3D virDomainAudioFormatTypeFromString(format)) <= =3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse 'format' value '%s'"), form= at); - return -1; - } - def->format =3D value; - } + if (virXMLPropEnum(settings, "format", + virDomainAudioFormatTypeFromString, + VIR_XML_PROP_NONE, &def->format) < 0) + return -1; } =20 return 0; --=20 2.26.3 From nobody Thu Apr 25 06:32:16 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=1619535907; cv=none; d=zohomail.com; s=zohoarc; b=DN8obfFopJmI08oTS44p3m7t1ec4WJZarqglI3LBf/3POSj7VONU2Ofx+dcLc+A7BPqssEw4cd/Lcumh3FE6O2yLtbnW59FV2tOL+X864xAKTHsZKfD5wlkMtbDvCc7iSxr2MdsHuXyp/F09XWAJEvjT3DtVaHnlxcvOgruXqB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535907; 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=Fp5wqS8+RvyLWbWkNHbb0LO3k44Y6gZ3tKRol245Ij4=; b=V3KwvdPzuV3h4B7R8DP/DNT4pkrvc6XuPR1eXCfu5YsqIyhjXnT0X/u2NpKPD9plW0QkhY7aKzR48WJkUdZN1TaSGUPbic4DWkLACuLfA8CIxT57pcDLkBw2NZoV9f3tVgQyes3afnXlCEXPOMmuXkrxw03yaOApEjNZrd2tQZk= 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 1619535907001452.7000582136627; Tue, 27 Apr 2021 08:05:07 -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-192-qOS1Q5-YPNeeKghJAqIIKA-1; Tue, 27 Apr 2021 11:05:02 -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 7898380362A; Tue, 27 Apr 2021 15:04:56 +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 547FB5D769; Tue, 27 Apr 2021 15:04:56 +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 D364144A5C; Tue, 27 Apr 2021 15:04:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF4oDl031871 for ; Tue, 27 Apr 2021 11:04:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0735660CC9; Tue, 27 Apr 2021 15:04:50 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CEA960C0F; Tue, 27 Apr 2021 15:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535904; 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=Fp5wqS8+RvyLWbWkNHbb0LO3k44Y6gZ3tKRol245Ij4=; b=hTBzQ/QxU6YrLP+c8Bwj6mgrNfIK1rpa8uIqAksLRfqFy6NIcbsrc4fhxfGLf3ReaWXKHO OPRiRbb9x5JZ/YMG7agY/fm1kkVydcJI9PmEUgO/YAw06wokPAjWxdANDIQJ3XD1yORRjX XB52KLo6hoiY0VQljryQ7tOngyHRbgI= X-MC-Unique: qOS1Q5-YPNeeKghJAqIIKA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 03/10] virDomainMemballoonDef: Change type of model to virDomainMemballoonModel Date: Tue, 27 Apr 2021 17:04:34 +0200 Message-Id: <20210427150441.206606-4-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" Signed-off-by: Tim Wiederhake Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 2 +- src/libxl/libxl_conf.c | 8 +++----- src/qemu/qemu_domain_address.c | 2 +- src/qemu/qemu_monitor.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 371a9dead7..5ce7a09848 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13913,6 +13913,7 @@ virDomainMemballoonDefParseXML(virDomainXMLOption *= xmlopt, g_autofree char *model =3D NULL; g_autofree char *freepage_reporting =3D NULL; g_autofree char *deflate =3D NULL; + int model_value; =20 def =3D g_new0(virDomainMemballoonDef, 1); =20 @@ -13923,11 +13924,12 @@ virDomainMemballoonDefParseXML(virDomainXMLOption= *xmlopt, goto error; } =20 - if ((def->model =3D virDomainMemballoonModelTypeFromString(model)) < 0= ) { + if ((model_value =3D virDomainMemballoonModelTypeFromString(model)) < = 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown memory balloon model '%s'"), model); goto error; } + def->model =3D model_value; =20 if ((deflate =3D virXMLPropString(node, "autodeflate"))) { int value; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a694b434c6..d9c0cb21d2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1924,7 +1924,7 @@ typedef enum { } virDomainMemballoonModel; =20 struct _virDomainMemballoonDef { - int model; + virDomainMemballoonModel model; virDomainDeviceInfo info; int period; /* seconds between collections */ virTristateSwitch autodeflate; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 3ccb00ec35..4de2158bea 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -740,9 +740,7 @@ libxlMakeDomBuildInfo(virDomainDef *def, =20 /* only the 'xen' balloon device model is supported */ if (def->memballoon) { - int model =3D def->memballoon->model; - - switch ((virDomainMemballoonModel)model) { + switch (def->memballoon->model) { case VIR_DOMAIN_MEMBALLOON_MODEL_XEN: break; case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO: @@ -750,7 +748,7 @@ libxlMakeDomBuildInfo(virDomainDef *def, case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported balloon device model '%s'"), - virDomainMemballoonModelTypeToString(model)); + virDomainMemballoonModelTypeToString(def->memba= lloon->model)); return -1; case VIR_DOMAIN_MEMBALLOON_MODEL_NONE: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -759,7 +757,7 @@ libxlMakeDomBuildInfo(virDomainDef *def, return -1; case VIR_DOMAIN_MEMBALLOON_MODEL_LAST: default: - virReportEnumRangeError(virDomainMemballoonModel, model); + virReportEnumRangeError(virDomainMemballoonModel, def->memball= oon->model); return -1; } } diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index e66efb3d1f..6c789615bd 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -882,7 +882,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDevic= eDef *dev, } =20 case VIR_DOMAIN_DEVICE_MEMBALLOON: - switch ((virDomainMemballoonModel) dev->data.memballoon->model) { + switch (dev->data.memballoon->model) { case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL: /* Transitional devices only work in conventional PCI slots */ return pciFlags; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 23161a0088..6d72b2aab0 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1030,7 +1030,7 @@ qemuMonitorInitBalloonObjectPath(qemuMonitor *mon, =20 switch (balloon->info.type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - switch ((virDomainMemballoonModel) balloon->model) { + switch (balloon->model) { case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO: name =3D "virtio-balloon-pci"; break; --=20 2.26.3 From nobody Thu Apr 25 06:32:16 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=1619535919; cv=none; d=zohomail.com; s=zohoarc; b=BDtNN96J8ldeeB+wWrMr9myyTEQQ/4vbjcVfnODolmroxiE2T3l6EMoDX9GfuRe1F0Xh60IWlTekx4Xj7bWBi2JrtFnaUKFbXyr8AVCdHk7cGgwvbP2QB1CiNdJoBf40wohq/soNUCr9Vi5Pv0bKg/u9dINRJUYzyToKV/ubJww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535919; 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=0+TQbg7q9rBTKYaOoqo+xBYU8TUIU/t8kWJSaFMFtmU=; b=RW64CWVKPA+J4GKIY/uBcmn11Ok6/ctriBQosIW7PV15HgzlJsMzR3kviSjbq6Cdeajqk7bvehZ5f5ApHByFt2TSdiIVxDkjSxa/7OJ5LgICvzAqf/+RS7KDGzcVH36fV3Hbf9te/jvEOd6yqPBkd5LFeHXrhGqQ1dEhlfyGCmA= 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 161953591976689.01040151012444; Tue, 27 Apr 2021 08:05:19 -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-435-el4d0lCdPUOIhKy21OTwRg-1; Tue, 27 Apr 2021 11:05:13 -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 74B67801106; Tue, 27 Apr 2021 15:05:06 +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 4C2A35D9C0; Tue, 27 Apr 2021 15:05:06 +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 ADA13180B617; Tue, 27 Apr 2021 15:05:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF4p3T031884 for ; Tue, 27 Apr 2021 11:04:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1BF7B60CC9; Tue, 27 Apr 2021 15:04:51 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CBA560C0F; Tue, 27 Apr 2021 15:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535917; 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=0+TQbg7q9rBTKYaOoqo+xBYU8TUIU/t8kWJSaFMFtmU=; b=dqAPa/SHPBd0El1g828IGrDIzJ1UCga72kjcakFklFHwOLoOelVAtIAn11W/+ccmLB8fea pSqIKeRHWgoVzj+zF/0VmHaUjwtM9kqyQxwOtT8YgLah2rmU/FpJmh93Vv2lX+2kwkvhPG k1J80kCrShlShDF0lNJmdrYVDSJkR6o= X-MC-Unique: el4d0lCdPUOIhKy21OTwRg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 04/10] virDomainMemballoonDefParseXML: Use virXMLProp* Date: Tue, 27 Apr 2021 17:04:35 +0200 Message-Id: <20210427150441.206606-5-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" Signed-off-by: Tim Wiederhake Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 57 +++++++++++++----------------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5ce7a09848..c9134c86c5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13909,59 +13909,36 @@ virDomainMemballoonDefParseXML(virDomainXMLOption= *xmlopt, { virDomainMemballoonDef *def; VIR_XPATH_NODE_AUTORESTORE(ctxt) + xmlNodePtr stats; unsigned int period =3D 0; - g_autofree char *model =3D NULL; - g_autofree char *freepage_reporting =3D NULL; - g_autofree char *deflate =3D NULL; - int model_value; + + ctxt->node =3D node; =20 def =3D g_new0(virDomainMemballoonDef, 1); =20 - model =3D virXMLPropString(node, "model"); - if (model =3D=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("balloon memory must contain model name")); + if (virXMLPropEnum(node, "model", virDomainMemballoonModelTypeFromStri= ng, + VIR_XML_PROP_REQUIRED, &def->model) < 0) goto error; - } =20 - if ((model_value =3D virDomainMemballoonModelTypeFromString(model)) < = 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown memory balloon model '%s'"), model); + if (virXMLPropTristateSwitch(node, "autodeflate", VIR_XML_PROP_NONE, + &def->autodeflate) < 0) goto error; - } - def->model =3D model_value; =20 - if ((deflate =3D virXMLPropString(node, "autodeflate"))) { - int value; - if ((value =3D virTristateSwitchTypeFromString(deflate)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid autodeflate attribute value '%s'"), = deflate); - goto error; - } - def->autodeflate =3D value; - } + if (virXMLPropTristateSwitch(node, "freePageReporting", + VIR_XML_PROP_NONE, + &def->free_page_reporting) < 0) + goto error; =20 - if ((freepage_reporting =3D virXMLPropString(node, "freePageReporting"= ))) { - int value; - if ((value =3D virTristateSwitchTypeFromString(freepage_reporting)= ) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid freePageReporting attribute value '%= s'"), freepage_reporting); + def->period =3D period; + if ((stats =3D virXPathNode("./stats", ctxt))) { + if (virXMLPropInt(stats, "period", 0, VIR_XML_PROP_NONE, + &def->period) < 0) goto error; - } - def->free_page_reporting =3D value; - } =20 - ctxt->node =3D node; - if (virXPathUInt("string(./stats/@period)", ctxt, &period) < -1) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("invalid statistics collection period")); - goto error; + if (def->period < 0) + def->period =3D 0; } =20 - def->period =3D period; - if (def->period < 0) - def->period =3D 0; - if (def->model =3D=3D VIR_DOMAIN_MEMBALLOON_MODEL_NONE) VIR_DEBUG("Ignoring device address for none model Memballoon"); else if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, --=20 2.26.3 From nobody Thu Apr 25 06:32:16 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=1619535922; cv=none; d=zohomail.com; s=zohoarc; b=Rd+MquHBhhWA+SYMiV/ZDm0ZSJvmsyZqJkvk7EUIjbzqNqBGgcn4zWZAXKEdDCcOCQQUqYyFC21qLRiWt4pCP4YC5/yN/+CBwa/tZxh1P2LSlBeTXEiolNFd37Lfvs5V6g/A0Tws51Suh7leIlc7SdrSwPJPFxkmB2S8fwthsN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535922; 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=RpN5lOtBq3FftIr7wMPOdOqen7vGZj38q1bPCd+pbjs=; b=Xnkb+1NLN8DcL4xKqE/fqaoVL08umEPyjl5Pt2n1OKAT/XfHzCUvp1bsimNEverJ0OL4EuizX0phktz9wJFgv/+v0wZiPwSL5oHgrvBQJCFN+ujBUkv41FPeE9s8zM5uNYxaTYgju0/PaGGpoSifRPkCvMHD8Qr+ge+bNqpAkDI= 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 1619535922012258.8535194152554; Tue, 27 Apr 2021 08:05:22 -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-218-uCoBkOxUOQmfTeJjX8zZIQ-1; Tue, 27 Apr 2021 11:05:15 -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 06938803625; Tue, 27 Apr 2021 15:05:10 +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 D8CAC6064B; Tue, 27 Apr 2021 15:05:09 +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 954D344A62; Tue, 27 Apr 2021 15:05:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF4qrX031892 for ; Tue, 27 Apr 2021 11:04:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 35EC960CC6; Tue, 27 Apr 2021 15:04:52 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77C9260C0F; Tue, 27 Apr 2021 15:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535919; 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=RpN5lOtBq3FftIr7wMPOdOqen7vGZj38q1bPCd+pbjs=; b=BkZdA9H6PP7Sowbso93jq4WG0q/7J+SoZfXjbf0TNsgyt6Stx5aq3gw2BCxa3zl8YvVZHd QVttMlYufE00HCRr4DodmjrfWN0el/jz7xQUb7OSgQD+07waUvM5hZhUrKs+zwSfcjXO2A mjKWRsZqJ2huFDHMXqMYWYw6GIb67qo= X-MC-Unique: uCoBkOxUOQmfTeJjX8zZIQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 05/10] virDomainShmemDef: Change type of model to virDomainShmemModel Date: Tue, 27 Apr 2021 17:04:36 +0200 Message-Id: <20210427150441.206606-6-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: J=C3=A1n Tomko --- src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_hotplug.c | 4 ++-- src/qemu/qemu_validate.c | 5 +++++ src/security/virt-aa-helper.c | 4 ++++ 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c9134c86c5..72d5545068 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13995,15 +13995,17 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, =20 tmp =3D virXPathString("string(./model/@type)", ctxt); if (tmp) { + int model; /* If there's none, we will automatically have the first one * (as default). Unfortunately this has to be done for * compatibility reasons. */ - if ((def->model =3D virDomainShmemModelTypeFromString(tmp)) < 0) { + if ((model =3D virDomainShmemModelTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Unknown shmem model type '%s'"), tmp); goto cleanup; } =20 + def->model =3D model; VIR_FREE(tmp); } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d9c0cb21d2..8afffd2451 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1955,7 +1955,7 @@ typedef enum { struct _virDomainShmemDef { char *name; unsigned long long size; - int model; /* enum virDomainShmemModel */ + virDomainShmemModel model; int role; /* enum virDomainShmemRole */ struct { bool enabled; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d7f1c715b6..8fb331eea0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9214,7 +9214,7 @@ qemuBuildShmemCommandLine(virLogManager *logManager, return -1; } =20 - switch ((virDomainShmemModel)shmem->model) { + switch (shmem->model) { case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM: devstr =3D qemuBuildShmemDevLegacyStr(def, shmem, qemuCaps); break; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 4344edc75b..58afa2fae6 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2978,7 +2978,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_SHMEM, { .shmem =3D shm= em } }; =20 - switch ((virDomainShmemModel)shmem->model) { + switch (shmem->model) { case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL: break; @@ -5583,7 +5583,7 @@ qemuDomainDetachPrepShmem(virDomainObj *vm, =20 *detach =3D shmem =3D vm->def->shmems[idx]; =20 - switch ((virDomainShmemModel)shmem->model) { + switch (shmem->model) { case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL: break; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 774426bceb..1d6881db5b 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4936,6 +4936,11 @@ qemuValidateDomainDeviceDefShmem(virDomainShmemDef *= shmem, virDomainShmemModelTypeToString(shmem->model)); return -1; } + break; + + case VIR_DOMAIN_SHMEM_MODEL_LAST: + virReportEnumRangeError(virDomainShmemModel, shmem->model); + return -1; } =20 return 0; diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 2331cc6648..e0d78ae309 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1209,6 +1209,10 @@ get_files(vahControl * ctl) mem_path =3D g_strdup_printf("/var/lib/libvirt/shmem-%s-so= ck", shmem->name); break; + case VIR_DOMAIN_SHMEM_MODEL_LAST: + virReportEnumRangeError(virDomainShmemModel, + shmem->model); + break; } if (mem_path !=3D NULL) { if (vah_add_file(&buf, mem_path, "rw") !=3D 0) --=20 2.26.3 From nobody Thu Apr 25 06:32:16 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=1619536226; cv=none; d=zohomail.com; s=zohoarc; b=TAGlN1S4mgdRFJ9rRL/VsITc3HBeXZ/Rnsp7zsrnbolL75SofESksA6JvQjNXVeCn15abSGzhn6QFXYnW9/DebnBRd8M/m6DSvfL0pZXsbCCVPjX0sz4JGYz1BUgh5RGUxPVvAvMkUEmznlQ8OcL4RPqpbbsDj2fs4ERymDeo/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619536226; 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=Vu0WO0iNx4MjpdCU1AnX+627a1WdlZXddcV5Q5BXILc=; b=NOuhH2vR3oa5X9xJFGlYBPdq/9aU65xOCHHlqVy8PJ9MqCZM777qh88qpygQfEIR580szOzIZXz/KHIY5u57xZuZNHphyXNYGMm80edyPHRpySj//lKrWfpowpNFR33qU9z/TzduOegZyOXFRGqrWRSWdPRt1TNjM54oVL4l5ao= 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 SMTP id 16195362265637.345784538577163; Tue, 27 Apr 2021 08:10:26 -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-534-TJRWlNy9MSOpbX2TRbfmQQ-1; Tue, 27 Apr 2021 11:05:18 -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 0B3CF8042A2; Tue, 27 Apr 2021 15:05:12 +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 DA82817567; Tue, 27 Apr 2021 15:05:09 +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 9605A180B617; Tue, 27 Apr 2021 15:05:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF4uEx031923 for ; Tue, 27 Apr 2021 11:04:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id D3F3060CC9; Tue, 27 Apr 2021 15:04:56 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AB5060C0F; Tue, 27 Apr 2021 15:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535924; 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=Vu0WO0iNx4MjpdCU1AnX+627a1WdlZXddcV5Q5BXILc=; b=eELNKyYVBCs3wMlxmihynjzsHQZBsDsYCpu0P4veON2dRtrb0tLJRM0MPyKebYjMaPhKfZ RYGi9bLgTaFbUWPpWg3Gb0klLcYdmQuR3x+kSOu7Ktf+0gQzXbhYiowgUMlxBaSELO/24o uWWZ9e4NjLzZVvAGmoAswVPvvqJf1/k= X-MC-Unique: TJRWlNy9MSOpbX2TRbfmQQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 06/10] virDomainShmemDef: Change type of role to virDomainShmemRole Date: Tue, 27 Apr 2021 17:04:37 +0200 Message-Id: <20210427150441.206606-7-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 --- src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 72d5545068..8b2a6dcf58 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14018,12 +14018,14 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, if (def->model !=3D VIR_DOMAIN_SHMEM_MODEL_IVSHMEM) { tmp =3D virXMLPropString(node, "role"); if (tmp) { - if ((def->role =3D virDomainShmemRoleTypeFromString(tmp)) <=3D= 0) { + int role; + if ((role =3D virDomainShmemRoleTypeFromString(tmp)) <=3D 0) { virReportError(VIR_ERR_XML_ERROR, _("Unknown shmem role type '%s'"), tmp); goto cleanup; } =20 + def->role =3D role; VIR_FREE(tmp); } } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8afffd2451..581ccb05a9 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1956,7 +1956,7 @@ struct _virDomainShmemDef { char *name; unsigned long long size; virDomainShmemModel model; - int role; /* enum virDomainShmemRole */ + virDomainShmemRole role; struct { bool enabled; virDomainChrSourceDef chr; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8fb331eea0..c17e1a987b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9120,7 +9120,7 @@ qemuBuildShmemDevStr(virDomainDef *def, } else { virBufferAsprintf(&buf, ",memdev=3Dshmmem-%s", shmem->info.alias); =20 - switch ((virDomainShmemRole) shmem->role) { + switch (shmem->role) { case VIR_DOMAIN_SHMEM_ROLE_MASTER: virBufferAddLit(&buf, ",master=3Don"); break; --=20 2.26.3 From nobody Thu Apr 25 06:32:16 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=1619535925; cv=none; d=zohomail.com; s=zohoarc; b=JqBaRsN4wydEGT1B1oSTBXhaa4wqHr1H4uD2hqeN+6c+BUeMCIsjLHHt0xqdkbGgk9JUY4dRy6UL1X67s2kGxyaBZh52ueD3TBsgME7mLfhwEznOY/fmd/nqN3JxSMQ0+HyNNs5zrBJEuECzUGV/7LklWhnU5IDcOqCXE6HGX88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535925; 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=XnqUu/htgWDo+Q7v1HqVPDUdb0Wsh428JAP/aUffgBU=; b=oLeJy29WHYBA6Sll7mO4qSzRu/wrzjm1P9pM3TJW+CDGnezA5whzbwHM1U2kAyv9KAEfwLkxvUOGbSKB2QsygZhpZSO0WggxepXYHSP5/T/6Z8C1gMrs+sQKFKmpUl11ADcXij5B43mCAH4PBJNduoE750z7gXiVaVq7uHNDCxU= 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 1619535925530852.5918271024308; Tue, 27 Apr 2021 08:05:25 -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-592-955KVkcON-Wz82lr2up-Fw-1; Tue, 27 Apr 2021 11:05:19 -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 18D20100962D; Tue, 27 Apr 2021 15:05:13 +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 E6FFF4D73A; Tue, 27 Apr 2021 15:05:12 +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 AB3E944A65; Tue, 27 Apr 2021 15:05:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF4vh6031932 for ; Tue, 27 Apr 2021 11:04:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id E6D6060CC9; Tue, 27 Apr 2021 15:04:57 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 324B860C0F; Tue, 27 Apr 2021 15:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535923; 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=XnqUu/htgWDo+Q7v1HqVPDUdb0Wsh428JAP/aUffgBU=; b=G+aKHDeyOrURqQEIbQKmvr5Rlkq4wAENGmxsfwUIG7Dfq3gEJ07IVM8SOgfRr/UCDmQtHF gXhzhxWq81O5iQPO7yXFPTqs355K65h59/R9PT2FQltLFRq13C6M9BVKcWuZdHP8gPnu1c 8bhCgcdMJDKcfPst5wf7CMr1XQrT3FI= X-MC-Unique: 955KVkcON-Wz82lr2up-Fw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 07/10] virDomainShmemDefParseXML: Use virXMLProp* Date: Tue, 27 Apr 2021 17:04:38 +0200 Message-Id: <20210427150441.206606-8-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: J=C3=A1n Tomko --- src/conf/domain_conf.c | 52 ++++++++++-------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8b2a6dcf58..a6547cad8e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13987,26 +13987,20 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, xmlNodePtr msi =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr server =3D NULL; + xmlNodePtr model; g_autofree char *tmp =3D NULL; =20 def =3D g_new0(virDomainShmemDef, 1); =20 ctxt->node =3D node; =20 - tmp =3D virXPathString("string(./model/@type)", ctxt); - if (tmp) { - int model; + if ((model =3D virXPathNode("./model", ctxt))) { /* If there's none, we will automatically have the first one * (as default). Unfortunately this has to be done for * compatibility reasons. */ - if ((model =3D virDomainShmemModelTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Unknown shmem model type '%s'"), tmp); + if (virXMLPropEnum(model, "type", virDomainShmemModelTypeFromStrin= g, + VIR_XML_PROP_NONE, &def->model) < 0) goto cleanup; - } - - def->model =3D model; - VIR_FREE(tmp); } =20 if (!(def->name =3D virXMLPropString(node, "name"))) { @@ -14016,18 +14010,9 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlo= pt, } =20 if (def->model !=3D VIR_DOMAIN_SHMEM_MODEL_IVSHMEM) { - tmp =3D virXMLPropString(node, "role"); - if (tmp) { - int role; - if ((role =3D virDomainShmemRoleTypeFromString(tmp)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Unknown shmem role type '%s'"), tmp); - goto cleanup; - } - - def->role =3D role; - VIR_FREE(tmp); - } + if (virXMLPropEnum(node, "role", virDomainShmemRoleTypeFromString, + VIR_XML_PROP_NONZERO, &def->role) < 0) + goto cleanup; } =20 if (virParseScaledValue("./size[1]", NULL, ctxt, @@ -14047,26 +14032,13 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, if ((msi =3D virXPathNode("./msi[1]", ctxt))) { def->msi.enabled =3D true; =20 - if ((tmp =3D virXMLPropString(msi, "vectors")) && - virStrToLong_uip(tmp, NULL, 0, &def->msi.vectors) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid number of vectors for shmem: '%s'"), - tmp); + if (virXMLPropUInt(msi, "vectors", 0, VIR_XML_PROP_NONE, + &def->msi.vectors) < 0) goto cleanup; - } - VIR_FREE(tmp); - - if ((tmp =3D virXMLPropString(msi, "ioeventfd"))) { - int val; =20 - if ((val =3D virTristateSwitchTypeFromString(tmp)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid msi ioeventfd setting for shmem:= '%s'"), - tmp); - goto cleanup; - } - def->msi.ioeventfd =3D val; - } + if (virXMLPropTristateSwitch(msi, "ioeventfd", VIR_XML_PROP_NONE, + &def->msi.ioeventfd) < 0) + goto cleanup; } =20 /* msi option is only relevant with a server */ --=20 2.26.3 From nobody Thu Apr 25 06:32:16 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=1619535929; cv=none; d=zohomail.com; s=zohoarc; b=PWkDkCBovl/BXKM09IyKzaC2ASKcWRW7yTc90ZB6o+CPnI62bwPNHctzFDbN82svrnJz62qmrXMkv8QjGfoYaxHfhbLWI8Ba2757Cif6vovEFaGFXyHjAx1YMfUVZF2hsPWz4ky6qbnixoCrZjsIoWsiDysK+Tc+umJLqM3zNDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535929; 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=YHQ24e8Eyj4HcfS6Cxz/xVQAIp+KwYaXSshVHNblJtQ=; b=Rc4r27omLblWJ4Up2ZcBJTpL99O/Giu075AVa5Dj+Iws0Fd5NDNUZ+QPR9LjPPUOQ278CAPIWO3oFOW7hZ4KnqNbP5u7S2y7P/mBW1jL+QAfDNS4Dfegxmubi9DM0rIxoA7fZykKgY7u4shY4a9X44Ol+RkUX8gaGFrXJtqeyh0= 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 1619535928971217.9263888872607; Tue, 27 Apr 2021 08:05:28 -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-262-x1eGacJ9NtC21Jb_cUHl9w-1; Tue, 27 Apr 2021 11:05:22 -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 8043E1009621; Tue, 27 Apr 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 541D55F7D0; Tue, 27 Apr 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 E1806180B654; Tue, 27 Apr 2021 15:05:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF52a4031959 for ; Tue, 27 Apr 2021 11:05:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 32D0060E3A; Tue, 27 Apr 2021 15:05:02 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4952960C0F; Tue, 27 Apr 2021 15:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535925; 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=YHQ24e8Eyj4HcfS6Cxz/xVQAIp+KwYaXSshVHNblJtQ=; b=g2zWjkyR41IbGN7NyZ16/VETSvVe3TmfvAoEsgLAw3Bc/gggxhnDxhxYhd8hS9/wTKi9BN U6989mn9Gx43l3yTDYGR8FKaXEoOAm1hnhxqjDBLCn/UCddYd2kuEKnZMk97L0nLX8AU+g WFDN3HtxeTjMoPyLe8MwHDxioAZKMj4= X-MC-Unique: x1eGacJ9NtC21Jb_cUHl9w-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 08/10] conf: domain: Register autoptr cleanup function for virDomainDeviceDef Date: Tue, 27 Apr 2021 17:04:39 +0200 Message-Id: <20210427150441.206606-9-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" Signed-off-by: Tim Wiederhake Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 581ccb05a9..8133d19fca 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3270,6 +3270,7 @@ void virDomainHubDefFree(virDomainHubDef *def); void virDomainRedirdevDefFree(virDomainRedirdevDef *def); void virDomainRedirFilterDefFree(virDomainRedirFilterDef *def); void virDomainShmemDefFree(virDomainShmemDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainShmemDef, virDomainShmemDefFree); void virDomainDeviceDefFree(virDomainDeviceDef *def); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDeviceDef, virDomainDeviceDefFree); --=20 2.26.3 From nobody Thu Apr 25 06:32:16 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=1619535966; cv=none; d=zohomail.com; s=zohoarc; b=Ho2RxF+hyhbOP4KDa8P1mfNlFa4hfqxj1ApyY3ocSZkAiWIZ8zEmFrM9XHCkmyhHO+93ayBkB5Y7v18BIVywxMIH08Wml0JEhxLyb8tzZQFS6xnuHoWlmbebop9a2tTT+GqXJvxp7C39BPD4q4YVRW4ZpnggQaFv41VLYDXYcdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535966; 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=NGKv/z0ZkzMksyDCKIwJAjFe+vSJWQJ5fI7iLCtyAQY=; b=aEtR6/cnOoMe4VOfbLpxhSjrrSMZ5CEFLj1Yx2Ev3q6TnKDRmFUCu5WDwvALKpr+yvraAJ7BiYtmm9Vv4EkH+/A0xie6PrqJnFaYqQhW8A/wClFJ1F72/sxKYRC80zzvR2BACXprzVNDE3LgFNY8gaAoWuJIdqiNfVUt7oDcTzM= 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 1619535966343991.2847199481206; Tue, 27 Apr 2021 08:06:06 -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-44-LLHO3pi9N8ObPzjc3vTHew-1; Tue, 27 Apr 2021 11:05:23 -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 5FA38804030; Tue, 27 Apr 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 1225E6A035; Tue, 27 Apr 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 CB7881806D20; Tue, 27 Apr 2021 15:05:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF5DcZ032033 for ; Tue, 27 Apr 2021 11:05:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id C09CC61093; Tue, 27 Apr 2021 15:05:13 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C07C61008; Tue, 27 Apr 2021 15:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535963; 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=NGKv/z0ZkzMksyDCKIwJAjFe+vSJWQJ5fI7iLCtyAQY=; b=Bpa3p1DfBvEFllFRbULO8Xdg1mPdORK6FOJx/jFiqm+7Cn9QP4/gujHWIttZ+yji3toFFE 44Kk/Rbyj+9w/Fqidj3xWrBpzCP8sGVhAwZ5XTBn5E3vZIIIP8/N1GxuYTJI96LtRqRue1 kj0po7WQC+MAqQacq4mSWXmYD+jCMck= X-MC-Unique: LLHO3pi9N8ObPzjc3vTHew-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 09/10] virDomainShmemDef: Use g_auto* Date: Tue, 27 Apr 2021 17:04:40 +0200 Message-Id: <20210427150441.206606-10-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" Signed-off-by: Tim Wiederhake Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a6547cad8e..2f7878da2b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13982,15 +13982,11 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, xmlXPathContextPtr ctxt, unsigned int flags) { - virDomainShmemDef *def =3D NULL; - virDomainShmemDef *ret =3D NULL; - xmlNodePtr msi =3D NULL; - VIR_XPATH_NODE_AUTORESTORE(ctxt) - xmlNodePtr server =3D NULL; + g_autoptr(virDomainShmemDef) def =3D g_new0(virDomainShmemDef, 1); xmlNodePtr model; - g_autofree char *tmp =3D NULL; - - def =3D g_new0(virDomainShmemDef, 1); + xmlNodePtr msi; + xmlNodePtr server; + VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 ctxt->node =3D node; =20 @@ -14000,33 +13996,33 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, * compatibility reasons. */ if (virXMLPropEnum(model, "type", virDomainShmemModelTypeFromStrin= g, VIR_XML_PROP_NONE, &def->model) < 0) - goto cleanup; + return NULL; } =20 if (!(def->name =3D virXMLPropString(node, "name"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("shmem element must contain 'name' attribute")); - goto cleanup; + return NULL; } =20 if (def->model !=3D VIR_DOMAIN_SHMEM_MODEL_IVSHMEM) { if (virXMLPropEnum(node, "role", virDomainShmemRoleTypeFromString, VIR_XML_PROP_NONZERO, &def->role) < 0) - goto cleanup; + return NULL; } =20 if (virParseScaledValue("./size[1]", NULL, ctxt, &def->size, 1, ULLONG_MAX, false) < 0) - goto cleanup; + return NULL; =20 if ((server =3D virXPathNode("./server[1]", ctxt))) { - def->server.enabled =3D true; + g_autofree char *tmp =3D NULL; =20 + def->server.enabled =3D true; def->server.chr.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; def->server.chr.data.nix.listen =3D false; if ((tmp =3D virXMLPropString(server, "path"))) def->server.chr.data.nix.path =3D virFileSanitizePath(tmp); - VIR_FREE(tmp); } =20 if ((msi =3D virXPathNode("./msi[1]", ctxt))) { @@ -14034,28 +14030,25 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, =20 if (virXMLPropUInt(msi, "vectors", 0, VIR_XML_PROP_NONE, &def->msi.vectors) < 0) - goto cleanup; + return NULL; =20 if (virXMLPropTristateSwitch(msi, "ioeventfd", VIR_XML_PROP_NONE, &def->msi.ioeventfd) < 0) - goto cleanup; + return NULL; } =20 /* msi option is only relevant with a server */ if (def->msi.enabled && !def->server.enabled) { virReportError(VIR_ERR_XML_ERROR, "%s", _("msi option is only supported with a server")); - goto cleanup; + return NULL; } =20 if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) - goto cleanup; + return NULL; =20 =20 - ret =3D g_steal_pointer(&def); - cleanup: - virDomainShmemDefFree(def); - return ret; + return g_steal_pointer(&def); } =20 static int --=20 2.26.3 From nobody Thu Apr 25 06:32:16 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=1619535934; cv=none; d=zohomail.com; s=zohoarc; b=RL9WzYk5LEUFpSagH9CG9cdQeGmj3/plFJNsa1qmhp4OnpE1t+veUSBcoaC9AlO512vkfPMytbOQSu3Z/HxZRLQ0B6ITbgnzr+Dd8AVzqO71E2yROZGyXXSfqIPUPKJET2bRcOjz61uslDSQ9vN0CMz1RqOe9j/cGPRe+Q0RNvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535934; 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=uhfLmwvVlu5WZaJ8UgSnc+P+mvNC+bAYT2bnRGgsvUA=; b=hb5b0BPv/+UEh/5TPbFs5IP9PbzvuXrTbaaEFJyvFZz9WFHhcw2WdZQRgNY/S656baDSfhW93OBljgcDA/HTKZSQTVBqhtF40U/Clz43lSfJJFfcKcEUMavNO9OpTUx86f86YhYSZgW1i9QSSCjWw0CrQBVZ8An67aRrXjJHps8= 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 1619535934661263.1916953228707; Tue, 27 Apr 2021 08:05: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-63-1vqbf3pdMqiQYc06v2w4LA-1; Tue, 27 Apr 2021 11:05:29 -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 868C3107ACED; Tue, 27 Apr 2021 15:05:22 +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 5C4BF1002D71; Tue, 27 Apr 2021 15:05: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 236D81806D25; Tue, 27 Apr 2021 15:05:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF5KaR032098 for ; Tue, 27 Apr 2021 11:05:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id E226561008; Tue, 27 Apr 2021 15:05:20 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id C69E960C0F; Tue, 27 Apr 2021 15:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535932; 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=uhfLmwvVlu5WZaJ8UgSnc+P+mvNC+bAYT2bnRGgsvUA=; b=TYrYM+d0peTuTgp0KwDUMemeZLNhDVcCTePZ+CFnEKYoU5FOGPaiC3rRKcuuhKvoXs/tDc 9+kYNJwW9cCoElsZpfX2GiVUKEERTLH3414l7VnNTvZsF9zyMaGfrFCLDpi2KWp2bpzj+f 8/vMYTSUwEDpPqHOhqgkB7+j7Az2wD4= X-MC-Unique: 1vqbf3pdMqiQYc06v2w4LA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 10/10] virDomainRedirFilterUSBDevDefParseXML: Use virXMLProp* Date: Tue, 27 Apr 2021 17:04:41 +0200 Message-Id: <20210427150441.206606-11-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: J=C3=A1n Tomko --- src/conf/domain_conf.c | 66 +++++++++++------------------------------- 1 file changed, 17 insertions(+), 49 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2f7878da2b..805494ca11 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14935,52 +14935,28 @@ static virDomainRedirFilterUSBDevDef * virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node) { virDomainRedirFilterUSBDevDef *def; - g_autofree char *class =3D NULL; - g_autofree char *vendor =3D NULL; - g_autofree char *product =3D NULL; g_autofree char *version =3D NULL; - g_autofree char *allow =3D NULL; + virTristateBool allow; =20 def =3D g_new0(virDomainRedirFilterUSBDevDef, 1); =20 - class =3D virXMLPropString(node, "class"); - if (class) { - if ((virStrToLong_i(class, NULL, 0, &def->usbClass)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Cannot parse USB Class code %s"), class); - goto error; - } + def->usbClass =3D -1; + if (virXMLPropInt(node, "class", 0, VIR_XML_PROP_NONE, &def->usbClass)= < 0) + goto error; =20 - if (def->usbClass !=3D -1 && def->usbClass &~ 0xFF) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid USB Class code %s"), class); - goto error; - } - } else { - def->usbClass =3D -1; + if (def->usbClass !=3D -1 && def->usbClass &~ 0xFF) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid USB Class code 0x%x"), def->usbClass); + goto error; } =20 - vendor =3D virXMLPropString(node, "vendor"); - if (vendor) { - if ((virStrToLong_i(vendor, NULL, 0, &def->vendor)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Cannot parse USB vendor ID %s"), vendor); - goto error; - } - } else { - def->vendor =3D -1; - } + def->vendor =3D -1; + if (virXMLPropInt(node, "vendor", 0, VIR_XML_PROP_NONE, &def->vendor) = < 0) + goto error; =20 - product =3D virXMLPropString(node, "product"); - if (product) { - if ((virStrToLong_i(product, NULL, 0, &def->product)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Cannot parse USB product ID %s"), product); - goto error; - } - } else { - def->product =3D -1; - } + def->product =3D -1; + if (virXMLPropInt(node, "product", 0, VIR_XML_PROP_NONE, &def->product= ) < 0) + goto error; =20 version =3D virXMLPropString(node, "version"); if (version) { @@ -14992,18 +14968,10 @@ virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr = node) def->version =3D -1; } =20 - allow =3D virXMLPropString(node, "allow"); - if (allow) { - if (virStringParseYesNo(allow, &def->allow) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Invalid allow value, either 'yes' or 'no'")); - goto error; - } - } else { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing allow attribute for USB redirection filt= er")); + if (virXMLPropTristateBool(node, "allow", VIR_XML_PROP_REQUIRED, &allo= w) < 0) goto error; - } + + def->allow =3D allow =3D=3D VIR_TRISTATE_BOOL_YES; =20 return def; =20 --=20 2.26.3