-
Notifications
You must be signed in to change notification settings - Fork 292
CA-393417: Drop device controller of cgroup v1 and fix USB passthrough for XS9 #6572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
For deprivileged qemu, following ops are performed - bind mount /dev/ to qemu chroot, so qemu can access it - cgroup controller deny all devices, except the target usb device However, new XS updated to cgroup v2 and the devices controller available anymore. Instead of bind mount all /dev folder, only the permitted usb devices are created into the chroot. Thus, the cgroup controller is no longer necessary. Besides, there are following updates accordingly - qemu pid is no longer necessary as command line args, as cgroup is dropped. - save and restore system /etc/ devices file ownership is no longer necessary. New file is cloned into chroot instead of bind mount system device file, so only need to set ownership of chroot file directly Signed-off-by: Lin Liu <[email protected]>
From strace/gdb, XS9 qemu requires /proc/self/fd/<fd> to work well
This is due to systemd/libudev update.
Just bind mount /proc/self/ to the chroot to permit qemu access
```
1047 openat(AT_FDCWD, "/proc/self/fd/46", O_RDONLY|O_NOCTTY|O_CLOEXEC|O_PATH) = -1 ENOENT (No such file or directory)
1048 openat(AT_FDCWD, "/proc/", O_RDONLY|O_NOCTTY|O_CLOEXEC|O_PATH) = -1 ENOENT (No such file or directory)
../sysdeps/unix/sysv/linux/fstatfs64.c:30
out>, dir_fd=<optimized out>) at ../src/basic/stat-util.c:566
magic_value=1650812274) at ../src/basic/stat-util.c:369
fd=<optimized out>) at ../src/basic/stat-util.h:66
verify=<optimized out>) at
../src/libsystemd/sd-device/sd-device.c:221
(ret=0x7ffc67ebba20, syspath=0x7ffc67ebb950
"/sys/bus/usb/devices/usb1", strict=true)
at ../src/libsystemd/sd-device/sd-device.c:271
(syspath=0x7ffc67ebb950 "/sys/bus/usb/devices/usb1",
ret=0x7ffc67ebba20)
at ../src/libsystemd/sd-device/sd-device.c:280
```
Signed-off-by: Lin Liu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you need add a new blank line at the end of the file to pass CI.
The CI failed due to coverage rate 😞 , Fixed now. |
7bf4565 to
9c45887
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised all the dance around /dev was needed before, since the vastly simpler approach seems to work
Yes, this is because previously, whole
Now we mount the target device (USB) into chroot only, thus we can drop above ops. |
- Add unitest for usb_reset for coverage - Move mock to unittest.mock as python3 only now - exit -> sys.exit Signed-off-by: Lin Liu <[email protected]>
The approach work for both XS8 and XS9