]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: when leaving iotune group update xml properly
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Wed, 8 Jan 2020 06:49:31 +0000 (09:49 +0300)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 29 Jan 2020 10:47:01 +0000 (11:47 +0100)
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>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_driver.c

index 9bf4d99fff6744092cfc23b8ad27ea5de3533573..3e6d14ead802c927ba862c9329a3849c69029a46 100644 (file)
@@ -19159,6 +19159,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,
@@ -19417,6 +19439,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) { \
@@ -19496,6 +19521,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;