]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainSetThrottleGroup: Always honour thottle group name passed as argument
authorPeter Krempa <pkrempa@redhat.com>
Fri, 16 Jan 2026 15:39:40 +0000 (16:39 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 20 Jan 2026 16:11:53 +0000 (17:11 +0100)
Due to the code share with 'qemuDomainSetBlockIoTune' the throttle group
setting code accepts the throttle group name also via typed parameters.

In 'qemuDomainSetThrottleGroup', this means that there are 2 ways to
pass it the throttle group name and both are handled slightly
differently. Specifically the name of the group used in the list of
groups is the name taken from the typed parameters rather than the one
passed via API. We also don't validate that they match.

Now if the name in the typed parameters is missing we'd add empty string
to the group list which would later crash when looking up the group
name.

To avoid this problem always use the name passed via argument. This is
achieved by passing it into 'qemuDomainSetBlockIoTuneFields' so that it
overrides whatever is in the typed parameters.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_driver.c

index 8c7a2e9fe242d2495a8abec3f9d75765bd9cdc5e..9addad3b9e0e11d6d708ad30402f2f65bee6b1fc 100644 (file)
@@ -15177,6 +15177,7 @@ static int
 qemuDomainSetBlockIoTuneFields(virDomainBlockIoTuneInfo *info,
                                virTypedParameterPtr params,
                                int nparams,
+                               const char *group_name,
                                qemuBlockIoTuneSetFlags *set_fields,
                                virTypedParameterPtr *eventParams,
                                int *eventNparams,
@@ -15247,6 +15248,10 @@ qemuDomainSetBlockIoTuneFields(virDomainBlockIoTuneInfo *info,
                          WRITE_IOPS_SEC_MAX_LENGTH);
     }
 
+    /* The name of the throttle group passed via API always takes precedence */
+    if (group_name)
+        param_group_name = group_name;
+
     if (param_group_name) {
         info->group_name = g_strdup(param_group_name);
         *set_fields |= QEMU_BLOCK_IOTUNE_SET_GROUP_NAME;
@@ -15394,6 +15399,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
     if (qemuDomainSetBlockIoTuneFields(&info,
                                        params,
                                        nparams,
+                                       NULL,
                                        &set_fields,
                                        &eventParams,
                                        &eventNparams,
@@ -20388,6 +20394,7 @@ qemuDomainSetThrottleGroup(virDomainPtr dom,
     if (qemuDomainSetBlockIoTuneFields(&info,
                                        params,
                                        nparams,
+                                       groupname,
                                        &set_fields,
                                        &eventParams,
                                        &eventNparams,