mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-21 20:08:54 +00:00
virtcontainers: kata_agent: Add virtio-scsi support
This commit enables the support of virtio-scsi for block devices used as root filesystem or as devices passed through the VM to be used directly from the container. Fixes #56 Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -51,6 +51,7 @@ var (
|
||||
vsockSocketScheme = "vsock"
|
||||
kata9pDevType = "9p"
|
||||
kataBlkDevType = "blk"
|
||||
kataSCSIDevType = "scsi"
|
||||
sharedDir9pOptions = []string{"trans=virtio,version=9p2000.L", "nodev"}
|
||||
)
|
||||
|
||||
@@ -588,11 +589,17 @@ func (k *kataAgent) appendDevices(deviceList []*grpc.Device, devices []Device) [
|
||||
}
|
||||
|
||||
kataDevice := &grpc.Device{
|
||||
Type: kataBlkDevType,
|
||||
VmPath: d.VirtPath,
|
||||
ContainerPath: d.DeviceInfo.ContainerPath,
|
||||
}
|
||||
|
||||
if d.SCSIAddr == "" {
|
||||
kataDevice.Type = kataBlkDevType
|
||||
kataDevice.VmPath = d.VirtPath
|
||||
} else {
|
||||
kataDevice.Type = kataSCSIDevType
|
||||
kataDevice.Id = d.SCSIAddr
|
||||
}
|
||||
|
||||
deviceList = append(deviceList, kataDevice)
|
||||
}
|
||||
|
||||
@@ -621,20 +628,30 @@ func (k *kataAgent) createContainer(pod *Pod, c *Container) (*Process, error) {
|
||||
|
||||
if c.state.Fstype != "" {
|
||||
// This is a block based device rootfs.
|
||||
// driveName is the predicted virtio-block guest name (the vd* in /dev/vd*).
|
||||
driveName, err := getVirtDriveName(c.state.BlockIndex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
virtPath := filepath.Join(devPath, driveName)
|
||||
|
||||
// Create a new device with empty ContainerPath so that we get
|
||||
// the device being waited for by the agent inside the VM,
|
||||
// without trying to match and update it into the OCI spec list
|
||||
// of actual devices. The device corresponding to the rootfs is
|
||||
// a very specific case.
|
||||
rootfs.Driver = kataBlkDevType
|
||||
rootfs.Source = virtPath
|
||||
// Pass a drive name only in case of virtio-blk driver.
|
||||
// If virtio-scsi driver, the agent will be able to find the
|
||||
// device based on the provided address.
|
||||
if pod.config.HypervisorConfig.BlockDeviceDriver == VirtioBlock {
|
||||
// driveName is the predicted virtio-block guest name (the vd* in /dev/vd*).
|
||||
driveName, err := getVirtDriveName(c.state.BlockIndex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
virtPath := filepath.Join(devPath, driveName)
|
||||
|
||||
rootfs.Driver = kataBlkDevType
|
||||
rootfs.Source = virtPath
|
||||
} else {
|
||||
scsiAddr, err := getSCSIAddress(c.state.BlockIndex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rootfs.Driver = kataSCSIDevType
|
||||
rootfs.Source = scsiAddr
|
||||
}
|
||||
|
||||
rootfs.MountPoint = rootPathParent
|
||||
rootfs.Fstype = c.state.Fstype
|
||||
|
||||
|
Reference in New Issue
Block a user