From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v3 manager 1/4] vzdump: storage info: move out activate storage call
Date: Thu, 11 Mar 2021 10:22:05 +0100 [thread overview]
Message-ID: <20210311092208.27221-1-f.ebner@proxmox.com> (raw)
Otherwise storage_info() cannot be used for (at least) PBS storages from an API
call without 'protected => 1', because the password cannot be read from
'/etc/pve/priv'. Note that the function itself does not need the storage to be
active, because it only uses storage_config() and get_backup_dir().
AFAICT new() is the only existing user of this function and can be responsible
for activating the storage itself.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
New in v3
PVE/VZDump.pm | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 02858d8e..fb4c8bad 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -106,8 +106,6 @@ sub storage_info {
die "can't use storage '$storage' for backups - wrong content type\n"
if (!$scfg->{content}->{backup});
- PVE::Storage::activate_storage($cfg, $storage);
-
my $info = {
scfg => $scfg,
};
@@ -505,6 +503,13 @@ sub new {
my $errors = '';
if ($opts->{storage}) {
+ my $storage_cfg = PVE::Storage::config();
+ eval { PVE::Storage::activate_storage($storage_cfg, $opts->{storage}) };
+ if (my $err = $@) {
+ chomp($err);
+ $errors .= "could not activate storage '$opts->{storage}': $err";
+ }
+
my $info = eval { storage_info ($opts->{storage}) };
if (my $err = $@) {
chomp($err);
--
2.20.1
next reply other threads:[~2021-03-11 9:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 9:22 Fabian Ebner [this message]
2021-03-11 9:22 ` [pve-devel] [PATCH v3 manager 2/4] api: vzdump: add call to get currently configured vzdump defaults Fabian Ebner
2021-04-01 13:40 ` Thomas Lamprecht
2021-04-02 12:27 ` Fabian Ebner
2021-04-02 12:58 ` Thomas Lamprecht
2021-03-11 9:22 ` [pve-devel] [PATCH v3 manager 3/4] ui: backup: fill in some of the " Fabian Ebner
2021-03-11 9:22 ` [pve-devel] [PATCH v3 manager 4/4] fix #2745: ui: backup: allow specifying remove parameter for manual backup Fabian Ebner
2021-04-01 13:25 ` [pve-devel] applied: [PATCH v3 manager 1/4] vzdump: storage info: move out activate storage call Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210311092208.27221-1-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.