From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Proxmox VE development discussion" <pve-devel@lists.proxmox.com>
Cc: "pve-devel" <pve-devel-bounces@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-storage] fix #6450: add file-checksum endpoint to storage API
Date: Thu, 02 Oct 2025 14:15:16 +0200 [thread overview]
Message-ID: <DD7TUB3A631N.10A53DGKL6JEZ@proxmox.com> (raw)
In-Reply-To: <20250929093555.86352-1-n.frey@proxmox.com>
one comment in-line
On Mon Sep 29, 2025 at 11:35 AM CEST, Nicolas Frey wrote:
> The storage API endpoint now supports an optional 'checksum' parameter.
> If set, the checksum is calculated using one of the hashing algorithms
> listed in the enum and returned in the 'checksum' return property.
>
> Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=6450
>
> Signed-off-by: Nicolas Frey <n.frey@proxmox.com>
> ---
> src/PVE/API2/Storage/Content.pm | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/src/PVE/API2/Storage/Content.pm b/src/PVE/API2/Storage/Content.pm
> index 1fe7303..ea60589 100644
> --- a/src/PVE/API2/Storage/Content.pm
> +++ b/src/PVE/API2/Storage/Content.pm
> @@ -306,6 +306,12 @@ __PACKAGE__->register_method({
> description => "Volume identifier",
> type => 'string',
> },
> + checksum => {
> + description => 'The algorithm to calculate the checksum of the file.',
> + enum => [qw(sha512 sha384 sha256 sha224 sha1 md5)],
> + type => 'string',
> + optional => 1,
> + }
> },
> },
> returns => {
> @@ -340,6 +346,11 @@ __PACKAGE__->register_method({
> type => 'boolean',
> optional => 1,
> },
> + checksum => {
> + description => 'The checksum of the file.',
> + type => 'string',
> + optional => 1,
> + }
> },
> },
> code => sub {
> @@ -376,6 +387,11 @@ __PACKAGE__->register_method({
> warn $@ if $@;
> }
>
> + if (exists $param->{checksum}) {
> + print "calculating checksum...\n";
> + $entry->{checksum} = PVE::Tools::get_file_hash($param->{checksum}, $path);
i've tested this with some not too uncommon disk images such as a 32GB
volume that is essentially empty and the api endpoint here just times
out. which is not too surprising. i wonder if we can cache the hashes
here somehow and calculate them in a worker tasks. i also wonder how
this should ideally work for running vm and container images as their
checksum could change all the time.
maybe we can at least calculate the hashes here for some more static
assets such iso etc. ahead of time and only enable this flag for things
like that (so isos, container templates, images of vm and container
templates etc.) basically things that don't change that much?
> + }
> +
> return $entry;
> },
> });
_______________________________________________
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-10-02 12:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 9:35 Nicolas Frey
2025-10-02 12:15 ` Shannon Sterz [this message]
2025-10-02 12:41 ` Thomas Lamprecht
2025-10-02 12:51 ` Fabian Grünbichler
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=DD7TUB3A631N.10A53DGKL6JEZ@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pve-devel-bounces@lists.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