qemu: Move qemuDiskConfigBlkdeviotuneHas* to conf

And introduce virDomainBlockIoTuneInfoHasAny.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Nikolay Shirokovskiy 2020-01-08 09:49:25 +03:00 committed by Michal Privoznik
parent 9dbf6871e6
commit 67ebd6ac26
4 changed files with 66 additions and 45 deletions

View File

@ -31712,3 +31712,49 @@ virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics)
return true;
}
bool
virDomainBlockIoTuneInfoHasBasic(const virDomainBlockIoTuneInfo *iotune)
{
return iotune->total_bytes_sec ||
iotune->read_bytes_sec ||
iotune->write_bytes_sec ||
iotune->total_iops_sec ||
iotune->read_iops_sec ||
iotune->write_iops_sec;
}
bool
virDomainBlockIoTuneInfoHasMax(const virDomainBlockIoTuneInfo *iotune)
{
return iotune->total_bytes_sec_max ||
iotune->read_bytes_sec_max ||
iotune->write_bytes_sec_max ||
iotune->total_iops_sec_max ||
iotune->read_iops_sec_max ||
iotune->write_iops_sec_max ||
iotune->size_iops_sec;
}
bool
virDomainBlockIoTuneInfoHasMaxLength(const virDomainBlockIoTuneInfo *iotune)
{
return iotune->total_bytes_sec_max_length ||
iotune->read_bytes_sec_max_length ||
iotune->write_bytes_sec_max_length ||
iotune->total_iops_sec_max_length ||
iotune->read_iops_sec_max_length ||
iotune->write_iops_sec_max_length;
}
bool
virDomainBlockIoTuneInfoHasAny(const virDomainBlockIoTuneInfo *iotune)
{
return virDomainBlockIoTuneInfoHasBasic(iotune) ||
virDomainBlockIoTuneInfoHasMax(iotune) ||
virDomainBlockIoTuneInfoHasMaxLength(iotune);
}

View File

@ -3698,3 +3698,15 @@ virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics);
bool
virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics);
bool
virDomainBlockIoTuneInfoHasBasic(const virDomainBlockIoTuneInfo *iotune);
bool
virDomainBlockIoTuneInfoHasMax(const virDomainBlockIoTuneInfo *iotune);
bool
virDomainBlockIoTuneInfoHasMaxLength(const virDomainBlockIoTuneInfo *iotune);
bool
virDomainBlockIoTuneInfoHasAny(const virDomainBlockIoTuneInfo *iotune);

View File

@ -226,6 +226,10 @@ virDomainActualNetDefFree;
virDomainActualNetDefValidate;
virDomainBlockedReasonTypeFromString;
virDomainBlockedReasonTypeToString;
virDomainBlockIoTuneInfoHasAny;
virDomainBlockIoTuneInfoHasBasic;
virDomainBlockIoTuneInfoHasMax;
virDomainBlockIoTuneInfoHasMaxLength;
virDomainBootTypeFromString;
virDomainBootTypeToString;
virDomainCapabilitiesPolicyTypeToString;

View File

@ -1137,50 +1137,11 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
}
static bool
qemuDiskConfigBlkdeviotuneHasBasic(virDomainDiskDefPtr disk)
{
return disk->blkdeviotune.total_bytes_sec ||
disk->blkdeviotune.read_bytes_sec ||
disk->blkdeviotune.write_bytes_sec ||
disk->blkdeviotune.total_iops_sec ||
disk->blkdeviotune.read_iops_sec ||
disk->blkdeviotune.write_iops_sec;
}
static bool
qemuDiskConfigBlkdeviotuneHasMax(virDomainDiskDefPtr disk)
{
return disk->blkdeviotune.total_bytes_sec_max ||
disk->blkdeviotune.read_bytes_sec_max ||
disk->blkdeviotune.write_bytes_sec_max ||
disk->blkdeviotune.total_iops_sec_max ||
disk->blkdeviotune.read_iops_sec_max ||
disk->blkdeviotune.write_iops_sec_max ||
disk->blkdeviotune.size_iops_sec;
}
static bool
qemuDiskConfigBlkdeviotuneHasMaxLength(virDomainDiskDefPtr disk)
{
return disk->blkdeviotune.total_bytes_sec_max_length ||
disk->blkdeviotune.read_bytes_sec_max_length ||
disk->blkdeviotune.write_bytes_sec_max_length ||
disk->blkdeviotune.total_iops_sec_max_length ||
disk->blkdeviotune.read_iops_sec_max_length ||
disk->blkdeviotune.write_iops_sec_max_length;
}
bool
qemuDiskConfigBlkdeviotuneEnabled(virDomainDiskDefPtr disk)
{
return !!disk->blkdeviotune.group_name ||
qemuDiskConfigBlkdeviotuneHasBasic(disk) ||
qemuDiskConfigBlkdeviotuneHasMax(disk) ||
qemuDiskConfigBlkdeviotuneHasMaxLength(disk);
virDomainBlockIoTuneInfoHasAny(&disk->blkdeviotune);
}
@ -1198,9 +1159,7 @@ qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr disk,
{
/* group_name by itself is ignored by qemu */
if (disk->blkdeviotune.group_name &&
!qemuDiskConfigBlkdeviotuneHasBasic(disk) &&
!qemuDiskConfigBlkdeviotuneHasMax(disk) &&
!qemuDiskConfigBlkdeviotuneHasMaxLength(disk)) {
!virDomainBlockIoTuneInfoHasAny(&disk->blkdeviotune)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("group_name can be configured only together with "
"settings"));
@ -1228,7 +1187,7 @@ qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr disk,
if (qemuCaps) {
/* block I/O throttling 1.7 */
if (qemuDiskConfigBlkdeviotuneHasMax(disk) &&
if (virDomainBlockIoTuneInfoHasMax(&disk->blkdeviotune) &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("there are some block I/O throttling parameters "
@ -1246,7 +1205,7 @@ qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr disk,
}
/* block I/O throttling length 2.6 */
if (qemuDiskConfigBlkdeviotuneHasMaxLength(disk) &&
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 parameters "