[PATCH] qemuDomainDiskChangeSupported: Add missing iothreads check

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

 



GSList of iothreads is not allowed to be changed while the
virtual machine is running.

Resolves: https://issues.redhat.com/browse/RHEL-23607
Signed-off-by: Adam Julis <ajulis@xxxxxxxxxx>
---
While the qemuDomainDiskChangeSupported() design primarily uses
its macros (CHECK_EQ and CHECK_STREQ_NULLABLE), the logic for comparing 2
GSList of iothreads could perhaps be extracted into a separate function
(e.g. IothreadsGslistCompare(GSList *first, GSList *second)). I am
absolutely not sure about this idea so feel free to comment.

 src/qemu/qemu_domain.c | 53 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 298f4bfb9e..2b5222c685 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8505,6 +8505,59 @@ qemuDomainDiskChangeSupported(virDomainDiskDef *disk,
     CHECK_EQ(discard, "discard", true);
     CHECK_EQ(iothread, "iothread", true);
 
+    /* compare list of iothreads, no change allowed */
+    if (orig_disk->iothreads != disk->iothreads) {
+        GSList *old;
+        GSList *new = disk->iothreads;
+        bool print_err = true;
+
+        for (old = orig_disk->iothreads; old; old = old->next) {
+            virDomainDiskIothreadDef *orig = old->data;
+            virDomainDiskIothreadDef *update;
+            print_err = false;
+
+            if (new == NULL) {
+                print_err = true;
+                break;
+            }
+
+            update = new->data;
+
+            if (orig->id != update->id) {
+                print_err = true;
+                break;
+            }
+
+            if (orig->nqueues != update->nqueues) {
+                print_err = true;
+                break;
+            }
+
+            if (orig->nqueues != 0) {
+                ssize_t i = 0;
+
+                while (i < orig->nqueues) {
+                    if (orig->queues[i] != update->queues[i]) {
+                        print_err = true;
+                        break;
+                    }
+                }
+            }
+
+            new = new->next;
+            if (new)
+                print_err = true;
+        }
+
+        if (print_err) {
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                           _("cannot modify field '%1$s' (or it's parts) of the disk"),
+                           "iothreads");
+            return false;
+        }
+    }
+
+
     CHECK_STREQ_NULLABLE(domain_name,
                          "backenddomain");
 
-- 
2.45.2




[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