From nobody Fri May 10 08:39:32 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 1649352482776772.3481815432713; Thu, 7 Apr 2022 10:28:02 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-489-8E6T64RZNeeh0-eCt5y0NQ-1; Thu, 07 Apr 2022 13:27:54 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C2705185A7BA; Thu, 7 Apr 2022 17:27:51 +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 3A43C40CF91D; Thu, 7 Apr 2022 17:27:51 +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 E0A061949761; Thu, 7 Apr 2022 17:27:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2BFF31947BBE for ; Thu, 7 Apr 2022 17:27:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AB4D51400C2D; Thu, 7 Apr 2022 17:27:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A74171402642 for ; Thu, 7 Apr 2022 17:27:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 77737811E7A for ; Thu, 7 Apr 2022 17:27:49 +0000 (UTC) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-507-LcYuuCU9PHeBN-1rCdiykQ-1; Thu, 07 Apr 2022 13:27:40 -0400 Received: by mail-pj1-f54.google.com with SMTP id u14so6263009pjj.0 for ; Thu, 07 Apr 2022 10:27:40 -0700 (PDT) Received: from localhost.localdomain ([2405:204:1e:2d9e:99b0:30b7:4912:b008]) by smtp.gmail.com with ESMTPSA id f31-20020a17090a702200b001ca996866b5sm9441828pjk.12.2022.04.07.10.27.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Apr 2022 10:27:38 -0700 (PDT) X-MC-Unique: 8E6T64RZNeeh0-eCt5y0NQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: LcYuuCU9PHeBN-1rCdiykQ-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=EbzQwk0sjTPF6sU1gow8uT7s5nGjk84WXNb1+hVA3U4=; b=iqMqOkKicG180S4zs7KEr022xOzCAjXcxEmVRL+kicDOHyeTsVhX4d6CZqXy+P6xCm 45i3c+m54JTbTH64CJ4Xv5nozUqJNJR7iapnioz5DhmaK+pP58uIv0/wdRDtFzIJL11P 5+LaND/KzhTdIgoY9c2SOWu2s/sZtx93Wt4WXe95cflKx9XIj/0ItzXxcGIGcAvOMPcz /jk2DrV4jaRZ2aMl/bpHqETWW+pqt9z8DrTqhKD2qg1lecOf8WtvIAFmZwu4uTnH94QI amq+jYlvAPo7lUa0kw4TyDIfZZXEedYRfPXSKk/HsWdLDkng4nMKuUTBoZlSxBYaUdWF BoqQ== X-Gm-Message-State: AOAM531mSZ+wl7FGyGMd9wi5s9LbPJClnBMu8k7/qcRjrsvbX2sUhKuP mEY7vUAfnplce7TXUyF/+gZUydIdWyR9Zw== X-Google-Smtp-Source: ABdhPJyQfpUesPku/TDVZT8HDlcaYgmPLilfIbyrmpdTbe/CD+at3Q7y4nTr9fqN0C8AB1oakV/dkw== X-Received: by 2002:a17:902:c941:b0:156:9ad7:d375 with SMTP id i1-20020a170902c94100b001569ad7d375mr14827114pla.167.1649352459024; Thu, 07 Apr 2022 10:27:39 -0700 (PDT) From: Moteen Shah X-Google-Original-From: Moteen Shah To: libvir-list@redhat.com Subject: [PATCH v2] conf: Move validation from virDomainDiskDefIotuneParse into the validation callback Date: Thu, 7 Apr 2022 22:57:29 +0530 Message-Id: <20220407172729.28923-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.85 on 10.11.54.7 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.84 on 10.11.54.1 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: 8bit Content-Type: application/octet-stream; x-default=true X-Zoho-Virus-Status: 1 X-ZM-MESSAGEID: 1649352484188100001 From: Moteen Shah all the option collision total and... error messages in virDomainDiskDefIotuneParse shifted to validation callback Signed-off-by: Moteen Shah --- src/conf/domain_conf.c | 55 +++----------------------------------- src/conf/domain_validate.c | 42 ++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 52 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f2480f37f6..48132c2f97 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1408,7 +1408,6 @@ VIR_ENUM_IMPL(virDomainSnapshotLocation, "no", "internal", "external", - "manual", ); /* Internal mapping: subset of block job types that can be present in @@ -6229,51 +6228,6 @@ virDomainDefPostParseCheckFailure(virDomainDef *def, return 0; } -static int -virDomainDefPostParseCheck(virDomainDiskDef *def) -{ - 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; -} - int virDomainDefPostParse(virDomainDef *def, unsigned int parseFlags, @@ -8826,9 +8780,9 @@ virDomainDiskDefIotuneParse(virDomainDiskDef *def, PARSE_IOTUNE(write_iops_sec_max_length); def->blkdeviotune.group_name = - virXPathString("string(./iotune/group_name)", ctxt); - - return virDomainDefPostParseCheck(def); + virXPathString("string(./iotune/group_name)", ctxt); + + return 0; } #undef PARSE_IOTUNE @@ -9278,8 +9232,7 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, return NULL; } - if (virDomainDiskDefIotuneParse(def, ctxt) < 0) - return NULL; + virDomainDiskDefIotuneParse(def, ctxt); def->domain_name = virXPathString("string(./backenddomain/@name)", ctxt); def->serial = virXPathString("string(./serial)", ctxt); diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index d6869e8fd8..4bdb95aa13 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -597,7 +597,6 @@ virDomainDiskDefSourceLUNValidate(const virStorageSource *src) return 0; } - static int virDomainDiskDefValidate(const virDomainDef *def, const virDomainDiskDef *disk) @@ -651,6 +650,47 @@ virDomainDiskDefValidate(const virDomainDef *def, } } + /* 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 the 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 -- 2.35.1