Disallow with sriov_numvfs is 0 or less when creating vf interface
When creating a vf interface, it is created even if the number of SR-IOV VFs is 0 or less. Closes-Bug: 1982543 Test Plan: PASS: Create vf interface with the number of SR-IOV VF is 1 and succeed in creation PASS: Create vf interface with the number of SR-IOV VF is -1 and fail in creation Signed-off-by: Joohyun <oh011798@gmail.com> Change-Id: I69ccf8d192fb57c54425e1229ee93a864ebf2573changes/57/850857/1
parent
2324cf7a6f
commit
d0ebe605dc
|
@ -1418,6 +1418,8 @@ def _check_interface_data(op, interface, ihost, existing_interface,
|
|||
msg = _("VF interfaces must be created over an interface of class"
|
||||
" %s" % constants.INTERFACE_CLASS_PCI_SRIOV)
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
if interface['sriov_numvfs'] <= 0:
|
||||
raise wsme.exc.ClientSideError(_("Value for number of SR-IOV VFs must be > 0."))
|
||||
avail_vfs = lower_iface['sriov_numvfs'] - 1
|
||||
for i in lower_iface['used_by']:
|
||||
if i != interface['ifname']:
|
||||
|
|
|
@ -1564,6 +1564,16 @@ class TestPostMixin(object):
|
|||
self._create_vf('vf1', lower_iface=lower_iface,
|
||||
host=self.worker, sriov_numvfs=4, expect_errors=True)
|
||||
|
||||
# Expected message:
|
||||
# Value for number of SR-IOV VFs must be > 0.
|
||||
def test_create_vf_interface_numvfs_less_than_zero(self):
|
||||
self._create_ethernet('mgmt', constants.NETWORK_TYPE_MGMT,
|
||||
host=self.worker)
|
||||
port, lower_iface = self._create_sriov(
|
||||
'sriov', host=self.worker, sriov_numvfs=4)
|
||||
self._create_vf('vf1', lower_iface=lower_iface,
|
||||
host=self.worker, sriov_numvfs=-1, expect_errors=True)
|
||||
|
||||
# Expected message:
|
||||
# The number of virtual functions _ must be less than or equal to the
|
||||
# available VFs _ available on the underlying interface _
|
||||
|
|
Loading…
Reference in New Issue