[PATCH] qemu: Validate QoS values in qemuDomainSetInterfaceParameters()

This is similar to one of my previous commits (v10.7.0-rc1~22) which introduce a check that <bandwidth/> values fit into certain limits. My original commit validated values when parsing <bandwidth/> XML, but completely missed the case when values are set over virDomainSetInterfaceParameters() API. Solution is simple - just perform validation after bandwidth structure is reconstructed from arguments passed to the API. Resolves: https://issues.redhat.com/browse/RHEL-65372 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_driver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d1b32de56a..09f7edda7d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9883,6 +9883,9 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (!bandwidth->out->average) VIR_FREE(bandwidth->out); + if (!virNetDevBandwidthValidate(bandwidth)) + goto endjob; + if (net) { newBandwidth = g_new0(virNetDevBandwidth, 1); -- 2.45.2

On Wed, Nov 27, 2024 at 12:30:05 +0100, Michal Privoznik wrote:
This is similar to one of my previous commits (v10.7.0-rc1~22) which introduce a check that <bandwidth/> values fit into certain
s/introduce/introduced/
limits. My original commit validated values when parsing <bandwidth/> XML, but completely missed the case when values are set over virDomainSetInterfaceParameters() API.
Solution is simple - just perform validation after bandwidth structure is reconstructed from arguments passed to the API.
Resolves: https://issues.redhat.com/browse/RHEL-65372 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_driver.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d1b32de56a..09f7edda7d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9883,6 +9883,9 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (!bandwidth->out->average) VIR_FREE(bandwidth->out);
+ if (!virNetDevBandwidthValidate(bandwidth)) + goto endjob; + if (net) { newBandwidth = g_new0(virNetDevBandwidth, 1);
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
participants (2)
-
Jiri Denemark
-
Michal Privoznik