From: Aníbal Limón anibal.limon@linaro.org
Now the Test writer has access to the images inside the LXC to make changes previous deploy/flash into the board, in order to support mount/modify rootfs images the loop device is needed.
Add a parameter in the lxc-boot action to map a free loop device (losetup -f) into the LXC.
Change-Id: I7060ebac12b10e5390560da082fe6c49568c5ffc Signed-off-by: Aníbal Limón anibal.limon@linaro.org --- lava_dispatcher/actions/boot/lxc.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/lava_dispatcher/actions/boot/lxc.py b/lava_dispatcher/actions/boot/lxc.py index d896d303..e3e3cb48 100644 --- a/lava_dispatcher/actions/boot/lxc.py +++ b/lava_dispatcher/actions/boot/lxc.py @@ -75,7 +75,11 @@ class BootLxcAction(BootAction): def populate(self, parameters): self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters) self.internal_pipeline.add_action(LxcStartAction()) - self.internal_pipeline.add_action(LxcAddStaticDevices()) + + lxc_add_loop = False + if 'lxc_add_loop' in parameters: + lxc_add_loop = parameters.get('lxc_add_loop', False) + self.internal_pipeline.add_action(LxcAddStaticDevices(lxc_add_loop)) self.internal_pipeline.add_action(ConnectLxc()) # Skip AutoLoginAction unconditionally as this action tries to parse kernel message # self.internal_pipeline.add_action(AutoLoginAction()) @@ -91,11 +95,12 @@ class LxcAddStaticDevices(Action): worker. """
- def __init__(self): + def __init__(self, lxc_add_loop=False): super(LxcAddStaticDevices, self).__init__() self.name = 'lxc-add-static' self.description = 'Add devices which are permanently powered by the worker to the LXC' self.summary = 'Add static devices to the LXC' + self.lxc_add_loop = lxc_add_loop
def validate(self): super(LxcAddStaticDevices, self).validate() @@ -115,6 +120,15 @@ class LxcAddStaticDevices(Action): def run(self, connection, max_end_time, args=None): connection = super(LxcAddStaticDevices, self).run(connection, max_end_time, args) lxc_name = self.get_namespace_data(action='lxc-create-action', label='lxc', key='name') + + if self.lxc_add_loop: + lxc_get_loop_cmd = ['losetup', '-f'] + loop_device = self.run_command(lxc_get_loop_cmd, allow_silent=True).strip() + lxc_loop_cmd = ['lxc-device', '-n', lxc_name, 'add', loop_device] + cmd_out = self.run_command(lxc_loop_cmd) + if cmd_out: + self.logger.debug(cmd_out) + # If there is no static_info then this action should be idempotent. if 'static_info' not in self.job.device: return connection
Hi Anibal,
On Saturday 16 December 2017 03:53 AM, Aníbal Limón wrote:
Now the Test writer has access to the images inside the LXC to make changes previous deploy/flash into the board, in order to support mount/modify rootfs images the loop device is needed.
Add a parameter in the lxc-boot action to map a free loop device (losetup -f) into the LXC.
I think the more appropriate place to add a loop device to the container will be the LXC protocol. When the protocol is defined the job writer can request loop device.
Thank You.
Hi Anibal,
On Wednesday 20 December 2017 03:39 PM, Senthil Kumaran S wrote:
I think the more appropriate place to add a loop device to the container will be the LXC protocol. When the protocol is defined the job writer can request loop device.
We had a proper design discussion within the LAVA team in order to solve this considering ease of administration and avoiding resource starvation. The following has been decided:
* The device dictionary will hold the loop device details for each DUT. * The number of loop devices and the exact loop devices a DUT shall use will be part of the device dictionary. * The admin should ensure the availability of loop devices as configured in each device dictionary. * There will be an easy way to check the loop devices are not duplicated among device dictionaries. * The loop device configuration will apply only to DUTs that use LXC directly or indirectly. * Documentation explaining how to expose/configure availability of loop devices within LXC.
The work related to this will be tracked via the LAVA story - https://projects.linaro.org/browse/LAVA-1188
Thank You.
lava-users@lists.lavasoftware.org