]> git.proxmox.com Git - qemu-server.git/commitdiff
fix clone_disk failing for nonexistent cloudinit disk
authorMira Limbeck <m.limbeck@proxmox.com>
Mon, 28 Sep 2020 08:36:31 +0000 (10:36 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 16 Oct 2020 13:39:43 +0000 (15:39 +0200)
After migration or a rollback the cloudinit disk might not be allocated, so
volume_size_info() fails. As we override the value anyway for cloudinit
and efi disks simply move the volume_size_info() call into the 'else'
branch.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
PVE/QemuServer.pm

index 1cbdc4108d709d2b14cff92a2dca4eb88de3b215..d6ea95b2745ca5abd502d4e9a0e3215a2e29df32 100644 (file)
@@ -6948,10 +6948,10 @@ sub clone_disk {
        $storeid = $storage if $storage;
 
        my $dst_format = resolve_dst_disk_format($storecfg, $storeid, $volname, $format);
-       my ($size) = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 3);
 
        print "create full clone of drive $drivename ($drive->{file})\n";
        my $name = undef;
+       my $size = undef;
        if (drive_is_cloudinit($drive)) {
            $name = "vm-$newvmid-cloudinit";
            $name .= ".$dst_format" if $dst_format ne 'raw';
@@ -6959,6 +6959,8 @@ sub clone_disk {
            $size = PVE::QemuServer::Cloudinit::CLOUDINIT_DISK_SIZE;
        } elsif ($drivename eq 'efidisk0') {
            $size = get_efivars_size($conf);
+       } else {
+           ($size) = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 3);
        }
        $size /= 1024;
        $newvolid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $newvmid, $dst_format, $name, $size);