[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 1/2] Remove incompletely transferred libvirt volumes



If a user interrupted transfer of data to a libvirt volume, the incomplete data
was left in place. This patch causes the volume to be removed.

Fixes RHBZ#616728
---
 lib/Sys/VirtV2V/Target/LibVirt.pm |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/lib/Sys/VirtV2V/Target/LibVirt.pm b/lib/Sys/VirtV2V/Target/LibVirt.pm
index 029e4e2..943b95a 100644
--- a/lib/Sys/VirtV2V/Target/LibVirt.pm
+++ b/lib/Sys/VirtV2V/Target/LibVirt.pm
@@ -21,6 +21,7 @@ use warnings;
 package Sys::VirtV2V::Target::LibVirt::Vol;
 
 use POSIX;
+use Sys::Virt;
 
 use Sys::VirtV2V::Util qw(user_message);
 
@@ -143,6 +144,17 @@ sub close
     delete($self->{fd});
 }
 
+sub DESTROY
+{
+    my  $self = shift;
+
+    # Check if the volume has been opened, but not closed
+    return unless (exists($self->{fd}));
+
+    # Assume the volume is incomplete and delete it
+    $self->{vol}->delete(Sys::Virt::StorageVol::DELETE_NORMAL);
+}
+
 package Sys::VirtV2V::Target::LibVirt;
 
 use Sys::Virt;
-- 
1.7.2.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]