Skip to content

Commit

Permalink
feat(kvm): use qemu attach/detach only for pcie
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 2, 2023
1 parent 0f13e5f commit 0c39af9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions pkg/kvm/nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ import (

// CreateNvmeController creates an Nvme controller device and attaches it to QEMU instance
func (s *Server) CreateNvmeController(ctx context.Context, in *pb.CreateNvmeControllerRequest) (*pb.NvmeController, error) {
if in.GetNvmeController().GetSpec().GetTrtype() != pb.NvmeTransportType_NVME_TRANSPORT_PCIE {
return s.Server.CreateNvmeController(ctx, in)
}

if in.Parent == "" {
return nil, errInvalidSubsystem
}
if in.NvmeController.Spec.PcieId == nil {
if in.GetNvmeController().GetSpec().GetPcieId() == nil {
log.Println("Pci endpoint should be specified")
return nil, errNoPcieEndpoint
}
location, err := s.locator.Calculate(in.NvmeController.Spec.PcieId)
location, err := s.locator.Calculate(in.GetNvmeController().GetSpec().GetPcieId())
if err != nil {
log.Println("Failed to calculate device location: ", err)
return nil, errDeviceEndpoint
Expand Down Expand Up @@ -75,6 +79,11 @@ func (s *Server) CreateNvmeController(ctx context.Context, in *pb.CreateNvmeCont

// DeleteNvmeController deletes an Nvme controller device and detaches it from QEMU instance
func (s *Server) DeleteNvmeController(ctx context.Context, in *pb.DeleteNvmeControllerRequest) (*emptypb.Empty, error) {
controller, ok := s.Nvme.Controllers[in.GetName()]
if !ok || controller.GetSpec().GetTrtype() != pb.NvmeTransportType_NVME_TRANSPORT_PCIE {
return s.Server.DeleteNvmeController(ctx, in)
}

mon, monErr := newMonitor(s.qmpAddress, s.protocol, s.timeout, s.pollDevicePresenceStep)
if monErr != nil {
log.Println("Couldn't create QEMU monitor")
Expand Down
2 changes: 1 addition & 1 deletion pkg/kvm/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewNvmeVfiouserTransport(ctrlrDir string) frontend.NvmeTransport {
}

func (c *nvmeVfiouserTransport) Params(ctrlr *pb.NvmeController, nqn string) (spdk.NvmfSubsystemAddListenerParams, error) {
pcieID := ctrlr.Spec.GetPcieId()
pcieID := ctrlr.GetSpec().GetPcieId()
if pcieID.PortId.Value != 0 {
return spdk.NvmfSubsystemAddListenerParams{},
errors.New("only port 0 is supported for vfiouser")
Expand Down

0 comments on commit 0c39af9

Please sign in to comment.