From e265d5401de6c595dbad215d4fe419be0327ff52 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 10 Mar 2017 14:33:55 -0500 Subject: [PATCH 1/3] Handle purging block or raw VM disks when removing a VM --- xCAT-server/lib/xcat/plugins/kvm.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 7e83f850f..17d1a66b0 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -1775,6 +1775,14 @@ sub rmvm { foreach $disk (@purgedisks) { my $disktype = $disk->parentNode()->getAttribute("device"); if ($disktype eq "cdrom") { next; } + + my @driver = $disk->parentNode()->findnodes("driver"); + my $drivertype = $driver[0]->getAttribute("type"); + if (($drivertype eq "raw") || ($disktype eq "block")) { + #For raw or block devices, do not remove, even if purge was specified. Log info message. + xCAT::MsgUtils->trace(0, "i", "Not purging raw or block storage device: $disk"); + next; + } my $file = $disk->getAttribute("file"); # try to check the existence first, if cannot find, do nothing. From 6a2164b6cbc4f418eae6ef95e14dfe5e3b322f39 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 10 Mar 2017 16:15:14 -0500 Subject: [PATCH 2/3] Extra checking --- xCAT-server/lib/xcat/plugins/kvm.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 17d1a66b0..6a8433e37 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -1777,6 +1777,7 @@ sub rmvm { if ($disktype eq "cdrom") { next; } my @driver = $disk->parentNode()->findnodes("driver"); + unless ($driver[0]) { next; } my $drivertype = $driver[0]->getAttribute("type"); if (($drivertype eq "raw") || ($disktype eq "block")) { #For raw or block devices, do not remove, even if purge was specified. Log info message. @@ -1784,6 +1785,7 @@ sub rmvm { next; } my $file = $disk->getAttribute("file"); + unless ($file) { next; } # try to check the existence first, if cannot find, do nothing. # we do retry because we found sometimes the delete might fail From 9763c34e7590aaffae3ca318299ea37af33ef2ea Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 13 Mar 2017 10:06:40 -0400 Subject: [PATCH 3/3] Added a warning message --- xCAT-server/lib/xcat/plugins/kvm.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 6a8433e37..becd4c557 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -1785,7 +1785,10 @@ sub rmvm { next; } my $file = $disk->getAttribute("file"); - unless ($file) { next; } + unless ($file) { + xCAT::MsgUtils->trace(0, "w", "Not able to find 'file' attribute value for: $disk"); + next; + } # try to check the existence first, if cannot find, do nothing. # we do retry because we found sometimes the delete might fail