From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BD53D6D1ED for ; Mon, 27 Sep 2021 15:11:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AB3CA21F42 for ; Mon, 27 Sep 2021 15:11:10 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 4233021F32 for ; Mon, 27 Sep 2021 15:11:07 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8843644B0A for ; Mon, 27 Sep 2021 15:07:34 +0200 (CEST) To: pve-devel@lists.proxmox.com References: <20210823143417.2080-1-proxmox8914@herold.me> From: Mira Limbeck Message-ID: Date: Mon, 27 Sep 2021 15:07:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210823143417.2080-1-proxmox8914@herold.me> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-SPAM-LEVEL: Spam detection results: 0 AWL 0.655 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.478 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH v2 qemu-server 1/1] fix #2429: allow to specify cloud-init vendor snippet via cicustom X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Sep 2021 13:11:40 -0000 I tested your patch with a Ubuntu 20.04 cloudimg. Works fine The patch looks good except for three small things. See comments inline. On 8/23/21 4:34 PM, Constantin Herold wrote: > v2 rebase with master > > Any updates on this ? Patch has been available since june > reference: https://lists.proxmox.com/pipermail/pve-devel/2021-June/049025.html This text should not be part of the commit message, please add it below the `---` line. > Example: > qm set 9000 --cicustom "vendor=local:snippets/vendor.yaml" > > cat << 'EOF' > /var/lib/vz/snippets/vendor.yaml > runcmd: > - apt update > - apt install -y qemu-guest-agent > - systemctl start qemu-guest-agent > EOF > > Signed-off-by: Constantin Herold > --- ^ this marks the end of the commit message add text not meant for the commit message here > PVE/QemuServer.pm | 8 ++++++++ > PVE/QemuServer/Cloudinit.pm | 23 ++++++++++++++++++----- > 2 files changed, 26 insertions(+), 5 deletions(-) > > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index cc73af8..54b1ce9 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -713,6 +713,14 @@ my $cicustom_fmt = { > format => 'pve-volume-id', > format_description => 'volume', > }, > + vendor => { > + type => 'string', > + optional => 1, > + description => 'Specify a custom file containing all vendor data passed to the VM via' > + .' cloud-init.', > + format => 'pve-volume-id', > + format_description => 'volume', > + }, > }; > PVE::JSONSchema::register_format('pve-qm-cicustom', $cicustom_fmt); > > diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm > index a5474d3..da776a9 100644 > --- a/PVE/QemuServer/Cloudinit.pm > +++ b/PVE/QemuServer/Cloudinit.pm > @@ -227,7 +227,7 @@ EOF > sub generate_configdrive2 { > my ($conf, $vmid, $drive, $volname, $storeid) = @_; > > - my ($user_data, $network_data, $meta_data) = get_custom_cloudinit_files($conf); > + my ($user_data, $network_data, $meta_data, $vendor_data) = get_custom_cloudinit_files($conf); > $user_data = cloudinit_userdata($conf, $vmid) if !defined($user_data); > $network_data = configdrive2_network($conf) if !defined($network_data); the configdrive2 implementation lacks the 3MiB size check > > @@ -237,7 +237,8 @@ sub generate_configdrive2 { > my $files = { > '/openstack/latest/user_data' => $user_data, > '/openstack/content/0000' => $network_data, > - '/openstack/latest/meta_data.json' => $meta_data > + '/openstack/latest/meta_data.json' => $meta_data, > + '/openstack/latest/vendor_data.json' => $vendor_data > }; > commit_cloudinit_disk($conf, $vmid, $drive, $volname, $storeid, $files, 'config-2'); > } > @@ -493,7 +494,7 @@ sub nocloud_gen_metadata { > sub generate_nocloud { > my ($conf, $vmid, $drive, $volname, $storeid) = @_; > > - my ($user_data, $network_data, $meta_data) = get_custom_cloudinit_files($conf); > + my ($user_data, $network_data, $meta_data, $vendor_data) = get_custom_cloudinit_files($conf); > $user_data = cloudinit_userdata($conf, $vmid) if !defined($user_data); > $network_data = nocloud_network($conf) if !defined($network_data); > > @@ -501,10 +502,16 @@ sub generate_nocloud { > $meta_data = nocloud_gen_metadata($user_data, $network_data); > } > > + # we always allocate a 4MiB disk for cloudinit and with the overhead of the ISO > + # make sure we always stay below it by keeping the sum of all files below 3 MiB > + my $sum = length($user_data) + length($network_data) + length($meta_data) + length($vendor_data); > + die "Cloud-Init sum of snippets too big (> 3 MiB)\n" if $sum > (3 * 1024 * 1024); > + > my $files = { > '/user-data' => $user_data, > '/network-config' => $network_data, > - '/meta-data' => $meta_data > + '/meta-data' => $meta_data, > + '/vendor-data' => $vendor_data > }; > commit_cloudinit_disk($conf, $vmid, $drive, $volname, $storeid, $files, 'cidata'); > } > @@ -518,6 +525,7 @@ sub get_custom_cloudinit_files { > my $network_volid = $files->{network}; > my $user_volid = $files->{user}; > my $meta_volid = $files->{meta}; > + my $vendor_volid = $files->{vendor}; > > my $storage_conf = PVE::Storage::config(); > > @@ -536,7 +544,12 @@ sub get_custom_cloudinit_files { > $meta_data = read_cloudinit_snippets_file($storage_conf, $meta_volid); > } > > - return ($user_data, $network_data, $meta_data); > + my $vendor_data; > + if ($vendor_volid) { > + $vendor_data = read_cloudinit_snippets_file($storage_conf, $vendor_volid); > + } > + trailing whitespace here > + return ($user_data, $network_data, $meta_data, $vendor_data); > } > > sub read_cloudinit_snippets_file {