render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
7a3408
From 571c0cf49730a6c636b71e42c71512ce1b772a31 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <571c0cf49730a6c636b71e42c71512ce1b772a31@dist-git>
7a3408
From: Michal Privoznik <mprivozn@redhat.com>
7a3408
Date: Mon, 10 Aug 2015 14:15:44 +0200
7a3408
Subject: [PATCH] virNetDevBandwidthParseRate: Reject negative values
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1022292
7a3408
7a3408
The following XML really does not make any sense:
7a3408
7a3408
<inbound average="-1" burst="-2" peak="-3" floor="-4"/>
7a3408
7a3408
There can't be a negative packet rate. Well, so far we haven't
7a3408
assigned any meaning to it. So reject it unless users harm themselves,
7a3408
because otherwise we turn the negative numbers into really big values.
7a3408
7a3408
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7a3408
(cherry picked from commit 2a5d3f227df7be78449792103e0101a4b859c49b)
7a3408
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/conf/netdev_bandwidth_conf.c | 8 ++++----
7a3408
 1 file changed, 4 insertions(+), 4 deletions(-)
7a3408
7a3408
diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c
7a3408
index fdd5b7f..8824332 100644
7a3408
--- a/src/conf/netdev_bandwidth_conf.c
7a3408
+++ b/src/conf/netdev_bandwidth_conf.c
7a3408
@@ -50,7 +50,7 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate)
7a3408
     floor = virXMLPropString(node, "floor");
7a3408
 
7a3408
     if (average) {
7a3408
-        if (virStrToLong_ull(average, NULL, 10, &rate->average) < 0) {
7a3408
+        if (virStrToLong_ullp(average, NULL, 10, &rate->average) < 0) {
7a3408
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
7a3408
                            _("could not convert bandwidth average value '%s'"),
7a3408
                            average);
7a3408
@@ -68,21 +68,21 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate)
7a3408
         goto cleanup;
7a3408
     }
7a3408
 
7a3408
-    if (peak && virStrToLong_ull(peak, NULL, 10, &rate->peak) < 0) {
7a3408
+    if (peak && virStrToLong_ullp(peak, NULL, 10, &rate->peak) < 0) {
7a3408
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
7a3408
                        _("could not convert bandwidth peak value '%s'"),
7a3408
                        peak);
7a3408
         goto cleanup;
7a3408
     }
7a3408
 
7a3408
-    if (burst && virStrToLong_ull(burst, NULL, 10, &rate->burst) < 0) {
7a3408
+    if (burst && virStrToLong_ullp(burst, NULL, 10, &rate->burst) < 0) {
7a3408
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
7a3408
                        _("could not convert bandwidth burst value '%s'"),
7a3408
                        burst);
7a3408
         goto cleanup;
7a3408
     }
7a3408
 
7a3408
-    if (floor && virStrToLong_ull(floor, NULL, 10, &rate->floor) < 0) {
7a3408
+    if (floor && virStrToLong_ullp(floor, NULL, 10, &rate->floor) < 0) {
7a3408
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
7a3408
                        _("could not convert bandwidth floor value '%s'"),
7a3408
                        floor);
7a3408
-- 
7a3408
2.5.0
7a3408