Skip to content
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

Test access to usb device from a container #20376

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tests/containers/privileged_mode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,23 @@ sub run {
# xen-pv does not define USB passthrough in the xml as of now
# this feature has to be added -> https://progress.opensuse.org/issues/138410
assert_script_run("$runtime run --rm $image bash -c '! test -d /dev/bus'");
assert_script_run("$runtime run --rm --privileged $image ls /dev/bus") unless (is_s390x || is_public_cloud || is_xen_pv || is_hyperv || is_vmware);
assert_script_run("$runtime run --rm --privileged $image ls /dev/bus") unless (is_s390x || is_public_cloud || is_hyperv || is_vmware);

# syscalls availability
if ($runtime eq 'podman') {
script_run("$runtime run --rm -d $image bash -c 'sleep infinity'");
assert_script_run("$runtime top -l seccomp | grep filter");
script_run("$runtime run --rm -d --privileged $image bash -c 'sleep infinity'");
assert_script_run("$runtime top -l seccomp | grep disabled");
}

# Mounting tmpfs only works in privileged mode because the read-only protection in the default mode
assert_script_run("$runtime run --rm --privileged $image mount -t tmpfs none /mnt");

# check how were kernel filesystem mounted
assert_script_run("$runtime run --rm $image mount | grep '\(ro'");
assert_script_run("$runtime run --rm --privileged $image mount | grep '\(rw'");

# Capabilities are only available in privileged mode
my $capbnd = script_output("cat /proc/1/status | grep CapBnd");
validate_script_output("$runtime run --rm --privileged $image cat /proc/1/status | grep CapBnd", sub { m/$capbnd/ });
Expand Down
3 changes: 3 additions & 0 deletions tests/installation/bootloader_svirt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ sub run {
});
}

if ($vmm_family eq 'xen' && $vmm_type eq 'linux') {
$svirt->add_usb_hub();
}
$svirt->add_vnc({port => get_var('VIRSH_INSTANCE', 1) + 5900});

my %ifacecfg = ();
Expand Down
Loading