diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 36b8f3cb7fd20062b817731604bd47ef39b90ad9..92e34076326d266e0ed7cbbea63c523422bbe98e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1623,6 +1623,46 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, } +static void +qemuBuildDiskThrottling(virDomainDiskDefPtr disk, + virBufferPtr buf) +{ +#define IOTUNE_ADD(_field, _label) \ + if (disk->blkdeviotune._field) { \ + virBufferAsprintf(buf, ",throttling." _label "=%llu", \ + disk->blkdeviotune._field); \ + } + + IOTUNE_ADD(total_bytes_sec, "bps-total"); + IOTUNE_ADD(read_bytes_sec, "bps-read"); + IOTUNE_ADD(write_bytes_sec, "bps-write"); + IOTUNE_ADD(total_iops_sec, "iops-total"); + IOTUNE_ADD(read_iops_sec, "iops-read"); + IOTUNE_ADD(write_iops_sec, "iops-write"); + + IOTUNE_ADD(total_bytes_sec_max, "bps-total-max"); + IOTUNE_ADD(read_bytes_sec_max, "bps-read-max"); + IOTUNE_ADD(write_bytes_sec_max, "bps-write-max"); + IOTUNE_ADD(total_iops_sec_max, "iops-total-max"); + IOTUNE_ADD(read_iops_sec_max, "iops-read-max"); + IOTUNE_ADD(write_iops_sec_max, "iops-write-max"); + + IOTUNE_ADD(size_iops_sec, "iops-size"); + if (disk->blkdeviotune.group_name) { + virBufferEscapeString(buf, ",throttling.group=%s", + disk->blkdeviotune.group_name); + } + + IOTUNE_ADD(total_bytes_sec_max_length, "bps-total-max-length"); + IOTUNE_ADD(read_bytes_sec_max_length, "bps-read-max-length"); + IOTUNE_ADD(write_bytes_sec_max_length, "bps-write-max-length"); + IOTUNE_ADD(total_iops_sec_max_length, "iops-total-max-length"); + IOTUNE_ADD(read_iops_sec_max_length, "iops-read-max-length"); + IOTUNE_ADD(write_iops_sec_max_length, "iops-write-max-length"); +#undef IOTUNE_ADD +} + + static void qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps, @@ -1776,40 +1816,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virDomainDiskIoTypeToString(disk->iomode)); } -#define IOTUNE_ADD(_field, _label) \ - if (disk->blkdeviotune._field) { \ - virBufferAsprintf(&opt, ",throttling." _label "=%llu", \ - disk->blkdeviotune._field); \ - } - - IOTUNE_ADD(total_bytes_sec, "bps-total"); - IOTUNE_ADD(read_bytes_sec, "bps-read"); - IOTUNE_ADD(write_bytes_sec, "bps-write"); - IOTUNE_ADD(total_iops_sec, "iops-total"); - IOTUNE_ADD(read_iops_sec, "iops-read"); - IOTUNE_ADD(write_iops_sec, "iops-write"); - - IOTUNE_ADD(total_bytes_sec_max, "bps-total-max"); - IOTUNE_ADD(read_bytes_sec_max, "bps-read-max"); - IOTUNE_ADD(write_bytes_sec_max, "bps-write-max"); - IOTUNE_ADD(total_iops_sec_max, "iops-total-max"); - IOTUNE_ADD(read_iops_sec_max, "iops-read-max"); - IOTUNE_ADD(write_iops_sec_max, "iops-write-max"); - - IOTUNE_ADD(size_iops_sec, "iops-size"); - if (disk->blkdeviotune.group_name) { - virBufferEscapeString(&opt, ",throttling.group=%s", - disk->blkdeviotune.group_name); - } - - IOTUNE_ADD(total_bytes_sec_max_length, "bps-total-max-length"); - IOTUNE_ADD(read_bytes_sec_max_length, "bps-read-max-length"); - IOTUNE_ADD(write_bytes_sec_max_length, "bps-write-max-length"); - IOTUNE_ADD(total_iops_sec_max_length, "iops-total-max-length"); - IOTUNE_ADD(read_iops_sec_max_length, "iops-read-max-length"); - IOTUNE_ADD(write_iops_sec_max_length, "iops-write-max-length"); - -#undef IOTUNE_ADD + qemuBuildDiskThrottling(disk, &opt); if (virBufferCheckError(&opt) < 0) goto error;