[pve-devel] [PATCH v3 qemu-server 1/7] cloudinit: add vm config to cloudinit drive
Alexandre Derumier
aderumier at odiso.com
Wed Jun 9 13:54:11 CEST 2021
To have current running cloudinit config.
An improvement could be to implement parsing of config drive format,
and also compare cicustom snippets content
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuServer/Cloudinit.pm | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
index a5474d3..abc62b7 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -19,6 +19,7 @@ sub commit_cloudinit_disk {
my $path = "/run/pve/cloudinit/$vmid/";
mkpath $path;
+
foreach my $filepath (keys %$files) {
if ($filepath !~ m@^(.*)\/[^/]+$@) {
die "internal error: bad file name in cloud-init image: $filepath\n";
@@ -30,6 +31,15 @@ sub commit_cloudinit_disk {
file_set_contents("$path/$filepath", $contents);
}
+ mkpath "$path/proxmox";
+ my $confcontent = "";
+ foreach my $opt (keys %$conf) {
+ next if $opt =~ m/^(pending|snapshots|digest)$/;
+ $confcontent .= "$opt: $conf->{$opt}\n";
+ }
+
+ file_set_contents("$path/proxmox/vmconf", $confcontent);
+
my $storecfg = PVE::Storage::config();
my $iso_path = PVE::Storage::path($storecfg, $drive->{file});
my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
--
2.20.1
More information about the pve-devel
mailing list