From nobody Tue Apr 23 10:03:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552426381255623.0301405894804; Tue, 12 Mar 2019 14:33:01 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5B6AD3092646; Tue, 12 Mar 2019 21:32:58 +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 E6B3317A91; Tue, 12 Mar 2019 21:32: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 68D66181A136; Tue, 12 Mar 2019 21:32:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2CLWrhf030954 for ; Tue, 12 Mar 2019 17:32:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id A1C3660169; Tue, 12 Mar 2019 21:32:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9BB3860163 for ; Tue, 12 Mar 2019 21:32:51 +0000 (UTC) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B53D5C04959C for ; Tue, 12 Mar 2019 21:32:50 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id a3so2740495pff.11 for ; Tue, 12 Mar 2019 14:32:50 -0700 (PDT) Received: from localhost.localdomain.localdomain ([150.135.165.9]) by smtp.gmail.com with ESMTPSA id b6sm15089310pfo.27.2019.03.12.14.32.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 14:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HABZY24ATeSwMzsKOeSWx0hA5JSHVJLO3ZLcqhvWS0s=; b=O+YjQjK9JmjC//yKJb97lsaBKdbmvLaa8pF+zlVQX+9uleqAbsu/KJdYLKdl+djgRx WuXmyjxJEQS8uH9SuRyP/o5/pPq4e6cenajzbfg01PTqko3NoU3McCWiwnfmgzEEXi3N eDUZiElLWwBlUYANClpKVCEqDMeFm8ccG6Pxu2nSEw4Oa+NUIrnSiq4zffCM/UDMv+2s BzIyV1X/XfU1NCYn1Z1Eh9Scg2/evrFxheDxUan+DvABRGQdTGxlITSDVBcSNeBB0ZD2 LyNkeCWQYf+RmUyZT0GAkzPZAkWQcc6B4KP7Mn9BTOW3rfHR0oh0cyDeHk1lbo29CYES mryA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HABZY24ATeSwMzsKOeSWx0hA5JSHVJLO3ZLcqhvWS0s=; b=Pc92BVKDk0gjP9ELK1t6Kjdu/Z60ezuS52gjRc1UnVhbRpqj6owgxxzdOB76ku92Ry 6wa+Z4M2wU6CA/cU5FWNIM1Rsb6eJbGQfTr3NMlOMbxkUeNB4Cts7i58BY2iNda0X/O+ gtQUmvmxa3YBMrRi18hRGNCp7f6k3BfZH33MppwNb1rwvo6DzAB+uQgHmiWdTsbtrS0e 8sHQdhV0zHpMEffF6j9sFRL7h6KP6YMXuz+yeTIN1FB0cPSVWtSmdr6Grh7kJnwAoFEn 9QGPDxTcUD15qRVEYRDhMoV7xxTsQUPLef1LvyPmWPaCZFfM7ZYcY37PAnxXhbGBoyqr aHQw== X-Gm-Message-State: APjAAAU1ccOeSdAae91BP3w/uSRloO5c7vcKyFzI++N8vgBd3R8KVrpz eTJ0SV1yfJCx5FkWMLIHjsy5C4M9 X-Google-Smtp-Source: APXvYqw7s9EIdvP0v0sHXYTiYvQk9TfXC2TGxUQ/H8ZXVTjbhGeAn7dSGl/9cQhPmsYd2ynvVS1RnA== X-Received: by 2002:a62:7602:: with SMTP id r2mr40313201pfc.191.1552426369820; Tue, 12 Mar 2019 14:32:49 -0700 (PDT) From: Suyang Chen To: libvir-list@redhat.com Date: Tue, 12 Mar 2019 15:32:40 -0600 Message-Id: <20190312213240.74232-1-dawson0xff@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 12 Mar 2019 21:32:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 12 Mar 2019 21:32:50 +0000 (UTC) for IP:'209.85.210.195' DOMAIN:'mail-pf1-f195.google.com' HELO:'mail-pf1-f195.google.com' FROM:'dawson0xff@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.108 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.210.195 mail-pf1-f195.google.com 209.85.210.195 mail-pf1-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Suyang Chen Subject: [libvirt] [PATCH] conf: Add a function virDomainDefCputuneValidate 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 12 Mar 2019 21:32:59 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" move all the def->cputune 'period must be in range' errors into virDomainDefCputuneValidate function and have it called from virDomainDefValidateInternal and virDomainDefParseXML function Solve the bitsizedtask: "Move validation checks out of domain XML parsing" Resolves: https://wiki.libvirt.org/page/BiteSizedTasks#Move_validation_checks_out_of_= domain_XML_parsing Signed-off-by: Suyang Chen --- src/conf/domain_conf.c | 75 ++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 995f87bcbe..e17ca0e0cb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6589,6 +6589,45 @@ virDomainDefMemtuneValidate(const virDomainDef *def) return 0; } =20 +static int +virDomainDefCputuneValidate(const virDomainDef *def) +{ + if (def->cputune.period > 0 && + (def->cputune.period < 1000 || def->cputune.period > 1000000)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Value of cputune period must be in range " + "[1000, 1000000]")); + return -1; + } + + if (def->cputune.global_period > 0 && + (def->cputune.global_period < 1000 || def->cputune.global_period >= 1000000)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Value of cputune global period must be in range " + "[1000, 1000000]")); + return -1; + } + + if (def->cputune.emulator_period > 0 && + (def->cputune.emulator_period < 1000 || + def->cputune.emulator_period > 1000000)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Value of cputune emulator_period must be in rang= e " + "[1000, 1000000]")); + return -1; + } + + if (def->cputune.iothread_period > 0 && + (def->cputune.iothread_period < 1000 || + def->cputune.iothread_period > 1000000)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Value of cputune iothread_period must be in rang= e " + "[1000, 1000000]")); + return -1; + } + + return 0; +} =20 static int virDomainDefValidateInternal(const virDomainDef *def) @@ -6628,6 +6667,9 @@ virDomainDefValidateInternal(const virDomainDef *def) if (virDomainDefMemtuneValidate(def) < 0) return -1; =20 + if (virDomainDefCputuneValidate(def) < 0) + return -1; + return 0; } =20 @@ -19594,13 +19636,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } =20 - if (def->cputune.period > 0 && - (def->cputune.period < 1000 || def->cputune.period > 1000000)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Value of cputune period must be in range " - "[1000, 1000000]")); + if (virDomainDefCputuneValidate(def) < 0) goto error; - } =20 if (virXPathLongLong("string(./cputune/quota[1])", ctxt, &def->cputune.quota) < -1) { @@ -19625,14 +19662,6 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } =20 - if (def->cputune.global_period > 0 && - (def->cputune.global_period < 1000 || def->cputune.global_period >= 1000000)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Value of cputune global period must be in range " - "[1000, 1000000]")); - goto error; - } - if (virXPathLongLong("string(./cputune/global_quota[1])", ctxt, &def->cputune.global_quota) < -1) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -19656,15 +19685,6 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } =20 - if (def->cputune.emulator_period > 0 && - (def->cputune.emulator_period < 1000 || - def->cputune.emulator_period > 1000000)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Value of cputune emulator_period must be in rang= e " - "[1000, 1000000]")); - goto error; - } - if (virXPathLongLong("string(./cputune/emulator_quota[1])", ctxt, &def->cputune.emulator_quota) < -1) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -19688,15 +19708,6 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } =20 - if (def->cputune.iothread_period > 0 && - (def->cputune.iothread_period < 1000 || - def->cputune.iothread_period > 1000000)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Value of cputune iothread_period must be in rang= e " - "[1000, 1000000]")); - goto error; - } - if (virXPathLongLong("string(./cputune/iothread_quota[1])", ctxt, &def->cputune.iothread_quota) < -1) { virReportError(VIR_ERR_XML_ERROR, "%s", --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list