[pve-devel] [PATCH 11/20] delete cloudinit discs instead of adding them as unused

Alexandre Derumier aderumier at odiso.com
Sun Jun 18 15:03:17 CEST 2017


From: Wolfgang Bumiller <w.bumiller at proxmox.com>

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 1a36eb0..c6a0698 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2014,7 +2014,10 @@ sub vmconfig_undelete_pending_option {
 sub vmconfig_register_unused_drive {
     my ($storecfg, $vmid, $conf, $drive) = @_;
 
-    if (!drive_is_cdrom($drive, 1)) {
+    if (drive_is_cloudinit($drive)) {
+	eval { PVE::Storage::vdisk_free($storecfg, $drive->{file}) };
+	warn $@ if $@;
+    } 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);
@@ -4624,6 +4627,9 @@ sub vmconfig_update_disk {
 
 		if ($drive->{file} eq 'none') {
 		    vm_mon_cmd($vmid, "eject",force => JSON::true,device => "drive-$opt");
+		    if (drive_is_cloudinit($old_drive)) {
+			vmconfig_register_unused_drive($storecfg, $vmid, $conf, $old_drive);
+		    }
 		} else {
 		    my $path = get_iso_path($storecfg, $vmid, $drive->{file});
 		    vm_mon_cmd($vmid, "eject", force => JSON::true,device => "drive-$opt"); # force eject if locked
-- 
2.11.0




More information about the pve-devel mailing list