From: Fabian Ebner <f.ebner@proxmox.com>
To: Aaron Lauterer <a.lauterer@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [RFC storage 1/7] storage: expose find_free_diskname
Date: Mon, 5 Jul 2021 09:58:46 +0200 [thread overview]
Message-ID: <b71382f6-ddf2-0c84-3e22-23b0ad4d46d1@proxmox.com> (raw)
In-Reply-To: <7bc5f848-8891-0b1f-39c1-4eab330907cd@proxmox.com>
Am 02.07.21 um 15:38 schrieb Aaron Lauterer:
>
>
> On 6/2/21 10:29 AM, Fabian Ebner wrote:
>> Am 01.06.21 um 18:10 schrieb Aaron Lauterer:
>>> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
>>> ---
>>> PVE/Storage.pm | 8 ++++++++
>>> 1 file changed, 8 insertions(+)
>>>
>>> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
>>> index aa36bad..93d09ce 100755
>>> --- a/PVE/Storage.pm
>>> +++ b/PVE/Storage.pm
>>> @@ -201,6 +201,14 @@ sub storage_can_replicate {
>>> return $plugin->storage_can_replicate($scfg, $storeid, $format);
>>> }
>>> +sub find_free_diskname {
>>> + my ($cfg, $storeid, $vmid, $fmt, $add_fmt_suffix) = @_;
>>
>> Nit: Ideally, the $add_fmt_suffix should be decided by the plugin, as
>> an outside caller cannot know what a plugin wants/expects. Don't know
>> if that's easy to do the way things are though.
>
> Yeah, I am not sure how to handle that... most of our storage plugins
> don't use it at all (ZFS, RBD, LVM). That leaves the Plugin.pm (storage
> based) and potential 3rd party plugins that have their own implementation.
> Depending on where you would use the now public `find_free_diskname`, it
> could be possible to know the format and if the suffix should already be
> added. For the move-disk to other guest (disk reassign) stuff I cannot
> do that and leave it undefined.
>
The problem is that half of the plugins will quietly ignore the
parameter and the other half (dir based plugins) will return a disk name
they cannot even handle when add_fmt_suffix=0. I'd rather avoid such a
surprising interface.
The same criticism applies to the plugin's interface, but at least there
the calls come from the plugins themselves, which know what they need/want.
Two potential solutions:
1) Remove the add_fmt_suffix parameter from the plugin's
find_free_diskname and either:
a) add custom implementations to the non-dir-based plugins, never adding
the suffix.
b) adapt the generic implementation to add the suffix depending on
whether $scfg->{path} is present or not.
2) Add a new function to the plugin interface, returning whether the
plugin expects a suffix to be added or not, and use that in this patch's
proposed find_free_diskname.
IMHO 1) is much cleaner, but also a breaking change to the plugin API.
But currently APIAGE is 0, so it wouldn't be as bad.
> In the Plugin.pm implementation of `rename_volume` I added a check if a
> suffix is present, and if not, take the one from the source volume.
> Thinking about it, I might even strip any potential suffixes and always
> use the one from the source as that should be kept since the file format
> probably should not change with a rename.
>
>>
>>> +
>>> + my $scfg = storage_config($cfg, $storeid);
>>> + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
>>> + return $plugin->find_free_diskname($storeid, $scfg, $vmid, $fmt,
>>> $add_fmt_suffix);
>>> +}
>>> +
>>> sub storage_ids {
>>> my ($cfg) = @_;
>>>
next prev parent reply other threads:[~2021-07-05 7:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-01 16:10 [pve-devel] [RFC series 0/7] move disk or volume to other guests Aaron Lauterer
2021-06-01 16:10 ` [pve-devel] [RFC storage 1/7] storage: expose find_free_diskname Aaron Lauterer
2021-06-02 8:29 ` Fabian Ebner
2021-07-02 13:38 ` Aaron Lauterer
2021-07-05 7:58 ` Fabian Ebner [this message]
2021-06-01 16:10 ` [pve-devel] [RFC storage 2/7] add disk rename feature Aaron Lauterer
2021-06-02 8:36 ` Fabian Ebner
2021-06-09 14:20 ` Aaron Lauterer
2021-06-01 16:10 ` [pve-devel] [RFC qemu-server 3/7] cli: qm: change move_disk to move-disk Aaron Lauterer
2021-06-01 16:10 ` [pve-devel] [RFC qemu-server 4/7] Drive: add valid_drive_names_with_unused Aaron Lauterer
2021-06-01 16:10 ` [pve-devel] [RFC qemu-server 5/7] api: move-disk: add move to other VM Aaron Lauterer
2021-06-02 8:52 ` Fabian Ebner
2021-06-01 16:10 ` [pve-devel] [PATCH container 6/7] cli: pct: change move_volume to move-volume Aaron Lauterer
2021-06-01 16:10 ` [pve-devel] [PATCH container 7/7] api: move-volume: add move to another container Aaron Lauterer
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=b71382f6-ddf2-0c84-3e22-23b0ad4d46d1@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=a.lauterer@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal