[PATCH v2 6/7] qemu: get defaults from iotune group we move disk into

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>

For example if disk is not in the group and we want to move it
there then it makes sense to specify only the group name in API call.
Currently the destination group iotune settings will be overwritten
with the disk settings which I would say is not what one would expect.
Thus let's get defaults from the group we are moving to.

And if we are moving the brand new group then is makes sense to
copy the current disk iotune settings to the group.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index eb4b85a20d..9bf4d99fff 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19137,6 +19137,28 @@ qemuDomainSetGroupBlockIoTune(virDomainDefPtr def,
 }
 
 
+static virDomainBlockIoTuneInfoPtr
+qemuDomainFindGroupBlockIoTune(virDomainDefPtr def,
+                               virDomainDiskDefPtr disk,
+                               virDomainBlockIoTuneInfoPtr newiotune)
+{
+    size_t i;
+
+    if (!newiotune->group_name ||
+        STREQ_NULLABLE(disk->blkdeviotune.group_name, newiotune->group_name))
+        return &disk->blkdeviotune;
+
+    for (i = 0; i < def->ndisks; i++) {
+        virDomainDiskDefPtr d = def->disks[i];
+
+        if (STREQ_NULLABLE(newiotune->group_name, d->blkdeviotune.group_name))
+            return &d->blkdeviotune;
+    }
+
+    return &disk->blkdeviotune;
+}
+
+
 static int
 qemuDomainSetBlockIoTune(virDomainPtr dom,
                          const char *path,
@@ -19166,6 +19188,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
     virTypedParameterPtr eventParams = NULL;
     int eventNparams = 0;
     int eventMaxparams = 0;
+    virDomainBlockIoTuneInfoPtr cur_info;
+    virDomainBlockIoTuneInfoPtr conf_cur_info;
+
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -19386,7 +19411,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
                 goto endjob;
         }
 
-        if (qemuDomainSetBlockIoTuneDefaults(&info, &disk->blkdeviotune,
+        cur_info = qemuDomainFindGroupBlockIoTune(def, disk, &info);
+
+        if (qemuDomainSetBlockIoTuneDefaults(&info, cur_info,
                                              set_fields) < 0)
             goto endjob;
 
@@ -19463,7 +19490,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
             goto endjob;
         }
 
-        if (qemuDomainSetBlockIoTuneDefaults(&conf_info, &conf_disk->blkdeviotune,
+        conf_cur_info = qemuDomainFindGroupBlockIoTune(persistentDef, conf_disk, &info);
+
+        if (qemuDomainSetBlockIoTuneDefaults(&conf_info, conf_cur_info,
                                              set_fields) < 0)
             goto endjob;
 
-- 
2.24.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux