mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-18 16:08:25 +00:00
virtcontainers: Pass the PCI address for block based rootfs
Store the PCI address of rootfs in case the rootfs is block based and passed using virtio-block. This helps up get rid of prdicting the device name inside the container for the block device. The agent will determine the device node name using the PCI address. Fixes #266 Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
parent
da08a65de3
commit
717bc4cd26
@ -212,6 +212,17 @@ func (c *Container) setStateHotpluggedDrive(hotplugged bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Container) setContainerRootfsPCIAddr(addr string) error {
|
||||||
|
c.state.RootfsPCIAddr = addr
|
||||||
|
|
||||||
|
err := c.sandbox.storage.storeContainerResource(c.sandbox.id, c.id, stateFileType, c.state)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetAnnotations returns container's annotations
|
// GetAnnotations returns container's annotations
|
||||||
func (c *Container) GetAnnotations() map[string]string {
|
func (c *Container) GetAnnotations() map[string]string {
|
||||||
return c.config.Annotations
|
return c.config.Annotations
|
||||||
@ -791,6 +802,11 @@ func (c *Container) hotplugDrive() error {
|
|||||||
if err := c.sandbox.hypervisor.hotplugAddDevice(&drive, blockDev); err != nil {
|
if err := c.sandbox.hypervisor.hotplugAddDevice(&drive, blockDev); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if drive.PCIAddr != "" {
|
||||||
|
c.setContainerRootfsPCIAddr(drive.PCIAddr)
|
||||||
|
}
|
||||||
|
|
||||||
c.setStateHotpluggedDrive(true)
|
c.setStateHotpluggedDrive(true)
|
||||||
|
|
||||||
if err := c.setStateBlockIndex(driveIndex); err != nil {
|
if err := c.setStateBlockIndex(driveIndex); err != nil {
|
||||||
|
@ -40,7 +40,6 @@ var (
|
|||||||
kataGuestSharedDir = "/run/kata-containers/shared/containers/"
|
kataGuestSharedDir = "/run/kata-containers/shared/containers/"
|
||||||
mountGuest9pTag = "kataShared"
|
mountGuest9pTag = "kataShared"
|
||||||
type9pFs = "9p"
|
type9pFs = "9p"
|
||||||
devPath = "/dev"
|
|
||||||
vsockSocketScheme = "vsock"
|
vsockSocketScheme = "vsock"
|
||||||
kata9pDevType = "9p"
|
kata9pDevType = "9p"
|
||||||
kataBlkDevType = "blk"
|
kataBlkDevType = "blk"
|
||||||
@ -692,15 +691,8 @@ func (k *kataAgent) createContainer(sandbox *Sandbox, c *Container) (p *Process,
|
|||||||
// If virtio-scsi driver, the agent will be able to find the
|
// If virtio-scsi driver, the agent will be able to find the
|
||||||
// device based on the provided address.
|
// device based on the provided address.
|
||||||
if sandbox.config.HypervisorConfig.BlockDeviceDriver == VirtioBlock {
|
if sandbox.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.Driver = kataBlkDevType
|
||||||
rootfs.Source = virtPath
|
rootfs.Source = c.state.RootfsPCIAddr
|
||||||
} else {
|
} else {
|
||||||
scsiAddr, err := getSCSIAddress(c.state.BlockIndex)
|
scsiAddr, err := getSCSIAddress(c.state.BlockIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -60,6 +60,9 @@ type State struct {
|
|||||||
|
|
||||||
// Bool to indicate if the drive for a container was hotplugged.
|
// Bool to indicate if the drive for a container was hotplugged.
|
||||||
HotpluggedDrive bool `json:"hotpluggedDrive"`
|
HotpluggedDrive bool `json:"hotpluggedDrive"`
|
||||||
|
|
||||||
|
// PCI slot at which the block device backing the container rootfs is attached.
|
||||||
|
RootfsPCIAddr string `json:"rootfsPCIAddr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// valid checks that the sandbox state is valid.
|
// valid checks that the sandbox state is valid.
|
||||||
|
Loading…
Reference in New Issue
Block a user