[libvirt PATCH 0/2] qemu: fix crash on invalid bandwidth request

https://bugzilla.redhat.com/show_bug.cgi?id=1800505 Ján Tomko (2): qemu: do not revert to NULL bandwidth qemu: preserve error on bandwidth rollback src/qemu/qemu_driver.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.21.1

Otherwise an attempt to set an invalid value: virsh domiftune rhel8.2 vnet0 --outbound 4294968 on an interface with no bandwidth set crashes. Signed-off-by: Ján Tomko <jtomko@redhat.com> Fixes: f02e21cb3379a41cd42f2d8116f2d10dabace83b https://bugzilla.redhat.com/show_bug.cgi?id=1800505 --- src/qemu/qemu_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 502f4ce342..0324c771a5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11665,8 +11665,10 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, net->bandwidth, false, !virDomainNetTypeSharesHostView(net))); - ignore_value(virDomainNetBandwidthUpdate(net, - net->bandwidth)); + if (net->bandwidth) { + ignore_value(virDomainNetBandwidthUpdate(net, + net->bandwidth)); + } goto endjob; } -- 2.21.1

On 2/7/20 8:54 AM, Ján Tomko wrote:
Otherwise an attempt to set an invalid value: virsh domiftune rhel8.2 vnet0 --outbound 4294968 on an interface with no bandwidth set crashes.
Signed-off-by: Ján Tomko <jtomko@redhat.com> Fixes: f02e21cb3379a41cd42f2d8116f2d10dabace83b https://bugzilla.redhat.com/show_bug.cgi?id=1800505 ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 502f4ce342..0324c771a5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11665,8 +11665,10 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, net->bandwidth, false, !virDomainNetTypeSharesHostView(net))); - ignore_value(virDomainNetBandwidthUpdate(net, - net->bandwidth)); + if (net->bandwidth) { + ignore_value(virDomainNetBandwidthUpdate(net, + net->bandwidth)); + } goto endjob; }

We call APIs that reset the error in the rollback code. Preserve the error from the original call that failed. This turns the boringly cryptic: error: Unable to set interface parameters error: An error occurred, but the cause is unknown to the unexpectedly anarchist: error: internal error: Child process (/usr/sbin/tc filter add dev vnet1 parent ffff: protocol all u32 match u32 0 0 police rate 4294968kbps burst 4294968kb mtu 64kb drop flowid :1) unexpected exit status 1: Illegal "rate" Illegal "police" Signed-off-by: Ján Tomko <jtomko@redhat.com> Fixes: f02e21cb3379a41cd42f2d8116f2d10dabace83b https://bugzilla.redhat.com/show_bug.cgi?id=1800505 --- src/qemu/qemu_driver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0324c771a5..ad5c7d9ff1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11661,6 +11661,9 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (virNetDevBandwidthSet(net->ifname, newBandwidth, false, !virDomainNetTypeSharesHostView(net)) < 0) { + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); ignore_value(virNetDevBandwidthSet(net->ifname, net->bandwidth, false, @@ -11669,6 +11672,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ignore_value(virDomainNetBandwidthUpdate(net, net->bandwidth)); } + virErrorRestore(&orig_err); goto endjob; } -- 2.21.1

On 2/7/20 8:54 AM, Ján Tomko wrote:
We call APIs that reset the error in the rollback code. Preserve the error from the original call that failed.
This turns the boringly cryptic: error: Unable to set interface parameters error: An error occurred, but the cause is unknown to the unexpectedly anarchist: error: internal error: Child process (/usr/sbin/tc filter add dev vnet1 parent ffff: protocol all u32 match u32 0 0 police rate 4294968kbps burst 4294968kb mtu 64kb drop flowid :1)
unexpected exit status 1: Illegal "rate" Illegal "police"
Anarchy In The Libvirt!
Signed-off-by: Ján Tomko <jtomko@redhat.com> Fixes: f02e21cb3379a41cd42f2d8116f2d10dabace83b https://bugzilla.redhat.com/show_bug.cgi?id=1800505 ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_driver.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0324c771a5..ad5c7d9ff1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11661,6 +11661,9 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
if (virNetDevBandwidthSet(net->ifname, newBandwidth, false, !virDomainNetTypeSharesHostView(net)) < 0) { + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); ignore_value(virNetDevBandwidthSet(net->ifname, net->bandwidth, false, @@ -11669,6 +11672,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ignore_value(virDomainNetBandwidthUpdate(net, net->bandwidth)); } + virErrorRestore(&orig_err); goto endjob; }
participants (2)
-
Daniel Henrique Barboza
-
Ján Tomko