[libvirt] [PATCH 7/7] qemu: when leaving iotune group update xml properly

Nikolay Shirokovskiy posted 7 patches 6 years, 1 month ago
There is a newer version of this series
[libvirt] [PATCH 7/7] qemu: when leaving iotune group update xml properly
Posted by Nikolay Shirokovskiy 6 years, 1 month ago
Currently when disk is removed from iotune group (by setting
all tunables to zero) group name is leaved in config. Let's fix
it.

Given iotune defaults are taken from the destination group setting
tunables to zero may require different set of zero settings in API
call. Let's prohibit removing from group while specifying different
group name then current for the sanity sake.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
---
 src/qemu/qemu_driver.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5da3748dc7..7c75d502d5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19147,6 +19147,28 @@ qemuDomainFindGroupBlockIoTune(virDomainDefPtr def,
 }
 
 
+static int
+qemuDomainCheckBlockIoTuneReset(virDomainDiskDefPtr disk,
+                                virDomainBlockIoTuneInfoPtr newiotune)
+{
+    if (virDomainBlockIoTuneInfoHasAny(newiotune))
+        return 0;
+
+    if (newiotune->group_name &&
+        STRNEQ_NULLABLE(newiotune->group_name, disk->blkdeviotune.group_name)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("creating a new group/updating existing with all"
+                         " tune parameters zero is not supported"));
+        return -1;
+    }
+
+    /* all zero means remove any throttling and remove from group for qemu */
+    VIR_FREE(newiotune->group_name);
+
+    return 0;
+}
+
+
 static int
 qemuDomainSetBlockIoTune(virDomainPtr dom,
                          const char *path,
@@ -19406,6 +19428,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
                                              set_fields) < 0)
             goto endjob;
 
+        if (qemuDomainCheckBlockIoTuneReset(disk, &info) < 0)
+            goto endjob;
+
 #define CHECK_MAX(val, _bool) \
         do { \
             if (info.val##_max) { \
@@ -19485,6 +19510,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
                                              set_fields) < 0)
             goto endjob;
 
+        if (qemuDomainCheckBlockIoTuneReset(conf_disk, &conf_info) < 0)
+            goto endjob;
+
         if (virDomainDiskSetBlockIOTune(conf_disk, &conf_info) < 0)
             goto endjob;
 
-- 
2.23.0


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 7/7] qemu: when leaving iotune group update xml properly
Posted by Daniel P. Berrangé 6 years ago
On Wed, Jan 08, 2020 at 09:49:31AM +0300, Nikolay Shirokovskiy wrote:
> Currently when disk is removed from iotune group (by setting
> all tunables to zero) group name is leaved in config. Let's fix
> it.
> 
> Given iotune defaults are taken from the destination group setting
> tunables to zero may require different set of zero settings in API
> call. Let's prohibit removing from group while specifying different
> group name then current for the sanity sake.
> 
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
> ---
>  src/qemu/qemu_driver.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|