Isolate it from the other code.
---
src/qemu/qemu_command.c | 75 +++++++++++++++++++++++++++----------------------
1 file changed, 41 insertions(+), 34 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index df3c14d627..6ae738020d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1609,6 +1609,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,
@@ -1761,40 +1801,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;
--
2.14.3