提交 5121457c 编写于 作者: P Peter Krempa

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.
上级 1055c1bf
......@@ -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
qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr disk,
virQEMUCapsPtr 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) {
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)) {
/* group_name by itself is ignored by qemu */
if (disk->blkdeviotune.group_name &&
!qemuDiskConfigBlkdeviotuneHasBasic(disk) &&
!qemuDiskConfigBlkdeviotuneHasMax(disk) &&
!qemuDiskConfigBlkdeviotuneHasMaxLength(disk)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("there are some block I/O throttling length parameters "
"that are not supported with this QEMU binary"));
_("group_name can be configured only together with "
"settings"));
return -1;
}
......@@ -1195,6 +1167,44 @@ qemuCheckDiskConfigBlkdeviotune(virDomainDiskDefPtr disk,
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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册