Instead of continuing without informing the user, a warning will now be displayed if the owner of a volume could not be determined due to a storage error. In addition, an explicit check for the existence of the underlying storage is added before the ownership check. If the storage no longer exists, a warning will be displayed, consistent with the handling of this scenario in other functions.
Signed-off-by: Michael Köppl <m.koe...@proxmox.com> --- PVE/QemuServer.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 5eb439a8..8a7bd30e 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -1821,6 +1821,7 @@ sub vm_is_volid_owner { if ($volid !~ m|^/|) { my ($path, $owner); eval { ($path, $owner) = PVE::Storage::path($storecfg, $volid); }; + log_warn("ownership of volume '$volid' could not be determined: $@") if $@; if ($owner && ($owner == $vmid)) { return 1; } @@ -1838,8 +1839,13 @@ sub vmconfig_register_unused_drive { delete $conf->{'special-sections'}->{cloudinit}; } elsif (!drive_is_cdrom($drive)) { my $volid = $drive->{file}; - if (vm_is_volid_owner($storecfg, $vmid, $volid)) { - PVE::QemuConfig->add_unused_volume($conf, $volid, $vmid); + my ($storeid, undef) = PVE::Storage::parse_volume_id($volid); + if (PVE::Storage::storage_config($storecfg, $storeid, 1)) { + if (vm_is_volid_owner($storecfg, $vmid, $volid)) { + PVE::QemuConfig->add_unused_volume($conf, $volid, $vmid); + } + } else { + log_warn("storage '$storeid' no longer exists, volume '$volid' will be removed"); } } } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel