diff --git a/virtcontainers/device.go b/virtcontainers/device.go index 77aeb64417..6b852bcbbb 100644 --- a/virtcontainers/device.go +++ b/virtcontainers/device.go @@ -391,6 +391,7 @@ func (device *BlockDevice) attach(h hypervisor, c *Container) (err error) { if c.sandbox.config.HypervisorConfig.BlockDeviceDriver == VirtioBlock { device.VirtPath = filepath.Join("/dev", driveName) + device.PCIAddr = drive.PCIAddr } else { scsiAddr, err := getSCSIAddress(index) if err != nil { diff --git a/virtcontainers/kata_agent.go b/virtcontainers/kata_agent.go index 2c2e8d464e..aa94ed3161 100644 --- a/virtcontainers/kata_agent.go +++ b/virtcontainers/kata_agent.go @@ -629,7 +629,7 @@ func (k *kataAgent) appendDevices(deviceList []*grpc.Device, devices []Device) [ if d.SCSIAddr == "" { kataDevice.Type = kataBlkDevType - kataDevice.VmPath = d.VirtPath + kataDevice.Id = d.PCIAddr } else { kataDevice.Type = kataSCSIDevType kataDevice.Id = d.SCSIAddr diff --git a/virtcontainers/kata_agent_test.go b/virtcontainers/kata_agent_test.go index d59ef9e486..6b58080a11 100644 --- a/virtcontainers/kata_agent_test.go +++ b/virtcontainers/kata_agent_test.go @@ -24,9 +24,9 @@ import ( ) var ( - testKataProxyURLTempl = "unix://%s/kata-proxy-test.sock" - testBlockDeviceVirtPath = "testBlockDeviceVirtPath" - testBlockDeviceCtrPath = "testBlockDeviceCtrPath" + testKataProxyURLTempl = "unix://%s/kata-proxy-test.sock" + testBlockDeviceCtrPath = "testBlockDeviceCtrPath" + testPCIAddr = "04/02" ) func proxyHandlerDiscard(c net.Conn) { @@ -366,16 +366,16 @@ func TestAppendDevices(t *testing.T) { expected := []*pb.Device{ { Type: kataBlkDevType, - VmPath: testBlockDeviceVirtPath, ContainerPath: testBlockDeviceCtrPath, + Id: testPCIAddr, }, } ctrDevices := []Device{ &BlockDevice{ - VirtPath: testBlockDeviceVirtPath, DeviceInfo: DeviceInfo{ ContainerPath: testBlockDeviceCtrPath, }, + PCIAddr: testPCIAddr, }, }