[libvirt] [PATCH 2/7] conf: expand iotune params if only group name is given

Nikolay Shirokovskiy posted 7 patches 6 years, 1 month ago
There is a newer version of this series
[libvirt] [PATCH 2/7] conf: expand iotune params if only group name is given
Posted by Nikolay Shirokovskiy 6 years, 1 month ago
Currenly if only iotune group name is given for some disk and
no any params then later start of domain will fail. I guess it will
be convinient to allow such configuration if there is another
disk in the same iotune group with iotune params set. The meaning
is that the first disk have same iotunes and the latter. Thus
one can easyly add disk to iotune group - just add group name
parameter and no need to copy all the params.

Also let's expand iotunes params in the described case so we don't
need to refer to another disk to know iotunes and this will make
logic in many places simple.

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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index abe21a93fd..f75841c60f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5106,6 +5106,33 @@ virDomainRNGDefPostParse(virDomainRNGDefPtr rng)
 }
 
 
+static void
+virDomainDiskExpandGroupIoTune(virDomainDiskDefPtr disk,
+                               const virDomainDef *def)
+{
+    size_t i;
+
+    if (!disk->blkdeviotune.group_name ||
+        virDomainBlockIoTuneInfoHasAny(&disk->blkdeviotune))
+        return;
+
+    for (i = 0; i < def->ndisks; i++) {
+        virDomainDiskDefPtr d = def->disks[i];
+
+        if (d->blkdeviotune.group_name &&
+            STREQ(disk->blkdeviotune.group_name, d->blkdeviotune.group_name) &&
+            virDomainBlockIoTuneInfoHasAny(&d->blkdeviotune)) {
+            char *tmp = disk->blkdeviotune.group_name;
+
+            disk->blkdeviotune = d->blkdeviotune;
+            disk->blkdeviotune.group_name = tmp;
+
+            return;
+        }
+    }
+}
+
+
 static int
 virDomainDiskDefPostParse(virDomainDiskDefPtr disk,
                           const virDomainDef *def,
@@ -5151,6 +5178,8 @@ virDomainDiskDefPostParse(virDomainDiskDefPtr disk,
         return -1;
     }
 
+    virDomainDiskExpandGroupIoTune(disk, def);
+
     return 0;
 }
 
-- 
2.23.0


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

Re: [libvirt] [PATCH 2/7] conf: expand iotune params if only group name is given
Posted by Daniel P. Berrangé 6 years ago
On Wed, Jan 08, 2020 at 09:49:26AM +0300, Nikolay Shirokovskiy wrote:
> Currenly if only iotune group name is given for some disk and
> no any params then later start of domain will fail. I guess it will
> be convinient to allow such configuration if there is another

convenient

> disk in the same iotune group with iotune params set. The meaning
> is that the first disk have same iotunes and the latter. Thus
> one can easyly add disk to iotune group - just add group name

"easily"   and   s/add disk/add a disk/

> parameter and no need to copy all the params.
> 
> Also let's expand iotunes params in the described case so we don't
> need to refer to another disk to know iotunes and this will make
> logic in many places simple.
> 
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
> ---
>  src/conf/domain_conf.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 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 :|