From nobody Fri Dec 19 19:09:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766938; cv=none; d=zohomail.com; s=zohoarc; b=CaqHQja73qTCUyFP1Ri1/6Sug/x5Adi42Ge82QvWNX6nNqDSTUVoS1lxrfmzYCLFvf0cvAKnqJlscSKsN1nqTUElgcR4NjJpqmFYavM7UpzWLAsM6pSy0dUR18lsAsCe02W/Ny4v6n55UHGhXm8w1uuaoCPszGVLkgq47zRP4kM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766938; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qHZbGP6O54gMvYsd7m3jzYQp1a8cGlqtzQr71csOSs0=; b=hDzqVFLZmp8K7r2vuEus1GL+Tq1zukBoUuddN9/9JbYP9gFM3AEUyjU5zOBUUD7OwUvb54UXpy3utD24iVM+hDuH82y8yMD0LCfjUCaA72Wtq8al91jzGIvEoZszDf+ht9bnsDkQrovoF5lzqGFV08oNkeJn9ro69BJKXYMkr+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1588766938900274.4247070720156; Wed, 6 May 2020 05:08:58 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-OZYDs8TnM0KZuHGLe1pVvw-1; Wed, 06 May 2020 08:08:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38227872FE1; Wed, 6 May 2020 12:08:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E06E5D9DC; Wed, 6 May 2020 12:08:50 +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 AD1EF54D02; Wed, 6 May 2020 12:08:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C8mTC029603 for ; Wed, 6 May 2020 08:08:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id AA1EB5C1BD; Wed, 6 May 2020 12:08:48 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C8B05C1D6 for ; Wed, 6 May 2020 12:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766937; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qHZbGP6O54gMvYsd7m3jzYQp1a8cGlqtzQr71csOSs0=; b=Q20NtMkT8DuUZJLCqcGMBkqQe5OQe2L+xHv1R4YHmWvpT5beHECJV0JROsr4D4/RvtEx9Y sat5GZcRuM9lKlF0hCS+Ozl49+eAmo49HhlkZqCNmVV2CjxaqVJro1GJQ8334P7CZV2kqF G/q/CruEdlJxK/MxcVT2L13L99efnIY= X-MC-Unique: OZYDs8TnM0KZuHGLe1pVvw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/20] qemu: validate: Validate blkdeviotune settings in the validator Date: Wed, 6 May 2020 14:08:19 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move the code from qemuCheckDiskConfigBlkdeviotune in src/qemu/qemu_commandline.c to qemuValidateDomainDeviceDefDiskBlkdeviotune. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 101 +------------------------------------- src/qemu/qemu_validate.c | 102 ++++++++++++++++++++++++++++++++++++++- src/qemu/qemu_validate.h | 1 + tests/qemublocktest.c | 2 +- 4 files changed, 104 insertions(+), 102 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 269bdbaf56..87cb78e350 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1131,102 +1131,6 @@ qemuDiskConfigBlkdeviotuneEnabled(virDomainDiskDefP= tr disk) } -/** - * qemuCheckDiskConfigBlkdeviotune: - * @disk: disk configuration - * @qemuCaps: qemu capabilities, NULL if checking cold-configuration - * - * Checks whether block io tuning settings make sense. Returns -1 on error= and - * reports a proper libvirt error. - */ -static int -qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr disk, - const virDomainDef *def, - virQEMUCapsPtr qemuCaps) -{ - /* group_name by itself is ignored by qemu */ - if (disk->blkdeviotune.group_name && - !virDomainBlockIoTuneInfoHasAny(&disk->blkdeviotune)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("group_name can be configured only together with " - "settings")); - return -1; - } - - /* checking def here is only for calling from tests */ - if (disk->blkdeviotune.group_name) { - size_t i; - - for (i =3D 0; i < def->ndisks; i++) { - virDomainDiskDefPtr d =3D def->disks[i]; - - if (STREQ(d->dst, disk->dst) || - STRNEQ_NULLABLE(d->blkdeviotune.group_name, - disk->blkdeviotune.group_name)) - continue; - - if (!virDomainBlockIoTuneInfoEqual(&d->blkdeviotune, - &disk->blkdeviotune)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("different iotunes for disks %s and %s"), - disk->dst, d->dst); - return -1; - } - } - } - - if (disk->blkdeviotune.total_bytes_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.read_bytes_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.write_bytes_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.total_iops_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.read_iops_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.write_iops_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.total_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.read_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.write_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.total_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.read_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.write_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.size_iops_sec > QEMU_BLOCK_IOTUNE_MAX) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, - _("block I/O throttle limit must " - "be no more than %llu using QEMU"), QEMU_BLOCK_IOT= UNE_MAX); - return -1; - } - - if (qemuCaps) { - /* block I/O throttling 1.7 */ - if (virDomainBlockIoTuneInfoHasMax(&disk->blkdeviotune) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("there are some block I/O throttling paramete= rs " - "that are not supported with this QEMU binary= ")); - return -1; - } - - /* block I/O group 2.4 */ - if (disk->blkdeviotune.group_name && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_GROUP)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the block I/O throttling group parameter is " - "not supported with this QEMU binary")); - return -1; - } - - /* block I/O throttling length 2.6 */ - if (virDomainBlockIoTuneInfoHasMaxLength(&disk->blkdeviotune) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("there are some block I/O throttling length p= arameters " - "that are not supported with this QEMU binary= ")); - return -1; - } - } - - return 0; -} - - /** * qemuCheckDiskConfig: * @disk: disk definition @@ -1237,12 +1141,9 @@ qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr = disk, */ int qemuCheckDiskConfig(virDomainDiskDefPtr disk, - const virDomainDef *def, + const virDomainDef *def G_GNUC_UNUSED, virQEMUCapsPtr qemuCaps) { - if (qemuCheckDiskConfigBlkdeviotune(disk, def, qemuCaps) < 0) - return -1; - if (disk->wwn) { if ((disk->bus !=3D VIR_DOMAIN_DISK_BUS_IDE) && (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI)) { diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 6f13a1df1b..17cfcddd30 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1956,8 +1956,105 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDo= mainDiskDef *disk) } +/** + * qemuValidateDomainDeviceDefDiskBlkdeviotune: + * @disk: disk configuration + * @qemuCaps: qemu capabilities, NULL if checking cold-configuration + * + * Checks whether block io tuning settings make sense. Returns -1 on error= and + * reports a proper libvirt error. + */ +static int +qemuValidateDomainDeviceDefDiskBlkdeviotune(const virDomainDiskDef *disk, + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) +{ + /* group_name by itself is ignored by qemu */ + if (disk->blkdeviotune.group_name && + !virDomainBlockIoTuneInfoHasAny(&disk->blkdeviotune)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("group_name can be configured only together with " + "settings")); + return -1; + } + + /* checking def here is only for calling from tests */ + if (disk->blkdeviotune.group_name) { + size_t i; + + for (i =3D 0; i < def->ndisks; i++) { + virDomainDiskDefPtr d =3D def->disks[i]; + + if (STREQ(d->dst, disk->dst) || + STRNEQ_NULLABLE(d->blkdeviotune.group_name, + disk->blkdeviotune.group_name)) + continue; + + if (!virDomainBlockIoTuneInfoEqual(&d->blkdeviotune, + &disk->blkdeviotune)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("different iotunes for disks %s and %s"), + disk->dst, d->dst); + return -1; + } + } + } + + if (disk->blkdeviotune.total_bytes_sec > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.read_bytes_sec > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.write_bytes_sec > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.total_iops_sec > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.read_iops_sec > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.write_iops_sec > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.total_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.read_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.write_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.total_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.read_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.write_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX || + disk->blkdeviotune.size_iops_sec > QEMU_BLOCK_IOTUNE_MAX) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("block I/O throttle limit must " + "be no more than %llu using QEMU"), QEMU_BLOCK_IOT= UNE_MAX); + return -1; + } + + if (qemuCaps) { + /* block I/O throttling 1.7 */ + if (virDomainBlockIoTuneInfoHasMax(&disk->blkdeviotune) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("there are some block I/O throttling paramete= rs " + "that are not supported with this QEMU binary= ")); + return -1; + } + + /* block I/O group 2.4 */ + if (disk->blkdeviotune.group_name && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_GROUP)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the block I/O throttling group parameter is " + "not supported with this QEMU binary")); + return -1; + } + + /* block I/O throttling length 2.6 */ + if (virDomainBlockIoTuneInfoHasMaxLength(&disk->blkdeviotune) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("there are some block I/O throttling length p= arameters " + "that are not supported with this QEMU binary= ")); + return -1; + } + } + + return 0; +} + + int qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk, + const virDomainDef *def, virQEMUCapsPtr qemuCaps) { const char *driverName =3D virDomainDiskGetDriver(disk); @@ -1968,6 +2065,9 @@ qemuValidateDomainDeviceDefDisk(const virDomainDiskDe= f *disk, if (qemuValidateDomainDeviceDefDiskFrontend(disk) < 0) return -1; + if (qemuValidateDomainDeviceDefDiskBlkdeviotune(disk, def, qemuCaps) <= 0) + return -1; + if (disk->src->shared && !disk->src->readonly && !qemuBlockStorageSourceSupportsConcurrentAccess(disk->src)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -3679,7 +3779,7 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef = *dev, break; case VIR_DOMAIN_DEVICE_DISK: - ret =3D qemuValidateDomainDeviceDefDisk(dev->data.disk, qemuCaps); + ret =3D qemuValidateDomainDeviceDefDisk(dev->data.disk, def, qemuC= aps); break; case VIR_DOMAIN_DEVICE_CONTROLLER: diff --git a/src/qemu/qemu_validate.h b/src/qemu/qemu_validate.h index f667a57195..acf7d26ce0 100644 --- a/src/qemu/qemu_validate.h +++ b/src/qemu/qemu_validate.h @@ -28,6 +28,7 @@ int qemuValidateDomainDef(const virDomainDef *def, void *opaque); int qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk, + const virDomainDef *def, virQEMUCapsPtr qemuCaps); int qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev, const virDomainDef *def, diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 8001807552..fbe4972981 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -284,7 +284,7 @@ testQemuDiskXMLToProps(const void *opaque) return -1; if (qemuCheckDiskConfig(disk, vmdef, data->qemuCaps) < 0 || - qemuValidateDomainDeviceDefDisk(disk, data->qemuCaps) < 0) { + qemuValidateDomainDeviceDefDisk(disk, vmdef, data->qemuCaps) < 0) { VIR_TEST_VERBOSE("invalid configuration for disk"); return -1; } --=20 2.26.2