xcp icon indicating copy to clipboard operation
xcp copied to clipboard

failing syscalls on virtualbox share filesystem

Open the8472 opened this issue 4 years ago • 2 comments

Copying to a virtualbox filesystem leads to xcp printing an error and not copying the files.

[pid 31325] statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_TYPE|STATX_MODE|STATX_NLINK|STATX_UID|STATX_GID|STATX_MTIME|STATX_CTIME|STATX_INO|STATX_SIZE|STATX_BLOCKS|STATX_BTIME|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0755, stx_size=20701696, ...}) = 0
[pid 31325] openat(AT_FDCWD, "/media/sf_c/temp/test.out", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 4
[pid 31325] ftruncate(4, 20701696)      = 0
[pid 31325] flistxattr(3, NULL, 0)      = -1 EOPNOTSUPP (Operation not supported)

after adding --no-perms

[pid 31423] openat(AT_FDCWD, "/media/sf_c/temp/test.out", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 4
[pid 31423] ftruncate(4, 20701696)      = 0
[pid 31423] statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_TYPE|STATX_MODE|STATX_NLINK|STATX_UID|STATX_GID|STATX_MTIME|STATX_CTIME|STATX_INO|STATX_SIZE|STATX_BLOCKS|STATX_BTIME|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0755, stx_size=20701696, ...}) = 0
[pid 31423] copy_file_range(3, NULL, 4, NULL, 20701696, 0) = -1 EINVAL (Invalid argument)

kernel 5.10.11

the8472 avatar Feb 02 '21 19:02 the8472

Hi @the8472, thanks for the report. I haven't used VB shared volumes before, could you give me some more information about the setup you're using and I'll reproduce locally:

  • OS/version
  • Filesystems used
  • How the shared filesystem is created/mounted.

Thanks, Steve

tarka avatar Feb 04 '21 00:02 tarka

OS: Arch Linux guest system with kernel 5.10.11 and the virtualbox-guest-utils package installed.

Filesystem: vboxsf, which is the 9p-based host-to-guest share mechanism used by virtualbox. Since Linux 5.6 the guest driver for that is in mainline

Setup

  1. host: you can either use the GUI or the VBoxManage CLI to setup a shared folder. In the GUI it's under virtual machine properties -> shared folders. You need to specify some directory which needs to be shared, as writable and give it a label such as foo.
  2. guest mkdir /mnt/bar (root)
  3. guest mount -t vboxsf foo /mnt/bar (root or member of the vboxsf group)
  4. guest xcp /tmp/test.in /mnt/bar/

I think all that's needed to fix this is to treat the syscall error codes in the strace output above as if the calls aren't available. Note that the rust standard library already does automatic fallback to userspace copy if copy_file_range returns EINVAL.

the8472 avatar Feb 04 '21 00:02 the8472