$code->($ct_name, $common_vars, $namespaces, $args);
}
-sub for_current_devices($&) {
- my ($vmid, $code) = @_;
+sub for_devices {
+ my ($devlist_file, $vmid, $code) = @_;
- my $devlist_file = "/var/lib/lxc/$vmid/devices";
my $fd;
if (! open $fd, '<', $devlist_file) {
}
while (defined(my $line = <$fd>)) {
- if ($line !~ m@^(b):(\d+):(\d+):/dev/(\S+)\s*$@) {
- warn "invalid .pve-devices entry: $line\n";
+ if ($line !~ m@^(b|c):(\d+):(\d+):/dev/(\S+)\s*$@) {
+ warn "invalid $devlist_file entry: $line\n";
next;
}
close $fd;
}
+sub for_current_passthrough_mounts($&) {
+ my ($vmid, $code) = @_;
+
+ my $devlist_file = "/var/lib/lxc/$vmid/passthrough/mounts";
+
+ if (-e $devlist_file) {
+ for_devices($devlist_file, $vmid, $code);
+ } else {
+ # Fallback to the old device list file in case a package upgrade
+ # occurs between lxc-pve-prestart-hook and now.
+ for_devices("/var/lib/lxc/$vmid/devices", $vmid, $code);
+ }
+}
+
+sub for_current_passthrough_devices($&) {
+ my ($vmid, $code) = @_;
+
+ my $passthrough_devlist_file = "/var/lib/lxc/$vmid/passthrough/devices";
+ for_devices($passthrough_devlist_file, $vmid, $code);
+}
+
sub cgroup_do_write($$) {
my ($path, $value) = @_;
my $fd;