[pve-devel] [PATCH V2 qemu-server 6/8] adapt behavior for detaching drives to deatching container mount points

Stefan Hrdlicka s.hrdlicka at proxmox.com
Mon Sep 12 17:25:05 CEST 2022


if a storage is not available a volume will be added to the container
config as unused. before it would just disappear from the config

Signed-off-by: Stefan Hrdlicka <s.hrdlicka at proxmox.com>
---
 PVE/QemuServer.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 4900e15..85b005e 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2006,7 +2006,10 @@ sub vmconfig_register_unused_drive {
 	warn $@ if $@;
     } elsif (!drive_is_cdrom($drive)) {
 	my $volid = $drive->{file};
-	if (vm_is_volid_owner($storecfg, $vmid, $volid)) {
+	if (!PVE::Storage::storage_exists($storecfg, $volid)) {
+	    # if storage is not in config, skip owner check and add as unused
+	    PVE::QemuConfig->add_unused_volume($conf, $volid, $vmid);
+	} elsif (vm_is_volid_owner($storecfg, $vmid, $volid)) {
 	    PVE::QemuConfig->add_unused_volume($conf, $volid, $vmid);
 	}
     }
-- 
2.30.2






More information about the pve-devel mailing list