From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 53F131FF15C for <inbox@lore.proxmox.com>; Wed, 26 Mar 2025 15:21:52 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F036D3941B; Wed, 26 Mar 2025 15:21:45 +0100 (CET) From: Max Carrara <m.carrara@proxmox.com> To: pve-devel@lists.proxmox.com Date: Wed, 26 Mar 2025 15:20:57 +0100 Message-Id: <20250326142059.261938-7-m.carrara@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250326142059.261938-1-m.carrara@proxmox.com> References: <20250326142059.261938-1-m.carrara@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.074 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 Subject: [pve-devel] [PATCH v1 pve-storage 6/8] pluginbase: document image operation methods X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Add documentation for the following methods: - list_images - create_base - clone_image - alloc_image - free_image Signed-off-by: Max Carrara <m.carrara@proxmox.com> Co-authored-by: Maximiliano Sandoval <m.sandoval@proxmox.com> --- src/PVE/Storage/PluginBase.pm | 111 ++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/src/PVE/Storage/PluginBase.pm b/src/PVE/Storage/PluginBase.pm index b3ce684..37b1471 100644 --- a/src/PVE/Storage/PluginBase.pm +++ b/src/PVE/Storage/PluginBase.pm @@ -721,26 +721,137 @@ sub on_delete_hook { =cut +=head3 $plugin->list_images($storeid, \%scfg [, $vmid, \@vollist, \%cache]) + +B<REQUIRED:> Must be implemented in every storage plugin. + +Returns a listref of all disk images of a storage. If the storage does not +support storing disk images, returns an empty listref. + +Optionally, if C<\@vollist> is provided, return only disks whose volume ID is +within C<\@vollist>. Note that this usually has higher precedence than +C<$vmid>. + +C<die>s in case of errors. + +This method may reuse L<< cached information via C<\%cache>|/"CACHING EXPENSIVE OPERATIONS" >>. + +The returned listref has the following structure: + + [ + { + ctime => "1689163322", # creation time as unix timestamp + format => "raw", + size => 8589934592, # in bytes! + vmid => 101, + volid => "local-lvm:base-101-disk-0", # volume ID, storage-specific + }, + # [...] + ] + +=cut + sub list_images { my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_; croak "implement me in sub-class\n"; } +=head3 $plugin->create_base($storeid, \%scfg, $volname) + +B<OPTIONAL:> May be implemented in a storage plugin. + +Creates a base volume from an existing volume, allowing the volume to be +L<< cloned|/"$plugin->clone_image(...)" >>. This cloned volume (usually +a disk image) may then be used as a base for the purpose of creating linked +clones. See L<C<PVE::Storage::LvmThinPlugin>> and +L<C<PVE::Storage::ZFSPoolPlugin>> for example implementations. + +On completion, returns the name of the new base volume (the new C<$volname>). + +This method is called in the context of C<L<< cluster_lock_storage()|/"cluster_lock_storage(...)" >>>, +i.e. when the storage is B<locked>. + +=cut + sub create_base { my ($class, $storeid, $scfg, $volname) = @_; croak "implement me in sub-class\n"; } +=head3 $plugin->clone_image($scfg, $storeid, $volname, $vmid [, $snap]) + +=head3 $plugin->clone_image(...) + +B<REQUIRED:> Must be implemented in every storage plugin. + +Clones a disk image or a snapshot of an image, returning the name of the new +image (the new C<$volname>). Note that I<cloning> here means to create a linked +clone and not duplicating an image. See L<C<PVE::Storage::LvmThinPlugin>> and +L<C<PVE::Storage::ZFSPoolPlugin>> for example implementations. + +C<die>s in case of an error of if the underlying storage doesn't support +cloning images. + +This method is called in the context of C<L<< cluster_lock_storage()|/"cluster_lock_storage(...)" >>>, +i.e. when the storage is B<locked>. + +=cut + sub clone_image { my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_; croak "implement me in sub-class\n"; } +=head3 $plugin->alloc_image($storeid, $scfg, $vmid, $fmt, $name, $size) + +B<REQUIRED:> Must be implemented in every storage plugin. + +Allocates a disk image with the given format C<$fmt> and C<$size> in bytes, +returning the name of the new image (the new C<$volname>). See +C<L<< plugindata()|/"$plugin->plugindata()" >>> for all disk formats. + +Optionally, if given, set the name of the image to C<$name>. If C<$name> isn't +provided, the next name should be determined via C<L<< find_free_diskname()|/"$plugin->find_free_diskname(...)" >>>. + +C<die>s in case of an error of if the underlying storage doesn't support +allocating images. + +This method is called in the context of C<L<< cluster_lock_storage()|/"cluster_lock_storage(...)" >>>, +i.e. when the storage is B<locked>. + +=cut + sub alloc_image { my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_; croak "implement me in sub-class\n"; } +=head3 $plugin->free_image($storeid, $scfg, $volname [, $isBase, $format]) + +=head3 $plugin->free_image(...) + +B<REQUIRED:> Must be implemented in every storage plugin. + +Frees (deletes) the disk image given by C<$volname>. Optionally, the image may +be a base image (C<$isBase>) and have a certain C<$format>. See +C<L<< plugindata()|/"$plugin->plugindata()" >>> for all disk formats. + +If a cleanup is required after freeing the image, returns a reference to a +subroutine that performs the cleanup, and C<undef> otherwise. + +C<die>s in case of errors, if the image has a L<< C<protected> attribute|/"$plugin->get_volume_attribute(...)" >> +(and may thus not be freed), or if the underlying storage implementation +doesn't support freeing images. + +This method is called in the context of C<L<< cluster_lock_storage()|/"cluster_lock_storage(...)" >>>, +i.e. when the storage is B<locked>. + +B<NOTE:> The returned cleanup subroutine is called in a separate worker and +should L<< lock|/"$plugin->cluster_lock_storage(...)" >> the underlying storage +separately. + +=cut + sub free_image { my ($class, $storeid, $scfg, $volname, $isBase, $format) = @_; croak "implement me in sub-class\n"; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel