[pve-devel] [PATCH qemu-server] fix #2344: allow '<storeid>:cloudinit' in drive_is_cloudinit

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Sep 25 18:10:33 CEST 2019


On 9/25/19 5:35 PM, Mira Limbeck wrote:
> Allow 'cloudinit' and '<storeid>:cloudinit' in drive_is_cloudinit so
> cloudinit disks are recognized by drive_is_cdrom even if they have not
> been renamed to 'vm-<vmid>-cloudinit' yet.
> This fixes the check_replication sub not recognizing the cloudinit disk
> when regenerating the cloudinit image or adding a new cloudinit disk and
> a replication job exists. Without the early return if its a cloudinit
> disk it dies in parse_volname.
> 
> Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
> ---
>  PVE/API2/Qemu.pm  | 2 +-
>  PVE/QemuServer.pm | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 1e8d350..d78a2ab 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -67,7 +67,7 @@ my $check_storage_access = sub {
>  
>  	if (!$volid || ($volid eq 'none' || $volid eq 'cloudinit')) {

isn't this check from context already handling the "<sid>:cloudinit" case??

>  	    # nothing to check
> -	} elsif ($volid =~ m/^(([^:\s]+):)?(cloudinit)$/) {
> +	} elsif (PVE::QemuServer::drive_is_cloudinit($drive)) {

can be still ok to change

>  	    # nothing to check
>  	} elsif ($isCDROM && ($volid eq 'cdrom')) {
>  	    $rpcenv->check($authuser, "/", ['Sys.Console']);
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index ad6902f..4d6ddc8 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -2207,7 +2207,8 @@ sub print_vga_device {
>  
>  sub drive_is_cloudinit {
>      my ($drive) = @_;
> -    return $drive->{file} =~ m@[:/]vm-\d+-cloudinit(?:\.$QEMU_FORMAT_RE)?$@;
> +    return $drive->{file} =~ m@[:/]vm-\d+-cloudinit(?:\.$QEMU_FORMAT_RE)?$@
> +	|| $drive->{file} =~ m!^(?:[^/:\s]+:)?cloudinit$!;

but this is not required, as a drive can only be like this if it gets
created?

Or are there other call-sites, not listed here, which would profit from this?

>  }
>  
>  sub drive_is_cdrom {
> 





More information about the pve-devel mailing list