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

Stefan Hrdlicka s.hrdlicka at proxmox.com
Tue Nov 15 11:55:25 CET 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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index e68d8b4..886ac92 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2038,7 +2038,11 @@ sub vmconfig_register_unused_drive {
 	delete $conf->{cloudinit};
     } elsif (!drive_is_cdrom($drive)) {
 	my $volid = $drive->{file};
-	if (vm_is_volid_owner($storecfg, $vmid, $volid)) {
+	my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
+	if (!PVE::Storage::storage_config($storecfg, $storeid, 1)) {
+	    # 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