use same verification than lxc also rename sshkey param to sshkeys (as we can define multiple ssh keys)
Signed-off-by: Alexandre Derumier <aderum...@odiso.com> --- PVE/API2/Qemu.pm | 7 +++++++ PVE/QemuServer.pm | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 895e048..9750b4a 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -472,6 +472,9 @@ __PACKAGE__->register_method({ my $storecfg = PVE::Storage::config(); + my $ssh_keys = extract_param($param, 'sshkeys'); + PVE::Tools::validate_ssh_public_keys($ssh_keys) if defined($ssh_keys); + PVE::Cluster::check_cfs_quorum(); if (defined($pool)) { @@ -933,6 +936,7 @@ my $update_vm_api = sub { my $background_delay = extract_param($param, 'background_delay'); + my @paramarr = (); # used for log message foreach my $key (keys %$param) { push @paramarr, "-$key", $param->{$key}; @@ -948,6 +952,9 @@ my $update_vm_api = sub { my $force = extract_param($param, 'force'); + my $ssh_keys = extract_param($param, 'sshkeys'); + PVE::Tools::validate_ssh_public_keys($ssh_keys) if defined($ssh_keys); + die "no options specified\n" if !$delete_str && !$revert_str && !scalar(keys %$param); my $storecfg = PVE::Storage::config(); diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 6aa0128..e844962 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -519,11 +519,11 @@ my $confdesc_cloudinit = { type => 'string', format => 'address-list', description => "cloud-init: Sets DNS server IP address for a container. Create will automatically use the setting from the host if neither searchdomain nor nameserver are set.", }, - sshkey => { + sshkeys => { optional => 1, - type => 'string', format => 'urlencoded', - maxLength => 1024, - description => "cloud-init: ssh keys for root", + type => 'string', + description => "cloud-init : Setup public SSH keys (one key per line, " . + "OpenSSH format).", }, hostname => { optional => 1, @@ -6738,7 +6738,7 @@ sub generate_cloudinit_userdata { $content .= " - ifdown -a\n"; $content .= " - ifup -a\n"; - my $keys = $conf->{sshkey}; + my $keys = $conf->{sshkeys}; if ($keys) { $keys = URI::Escape::uri_unescape($keys); $keys = [map { chomp $_; $_ } split(/\n/, $keys)]; -- 2.11.0 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel