Skip to content

Commit

Permalink
vhost-vdpa: fix env val not show
Browse files Browse the repository at this point in the history
vdpaPath is now assigned a value in NewVdpaInfoProvider.

Signed-off-by: Ziteng Liu <[email protected]>
  • Loading branch information
makoto126 committed Feb 19, 2024
1 parent cb2802b commit 76467f8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pkg/infoprovider/vdpaInfoProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ func NewVdpaInfoProvider(vdpaType types.VdpaType, vdpaDev types.VdpaDevice) type
dev: vdpaDev,
vdpaType: vdpaType,
}
if vdpaType == types.VdpaVhostType && vdpaDev != nil {
vdpaPath, err := vdpaDev.GetPath()
if err != nil {
glog.Errorf("Unexpected error when fetching the vdpa device path: %s", err)
}
vdpaInfoProvider.vdpaPath = vdpaPath
}
return vdpaInfoProvider
}

Expand All @@ -58,20 +65,14 @@ func (vip *vdpaInfoProvider) GetDeviceSpecs() []*pluginapi.DeviceSpec {
}
devSpecs := make([]*pluginapi.DeviceSpec, 0)

// DeviceSpecs only required for vhost vdpa type as the
if vip.vdpaType == types.VdpaVhostType {
vdpaPath, err := vip.dev.GetPath()
if err != nil {
glog.Errorf("Unexpected error when fetching the vdpa device path: %s", err)
return nil
}
if vip.vdpaPath != "" {
devSpecs = append(devSpecs, &pluginapi.DeviceSpec{
HostPath: vdpaPath,
ContainerPath: vdpaPath,
HostPath: vip.vdpaPath,
ContainerPath: vip.vdpaPath,
Permissions: "rw",
})
vip.vdpaPath = vdpaPath
}

return devSpecs
}

Expand Down

0 comments on commit 76467f8

Please sign in to comment.