From: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
virDomainSetBlockIoTune not simply sets the iotune params given in API
but use current settings for all the omitted params. Unfortunately
it uses current settings for active config when setting inactive
params. Let's fix it.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 9 +++++++++
src/conf/domain_conf.h | 7 ++++++-
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 9 +++++++--
4 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 89c9ed2834..7bbd3fcaaf 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -31811,3 +31811,12 @@ virDomainBlockIoTuneInfoEqual(const virDomainBlockIoTuneInfo *a,
a->read_iops_sec_max_length == b->read_iops_sec_max_length &&
a->write_iops_sec_max_length == b->write_iops_sec_max_length;
}
+
+
+void
+virDomainBlockIoTuneInfoCopy(const virDomainBlockIoTuneInfo *src,
+ virDomainBlockIoTuneInfoPtr dst)
+{
+ *dst = *src;
+ dst->group_name = g_strdup(src->group_name);
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5c3156a0aa..0c35c9155d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -489,7 +489,8 @@ struct _virDomainBlockIoTuneInfo {
unsigned long long total_iops_sec_max_length;
unsigned long long read_iops_sec_max_length;
unsigned long long write_iops_sec_max_length;
- /* Don't forget to update virDomainBlockIoTuneInfoEqual. */
+ /* Don't forget to update virDomainBlockIoTuneInfoEqual
+ * and virDomainBlockIoTuneInfoCopy. */
};
@@ -3715,3 +3716,7 @@ virDomainBlockIoTuneInfoHasAny(const virDomainBlockIoTuneInfo
*iotune);
bool
virDomainBlockIoTuneInfoEqual(const virDomainBlockIoTuneInfo *a,
const virDomainBlockIoTuneInfo *b);
+
+void
+virDomainBlockIoTuneInfoCopy(const virDomainBlockIoTuneInfo *src,
+ virDomainBlockIoTuneInfoPtr dst);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5e9eb34459..970f412527 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -226,6 +226,7 @@ virDomainActualNetDefFree;
virDomainActualNetDefValidate;
virDomainBlockedReasonTypeFromString;
virDomainBlockedReasonTypeToString;
+virDomainBlockIoTuneInfoCopy;
virDomainBlockIoTuneInfoEqual;
virDomainBlockIoTuneInfoHasAny;
virDomainBlockIoTuneInfoHasBasic;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 255b77cbb4..eb4b85a20d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19150,6 +19150,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
virDomainDefPtr def = NULL;
virDomainDefPtr persistentDef = NULL;
virDomainBlockIoTuneInfo info;
+ virDomainBlockIoTuneInfo conf_info;
g_autofree char *drivealias = NULL;
const char *qdevid = NULL;
int ret = -1;
@@ -19213,6 +19214,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
return -1;
memset(&info, 0, sizeof(info));
+ memset(&conf_info, 0, sizeof(conf_info));
if (!(vm = qemuDomainObjFromDomain(dom)))
return -1;
@@ -19337,6 +19339,8 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto endjob;
}
+ virDomainBlockIoTuneInfoCopy(&info, &conf_info);
+
if (def) {
supportMaxOptions = virQEMUCapsGet(priv->qemuCaps,
QEMU_CAPS_DRIVE_IOTUNE_MAX);
@@ -19459,11 +19463,11 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto endjob;
}
- if (qemuDomainSetBlockIoTuneDefaults(&info, &conf_disk->blkdeviotune,
+ if (qemuDomainSetBlockIoTuneDefaults(&conf_info,
&conf_disk->blkdeviotune,
set_fields) < 0)
goto endjob;
- if (virDomainDiskSetBlockIOTune(conf_disk, &info) < 0)
+ if (virDomainDiskSetBlockIOTune(conf_disk, &conf_info) < 0)
goto endjob;
qemuDomainSetGroupBlockIoTune(persistentDef, &conf_info);
@@ -19479,6 +19483,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
cleanup:
VIR_FREE(info.group_name);
+ VIR_FREE(conf_info.group_name);
virDomainObjEndAPI(&vm);
if (eventNparams)
virTypedParamsFree(eventParams, eventNparams);
--
2.24.1