Set it same way we set throttling for other disks in qemuProcessSetupDiskThrottling. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_command.c | 42 ----------------------------------------- src/qemu/qemu_process.c | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 51 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index afdf79ff55..6b93c5f579 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1676,46 +1676,6 @@ qemuBuildDriveSourceStr(virDomainDiskDef *disk, } -static void -qemuBuildDiskThrottling(virDomainDiskDef *disk, - virBuffer *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) { - virBufferAddLit(buf, ",throttling.group="); - virQEMUBuildBufferEscapeComma(buf, 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 qemuBuildDiskGetErrorPolicy(virDomainDiskDef *disk, const char **wpolicy, @@ -1790,8 +1750,6 @@ qemuBuildDriveStr(virDomainDiskDef *disk) } } - qemuBuildDiskThrottling(disk, &opt); - return virBufferContentAndReset(&opt); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ac463571bb..f15222e932 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7220,7 +7220,7 @@ qemuProcessGenID(virDomainObj *vm, /** - * qemuProcessSetupDiskThrottlingBlockdev: + * qemuProcessSetupDiskThrottling: * * Sets up disk trottling for -blockdev via block_set_io_throttle monitor * command. This hack should be replaced by proper use of the 'throttle' @@ -7228,9 +7228,9 @@ qemuProcessGenID(virDomainObj *vm, * Same hack is done in qemuDomainAttachDiskGeneric. */ static int -qemuProcessSetupDiskThrottlingBlockdev(virQEMUDriver *driver, - virDomainObj *vm, - virDomainAsyncJob asyncJob) +qemuProcessSetupDiskThrottling(virQEMUDriver *driver, + virDomainObj *vm, + virDomainAsyncJob asyncJob) { size_t i; int ret = -1; @@ -7243,10 +7243,12 @@ qemuProcessSetupDiskThrottlingBlockdev(virQEMUDriver *driver, for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDef *disk = vm->def->disks[i]; qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); + g_autofree char *drivealias = NULL; - /* sd-cards are instantiated via -drive */ - if (qemuDiskBusIsSD(disk->bus)) - continue; + if (!QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) { + if (!(drivealias = qemuAliasDiskDriveFromDisk(disk))) + goto cleanup; + } /* Setting throttling for empty drives fails */ if (virStorageSourceIsEmpty(disk->src)) @@ -7255,7 +7257,7 @@ qemuProcessSetupDiskThrottlingBlockdev(virQEMUDriver *driver, if (!qemuDiskConfigBlkdeviotuneEnabled(disk)) continue; - if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), NULL, + if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), drivealias, diskPriv->qomName, &disk->blkdeviotune) < 0) goto cleanup; } @@ -7768,7 +7770,7 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessSetupBalloon(driver, vm, asyncJob) < 0) goto cleanup; - if (qemuProcessSetupDiskThrottlingBlockdev(driver, vm, asyncJob) < 0) + if (qemuProcessSetupDiskThrottling(driver, vm, asyncJob) < 0) goto cleanup; /* Since CPUs were not started yet, the balloon could not return the memory -- 2.36.1