Matthew Booth
2011-Jan-17 16:06 UTC
[Libguestfs] [PATCH] RHEV: Ensure DESTROY won't be called for uninitialized object
Fixes RHBZ#615182
---
lib/Sys/VirtV2V/Connection/RHEVTarget.pm | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/Sys/VirtV2V/Connection/RHEVTarget.pm
b/lib/Sys/VirtV2V/Connection/RHEVTarget.pm
index c9dd148..b63d956 100644
--- a/lib/Sys/VirtV2V/Connection/RHEVTarget.pm
+++ b/lib/Sys/VirtV2V/Connection/RHEVTarget.pm
@@ -442,9 +442,7 @@ sub new
my $class = shift;
my ($domain_path) = @_;
- my $self = {};
- bless($self, $class);
-
+ # Must do this before bless, or DESTROY will be called
die(user_message(__"You must be root to output to RHEV"))
unless ($> == 0);
@@ -456,6 +454,9 @@ sub new
"36:36",
mountdir => $mountdir)));
+ my $self = {};
+ bless($self, $class);
+
$self->{mountdir} = $mountdir;
$self->{domain_path} = $domain_path;
--
1.7.3.4
Richard W.M. Jones
2011-Jan-17 16:14 UTC
[Libguestfs] [PATCH] RHEV: Ensure DESTROY won't be called for uninitialized object
On Mon, Jan 17, 2011 at 04:06:00PM +0000, Matthew Booth wrote:> Fixes RHBZ#615182 > --- > lib/Sys/VirtV2V/Connection/RHEVTarget.pm | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/lib/Sys/VirtV2V/Connection/RHEVTarget.pm b/lib/Sys/VirtV2V/Connection/RHEVTarget.pm > index c9dd148..b63d956 100644 > --- a/lib/Sys/VirtV2V/Connection/RHEVTarget.pm > +++ b/lib/Sys/VirtV2V/Connection/RHEVTarget.pm > @@ -442,9 +442,7 @@ sub new > my $class = shift; > my ($domain_path) = @_; > > - my $self = {}; > - bless($self, $class); > - > + # Must do this before bless, or DESTROY will be called > die(user_message(__"You must be root to output to RHEV")) > unless ($> == 0); > > @@ -456,6 +454,9 @@ sub new > "36:36", > mountdir => $mountdir))); > > + my $self = {}; > + bless($self, $class); > + > $self->{mountdir} = $mountdir; > $self->{domain_path} = $domain_path;ACK, perfectly sensible. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Possibly Parallel Threads
- [PREVIEW ONLY] Refactor data transfer code
- [PATCH 1/3] Fix RHEV cleanup on unclean shutdown
- [PATCH 1/4] Check that we're not overwriting an existing Libvirt domain
- [PATCH 1/2] Refactor guest and volume creation into Sys::VirtV2V::Target::LibVirt
- [PATCH] Fix virt-v2v exit codes