提交 653137eb 编写于 作者: P Peter Krempa

qemu: blkiotune: Avoid accessing non-existing disk configuration

When a user would try changing the persistent IO tuning settings for a
disk that was hotplugged to a vm in a transient way, the
qemuDomainSetBlockIoTune API would use the same index for both the
live and config disk array. The disk was missing from the config array
though causing a crash of libvirtd.

To fix the issue, determine the indexes separately.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131819
上级 cf976d9d
......@@ -15807,6 +15807,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
int ret = -1;
size_t i;
int idx = -1;
int conf_idx;
bool set_bytes = false;
bool set_iops = false;
virQEMUDriverConfigPtr cfg = NULL;
......@@ -15848,9 +15849,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto endjob;
if (!(device = qemuDiskPathToAlias(vm, disk, &idx)))
goto endjob;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
&persistentDef) < 0)
goto endjob;
......@@ -15905,6 +15903,15 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if ((conf_idx = virDomainDiskIndexByName(persistentDef, disk, true)) < 0) {
virReportError(VIR_ERR_INVALID_ARG,
_("missing persistent configuration for disk '%s'"),
disk);
goto endjob;
}
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
......@@ -15913,6 +15920,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto endjob;
}
if (!(device = qemuDiskPathToAlias(vm, disk, &idx)))
goto endjob;
/* If the user didn't specify bytes limits, inherit previous
* values; likewise if the user didn't specify iops
* limits. */
......@@ -15937,7 +15947,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
sa_assert(persistentDef);
oldinfo = &persistentDef->disks[idx]->blkdeviotune;
oldinfo = &persistentDef->disks[conf_idx]->blkdeviotune;
if (!set_bytes) {
info.total_bytes_sec = oldinfo->total_bytes_sec;
info.read_bytes_sec = oldinfo->read_bytes_sec;
......@@ -15948,7 +15958,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
info.read_iops_sec = oldinfo->read_iops_sec;
info.write_iops_sec = oldinfo->write_iops_sec;
}
persistentDef->disks[idx]->blkdeviotune = info;
persistentDef->disks[conf_idx]->blkdeviotune = info;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
if (ret < 0) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册