my $local_disks = {};
# add some more information to the disks e.g. cdrom
- PVE::QemuServer::foreach_volid($vmconf, sub {
+ PVE::QemuServer::foreach_volid($vmconf, 1, sub {
my ($volid, $attr) = @_;
my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
if PVE::Storage::volume_is_base_and_used($storecfg, $volid);
};
- PVE::QemuServer::foreach_volid($conf, sub {
+ PVE::QemuServer::foreach_volid($conf, 1, sub {
my ($volid, $attr) = @_;
eval { $test_volid->($volid, $attr); };
if (my $err = $@) {
}
sub foreach_volid {
- my ($conf, $func, @param) = @_;
+ my ($conf, $include_pending, $func, @param) = @_;
my $volhash = {};
my $test_volid = sub {
- my ($key, $drive, $snapname) = @_;
+ my ($key, $drive, $snapname, $pending) = @_;
my $volid = $drive->{file};
return if !$volid;
$volhash->{$volid}->{shared} = 1 if $drive->{shared};
$volhash->{$volid}->{referenced_in_config} //= 0;
- $volhash->{$volid}->{referenced_in_config} = 1 if !defined($snapname);
+ $volhash->{$volid}->{referenced_in_config} = 1 if !defined($snapname) && !defined($pending);
$volhash->{$volid}->{referenced_in_snapshot}->{$snapname} = 1
if defined($snapname);
+ $volhash->{$volid}->{referenced_in_pending} = 1 if defined($pending);
+
my $size = $drive->{size};
$volhash->{$volid}->{size} //= $size if $size;
};
PVE::QemuConfig->foreach_volume_full($conf, $include_opts, $test_volid);
+
+ if ($include_pending && defined($conf->{pending}) && $conf->{pending}->%*) {
+ PVE::QemuConfig->foreach_volume_full($conf->{pending}, $include_opts, $test_volid, undef, 1);
+ }
+
foreach my $snapname (keys %{$conf->{snapshots}}) {
my $snap = $conf->{snapshots}->{$snapname};
PVE::QemuConfig->foreach_volume_full($snap, $include_opts, $test_volid, $snapname);
my ($conf) = @_;
my $vollist = [];
- foreach_volid($conf, sub {
+ foreach_volid($conf, 1, sub {
my ($volid, $attr) = @_;
return if $volid =~ m|^/|;