[pve-devel] applied: [PATCH qemu-server] fix clone_disk with formats other than raw/qcow2

Thomas Lamprecht t.lamprecht at proxmox.com
Fri May 17 12:15:16 CEST 2019


On 5/16/19 3:08 PM, Mira Limbeck wrote:
> 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 at proxmox.com>

applied, but not happy, CI should not be mirrored backuped, ... saved in
anyway in our case, the state is in the config, it gets generated on start
and prob. should be deleted on stop, and that could be even done in memory
... but not your fault, so much thanks for fixing stuff here in this brittle
construction side, appreciated...

> ---
>  PVE/QemuServer.pm | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 9d560ec..d6e065e 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -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));
> 





More information about the pve-devel mailing list