mirror of https://gitee.com/openkylin/libvirt.git
qemu: Setup disk throttling for SD cards via monitor
Set it same way we set throttling for other disks in qemuProcessSetupDiskThrottling. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
a0b8b54348
commit
0bbd7257c4
|
@ -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
|
static void
|
||||||
qemuBuildDiskGetErrorPolicy(virDomainDiskDef *disk,
|
qemuBuildDiskGetErrorPolicy(virDomainDiskDef *disk,
|
||||||
const char **wpolicy,
|
const char **wpolicy,
|
||||||
|
@ -1790,8 +1750,6 @@ qemuBuildDriveStr(virDomainDiskDef *disk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuBuildDiskThrottling(disk, &opt);
|
|
||||||
|
|
||||||
return virBufferContentAndReset(&opt);
|
return virBufferContentAndReset(&opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7198,7 +7198,7 @@ qemuProcessGenID(virDomainObj *vm,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemuProcessSetupDiskThrottlingBlockdev:
|
* qemuProcessSetupDiskThrottling:
|
||||||
*
|
*
|
||||||
* Sets up disk trottling for -blockdev via block_set_io_throttle monitor
|
* Sets up disk trottling for -blockdev via block_set_io_throttle monitor
|
||||||
* command. This hack should be replaced by proper use of the 'throttle'
|
* command. This hack should be replaced by proper use of the 'throttle'
|
||||||
|
@ -7206,8 +7206,8 @@ qemuProcessGenID(virDomainObj *vm,
|
||||||
* Same hack is done in qemuDomainAttachDiskGeneric.
|
* Same hack is done in qemuDomainAttachDiskGeneric.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
qemuProcessSetupDiskThrottlingBlockdev(virDomainObj *vm,
|
qemuProcessSetupDiskThrottling(virDomainObj *vm,
|
||||||
virDomainAsyncJob asyncJob)
|
virDomainAsyncJob asyncJob)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
@ -7220,10 +7220,12 @@ qemuProcessSetupDiskThrottlingBlockdev(virDomainObj *vm,
|
||||||
for (i = 0; i < vm->def->ndisks; i++) {
|
for (i = 0; i < vm->def->ndisks; i++) {
|
||||||
virDomainDiskDef *disk = vm->def->disks[i];
|
virDomainDiskDef *disk = vm->def->disks[i];
|
||||||
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||||
|
g_autofree char *drivealias = NULL;
|
||||||
|
|
||||||
/* sd-cards are instantiated via -drive */
|
if (!QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) {
|
||||||
if (qemuDiskBusIsSD(disk->bus))
|
if (!(drivealias = qemuAliasDiskDriveFromDisk(disk)))
|
||||||
continue;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* Setting throttling for empty drives fails */
|
/* Setting throttling for empty drives fails */
|
||||||
if (virStorageSourceIsEmpty(disk->src))
|
if (virStorageSourceIsEmpty(disk->src))
|
||||||
|
@ -7232,7 +7234,7 @@ qemuProcessSetupDiskThrottlingBlockdev(virDomainObj *vm,
|
||||||
if (!qemuDiskConfigBlkdeviotuneEnabled(disk))
|
if (!qemuDiskConfigBlkdeviotuneEnabled(disk))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), NULL,
|
if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm), drivealias,
|
||||||
diskPriv->qomName, &disk->blkdeviotune) < 0)
|
diskPriv->qomName, &disk->blkdeviotune) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -7745,7 +7747,7 @@ qemuProcessLaunch(virConnectPtr conn,
|
||||||
if (qemuProcessSetupBalloon(vm, asyncJob) < 0)
|
if (qemuProcessSetupBalloon(vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuProcessSetupDiskThrottlingBlockdev(vm, asyncJob) < 0)
|
if (qemuProcessSetupDiskThrottling(vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Since CPUs were not started yet, the balloon could not return the memory
|
/* Since CPUs were not started yet, the balloon could not return the memory
|
||||||
|
|
Loading…
Reference in New Issue