]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainDiskChangeSupported: Add missing iothreads check
authorAdam Julis <ajulis@redhat.com>
Fri, 26 Jul 2024 08:52:18 +0000 (10:52 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 19 Nov 2024 12:04:58 +0000 (13:04 +0100)
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@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c

index 66ab4baa8b381fc9556164e73f9d88989108f990..153bd56e86f8bb4b0571fe8ac06a5f987977c45c 100644 (file)
@@ -6591,6 +6591,49 @@ qemuDomainStorageSourceAccessAllow(virQEMUDriver *driver,
 }
 
 
+static bool
+qemuDomainDiskChangeSupportedIothreads(virDomainDiskDef *disk,
+                                       virDomainDiskDef *orig_disk)
+{
+    GSList *old = orig_disk->iothreads;
+    GSList *new = disk->iothreads;
+
+    while (true) {
+        virDomainDiskIothreadDef *old_def;
+        virDomainDiskIothreadDef *new_def;
+        size_t i;
+
+        /* match - both empty or both at the end */
+        if (!old && !new)
+            return true;
+
+        /* mismatched length of lists */
+        if (!old || !new)
+            goto fail;
+
+        old_def = old->data;
+        new_def = new->data;
+
+        if (old_def->id != new_def->id ||
+            old_def->nqueues != new_def->nqueues)
+            goto fail;
+
+        for (i = 0; i < old_def->nqueues; i++) {
+            if (old_def->queues[i] != new_def->queues[i])
+                goto fail;
+        }
+
+        new = new->next;
+        old = old->next;
+    }
+
+ fail:
+    virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                   _("cannot modify field '<iothreads>' (or it's parts) of the disk"));
+    return false;
+}
+
+
 /*
  * Makes sure the @disk differs from @orig_disk only by the source
  * path and nothing else.  Fields that are being checked and the
@@ -6735,6 +6778,9 @@ qemuDomainDiskChangeSupported(virDomainDiskDef *disk,
     CHECK_EQ(discard, "discard", true);
     CHECK_EQ(iothread, "iothread", true);
 
+    if (!qemuDomainDiskChangeSupportedIothreads(disk, orig_disk))
+        return false;
+
     CHECK_STREQ_NULLABLE(domain_name,
                          "backenddomain");