Am 20.06.22 um 12:44 schrieb Alexandre Derumier: > Instead using vm pending options for pending cloudinit generated config, > > write current generated cloudinit config in a new [special:cloudinit] SECTION. > > Currently, some options like vm name, nic mac address can be hotplugged, > so they are not way to know if the cloud-init disk is already updated. > > Signed-off-by: Alexandre Derumier <aderum...@odiso.com> > --- > PVE/QemuServer.pm | 20 +++++++++++++++++--- > PVE/QemuServer/Cloudinit.pm | 31 +++++++++++++++++++++++++++++++ > 2 files changed, 48 insertions(+), 3 deletions(-) > > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index b3964bc..9f550d9 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -2504,7 +2511,7 @@ sub write_vm_config { > > foreach my $key (keys %$cref) { > next if $key eq 'digest' || $key eq 'description' || $key eq > 'snapshots' || > - $key eq 'snapstate' || $key eq 'pending'; > + $key eq 'snapstate' || $key eq 'pending' || $key eq 'cloudinit'; > my $value = $cref->{$key}; > if ($key eq 'delete') { > die "propertry 'delete' is only allowed in [PENDING]\n" > @@ -2528,6 +2535,8 @@ sub write_vm_config { > > &$cleanup_config($conf->{pending}, 1); > > + &$cleanup_config($conf->{cloudinit}, 1);
As noted in the review of v4 already: The second parameter should not be 1 here (it's called $pending and used to check if the key 'delete' is allowed). > + > foreach my $snapname (keys %{$conf->{snapshots}}) { > die "internal error: snapshot name '$snapname' is forbidden" if > lc($snapname) eq 'pending'; > &$cleanup_config($conf->{snapshots}->{$snapname}, undef, $snapname); > @@ -2571,6 +2580,11 @@ sub write_vm_config { > $raw .= &$generate_raw_config($conf->{pending}, 1); > } > > + if (scalar(keys %{$conf->{cloudinit}})){ > + $raw .= "\n[special:cloudinit]\n"; > + $raw .= &$generate_raw_config($conf->{cloudinit}, 1); Similar here, setting the second parameter is specific to pending. > + } > + > foreach my $snapname (sort keys %{$conf->{snapshots}}) { > $raw .= "\n[$snapname]\n"; > $raw .= &$generate_raw_config($conf->{snapshots}->{$snapname}); > @@ -5102,9 +5116,9 @@ sub vmconfig_apply_pending { > $conf->{$opt} = delete $conf->{pending}->{$opt}; > } > } > - > # write all changes at once to avoid unnecessary i/o > PVE::QemuConfig->write_config($vmid, $conf); > + Style nit: unrelated and doesn't make it better IMHO. > } > > sub vmconfig_update_net { _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel