[pve-devel] [PATCH qemu-server v8 4/4] display warnings for storage errors or if storage no longer exists

Michael Köppl m.koeppl at proxmox.com
Thu Jun 26 18:06:26 CEST 2025


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.koeppl at proxmox.com>
---
 src/PVE/QemuServer.pm | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 27b4093b..71c5ce00 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -1599,6 +1599,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;
         }
@@ -1616,8 +1617,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





More information about the pve-devel mailing list