[libvirt PATCH 1/5] qemu: fail on attempt to set 'floor' if interface type is not 'network'

Pavel Mores posted 5 patches 6 years ago
There is a newer version of this series
[libvirt PATCH 1/5] qemu: fail on attempt to set 'floor' if interface type is not 'network'
Posted by Pavel Mores 6 years ago
QoS 'floor' setting is documented to be only supported for interfaces of
type 'network'.  Fail with an error message on attempt to set 'floor' on
an interface of any other type.

Signed-off-by: Pavel Mores <pmores@redhat.com>
---
 src/qemu/qemu_driver.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e69d083836..88fa56da42 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11672,9 +11672,16 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
                    sizeof(*newBandwidth->out));
         }
 
-        if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
-            virDomainNetBandwidthUpdate(net, newBandwidth) < 0)
-            goto endjob;
+        if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
+            if (virDomainNetBandwidthUpdate(net, newBandwidth) < 0)
+                goto endjob;
+        } else {
+            if (bandwidth->in && bandwidth->in->floor != 0) {
+                virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                               _("'floor' is only supported for interface type 'network' with forward type 'nat', 'route', 'open' or none"));
+                goto endjob;
+            }
+        }
 
         if (virNetDevBandwidthSet(net->ifname, newBandwidth, false,
                                   !virDomainNetTypeSharesHostView(net)) < 0) {
-- 
2.24.1

Re: [libvirt PATCH 1/5] qemu: fail on attempt to set 'floor' if interface type is not 'network'
Posted by Michal Privoznik 5 years, 12 months ago
On 2/10/20 5:10 PM, Pavel Mores wrote:
> QoS 'floor' setting is documented to be only supported for interfaces of
> type 'network'.  Fail with an error message on attempt to set 'floor' on
> an interface of any other type.
> 
> Signed-off-by: Pavel Mores <pmores@redhat.com>
> ---
>   src/qemu/qemu_driver.c | 13 ++++++++++---
>   1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index e69d083836..88fa56da42 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -11672,9 +11672,16 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
>                      sizeof(*newBandwidth->out));
>           }
>   
> -        if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
> -            virDomainNetBandwidthUpdate(net, newBandwidth) < 0)
> -            goto endjob;
> +        if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
> +            if (virDomainNetBandwidthUpdate(net, newBandwidth) < 0)
> +                goto endjob;
> +        } else {
> +            if (bandwidth->in && bandwidth->in->floor != 0) {
> +                virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
> +                               _("'floor' is only supported for interface type 'network' with forward type 'nat', 'route', 'open' or none"));

Please break this long line.

Michal

Re: [libvirt PATCH 1/5] qemu: fail on attempt to set 'floor' if interface type is not 'network'
Posted by Pavel Hrdina 5 years, 12 months ago
On Wed, Feb 12, 2020 at 09:21:05AM +0100, Michal Privoznik wrote:
> On 2/10/20 5:10 PM, Pavel Mores wrote:
> > QoS 'floor' setting is documented to be only supported for interfaces of
> > type 'network'.  Fail with an error message on attempt to set 'floor' on
> > an interface of any other type.
> > 
> > Signed-off-by: Pavel Mores <pmores@redhat.com>
> > ---
> >   src/qemu/qemu_driver.c | 13 ++++++++++---
> >   1 file changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> > index e69d083836..88fa56da42 100644
> > --- a/src/qemu/qemu_driver.c
> > +++ b/src/qemu/qemu_driver.c
> > @@ -11672,9 +11672,16 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
> >                      sizeof(*newBandwidth->out));
> >           }
> > -        if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
> > -            virDomainNetBandwidthUpdate(net, newBandwidth) < 0)
> > -            goto endjob;
> > +        if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
> > +            if (virDomainNetBandwidthUpdate(net, newBandwidth) < 0)
> > +                goto endjob;
> > +        } else {
> > +            if (bandwidth->in && bandwidth->in->floor != 0) {
> > +                virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
> > +                               _("'floor' is only supported for interface type 'network' with forward type 'nat', 'route', 'open' or none"));
> 
> Please break this long line.

Please do not break this long line as stated in our hacking guide [1].

Pavel

[1] <https://libvirt.org/hacking.html#errors>