From nobody Sun May 19 00:17:35 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 1649497162377347.0112026508368; Sat, 9 Apr 2022 02:39:22 -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-265-J8QySdLXN-CdyXKBFJqazA-1; Sat, 09 Apr 2022 05:39:15 -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 A3ACF811E76; Sat, 9 Apr 2022 09:39:08 +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 9035E141512C; Sat, 9 Apr 2022 09:39:08 +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 4F34B19451EC; Sat, 9 Apr 2022 09:39:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8CBEE19452D2 for ; Sat, 9 Apr 2022 09:39:07 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 778F5814B; Sat, 9 Apr 2022 09:39:07 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 72F2D8145 for ; Sat, 9 Apr 2022 09:39:04 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 35BE8380214A for ; Sat, 9 Apr 2022 09:39:04 +0000 (UTC) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-463-jnPE759-OrWp4qyuniFUZw-1; Sat, 09 Apr 2022 05:39:02 -0400 Received: by mail-pl1-f172.google.com with SMTP id k13so4725954plk.12 for ; Sat, 09 Apr 2022 02:39:02 -0700 (PDT) Received: from localhost.localdomain ([103.199.136.37]) by smtp.gmail.com with ESMTPSA id t143-20020a635f95000000b0039d2647a64dsm727510pgb.48.2022.04.09.02.38.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Apr 2022 02:39:00 -0700 (PDT) X-MC-Unique: J8QySdLXN-CdyXKBFJqazA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: jnPE759-OrWp4qyuniFUZw-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=sTrH3ktqDHIGabWuUzIcwA8cEai9GvJU/HorGTaHA3Q=; b=dQUEkwmELMqpYLEdS/2PY01Mju0uFGR8YD5HUapUqJqmZZAu84ePq8dKSMcYWO7cgK cWKyFvRRorTb4JL1DOjbuPJiGkSdsTHMXG9kcxVSy7YBoaEm64wxhEwdwsSP3El6/0Jx W83cZPpPEd4Dp9RRWaY0nefJXCu4Gj1cLgs7f4WqZHZ+AaECgMY6PQZYrvMN8uD2i3Mk woQaxTebmvrhosSYLu9lTTgd/sMieOut9h1MoDPuw22vZgRjC3RgmYzYsqmpUxJQn0GN T6qI+tBZ3M6E7Fi5g06kShe984nt/IA8skLHN6i2hDH9HjO7Ih9vOD5Xrh9vY8xPqdd3 +a1Q== X-Gm-Message-State: AOAM533vsx/K3lOFJY5LYXEYW2PMdGjTqez6f/kFVAzLenUgyiqepKn6 EmORbpHQPe0WN3cvYJJI6HBRSzrlA49bSQ== X-Google-Smtp-Source: ABdhPJwmDfE0Pu72knIXkOMV46t9tBLIGk/ilHEqHw9VhATkpqQ2Ln36dwj+smlfyYI7gNp1uZQP0w== X-Received: by 2002:a17:90b:4b89:b0:1c8:105a:2262 with SMTP id lr9-20020a17090b4b8900b001c8105a2262mr26402494pjb.225.1649497140801; Sat, 09 Apr 2022 02:39:00 -0700 (PDT) From: Moteen Shah X-Google-Original-From: Moteen Shah To: libvir-list@redhat.com Subject: [PATCH v2] conf: Move validation checks from virDomainDiskDefIotuneParse into domain_validate.c Date: Sat, 9 Apr 2022 15:08:53 +0530 Message-Id: <20220409093853.44916-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.79 on 10.11.54.5 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: 8bit Content-Type: application/octet-stream; x-default=true X-Zoho-Virus-Status: 1 X-ZM-MESSAGEID: 1649497163372100001 From: Moteen Shah Move validation from virDomainDiskDefIotuneParse into the validation callback Signed-off-by: Moteen Shah --- src/conf/domain_conf.c | 40 ------------------------------------- src/conf/domain_validate.c | 41 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 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 = virXPathString("string(./iotune/group_name)", ctxt); - 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..71dc74abc8 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -651,6 +651,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