[Libguestfs] [PATCH 3/3] RHEV: Cleanup volumes on unclean shutdown
Matthew Booth
mbooth at redhat.com
Tue Jun 8 15:43:06 UTC 2010
On 08/06/10 16:24, Richard W.M. Jones wrote:
> On Tue, Jun 08, 2010 at 03:55:50PM +0100, Matthew Booth wrote:
>> Currently image files will be left on the export domain if a conversion fails.
>> It isn't possible to delete these through the RHEV UI, requiring an
>> administrator to clean them up manually.
>>
>> This change causes images to be written to a temporary directory on the export
>> domain, and moved to the correct location immediately before writing the OVF
>> file. It also removes this temporary directory automatically on unclean
>> shutdown. This means that a failed conversion shouldn't leave anything on the
>> export domain. Even if it does, for example because of a power failure, the
>> temporary files are clearly separated in their own directory.
>
> The patch is fairly confusing because of the use of NFSHelper, but I
> have two potential concerns:
NFSHelper is unfortunate. As is NFS...
> (a) I don't think Perl 'rename' function will work if the temporary
> directory is on a different filesystem from the final destination.
> You might be better off using the 'mv' shell command (possibly with
> suitable shell quoting) instead.
This is ok, because the temporary directory is explicitly created on the
export storage domain, so it won't cross a filesystem boundary. I do
this specifically to avoid an additional data copy.
+ my $root = "$mountdir/$domainuuid";
$root is the top level directory of the export storage domain. Because
it's a subdirectory of $mountdir, it's on NFS.
+ unless (defined($tmpdir)) {
+ my $nfs = Sys::VirtV2V::Target::RHEV::NFSHelper->new(sub {
+ print tempdir("v2v.XXXXXXXX", DIR => $root);
+ });
The NFS helper creates a new temporary directory will the given template
under $root, so is also on NFS. NFSHelper works with stdout, so it
prints the result.
+ my $fromchild = $nfs->{fromchild};
+ ($tmpdir) = <$fromchild>;
$tmpdir is the first line of output from the child.
+ $nfs->check_exit();
check_exit() will die() with error output if there was any error.
> (b) Where is $tmpdir typically? If it's on /tmp you might find you
> have limited space, eg. if /tmp is a ramdisk. (We have the same
> problem in libguestfs, and people can override it by setting $TMPDIR).
See above. The location of tmpdir is chosen deliberately.
Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team
M: +44 (0)7977 267231
GPG ID: D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
More information about the Libguestfs
mailing list