Skip to content

Commit

Permalink
fix(kvm): do not allow vfiouser controller for subsys with hostnqn
Browse files Browse the repository at this point in the history
Signed-off-by: Artsiom Koltun <[email protected]>
  • Loading branch information
artek-koltun authored and glimchb committed Oct 9, 2023
1 parent 6dd821d commit 6aa3fd9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/kvm/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func (c *nvmeVfiouserTransport) Params(ctrlr *pb.NvmeController, subsys *pb.Nvme
errors.New("virtual functions are not supported for vfiouser")
}

if subsys.Spec.Hostnqn != "" {
return spdk.NvmfSubsystemAddListenerParams{},
errors.New("hostnqn for subsystem is not supported for vfiouser")
}

result := spdk.NvmfSubsystemAddListenerParams{}
ctrlrDirPath := controllerDirPath(c.ctrlrDir, utils.GetSubsystemIDFromNvmeName(ctrlr.Name))
result.Nqn = subsys.Spec.Nqn
Expand Down
15 changes: 14 additions & 1 deletion pkg/kvm/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,39 @@ func TestNewNvmeVfiouserTransportParams(t *testing.T) {
pf int32
vf int32
port int32
hostnqn string
wantErr bool
wantParams spdk.NvmfSubsystemAddListenerParams
}{
"not allowed vf": {
pf: 0,
vf: 1,
port: 0,
hostnqn: "",
wantErr: true,
wantParams: spdk.NvmfSubsystemAddListenerParams{},
},
"not allowed port": {
pf: 0,
vf: 0,
port: 2,
hostnqn: "",
wantErr: true,
wantParams: spdk.NvmfSubsystemAddListenerParams{},
},
"not allowed hostnqn in subsystem": {
pf: 0,
vf: 0,
port: 0,
hostnqn: "nqn.2014-08.org.nvmexpress:uuid:feb98abe-d51f-40c8-b348-2753f3571d3c",
wantErr: true,
wantParams: spdk.NvmfSubsystemAddListenerParams{},
},
"successful params": {
pf: 3,
vf: 0,
port: 0,
hostnqn: "",
wantErr: false,
wantParams: spdk.NvmfSubsystemAddListenerParams{
Nqn: "nqn.2014-08.org.nvmexpress:uuid:1630a3a6-5bac-4563-a1a6-d2b0257c282a",
Expand Down Expand Up @@ -121,7 +133,8 @@ func TestNewNvmeVfiouserTransportParams(t *testing.T) {
},
}, &pb.NvmeSubsystem{
Spec: &pb.NvmeSubsystemSpec{
Nqn: "nqn.2014-08.org.nvmexpress:uuid:1630a3a6-5bac-4563-a1a6-d2b0257c282a",
Nqn: "nqn.2014-08.org.nvmexpress:uuid:1630a3a6-5bac-4563-a1a6-d2b0257c282a",
Hostnqn: tt.hostnqn,
},
})

Expand Down

0 comments on commit 6aa3fd9

Please sign in to comment.