qemu: command: Refactor blkiotune checks to tolerate NULL qemuCaps
To allow aggregating the checks, refactor the code to check capabilities only if they were provided.
This commit is contained in:
parent
1055c1bf24
commit
5121457cad
@ -1125,54 +1125,26 @@ qemuDiskConfigBlkdeviotuneHasMaxLength(virDomainDiskDefPtr 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
|
static int
|
||||||
qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr disk,
|
qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr disk,
|
||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
/* block I/O throttling */
|
/* group_name by itself is ignored by qemu */
|
||||||
if (qemuDiskConfigBlkdeviotuneHasBasic(disk) &&
|
if (disk->blkdeviotune.group_name &&
|
||||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
|
!qemuDiskConfigBlkdeviotuneHasBasic(disk) &&
|
||||||
|
!qemuDiskConfigBlkdeviotuneHasMax(disk) &&
|
||||||
|
!qemuDiskConfigBlkdeviotuneHasMaxLength(disk)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("block I/O throttling not supported with this "
|
_("group_name can be configured only together with "
|
||||||
"QEMU binary"));
|
"settings"));
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* block I/O throttling 1.7 */
|
|
||||||
if (qemuDiskConfigBlkdeviotuneHasMax(disk) &&
|
|
||||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX)) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("there are some block I/O throttling parameters "
|
|
||||||
"that are not supported with this QEMU binary"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* block I/O group 2.4 */
|
|
||||||
if (disk->blkdeviotune.group_name) {
|
|
||||||
if (!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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* group_name by itself is ignored by qemu */
|
|
||||||
if (!qemuDiskConfigBlkdeviotuneHasBasic(disk) &&
|
|
||||||
!qemuDiskConfigBlkdeviotuneHasMax(disk) &&
|
|
||||||
!qemuDiskConfigBlkdeviotuneHasMaxLength(disk)) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("group_name can be configured only together with "
|
|
||||||
"settings"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* block I/O throttling length 2.6 */
|
|
||||||
if (qemuDiskConfigBlkdeviotuneHasMaxLength(disk) &&
|
|
||||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH)) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("there are some block I/O throttling length parameters "
|
|
||||||
"that are not supported with this QEMU binary"));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1195,6 +1167,44 @@ qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr disk,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qemuCaps) {
|
||||||
|
/* block I/O throttling */
|
||||||
|
if (qemuDiskConfigBlkdeviotuneHasBasic(disk) &&
|
||||||
|
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("block I/O throttling not supported with this "
|
||||||
|
"QEMU binary"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* block I/O throttling 1.7 */
|
||||||
|
if (qemuDiskConfigBlkdeviotuneHasMax(disk) &&
|
||||||
|
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("there are some block I/O throttling parameters "
|
||||||
|
"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 (qemuDiskConfigBlkdeviotuneHasMaxLength(disk) &&
|
||||||
|
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("there are some block I/O throttling length parameters "
|
||||||
|
"that are not supported with this QEMU binary"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user