Commit 7bbdccd1 authored by Denis Pynkin's avatar Denis Pynkin Committed by Guillaume Tucker

Add guestfs target mount point

Allow to specify any path in `lava_test_results_dir` for deployments.

Originally guest image for Qemu is mounted to target mount point but in the same
time path inside the image skip only 1 directory in hierarchy doubling
the rest of the path in Qemu VM, for instance:
`/var/lib/lava-5/lib/lava-5/bin/...` instead of `/var/lib/lava-5/bin/...`.
This behavior causes the issues in `lava-test-shell` test:
 lava-test: # lava-test: # sh: 9: /var/lib/lava-4/bin/lava-test-runner: not found
Signed-off-by: Denis Pynkin's avatarDenis Pynkin <denis.pynkin@collabora.com>
parent b1530384
......@@ -82,12 +82,15 @@ class ApplyOverlayGuest(Action):
self.set_namespace_data(
action=self.name, label="guest", key="filename", value=guest_file
)
lava_test_results_dir = self.get_namespace_data(
action='test', label='results', key='lava_test_results_dir')
blkid = prepare_guestfs(
guest_file,
overlay_file,
self.job.device["actions"]["deploy"]["methods"]["image"]["parameters"][
"guest"
]["size"],
lava_test_results_dir
)
self.results = {"success": blkid}
self.set_namespace_data(
......
......@@ -124,9 +124,9 @@ def _launch_guestfs(guest):
@replace_exception(RuntimeError, JobError)
def prepare_guestfs(output, overlay, size):
def prepare_guestfs(output, overlay, size, target_mountpoint=""):
"""
Applies the overlay, offset by one directory.
Applies the overlay, offset by the target directory.
This allows the booted device to mount at the
original lava directory and retain the same path
as if the overlay was unpacked directly into the
......@@ -134,6 +134,7 @@ def prepare_guestfs(output, overlay, size):
:param output: filename of the temporary device
:param overlay: tarball of the lava test shell overlay.
:param size: size of the filesystem in Mb
:param target_mountpoint: path to the mount point on the host
:return blkid of the guest device
"""
guest = guestfs.GuestFS(python_return_dict=True)
......@@ -154,9 +155,10 @@ def prepare_guestfs(output, overlay, size):
guest_dir = mkdtemp()
guest_tar = os.path.join(guest_dir, "guest.tar")
root_tar = tarfile.open(guest_tar, "w")
for topdir in os.listdir(tar_output):
for dirname in os.listdir(os.path.join(tar_output, topdir)):
root_tar.add(os.path.join(tar_output, topdir, dirname), arcname=dirname)
target_mountpoint = target_mountpoint.lstrip("/")
topdir = os.path.join(tar_output, target_mountpoint)
for dirname in os.listdir(topdir):
root_tar.add(os.path.join(tar_output, topdir, dirname), arcname=dirname)
root_tar.close()
guest.tar_in(guest_tar, "/")
os.unlink(guest_tar)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment