From: Adam Julis Date: Fri, 26 Jul 2024 08:52:18 +0000 (+0200) Subject: qemuDomainDiskChangeSupported: Add missing iothreads check X-Git-Tag: v10.10.0-rc1~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74ef4888ff5c6272bf7ddd500a69870a219fedf9;p=thirdparty%2Flibvirt.git qemuDomainDiskChangeSupported: Add missing iothreads check 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 Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 66ab4baa8b..153bd56e86 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -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 '' (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");