[pve-devel] [PATCH v3 qemu-server 1/2] introduce one global CLOUDINIT_DISK_SIZE constant

Mira Limbeck m.limbeck at proxmox.com
Thu May 16 14:07:00 CEST 2019


The variable is used instead of the literal value so we have one single
place to change the actual value of every use.

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
v3: no changes
v2:
  made CLOUDINIT_DISK_SIZE a constant instead of a variable

 PVE/API2/Qemu.pm            | 4 ++--
 PVE/QemuServer/Cloudinit.pm | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 62e6549..a628a20 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -159,8 +159,8 @@ my $create_disks = sub {
 	    }
 
 	    # Initial disk created with 4 MB and aligned to 4MB on regeneration
-	    my $ci_size = 4 * 1024;
-	    my $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $fmt, $name, $ci_size);
+	    my $ci_size = PVE::QemuServer::Cloudinit::CLOUDINIT_DISK_SIZE;
+	    my $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $fmt, $name, $ci_size/1024);
 	    $disk->{file} = $volid;
 	    $disk->{media} = 'cdrom';
 	    push @$vollist, $volid;
diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
index 0e4bfd5..45176ea 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -11,6 +11,8 @@ use PVE::Tools qw(run_command file_set_contents);
 use PVE::Storage;
 use PVE::QemuServer;
 
+use constant CLOUDINIT_DISK_SIZE => 4 * 1024 * 1024; # 4MiB in bytes
+
 sub commit_cloudinit_disk {
     my ($conf, $vmid, $drive, $volname, $storeid, $files, $label) = @_;
 
-- 
2.11.0





More information about the pve-devel mailing list