description => "Select BIOS implementation.",
default => 'seabios',
},
+};
+
+my $confdesc_cloudinit = {
searchdomain => {
optional => 1,
type => 'string',
for (my $i = 0; $i < $MAX_NETS; $i++) {
$confdesc->{"net$i"} = $netdesc;
- $confdesc->{"ipconfig$i"} = $ipconfigdesc;
+ $confdesc_cloudinit->{"ipconfig$i"} = $ipconfigdesc;
+}
+
+foreach my $key (keys %$confdesc_cloudinit) {
+ $confdesc->{$key} = $confdesc_cloudinit->{$key};
}
PVE::JSONSchema::register_format('pve-volume-id-or-qm-path', \&verify_volume_id_or_qm_path);
return "$cpu-x86_64-cpu,id=cpu$id,socket-id=$current_socket,core-id=$current_core,thread-id=0";
}
+sub drive_is_cloudinit {
+ my ($drive) = @_;
+ return $drive->{file} =~ m@[:/]vm-\d+-cloudinit(?:\.$QEMU_FORMAT_RE)?$@;
+}
+
sub drive_is_cdrom {
my ($drive, $exclude_cloudinit) = @_;
- return 0 if $exclude_cloudinit && $drive->{file} =~ m@[:/]vm-\d+-cloudinit(?:\.$QEMU_FORMAT_RE)?$@;
+ return 0 if $exclude_cloudinit && drive_is_cloudinit($drive);
return $drive && $drive->{media} && ($drive->{media} eq 'cdrom');
}
}
+ my $apply_pending_cloudinit;
+ $apply_pending_cloudinit = sub {
+ my ($key, $value) = @_;
+ $apply_pending_cloudinit = sub {}; # once is enough
+
+ my @cloudinit_opts = keys %$confdesc_cloudinit;
+ foreach my $opt (keys %{$conf->{pending}}) {
+ next if !grep { $_ eq $opt } @cloudinit_opts;
+ $conf->{$opt} = delete $conf->{pending}->{$opt};
+ }
+
+ my $new_conf = { %$conf };
+ $new_conf->{$key} = $value;
+ PVE::QemuServer::Cloudinit::generate_cloudinitconfig($new_conf, $vmid);
+ };
+
foreach my $opt (keys %{$conf->{pending}}) {
next if $selection && !$selection->{$opt};
my $value = $conf->{pending}->{$opt};
$vmid, $opt, $value);
} elsif (is_valid_drivename($opt)) {
# some changes can be done without hotplug
+ my $drive = parse_drive($opt, $value);
+ if (drive_is_cloudinit($drive)) {
+ &$apply_pending_cloudinit($opt, $value);
+ }
vmconfig_update_disk($storecfg, $conf, $hotplug_features->{disk},
$vmid, $opt, $value, 1);
} elsif ($opt =~ m/^memory$/) { #dimms