mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-23 11:52:20 +00:00
qemu: command: Move disk trhottling argument building into a separate function
Isolate it from the other code.
This commit is contained in:
parent
55a5d71825
commit
3443fddfea
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user