From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC v3 storage 5/9] ceph/rbd: set 'keyring' in ceph configuration for externally managed RBD storages
Date: Thu, 26 Jun 2025 16:40:19 +0200 [thread overview]
Message-ID: <20250626144644.279679-6-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250626144644.279679-1-f.ebner@proxmox.com>
For QEMU, when using '-blockdev', there is no way to specify the
keyring file like was possible with '-drive', so it has to be set in
the corresponding Ceph configuration file. As it applies to all images
on the storage, it also is the most natural place for the setting.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
New in v3.
This should also be mentioned in the upgrade guide for PVE 9 and
the pve8to9 script should tell the user and/or automatically set it
for existing externally managed RBD storages, that already do have a
custom configuration.
src/PVE/CephConfig.pm | 50 ++++++++++++++++++++++++++++++++++++
src/PVE/Storage/RBDPlugin.pm | 3 +++
2 files changed, 53 insertions(+)
diff --git a/src/PVE/CephConfig.pm b/src/PVE/CephConfig.pm
index 5347781..e5815c4 100644
--- a/src/PVE/CephConfig.pm
+++ b/src/PVE/CephConfig.pm
@@ -3,6 +3,8 @@ package PVE::CephConfig;
use strict;
use warnings;
use Net::IP;
+
+use PVE::RESTEnvironment qw(log_warn);
use PVE::Tools qw(run_command);
use PVE::Cluster qw(cfs_register_file);
@@ -420,6 +422,10 @@ sub ceph_connect_option {
} else {
$cmd_option->{ceph_conf} = "/etc/pve/priv/ceph/${storeid}.conf";
}
+ } elsif (!$pveceph_managed) {
+ # No dedicated config for non-PVE-managed cluster, create new
+ # TODO PVE 10 - remove. All such storages already got a configuration upon creation or here.
+ ceph_create_configuration($scfg->{type}, $storeid);
}
$cmd_option->{keyring} = $keyfile if (-e $keyfile);
@@ -487,6 +493,50 @@ sub ceph_remove_keyfile {
}
}
+sub ceph_create_configuration {
+ my ($type, $storeid) = @_;
+
+ return if $type eq 'cephfs'; # no configuration file needed currently
+
+ my $extension = 'keyring';
+ $extension = 'secret' if $type eq 'cephfs';
+ my $ceph_storage_keyring = "/etc/pve/priv/ceph/${storeid}.$extension";
+
+ return if !-e $ceph_storage_keyring;
+
+ my $ceph_storage_config = "/etc/pve/priv/ceph/${storeid}.conf";
+
+ if (-e $ceph_storage_config) {
+ log_warn(
+ "file $ceph_storage_config already exists, check manually and ensure 'keyring'"
+ . " option is set to '$ceph_storage_keyring'!\n",
+ );
+ return;
+ }
+
+ my $ceph_config = {
+ global => {
+ keyring => $ceph_storage_keyring,
+ },
+ };
+
+ my $contents = PVE::CephConfig::write_ceph_config($ceph_storage_config, $ceph_config);
+ PVE::Tools::file_set_contents($ceph_storage_config, $contents, 0600);
+
+ return;
+}
+
+sub ceph_remove_configuration {
+ my ($storeid) = @_;
+
+ my $ceph_storage_config = "/etc/pve/priv/ceph/${storeid}.conf";
+ if (-f $ceph_storage_config) {
+ unlink $ceph_storage_config or log_warn("removing $ceph_storage_config failed - $!\n");
+ }
+
+ return;
+}
+
my $ceph_version_parser = sub {
my $ceph_version = shift;
# FIXME this is the same as pve-manager PVE::Ceph::Tools get_local_version
diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
index c0bbe2c..3f7ca9f 100644
--- a/src/PVE/Storage/RBDPlugin.pm
+++ b/src/PVE/Storage/RBDPlugin.pm
@@ -448,6 +448,7 @@ sub on_add_hook {
my ($class, $storeid, $scfg, %param) = @_;
PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid, $param{keyring});
+ PVE::CephConfig::ceph_create_configuration($scfg->{type}, $storeid);
return;
}
@@ -469,6 +470,8 @@ sub on_update_hook {
sub on_delete_hook {
my ($class, $storeid, $scfg) = @_;
PVE::CephConfig::ceph_remove_keyfile($scfg->{type}, $storeid);
+ PVE::CephConfig::ceph_remove_configuration($storeid);
+
return;
}
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-06-26 14:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 14:40 [pve-devel] [PATCH-SERIES v3 storage 0/9] storage plugin method to get qemu blockdevice options for volume Fiona Ebner
2025-06-26 14:40 ` [pve-devel] [PATCH v3 storage 1/9] plugin: add " Fiona Ebner
2025-07-01 9:28 ` Thomas Lamprecht
2025-07-01 11:01 ` Fiona Ebner
2025-07-01 11:09 ` Fabian Grünbichler
2025-07-02 8:27 ` Thomas Lamprecht
2025-07-02 8:40 ` Fabian Grünbichler
2025-07-01 11:52 ` Fiona Ebner
2025-07-02 8:12 ` Thomas Lamprecht
2025-07-02 8:32 ` Fiona Ebner
2025-06-26 14:40 ` [pve-devel] [PATCH v3 storage 2/9] iscsi direct plugin: implement method to get qemu blockdevice options Fiona Ebner
2025-06-26 14:40 ` [pve-devel] [PATCH v3 storage 3/9] zfs iscsi plugin: implement new " Fiona Ebner
2025-06-26 14:40 ` [pve-devel] [PATCH v3 storage 4/9] zfs pool plugin: implement " Fiona Ebner
2025-06-30 11:20 ` Fabian Grünbichler
2025-07-01 12:08 ` Fiona Ebner
2025-06-26 14:40 ` Fiona Ebner [this message]
2025-06-26 14:40 ` [pve-devel] [PATCH v3 storage 6/9] rbd plugin: implement new " Fiona Ebner
2025-06-30 11:19 ` Fabian Grünbichler
2025-07-01 12:15 ` Fiona Ebner
2025-06-26 14:40 ` [pve-devel] [RFC v3 storage 7/9] plugin: qemu block device: add hints option and EFI disk hint Fiona Ebner
2025-06-26 14:40 ` [pve-devel] [RFC v3 storage 8/9] plugin: qemu block device: add support for snapshot option Fiona Ebner
2025-06-30 11:40 ` Fabian Grünbichler
2025-07-01 12:23 ` Fiona Ebner
2025-06-26 14:40 ` [pve-devel] [PATCH v3 storage 9/9] plugin api: bump api version and age Fiona Ebner
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=20250626144644.279679-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox