fix: accept vm-N-cloudinit / base-N-cloudinit in parse_volname (#294)

alloc_image already creates cloud-init drives under PVE's standard name,
but parse_volname only knew disk-N and state-* volumes, so every later
operation on the drive - including qm destroy - died with "unable to
parse TrueNAS volume name". base- variant covers templates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c45c3b0abf)
This commit is contained in:
Kevin Adams
2026-10-13 12:20:06 -04:00
parent e0c5f46dbf
commit 3d092029db
2 changed files with 48 additions and 0 deletions
+6
View File
@@ -424,6 +424,12 @@ sub parse_volname {
return ('images', $volname, $vmid, undef, undef, $isBase, 'raw');
}
# Cloud-init drive: vm-<vmid>-cloudinit, or base-<vmid>-cloudinit once the
# VM is converted to a template. alloc_image already creates these (#294).
if ($volname =~ /^(vm|base)-(\d+)-cloudinit$/) {
return ('images', $volname, $2, undef, undef, ($1 eq 'base' ? 1 : 0), 'raw');
}
# RAM snapshot state volume: vm-<vmid>-state-<snapname>
# PVE allocates one of these per snapshot when "Include RAM" is selected.
if ($volname =~ /^vm-(\d+)-state-.+$/) {
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/perl
# parse_volname: every volume name the plugin (or PVE on its behalf) creates
# must parse, or later operations on it (destroy, resize, regenerate) fail.
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib", "$FindBin::Bin/../perl5";
use Test::More;
use PVE::Storage::Custom::TrueNAS;
my $TN = 'PVE::Storage::Custom::TrueNAS';
my @ok = (
# volname vmid isBase
[ 'vm-100-disk-0', 100, 0 ],
[ 'base-9000-disk-1', 9000, 1 ],
[ 'vm-100-state-pre_upg', 100, 0 ],
[ 'vm-9100-cloudinit', 9100, 0 ], # #294
[ 'base-9000-cloudinit', 9000, 1 ], # #294
);
for my $case (@ok) {
my ($volname, $vmid, $isBase) = @$case;
my @r = eval { $TN->parse_volname($volname) };
is($@, '', "$volname parses");
is($r[0], 'images', "$volname vtype");
is($r[1], $volname, "$volname name");
is($r[2], $vmid, "$volname owner");
is($r[5], $isBase, "$volname isBase");
is($r[6], 'raw', "$volname format");
}
for my $bad (qw(vm-100 vm-abc-disk-0 vm-100-cloudinit.qcow2 subvol-100-disk-0 ../vm-100-disk-0)) {
eval { $TN->parse_volname($bad) };
like($@, qr/unable to parse/, "$bad rejected");
}
done_testing();