mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-22 04:18:53 +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"
|
vsockSocketScheme = "vsock"
|
||||||
kata9pDevType = "9p"
|
kata9pDevType = "9p"
|
||||||
kataBlkDevType = "blk"
|
kataBlkDevType = "blk"
|
||||||
|
kataSCSIDevType = "scsi"
|
||||||
sharedDir9pOptions = []string{"trans=virtio,version=9p2000.L", "nodev"}
|
sharedDir9pOptions = []string{"trans=virtio,version=9p2000.L", "nodev"}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -588,11 +589,17 @@ func (k *kataAgent) appendDevices(deviceList []*grpc.Device, devices []Device) [
|
|||||||
}
|
}
|
||||||
|
|
||||||
kataDevice := &grpc.Device{
|
kataDevice := &grpc.Device{
|
||||||
Type: kataBlkDevType,
|
|
||||||
VmPath: d.VirtPath,
|
|
||||||
ContainerPath: d.DeviceInfo.ContainerPath,
|
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)
|
deviceList = append(deviceList, kataDevice)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,20 +628,30 @@ func (k *kataAgent) createContainer(pod *Pod, c *Container) (*Process, error) {
|
|||||||
|
|
||||||
if c.state.Fstype != "" {
|
if c.state.Fstype != "" {
|
||||||
// This is a block based device rootfs.
|
// 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
|
// Pass a drive name only in case of virtio-blk driver.
|
||||||
// the device being waited for by the agent inside the VM,
|
// If virtio-scsi driver, the agent will be able to find the
|
||||||
// without trying to match and update it into the OCI spec list
|
// device based on the provided address.
|
||||||
// of actual devices. The device corresponding to the rootfs is
|
if pod.config.HypervisorConfig.BlockDeviceDriver == VirtioBlock {
|
||||||
// a very specific case.
|
// driveName is the predicted virtio-block guest name (the vd* in /dev/vd*).
|
||||||
rootfs.Driver = kataBlkDevType
|
driveName, err := getVirtDriveName(c.state.BlockIndex)
|
||||||
rootfs.Source = virtPath
|
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.MountPoint = rootPathParent
|
||||||
rootfs.Fstype = c.state.Fstype
|
rootfs.Fstype = c.state.Fstype
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user