From nobody Tue Feb 10 12:57:44 2026 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