[pve-devel] [PATCH Qemu-Server Adapt Cloudbase-init for windows 1/1] Signed-off-by: Austin Chan <sptrsca at gmail.com>
Austin Chan
sptrsca at gmail.com
Thu Apr 11 10:46:33 CEST 2019
On branch cloudbase-init
Changes to be committed:
modified: PVE/API2/Qemu.pm
modified: PVE/QemuServer/Cloudinit.pm
---
PVE/API2/Qemu.pm | 8 ++++++--
PVE/QemuServer/Cloudinit.pm | 13 +++++++++----
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index d8c9726..b1b7191 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1012,10 +1012,14 @@ my $update_vm_api = sub {
my $background_delay = extract_param($param, 'background_delay');
+ my $ostype = PVE::QemuConfig->load_config($vmid)->{ostype};
+
if (defined(my $cipassword = $param->{cipassword})) {
# Same logic as in cloud-init (but with the regex fixed...)
- $param->{cipassword} = PVE::Tools::encrypt_pw($cipassword)
- if $cipassword !~ /^\$(?:[156]|2[ay])(\$.+){2}/;
+ if (!(PVE::QemuServer::windows_version($ostype))) {
+ $param->{cipassword} = PVE::Tools::encrypt_pw($cipassword)
+ if $cipassword !~ /^\$(?:[156]|2[ay])(\$.+){2}/;
+ }
}
my @paramarr = (); # used for log message
diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
index 445c777..4f39a2b 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -43,7 +43,7 @@ sub commit_cloudinit_disk {
my $size = PVE::Storage::file_size_info($iso_path);
eval {
- run_command([['genisoimage', '-R', '-V', $label, $path],
+ run_command([['genisoimage','-iso-level', '3', '-R', '-V', $label, $path],
['qemu-img', 'dd', '-n', '-f', 'raw', '-O', $format,
'isize=0', "osize=$size", "of=$iso_path"]]);
};
@@ -159,11 +159,11 @@ sub configdrive2_network {
my ($searchdomains, $nameservers) = get_dns_conf($conf);
if ($nameservers && @$nameservers) {
$nameservers = join(' ', @$nameservers);
- $content .= " dns_nameservers $nameservers\n";
+ $content .= " dns-nameservers $nameservers\n";
}
if ($searchdomains && @$searchdomains) {
$searchdomains = join(' ', @$searchdomains);
- $content .= " dns_search $searchdomains\n";
+ $content .= " dns-search $searchdomains\n";
}
my @ifaces = grep(/^net(\d+)$/, keys %$conf);
@@ -203,9 +203,14 @@ sub configdrive2_network {
sub configdrive2_metadata {
my ($uuid) = @_;
+ my ($conf, $vmid, $uuid) = @_;
+ my ($hostname, $fqdn) = get_hostname_fqdn($conf, $vmid);
+ my $password = $conf->{cipassword};
return <<"EOF";
{
"uuid": "$uuid",
+ "hostname": "$hostname",
+ "admin_pass": "$password",
"network_config": { "content_path": "/content/0000" }
}
EOF
@@ -222,7 +227,7 @@ sub generate_configdrive2 {
my $digest_data = $user_data . $network_data;
my $uuid_str = Digest::SHA::sha1_hex($digest_data);
- $meta_data = configdrive2_metadata($uuid_str);
+ $meta_data = configdrive2_metadata($conf, $vmid, $uuid_str);
}
my $files = {
'/openstack/latest/user_data' => $user_data,
--
2.15.1
More information about the pve-devel
mailing list