Skip to content

Commit 76467f8

Browse files
committed
vhost-vdpa: fix env val not show
vdpaPath is now assigned a value in NewVdpaInfoProvider. Signed-off-by: Ziteng Liu <[email protected]>
1 parent cb2802b commit 76467f8

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

pkg/infoprovider/vdpaInfoProvider.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ func NewVdpaInfoProvider(vdpaType types.VdpaType, vdpaDev types.VdpaDevice) type
3939
dev: vdpaDev,
4040
vdpaType: vdpaType,
4141
}
42+
if vdpaType == types.VdpaVhostType && vdpaDev != nil {
43+
vdpaPath, err := vdpaDev.GetPath()
44+
if err != nil {
45+
glog.Errorf("Unexpected error when fetching the vdpa device path: %s", err)
46+
}
47+
vdpaInfoProvider.vdpaPath = vdpaPath
48+
}
4249
return vdpaInfoProvider
4350
}
4451

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

61-
// DeviceSpecs only required for vhost vdpa type as the
62-
if vip.vdpaType == types.VdpaVhostType {
63-
vdpaPath, err := vip.dev.GetPath()
64-
if err != nil {
65-
glog.Errorf("Unexpected error when fetching the vdpa device path: %s", err)
66-
return nil
67-
}
68+
if vip.vdpaPath != "" {
6869
devSpecs = append(devSpecs, &pluginapi.DeviceSpec{
69-
HostPath: vdpaPath,
70-
ContainerPath: vdpaPath,
70+
HostPath: vip.vdpaPath,
71+
ContainerPath: vip.vdpaPath,
7172
Permissions: "rw",
7273
})
73-
vip.vdpaPath = vdpaPath
7474
}
75+
7576
return devSpecs
7677
}
7778

0 commit comments

Comments
 (0)