mirror of
				https://git.proxmox.com/git/qemu-server
				synced 2025-11-04 09:40:34 +00:00 
			
		
		
		
	fix clone_disk with formats other than raw/qcow2
with commit 64d1a6a it's now possible to specify a format other than raw
or qcow2 when creating VMs. This can lead to an error when cloning the
VMs and a cloudinit disk with a different format is attached (e.g.
vmdk).
We use QEMU_FORMAT_RE in drive_is_cloudinit and according to the
QEMU_FORMAT_RE we support 7 different formats.
With this change we add any format other than 'raw' as '.<format>' to the
name and no longer die on any other format. Cloudinit disks with invalid
format are not cloned as the drive is recognized as cdrom, not cloudinit.
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
			
			
This commit is contained in:
		
							parent
							
								
									5cda6c69e3
								
							
						
					
					
						commit
						e1afab6e28
					
				@ -6925,11 +6925,11 @@ sub clone_disk {
 | 
			
		||||
	if (drive_is_cloudinit($drive)) {
 | 
			
		||||
	    $name = "vm-$newvmid-cloudinit";
 | 
			
		||||
	    $snapname = undef;
 | 
			
		||||
	    # cloudinit only supports raw and qcow2 atm:
 | 
			
		||||
	    if ($dst_format eq 'qcow2') {
 | 
			
		||||
		$name .= '.qcow2';
 | 
			
		||||
	    } elsif ($dst_format ne 'raw') {
 | 
			
		||||
		die "clone: unhandled format for cloudinit image\n";
 | 
			
		||||
	    # accept any format when cloning that's supported by QEMU_FORMAT_RE
 | 
			
		||||
	    # if it is not supported by QEMU_FORMAT_RE we do not reach here as
 | 
			
		||||
	    # it is recognized as cdrom, not cloudinit
 | 
			
		||||
	    if ($dst_format ne 'raw') {
 | 
			
		||||
		$name .= ".$dst_format";
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
	$newvolid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $newvmid, $dst_format, $name, ($size/1024));
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user