From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 7B7EBB8A3D for ; Wed, 6 Dec 2023 08:48:05 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 646603570A for ; Wed, 6 Dec 2023 08:48:05 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 6 Dec 2023 08:48:04 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9422942295 for ; Wed, 6 Dec 2023 08:48:04 +0100 (CET) From: Hannes Duerr To: pve-devel@lists.proxmox.com Date: Wed, 6 Dec 2023 08:47:43 +0100 Message-Id: <20231206074745.18832-3-h.duerr@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231206074745.18832-1-h.duerr@proxmox.com> References: <20231206074745.18832-1-h.duerr@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.001 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v6 qemu-server 2/4] Move NEW_DISK_RE to QemuServer/Drive.pm X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Dec 2023 07:48:05 -0000 Prepare for introduction of new helper Signed-off-by: Hannes Duerr --- PVE/API2/Qemu.pm | 10 ++++------ PVE/QemuServer/Drive.pm | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index f26adf5..9e3cfb5 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -86,8 +86,6 @@ my $foreach_volume_with_alloc = sub { } }; -my $NEW_DISK_RE = qr!^(([^/:\s]+):)?(\d+(\.\d+)?)$!; - my $check_drive_param = sub { my ($param, $storecfg, $extra_checks) = @_; @@ -98,7 +96,7 @@ my $check_drive_param = sub { raise_param_exc({ $opt => "unable to parse drive options" }) if !$drive; if ($drive->{'import-from'}) { - if ($drive->{file} !~ $NEW_DISK_RE || $3 != 0) { + if ($drive->{file} !~ $PVE::QemuServer::Drive::NEW_DISK_RE || $3 != 0) { raise_param_exc({ $opt => "'import-from' requires special syntax - ". "use :0,import-from=", @@ -142,7 +140,7 @@ my $check_storage_access = sub { # nothing to check } elsif ($isCDROM && ($volid eq 'cdrom')) { $rpcenv->check($authuser, "/", ['Sys.Console']); - } elsif (!$isCDROM && ($volid =~ $NEW_DISK_RE)) { + } elsif (!$isCDROM && ($volid =~ $PVE::QemuServer::Drive::NEW_DISK_RE)) { my ($storeid, $size) = ($2 || $default_storage, $3); die "no storage ID specified (and no default storage)\n" if !$storeid; $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']); @@ -365,7 +363,7 @@ my $create_disks = sub { delete $disk->{format}; # no longer needed $res->{$ds} = PVE::QemuServer::print_drive($disk); print "$ds: successfully created disk '$res->{$ds}'\n"; - } elsif ($volid =~ $NEW_DISK_RE) { + } elsif ($volid =~ $PVE::QemuServer::Drive::NEW_DISK_RE) { my ($storeid, $size) = ($2 || $default_storage, $3); die "no storage ID specified (and no default storage)\n" if !$storeid; @@ -1633,7 +1631,7 @@ my $update_vm_api = sub { return if defined($volname) && $volname eq 'cloudinit'; my $format; - if ($volid =~ $NEW_DISK_RE) { + if ($volid =~ $PVE::QemuServer::Drive::NEW_DISK_RE) { $storeid = $2; $format = $drive->{format} || PVE::Storage::storage_default_format($storecfg, $storeid); } else { diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm index f3fbaaa..3a27a6e 100644 --- a/PVE/QemuServer/Drive.pm +++ b/PVE/QemuServer/Drive.pm @@ -36,6 +36,7 @@ my $MAX_SCSI_DISKS = 31; my $MAX_VIRTIO_DISKS = 16; our $MAX_SATA_DISKS = 6; our $MAX_UNUSED_DISKS = 256; +our $NEW_DISK_RE = qr!^(([^/:\s]+):)?(\d+(\.\d+)?)$!; our $drivedesc_hash; # Schema when disk allocation is possible. -- 2.39.2