guests: allow change nic bandwidth to 0

To restore the default no limit behavior
This commit is contained in:
Yousong Zhou
2018-10-18 07:18:58 +00:00
parent f0e712e8d1
commit c96849e334
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -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
}
+2 -2
View File
@@ -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) {