]> git.proxmox.com Git - qemu-server.git/commitdiff
clone: pre-create cloud-init disk for destination
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 19 Nov 2019 08:25:54 +0000 (09:25 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 19 Nov 2019 09:29:58 +0000 (10:29 +0100)
While we may not want to copy the cloudinit disk/drive, we still need
to create+allocate the volume, else the next start complains about a
missing CI drive..

fixes commit 7d6c99f0a0026ce07fa0eb858db7b6b7756ae021.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Qemu.pm
PVE/QemuServer.pm

index a04ff219c6c91118259842718ea852dd7b8b6c26..8fcd3ab04f2b95242510e9e03b64d1757c62c1f2 100644 (file)
@@ -2801,10 +2801,10 @@ __PACKAGE__->register_method({
                } elsif (PVE::QemuServer::is_valid_drivename($opt)) {
                    my $drive = PVE::QemuServer::parse_drive($opt, $value);
                    die "unable to parse drive options for '$opt'\n" if !$drive;
-                   if (PVE::QemuServer::drive_is_cdrom($drive)) {
+                   if (PVE::QemuServer::drive_is_cdrom($drive, 1)) {
                        $newconf->{$opt} = $value; # simply copy configuration
                    } else {
-                       if ($full) {
+                       if ($full || PVE::QemuServer::drive_is_cloudinit($drive)) {
                            die "Full clone feature is not supported for drive '$opt'\n"
                                if !PVE::Storage::volume_has_feature($storecfg, 'copy', $drive->{file}, $snapname, $running);
                            $fullclone->{$opt} = 1;
index d661afe5cd666506c8e4644b7f7a110a8abc3a39..11e716967084ce6617aba850bf556d674cabf3a6 100644 (file)
@@ -7108,11 +7108,21 @@ sub clone_disk {
 
        print "create full clone of drive $drivename ($drive->{file})\n";
        my $name = undef;
+       if (drive_is_cloudinit($drive)) {
+           $name = "vm-$newvmid-cloudinit";
+           $name .= ".$dst_format" if $dst_format ne 'raw';
+           $snapname = undef;
+           $size = PVE::QemuServer::Cloudinit::CLOUDINIT_DISK_SIZE;
+       }
        $newvolid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $newvmid, $dst_format, $name, ($size/1024));
        push @$newvollist, $newvolid;
 
        PVE::Storage::activate_volumes($storecfg, [$newvolid]);
 
+       if (drive_is_cloudinit($drive)) {
+           goto no_data_clone;
+       }
+
        my $sparseinit = PVE::Storage::volume_has_feature($storecfg, 'sparseinit', $newvolid);
        if (!$running || $snapname) {
            # TODO: handle bwlimits
@@ -7129,6 +7139,7 @@ sub clone_disk {
        }
     }
 
+no_data_clone:
     my ($size) = PVE::Storage::volume_size_info($storecfg, $newvolid, 3);
 
     my $disk = $drive;