}
-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,
}
}
- qemuBuildDiskThrottling(disk, &opt);
-
return virBufferContentAndReset(&opt);
}
/**
- * 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'
* Same hack is done in qemuDomainAttachDiskGeneric.
*/
static int
-qemuProcessSetupDiskThrottlingBlockdev(virDomainObj *vm,
- virDomainAsyncJob asyncJob)
+qemuProcessSetupDiskThrottling(virDomainObj *vm,
+ virDomainAsyncJob asyncJob)
{
size_t i;
int ret = -1;
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))
if (!qemuDiskConfigBlkdeviotuneEnabled(disk))
continue;
- if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), NULL,
+ if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), drivealias,
diskPriv->qomName, &disk->blkdeviotune) < 0)
goto cleanup;
}
if (qemuProcessSetupBalloon(vm, asyncJob) < 0)
goto cleanup;
- if (qemuProcessSetupDiskThrottlingBlockdev(vm, asyncJob) < 0)
+ if (qemuProcessSetupDiskThrottling(vm, asyncJob) < 0)
goto cleanup;
/* Since CPUs were not started yet, the balloon could not return the memory