From c96849e3343879e60925d2ab92bcfbbb6f43dff1 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Thu, 18 Oct 2018 07:14:39 +0000 Subject: [PATCH] guests: allow change nic bandwidth to 0 To restore the default no limit behavior --- pkg/compute/models/guestnetworks.go | 2 +- pkg/compute/models/guests.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/compute/models/guestnetworks.go b/pkg/compute/models/guestnetworks.go index b2cc9b7df5..bd17515f73 100644 --- a/pkg/compute/models/guestnetworks.go +++ b/pkg/compute/models/guestnetworks.go @@ -122,7 +122,7 @@ func (manager *SGuestnetworkManager) newGuestNetwork(ctx context.Context, userCr driver = "virtio" } gn.Driver = driver - if bwLimit > 0 { + if bwLimit >= 0 { gn.BwLimit = bwLimit } diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index 2c8f06fe80..09940bd3bc 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -2881,8 +2881,8 @@ func (self *SGuest) PerformChangeBandwidth(ctx context.Context, userCred mcclien return nil, httperrors.NewBadRequestError("Index Not fount or out of NIC index") } bandwidth, err := data.Int("bandwidth") - if err != nil || bandwidth <= 0 { - return nil, httperrors.NewBadRequestError("Bandwidth must be larger than 0") + if err != nil || bandwidth < 0 { + return nil, httperrors.NewBadRequestError("Bandwidth must be non-negative") } guestnic := &guestnics[index] if guestnic.BwLimit != int(bandwidth) {