Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
device: Assign pci address to block device for kata_agent
Browse files Browse the repository at this point in the history
Store PCI address for a block device on hotplugging it via
virtio-blk. This address will be passed by kata agent in the
device "Id" field. The agent within the guest can then use this
to identify the PCI slot in the guest and create the device node
based on it.

Signed-off-by: Archana Shinde <[email protected]>
  • Loading branch information
amshinde committed May 3, 2018
1 parent 85865f1 commit da08a65
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions virtcontainers/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions virtcontainers/kata_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
},
}

Expand Down

0 comments on commit da08a65

Please sign in to comment.