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 8006C737AB for ; Fri, 18 Jun 2021 12:59:45 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5D75B26B95 for ; Fri, 18 Jun 2021 12:59:45 +0200 (CEST) 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 id D56F626B2F for ; Fri, 18 Jun 2021 12:59:42 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AF380441D9 for ; Fri, 18 Jun 2021 12:59:42 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 18 Jun 2021 12:59:33 +0200 Message-Id: <20210618105938.57107-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210618105938.57107-1-f.ebner@proxmox.com> References: <20210618105938.57107-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.728 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemuserver.pm, qemu.pm, qemumigrate.pm] Subject: [pve-devel] [PATCH qemu-server 1/2] prefer storage_check_enabled over storage_check_node 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: Fri, 18 Jun 2021 10:59:45 -0000 storage_check_enabled simply checks for the 'disable' option and then calls storage_check_node. While not strictly necessary for a second call where only the storage differs, e.g. in case of clone, it is more future-proof: if support for a target storage is added at some point, it might be easy to miss adapting the call. For the migration checks, the situation is improved by now always catching disabled (target) storages. Signed-off-by: Fabian Ebner --- PVE/API2/Qemu.pm | 4 ++-- PVE/QemuMigrate.pm | 10 +++++----- PVE/QemuServer.pm | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index bc313f9..eeb07d1 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -3024,7 +3024,7 @@ __PACKAGE__->register_method({ PVE::Storage::storage_check_enabled($storecfg, $storage); if ($target) { # check if storage is available on target node - PVE::Storage::storage_check_node($storecfg, $storage, $target); + PVE::Storage::storage_check_enabled($storecfg, $storage, $target); # clone only works if target storage is shared my $scfg = PVE::Storage::storage_config($storecfg, $storage); die "can't clone to non-shared storage '$storage'\n" if !$scfg->{shared}; @@ -3687,7 +3687,7 @@ __PACKAGE__->register_method({ if (my $targetstorage = $param->{targetstorage}) { my $check_storage = sub { my ($target_sid) = @_; - PVE::Storage::storage_check_node($storecfg, $target_sid, $target); + PVE::Storage::storage_check_enabled($storecfg, $target_sid, $target); $rpcenv->check($authuser, "/storage/$target_sid", ['Datastore.AllocateSpace']); my $scfg = PVE::Storage::storage_config($storecfg, $target_sid); raise_param_exc({ targetstorage => "storage '$target_sid' does not support vm images"}) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 6375a15..2576196 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -340,8 +340,8 @@ sub prepare { # check if storage is available on both nodes my $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $sid); - my $scfg = PVE::Storage::storage_check_node($self->{storecfg}, $sid); - PVE::Storage::storage_check_node($self->{storecfg}, $targetsid, $self->{node}); + my $scfg = PVE::Storage::storage_check_enabled($self->{storecfg}, $sid); + PVE::Storage::storage_check_enabled($self->{storecfg}, $targetsid, $self->{node}); if ($scfg->{shared}) { # PVE::Storage::activate_storage checks this for non-shared storages @@ -402,7 +402,7 @@ sub scan_local_volumes { my $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $storeid); # check if storage is available on target node - PVE::Storage::storage_check_node($storecfg, $targetsid, $self->{node}); + PVE::Storage::storage_check_enabled($storecfg, $targetsid, $self->{node}); # grandfather in existing mismatches if ($targetsid ne $storeid) { @@ -467,8 +467,8 @@ sub scan_local_volumes { my $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $sid); # check if storage is available on both nodes - my $scfg = PVE::Storage::storage_check_node($storecfg, $sid); - PVE::Storage::storage_check_node($storecfg, $targetsid, $self->{node}); + my $scfg = PVE::Storage::storage_check_enabled($storecfg, $sid); + PVE::Storage::storage_check_enabled($storecfg, $targetsid, $self->{node}); return if $scfg->{shared}; diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 6d9cf2d..bd00af3 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2456,8 +2456,8 @@ sub check_storage_availability { return if !$sid; # check if storage is available on both nodes - my $scfg = PVE::Storage::storage_check_node($storecfg, $sid); - PVE::Storage::storage_check_node($storecfg, $sid, $node); + my $scfg = PVE::Storage::storage_check_enabled($storecfg, $sid); + PVE::Storage::storage_check_enabled($storecfg, $sid, $node); }); } -- 2.30.2