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

Mira Limbeck m.limbeck at proxmox.com
Wed Sep 25 17:35:18 CEST 2019


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')) {
 	    # nothing to check
-	} elsif ($volid =~ m/^(([^:\s]+):)?(cloudinit)$/) {
+	} elsif (PVE::QemuServer::drive_is_cloudinit($drive)) {
 	    # 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$!;
 }
 
 sub drive_is_cdrom {
-- 
2.20.1





More information about the pve-devel mailing list