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

"only root can set 'hostpci1' config for non-mapped devices" in PVE8 despite patches for #3829 #38

Open
btravouillon opened this issue Mar 27, 2024 · 0 comments
Assignees

Comments

@btravouillon
Copy link
Contributor

Looks like the code changed in PVE 8. While custom patch for #3829 are applied, trying to create VMs with a token for root@pam fails with :

    "msg": "creation of qemu VM gpulab2 with vmid 1022 failed with exception=500 Internal Server Error: only root can set 'hostpci1' config for non-mapped devices",

Workaround: update the function below and restart pvedaemon.service on the hosts.

my sub check_hostpci_perm {
    my ($rpcenv, $authuser, $vmid, $pool, $opt, $value) = @_;

    return 1 if (substr($authuser, 0, 8)) eq 'root@pam';

    my $device = PVE::JSONSchema::parse_property_string('pve-qm-hostpci', $value);
    if ($device->{host}) {
        die "only root can set '$opt' config for non-mapped devices\n";
    } elsif ($device->{mapping}) {
        $rpcenv->check_full($authuser, "/mapping/pci/$device->{mapping}", ['Mapping.Use']);
        $rpcenv->check_vm_perm($authuser, $vmid, $pool, ['VM.Config.HWType']);
    } else {
        die "either 'host' or 'mapping' must be set.\n";
    }

    return 1;
}
@btravouillon btravouillon self-assigned this Mar 27, 2024
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

No branches or pull requests

1 participant