mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
qemu: Extract disk setup done via QMP into a separate helper
Introduce 'qemuProcessSetupDiskPropsRuntime' helper function which will collect all code used for runtime setup of a disk. This is currently old-style throttling. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
1 parent
11057abfd1
commit
1789a0f8a3
3 files changed
+35
-30
No files matched your search
+5
-20
@@ -567,13 +567,8 @@ qemuDomainChangeMediaBlockdev(virDomainObj *vm,
|
||||
}
|
||||
|
||||
/* set throttling for the new image */
|
||||
if (rc == 0 &&
|
||||
!virStorageSourceIsEmpty(newsrc) &&
|
||||
qemuDiskConfigBlkdeviotuneEnabled(disk)) {
|
||||
rc = qemuMonitorSetBlockIoThrottle(priv->mon,
|
||||
diskPriv->qomName,
|
||||
&disk->blkdeviotune);
|
||||
}
|
||||
if (rc == 0)
|
||||
rc = qemuProcessSetupDiskPropsRuntime(priv->mon, disk);
|
||||
|
||||
/* Close any device with a tray since we've opened it before (regardless
|
||||
* of the current state if it e.g. wasn't updated) */
|
||||
@@ -798,20 +793,10 @@ qemuDomainAttachDiskGeneric(virDomainObj *vm,
|
||||
if (rc == 0)
|
||||
rc = qemuMonitorAddDeviceProps(priv->mon, &devprops);
|
||||
|
||||
/* Setup throttling of disk via block_set_io_throttle QMP command. This
|
||||
* is a hack until the 'throttle' blockdev driver will support modification
|
||||
* of the trhottle group. See also qemuProcessSetupDiskThrottlingBlockdev.
|
||||
* As there isn't anything sane to do if this fails, let's just return
|
||||
* success.
|
||||
*/
|
||||
if (rc == 0) {
|
||||
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||
|
||||
if (qemuDiskConfigBlkdeviotuneEnabled(disk)) {
|
||||
if (qemuMonitorSetBlockIoThrottle(priv->mon, diskPriv->qomName,
|
||||
&disk->blkdeviotune) < 0)
|
||||
VIR_WARN("failed to set blkdeviotune for '%s' of '%s'", disk->dst, vm->def->name);
|
||||
}
|
||||
/* There isn't anything sane to do if this fails (rollback would
|
||||
* require hot-unplug), let's just return success. */
|
||||
ignore_value(qemuProcessSetupDiskPropsRuntime(priv->mon, disk));
|
||||
}
|
||||
|
||||
if (rc == 0 &&
|
||||
|
||||
+27
-10
@@ -7941,6 +7941,32 @@ qemuProcessGenID(virDomainObj *vm,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuProcessSetupDiskPropsRuntime:
|
||||
* @mon: qemu monitor object
|
||||
* @disk: disk definition
|
||||
*
|
||||
* This function expects that caller already entered 'monitor' context.
|
||||
*
|
||||
* Sets up disk properties which are only possible to be set in runtime.
|
||||
*/
|
||||
int
|
||||
qemuProcessSetupDiskPropsRuntime(qemuMonitor *mon,
|
||||
virDomainDiskDef *disk)
|
||||
{
|
||||
if (virStorageSourceIsEmpty(disk->src))
|
||||
return 0;
|
||||
|
||||
if (qemuDiskConfigBlkdeviotuneEnabled(disk) &&
|
||||
qemuMonitorSetBlockIoThrottle(mon,
|
||||
QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName,
|
||||
&disk->blkdeviotune) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuProcessSetupDiskThrottling:
|
||||
*
|
||||
@@ -7964,16 +7990,7 @@ qemuProcessSetupDiskThrottling(virDomainObj *vm,
|
||||
for (i = 0; i < vm->def->ndisks; i++) {
|
||||
virDomainDiskDef *disk = vm->def->disks[i];
|
||||
|
||||
/* Setting throttling for empty drives fails */
|
||||
if (virStorageSourceIsEmpty(disk->src))
|
||||
continue;
|
||||
|
||||
if (!qemuDiskConfigBlkdeviotuneEnabled(disk))
|
||||
continue;
|
||||
|
||||
if (qemuMonitorSetBlockIoThrottle(qemuDomainGetMonitor(vm),
|
||||
QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName,
|
||||
&disk->blkdeviotune) < 0)
|
||||
if (qemuProcessSetupDiskPropsRuntime(qemuDomainGetMonitor(vm), disk) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,9 @@ int qemuProcessPrepareHostStorageSourceChain(virDomainObj *vm,
|
||||
int qemuProcessPrepareHostStorageDisk(virDomainObj *vm,
|
||||
virDomainDiskDef *disk);
|
||||
|
||||
int qemuProcessSetupDiskPropsRuntime(qemuMonitor *mon,
|
||||
virDomainDiskDef *disk);
|
||||
|
||||
int qemuProcessDeleteThreadContext(virDomainObj *vm);
|
||||
|
||||
int qemuProcessLaunch(virConnectPtr conn,
|
||||
|
||||
Reference in new issue
Block a user