[libvirt] [PATCH 5/7] qemu: propagate iotune settings to all disks in the group

Nikolay Shirokovskiy posted 7 patches 6 years, 1 month ago
There is a newer version of this series
[libvirt] [PATCH 5/7] qemu: propagate iotune settings to all disks in the group
Posted by Nikolay Shirokovskiy 6 years, 1 month ago
Currently upon successfull call to qemu's implementation of
virDomainSetBlockIoTune iotune settings are changed only for the
disk given in API if the disk is in iotune group while we need
to change the settings for all disks in the group.

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

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f1ee25aebd..5713266329 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19102,6 +19102,29 @@ qemuDomainSetBlockIoTuneDefaults(virDomainBlockIoTuneInfoPtr newinfo,
 }
 
 
+static void
+qemuDomainSetGroupBlockIoTune(virDomainDefPtr def,
+                              virDomainBlockIoTuneInfoPtr iotune)
+{
+    size_t i;
+
+    if (!iotune->group_name)
+        return;
+
+    for (i = 0; i < def->ndisks; i++) {
+        virDomainDiskDefPtr d = def->disks[i];
+
+        if (STREQ_NULLABLE(d->blkdeviotune.group_name, iotune->group_name)) {
+            char *tmp;
+
+            tmp = d->blkdeviotune.group_name;
+            d->blkdeviotune = *iotune;
+            d->blkdeviotune.group_name = tmp;
+        }
+    }
+}
+
+
 static int
 qemuDomainSetBlockIoTune(virDomainPtr dom,
                          const char *path,
@@ -19409,6 +19432,8 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
         if (virDomainDiskSetBlockIOTune(disk, &info) < 0)
             goto endjob;
 
+        qemuDomainSetGroupBlockIoTune(def, &info);
+
         if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
             goto endjob;
 
@@ -19434,6 +19459,8 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
         if (virDomainDiskSetBlockIOTune(conf_disk, &conf_info) < 0)
             goto endjob;
 
+        qemuDomainSetGroupBlockIoTune(persistentDef, &conf_info);
+
         if (virDomainDefSave(persistentDef, driver->xmlopt,
                              cfg->configDir) < 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 5/7] qemu: propagate iotune settings to all disks in the group
Posted by Daniel P. Berrangé 6 years ago
On Wed, Jan 08, 2020 at 09:49:29AM +0300, Nikolay Shirokovskiy wrote:
> Currently upon successfull call to qemu's implementation of
> virDomainSetBlockIoTune iotune settings are changed only for the
> disk given in API if the disk is in iotune group while we need
> to change the settings for all disks in the group.
> 
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
> ---
>  src/qemu/qemu_driver.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)

I'd suggest re-ordering so that this patch is *before* the
patch 3 which forbids the inconsistent disk settings.

> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index f1ee25aebd..5713266329 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -19102,6 +19102,29 @@ qemuDomainSetBlockIoTuneDefaults(virDomainBlockIoTuneInfoPtr newinfo,
>  }
>  
>  
> +static void
> +qemuDomainSetGroupBlockIoTune(virDomainDefPtr def,
> +                              virDomainBlockIoTuneInfoPtr iotune)
> +{
> +    size_t i;
> +
> +    if (!iotune->group_name)
> +        return;
> +
> +    for (i = 0; i < def->ndisks; i++) {
> +        virDomainDiskDefPtr d = def->disks[i];
> +
> +        if (STREQ_NULLABLE(d->blkdeviotune.group_name, iotune->group_name)) {
> +            char *tmp;
> +
> +            tmp = d->blkdeviotune.group_name;

nitpick - assign tmp at time of declaration.

> +            d->blkdeviotune = *iotune;
> +            d->blkdeviotune.group_name = tmp;
> +        }
> +    }
> +}

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 :|