From nobody Sat Apr 20 14:03:08 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 1552416899598664.8289913424676; Tue, 12 Mar 2019 11:54:59 -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 933A288AB0; Tue, 12 Mar 2019 18:54:56 +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 6C9EB1797C; Tue, 12 Mar 2019 18:54:54 +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 520FC181A136; Tue, 12 Mar 2019 18:54:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2CIsmog001468 for ; Tue, 12 Mar 2019 14:54:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 379421001DEA; Tue, 12 Mar 2019 18:54:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30ED11001E6A for ; Tue, 12 Mar 2019 18:54:45 +0000 (UTC) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.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 BD12D3082E69 for ; Tue, 12 Mar 2019 18:54:44 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id k11so2496907pgb.8 for ; Tue, 12 Mar 2019 11:54:44 -0700 (PDT) Received: from localhost.localdomain (ip72-208-5-168.ph.ph.cox.net. [72.208.5.168]) by smtp.gmail.com with ESMTPSA id a1sm11499212pgt.11.2019.03.12.11.54.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 11:54:43 -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=R8rYkQHHPBj+dGenWNgZnqH7yqdLgNoPoRW99GW1NzQ=; b=tVo3FcIiCEc4StZLAQLUNB1Z4XBhBPo6A7lHEnmmv030Psy5knANRkX87JG1aIM4Fr oQwWyD+q/aLpDYpKSBvHrrSQ/5+XAZoSj0itTLRPZybRQqb0tjD7vrAtKrNK3eu0J1YQ 1VHw4P0Uy6XN3r2+H5i/5hGuPfXMJbI6KxkXA5lE6+c8YjgckB45RvXsUz9gR2ZXKFGW 6GP+wrloAxDDgiXOCwibpcWMdwF4IuwmZtm5goFzmoWvQ6lZWOWdHBjxRTCRJtvRqVVa uXmFfQzVHM0nYlTgf7E2XZRfBx1pKxIySVMCQk1A2lzvNn6YqskT/KCWiqjQYPGhaSYw 9uFQ== 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=R8rYkQHHPBj+dGenWNgZnqH7yqdLgNoPoRW99GW1NzQ=; b=b6orj1GOfgTFP3oiGzhFGyIbgswGpziFMNPnUFz87Ejt2uFfRPApvOIEAEzpUSWo91 Qa27SQrO6smrGOYE7ypucegzCXeVs6wYdQ2m6IByjO7W3pqtkhNnKMREy4XkPUJUMo5f MZpooBgZJDcDUt4gWws5SK760hGZO16yACMNgeme8bQ83weqU9eybwngy/rvORw0UZ8l JyxHZJV0qX3c/8WWee4PrInF1MG06mfa2DchObk6hElC/redOtVMZHaoKCWy78RlwMEl a3L92N0MHIJOiKcleB+YQ3UyAuJGYxR5DCXApa+5AmHBt/tjwmBxGz0hO8rIJGyq6H/y +xYA== X-Gm-Message-State: APjAAAVKu1uY/D+j88VDU5sLPQFBDTBj5/hAwolfq3WhNSK2IROKskr9 fmsp6x9HM9wnDPIhDbtur8UzeUez X-Google-Smtp-Source: APXvYqzxiuJSznp5zfWd19cNTv0kTmpWjcbg/18n4KdI3xKQQsU6uMdk3mGIOKOJg8jsK20r1WFdxw== X-Received: by 2002:a65:41ca:: with SMTP id b10mr36495469pgq.146.1552416883850; Tue, 12 Mar 2019 11:54:43 -0700 (PDT) From: Suyang Chen To: libvir-list@redhat.com Date: Tue, 12 Mar 2019 12:54:05 -0600 Message-Id: <20190312185405.3442-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.46]); Tue, 12 Mar 2019 18:54:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 12 Mar 2019 18:54:44 +0000 (UTC) for IP:'209.85.215.195' DOMAIN:'mail-pg1-f195.google.com' HELO:'mail-pg1-f195.google.com' FROM:'dawson0xff@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.215.195 mail-pg1-f195.google.com 209.85.215.195 mail-pg1-f195.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.26]); Tue, 12 Mar 2019 18:54:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Solve the bitsizedtask: "Move validation checks out of domain XML parsing" Resolves: https://wiki.libvirt.org/page/BiteSizedTasks#Move_validation_chec= ks_out_of_domain_XML_parsing Signed-off-by: Suyang Chen --- src/conf/domain_conf.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 995f87bcbe..eb63800b9a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6589,6 +6589,46 @@ virDomainDefMemtuneValidate(const virDomainDef *def) return 0; } =20 +static int +virDomainDefCputuneValidate(const virDomainDef *def) +{ + 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.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 +6668,9 @@ virDomainDefValidateInternal(const virDomainDef *def) if (virDomainDefMemtuneValidate(def) < 0) return -1; =20 + if (virDomainDefCputuneValidate(def) < 0) + return -1; + return 0; } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list