mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-02-23 15:34:28 +01:00
virtcontainers: block: Factorize checks for evaluating block support
Factorize configuration and hardware support for hotplugging block devices into a single function and use that. Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
committed by
Julio Montes
parent
cde11c36db
commit
50fd76eb9a
@@ -432,6 +432,19 @@ func (c *Container) rollbackFailingContainerCreation() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Container) checkBlockDeviceSupport() bool {
|
||||
if !c.pod.config.HypervisorConfig.DisableBlockDeviceUse {
|
||||
agentCaps := c.pod.agent.capabilities()
|
||||
hypervisorCaps := c.pod.hypervisor.capabilities()
|
||||
|
||||
if agentCaps.isBlockDeviceSupported() && hypervisorCaps.isBlockDeviceHotplugSupported() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// createContainer creates and start a container inside a Pod. It has to be
|
||||
// called only when a new container, not known by the pod, has to be created.
|
||||
func createContainer(pod *Pod, contConfig ContainerConfig) (c *Container, err error) {
|
||||
@@ -456,8 +469,10 @@ func createContainer(pod *Pod, contConfig ContainerConfig) (c *Container, err er
|
||||
}
|
||||
}()
|
||||
|
||||
if err = c.hotplugDrive(); err != nil {
|
||||
return
|
||||
if c.checkBlockDeviceSupport() {
|
||||
if err = c.hotplugDrive(); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Attach devices
|
||||
@@ -683,15 +698,6 @@ func (c *Container) processList(options ProcessListOptions) (ProcessList, error)
|
||||
}
|
||||
|
||||
func (c *Container) hotplugDrive() error {
|
||||
agentCaps := c.pod.agent.capabilities()
|
||||
hypervisorCaps := c.pod.hypervisor.capabilities()
|
||||
|
||||
if c.pod.config.HypervisorConfig.DisableBlockDeviceUse ||
|
||||
!agentCaps.isBlockDeviceSupported() ||
|
||||
!hypervisorCaps.isBlockDeviceHotplugSupported() {
|
||||
return nil
|
||||
}
|
||||
|
||||
dev, err := getDeviceForPath(c.rootFs)
|
||||
|
||||
if err == errMountPointNotFound {
|
||||
|
||||
Reference in New Issue
Block a user