Skip to content

cptofs cleanups, fixes and tests - #647

Draft
ddiss wants to merge 14 commits into
lkl:masterfrom
ddiss:cptofs_tests
Draft

ddiss wants to merge 14 commits into
lkl:masterfrom
ddiss:cptofs_tests

Conversation

@ddiss

@ddiss ddiss commented Sep 30, 2026

Copy link
Copy Markdown

Draft for now, until I better understand the LKL virtio-blk I/O errors when running cptofs.sh -t xfs

Close src fd on dst open failure. Close dst fd on chown failure.

Signed-off-by: David Disseldorp <ddiss@suse.de>
copy_file() doesn't check close() return values. Perform an explicit
fsync() of the copy destination to catch any writeback errors.

Signed-off-by: David Disseldorp <ddiss@suse.de>
selinux attrs provided by -s are only handled when the copy destination
is LKL based (cptofs). Indicate this in the usage message and return
an error if cpfromfs is provided -s instead of ignoring it.

It may make sense to add corresponding host fsetxattr() calls, but the
security namespace is privileged, which will likely cause issues.

Signed-off-by: David Disseldorp <ddiss@suse.de>
cptofs behaves differently depending on whether argv[0] includes cptofs
or not, i.e. when run as cpfromfs.
install (from coreutils) resolves symlinks during binary installation,
so add an explicit ln call to the install rule instead of adding
cpfromfs to progs-y and reusing the existing build rule.

Signed-off-by: David Disseldorp <ddiss@suse.de>
If the user explicitly requests an copy destination selinux attribute
via -s, then we should fail if the fsetattr returns an error.

Signed-off-by: David Disseldorp <ddiss@suse.de>
On short write, copy_file() currently attempts to write any remainder
from a source buffer address *after* the full read length.
I've not actually triggered this code-path, but it's a theoretical
buffer overrun. Fix it by incrementing the buffer address by the amount
written instead of the read amount.

Link: lkl#646
Signed-off-by: David Disseldorp <ddiss@suse.de>
With cptofs the destination is LKL, so lkl_strerror(ret) should be used
instead of strerror(errno). Vice-versa for cpfromfs.

Signed-off-by: David Disseldorp <ddiss@suse.de>
mkdir_dst() already squashes EEXIST errors, so chown will continue to be
triggered in that case.

Signed-off-by: David Disseldorp <ddiss@suse.de>
The new cptofs.sh wrapper attempts basic file and directory tree copies
between lkl and host via cptofs and cpfromfs.

Signed-off-by: David Disseldorp <ddiss@suse.de>
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Test Results

110 files  +  4  110 suites  +4   10m 5s ⏱️ -25s
184 tests  -  22  165 ✅  -  30  11 💤 ±0  0 ❌ ±0   8 🔥 + 8 
662 runs   - 128  592 ✅  - 142  56 💤 ±0  0 ❌ ±0  14 🔥 +14 

For more details on these errors, see this check.

Results for commit fafdd1a. ± Comparison against base commit d0f76a7.

This pull request removes 30 and adds 8 tests. Note that renamed tests count towards both.
disk btrfs ‑ chdir_mnt_point
disk btrfs ‑ closedir
disk btrfs ‑ disk_add
disk btrfs ‑ disk_remove
disk btrfs ‑ mount_dev
disk btrfs ‑ opendir
disk btrfs ‑ readdir
disk btrfs ‑ start_kernel
disk btrfs ‑ stop_kernel
disk btrfs ‑ umount_dev
…
disk btrfs ‑ cptofs_file
disk btrfs ‑ cptofs_tree
disk ext4 ‑ cptofs_file
disk ext4 ‑ cptofs_tree
disk vfat ‑ cptofs_file
disk vfat ‑ cptofs_tree
disk xfs ‑ cptofs_file
disk xfs ‑ cptofs_tree

♻️ This comment has been updated with latest results.

ddiss added 3 commits October 6, 2026 23:33
The existing behavior of opening the image read-only for cpfromfs can
cause XFS mount failures, e.g. if log replay is required. The existing
cptofs.sh -t xfs test cases trigger this.

Signed-off-by: David Disseldorp <ddiss@suse.de>
This reverts commit dd6a274. This
remount isn't enough to avoid a dirty journal on unmount. With cpfromfs
now mounting read-write by default, it should be possible to remove this
attempted workaround.
If a clean journal is really needed, then we could consider going down
the fsfreeze path of other utilities such as Dracut.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Ensure that write fails if the image is opened read-only via the new
--ro cptofs/cpfromfs parameter.

Signed-off-by: David Disseldorp <ddiss@suse.de>
@ddiss

ddiss commented Oct 6, 2026

Copy link
Copy Markdown
Author

I found some time to look closer at the XFS test failures. The I/O errors are due to cpfromfs opening the filesystem image O_RDONLY, where XFS log replay write I/O is triggered on mount.
I've resolved this by adding an explicit --ro parameter (similar to lklfuse) and changing cpfromfs the default behavior to open O_RDWR.

ddiss added 2 commits October 7, 2026 23:38
Allow for passing of virtio feature flags.

Signed-off-by: David Disseldorp <ddiss@suse.de>
This ensures that the lkl guest block layer properly tracks the device
as read-only, instead of passing write requests through to host, which
subsequently fail with EBADF.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant