From nobody Fri May 10 06:43:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 16496808890951022.1120754079127; Mon, 11 Apr 2022 05:41:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-189-vN41oHkeMxSdX5bXU8M4dA-1; Mon, 11 Apr 2022 08:41:25 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88E7F2999B2F; Mon, 11 Apr 2022 12:41:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FC41145B994; Mon, 11 Apr 2022 12:41:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1A78719451F2; Mon, 11 Apr 2022 12:41:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CC46619451F2 for ; Mon, 11 Apr 2022 12:41:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BF35540EC00A; Mon, 11 Apr 2022 12:41:14 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAD5F40EC004 for ; Mon, 11 Apr 2022 12:41:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A250086B8A8 for ; Mon, 11 Apr 2022 12:41:14 +0000 (UTC) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-ubKkd333PlKd0J5S6QzRJw-1; Mon, 11 Apr 2022 08:41:13 -0400 Received: by mail-pl1-f175.google.com with SMTP id n8so13738553plh.1 for ; Mon, 11 Apr 2022 05:41:12 -0700 (PDT) Received: from localhost.localdomain ([103.199.136.213]) by smtp.gmail.com with ESMTPSA id r35-20020a635163000000b0039d2213ca6csm6527247pgl.45.2022.04.11.05.41.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Apr 2022 05:41:11 -0700 (PDT) X-MC-Unique: vN41oHkeMxSdX5bXU8M4dA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ubKkd333PlKd0J5S6QzRJw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xZfvOtl2b0Y3U0Y3vFnLZQwfs/LndjgFrWrrHzcg3PY=; b=c2ugsrbhpTzhe4JDRo5PbuxMYFmlUpPMBhOhVPou+xm5e9ijlEcW7Wdyod6/5jzUI1 JrKK6s1fiIefapfOXxr5QTRrffDuMqUDg6R8RLZa0VcWAagaqCl6QWz7HPLph7JP9Bt/ BZclT+jgsUa7h+zfn5Tns+3dwYlZ33CsYM80JEpkKoPSM1MYxmDjlDz3g6a2YZ9kTHNo qaEe2bZlVsMXzIeHOtSWR73EW8D8gNb7564cunLiRqPMhk8RUpZqjNJwreO2BGxjWUTq 323ZviifJwjJtlqXpM848uztOyHLDMlSiT9jbXolRFxppktfILSfzz+k5lcJK56OsGO8 Eeeg== X-Gm-Message-State: AOAM5312AS1gfx0Y9MgivABLxLbyTbR0UmvxCTjJ3rQlekwNA+wdi6oe zqFHSgNoVRE60ulja9jCao6g/bTX8Cid/Q== X-Google-Smtp-Source: ABdhPJw257eGm2VhIu5SDCiFGg/3oBL+c4GDowNajN/G3gf3QN/shtvump1l8sLESkn6WOUUuVyi/w== X-Received: by 2002:a17:903:22cc:b0:158:3bea:5862 with SMTP id y12-20020a17090322cc00b001583bea5862mr10489169plg.48.1649680871562; Mon, 11 Apr 2022 05:41:11 -0700 (PDT) From: Moteen Shah X-Google-Original-From: Moteen Shah To: libvir-list@redhat.com Subject: [PATCH v3] conf: Move validation checks from virDomainDiskDefIotuneParse into domain_validate.c Date: Mon, 11 Apr 2022 18:10:49 +0530 Message-Id: <20220411124049.98272-1-codeguy.moteen@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Moteen Shah Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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-ZM-MESSAGEID: 1649680889759100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Move validation from virDomainDiskDefIotuneParse into the validation callba= ck Signed-off-by: Moteen Shah Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 40 -------------------------------------- src/conf/domain_validate.c | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5dd269b283..bd2884088c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8790,46 +8790,6 @@ virDomainDiskDefIotuneParse(virDomainDiskDef *def, def->blkdeviotune.group_name =3D virXPathString("string(./iotune/group_name)", ctxt); =20 - if ((def->blkdeviotune.total_bytes_sec && - def->blkdeviotune.read_bytes_sec) || - (def->blkdeviotune.total_bytes_sec && - def->blkdeviotune.write_bytes_sec)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write bytes_sec " - "cannot be set at the same time")); - return -1; - } - - if ((def->blkdeviotune.total_iops_sec && - def->blkdeviotune.read_iops_sec) || - (def->blkdeviotune.total_iops_sec && - def->blkdeviotune.write_iops_sec)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write iops_sec " - "cannot be set at the same time")); - return -1; - } - - if ((def->blkdeviotune.total_bytes_sec_max && - def->blkdeviotune.read_bytes_sec_max) || - (def->blkdeviotune.total_bytes_sec_max && - def->blkdeviotune.write_bytes_sec_max)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write bytes_sec_max " - "cannot be set at the same time")); - return -1; - } - - if ((def->blkdeviotune.total_iops_sec_max && - def->blkdeviotune.read_iops_sec_max) || - (def->blkdeviotune.total_iops_sec_max && - def->blkdeviotune.write_iops_sec_max)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write iops_sec_max " - "cannot be set at the same time")); - return -1; - } - return 0; } #undef PARSE_IOTUNE diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index d6869e8fd8..68190fc3e2 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -651,6 +651,43 @@ virDomainDiskDefValidate(const virDomainDef *def, } } =20 + /* Validate IotuneParse */ + if ((disk->blkdeviotune.total_bytes_sec && + disk->blkdeviotune.read_bytes_sec) || + (disk->blkdeviotune.total_bytes_sec && + disk->blkdeviotune.write_bytes_sec)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write bytes_sec cannot be set at = the same time")); + return -1; + } + + if ((disk->blkdeviotune.total_iops_sec && + disk->blkdeviotune.read_iops_sec) || + (disk->blkdeviotune.total_iops_sec && + disk->blkdeviotune.write_iops_sec)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write iops_sec cannot be set at t= he same time")); + return -1; + } + + if ((disk->blkdeviotune.total_bytes_sec_max && + disk->blkdeviotune.read_bytes_sec_max) || + (disk->blkdeviotune.total_bytes_sec_max && + disk->blkdeviotune.write_bytes_sec_max)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write bytes_sec_max cannot be set= at the same time")); + return -1; + } + + if ((disk->blkdeviotune.total_iops_sec_max && + disk->blkdeviotune.read_iops_sec_max) || + (disk->blkdeviotune.total_iops_sec_max && + disk->blkdeviotune.write_iops_sec_max)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write iops_sec_max cannot be set = at the same time")); + return -1; + } + /* Reject disks with a bus type that is not compatible with the * given address type. The function considers only buses that are * handled in common code. For other bus types it's not possible --=20 2.35.1