That function sets disk->blkdeviotune sensibly.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/conf/domain_conf.c | 27 +++++++++++++++++++++++++++
src/conf/domain_conf.h | 4 ++++
src/libvirt_private.syms | 1 +
3 files changed, 32 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 877a0bf5c148..c06b128ddcb4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25845,3 +25845,30 @@ virDomainDefVcpuOrderClear(virDomainDefPtr def)
for (i = 0; i < def->maxvcpus; i++)
def->vcpus[i]->order = 0;
}
+
+
+/**
+ * virDomainDiskSetBlockIOTune:
+ * @disk: The disk to set block I/O tuning on
+ * @info: The BlockIoTuneInfo to be set on the @disk
+ *
+ * Set the block I/O tune settings from @info on the @disk, but error out early
+ * in case of any error. That is to make sure nothing will fail half-way.
+ *
+ * Returns: 0 on success, -1 otherwise
+ */
+int
+virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
+ virDomainBlockIoTuneInfo *info)
+{
+ char *tmp_group = NULL;
+
+ if (VIR_STRDUP(tmp_group, info->group_name) < 0)
+ return -1;
+
+ VIR_FREE(disk->blkdeviotune.group_name);
+ disk->blkdeviotune = *info;
+ VIR_STEAL_PTR(disk->blkdeviotune.group_name, tmp_group);
+
+ return 0;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4d830c51d4f7..507ace871174 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3219,4 +3219,8 @@ bool
virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a,
const virDomainDeviceInfo *b)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+
+int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
+ virDomainBlockIoTuneInfo *info);
+
#endif /* __DOMAIN_CONF_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a2866a3a06f0..8e994c7f062b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -314,6 +314,7 @@ virDomainDiskMirrorStateTypeToString;
virDomainDiskPathByName;
virDomainDiskRemove;
virDomainDiskRemoveByName;
+virDomainDiskSetBlockIOTune;
virDomainDiskSetDriver;
virDomainDiskSetFormat;
virDomainDiskSetSource;
--
2.11.0