search for: rmdir_on_exit

Displaying 20 results from an estimated 101 matches for "rmdir_on_exit".

2020 Apr 06
0
[v2v PATCH 2/2] Consolidate handling of temporary files/dirs
...f94 100644 --- a/v2v/input_vmx.ml +++ b/v2v/input_vmx.ml @@ -388,11 +388,6 @@ and find_nics vmx = nics class input_vmx input_password input_transport arg = - let tmpdir = - let base_dir = (open_guestfs ())#get_cachedir () in - let t = Mkdtemp.temp_dir ~base_dir "vmx." in - rmdir_on_exit t; - t in object inherit input diff --git a/v2v/measure_disk.ml b/v2v/measure_disk.ml index 5c01eaac..6a1212f0 100644 --- a/v2v/measure_disk.ml +++ b/v2v/measure_disk.ml @@ -21,6 +21,8 @@ open Tools_utils open JSON_parser open Common_gettext.Gettext +open Utils + (* Run qemu-img measu...
2020 Apr 06
0
[PATCH virt-v2v v2 2/2] v2v: Allow large temporary directory to be set on a global basis.
...2v/input_vmx.ml @@ -389,8 +389,7 @@ and find_nics vmx = class input_vmx input_password input_transport arg = let tmpdir = - let base_dir = (open_guestfs ())#get_cachedir () in - let t = Mkdtemp.temp_dir ~base_dir "vmx." in + let t = Mkdtemp.temp_dir "vmx." in rmdir_on_exit t; t in object diff --git a/v2v/nbdkit.ml b/v2v/nbdkit.ml index 65317f9b9..06b240b54 100644 --- a/v2v/nbdkit.ml +++ b/v2v/nbdkit.ml @@ -105,8 +105,7 @@ let add_filter_if_available cmd filter = let run_unix cmd = (* Create a temporary directory where we place the socket and PID file. *)...
2015 Oct 21
2
[PATCH] v2v: use open_guestfs everywhere
..._ova.ml +++ b/v2v/input_ova.ml @@ -26,7 +26,7 @@ open Utils class input_ova ova = let tmpdir = - let base_dir = (new Guestfs.guestfs ())#get_cachedir () in + let base_dir = (open_guestfs ())#get_cachedir () in let t = Mkdtemp.temp_dir ~base_dir "ova." "" in rmdir_on_exit t; t in diff --git a/v2v/output_glance.ml b/v2v/output_glance.ml index e775229..ddcd771 100644 --- a/v2v/output_glance.ml +++ b/v2v/output_glance.ml @@ -31,7 +31,7 @@ class output_glance () = * to write to a temporary file. XXX *) let tmpdir = - let base_dir = (new Guestfs.guest...
2020 Apr 06
4
[v2v PATCH 1/2] v2v: nbdkit: change base dir for nbdkit sockets/pidfiles
Since this new temporary directory will contain UNIX sockets for communicating with nbdkit, then its path must not be too long. Use the existing directory that libguestfs exposes for this, i.e. sockdir. --- v2v/nbdkit.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/v2v/nbdkit.ml b/v2v/nbdkit.ml index 65317f9b..46b20c9d 100644 --- a/v2v/nbdkit.ml +++ b/v2v/nbdkit.ml
2020 Apr 06
6
[PATCH virt-v2v v2 0/2] v2v: Large temporary directory handling.
v1 was here: https://www.redhat.com/archives/libguestfs/2020-April/msg00007.html There's a BZ for this now which I forgot to add to the commit message: https://bugzilla.redhat.com/show_bug.cgi?id=1814611 For v2: - Fix incorrect reference to $TMPDIR in existing manual. - Separate handling for small temporary files and large temporary files. Small temporary files go into $TMPDIR
2014 Jul 07
2
Re: [PATCH] Use Mkdtemp.temp_dir instead of Mkdtemp.mkdtemp
...> let rec create ~verbose ~gpg ~gpgkey ~check_signature = > (* Create a temporary directory for gnupg. *) > - let tmpdir = Mkdtemp.mkdtemp (Filename.temp_dir_name // "vb.gpghome.XXXXXX") in > + let tmpdir = Mkdtemp.temp_dir "vb.gpghome." "" in > rmdir_on_exit tmpdir; > (* Make sure we have no check_signature=true with no actual key. *) > let check_signature, gpgkey = > diff --git a/sysprep/sysprep_operation_script.ml b/sysprep/sysprep_operation_script.ml > index d486a88..06d4dfc 100644 > --- a/sysprep/sysprep_operation_script.ml &gt...
2015 Oct 21
0
Re: [PATCH] v2v: use open_guestfs everywhere
...26,7 +26,7 @@ open Utils > > class input_ova ova = > let tmpdir = > - let base_dir = (new Guestfs.guestfs ())#get_cachedir () in > + let base_dir = (open_guestfs ())#get_cachedir () in > let t = Mkdtemp.temp_dir ~base_dir "ova." "" in > rmdir_on_exit t; > t in > diff --git a/v2v/output_glance.ml b/v2v/output_glance.ml > index e775229..ddcd771 100644 > --- a/v2v/output_glance.ml > +++ b/v2v/output_glance.ml > @@ -31,7 +31,7 @@ class output_glance () = > * to write to a temporary file. XXX > *) > let tm...
2019 Nov 19
0
Re: [PATCH v2 00/11] rvh-upload: Various fixes and cleanups
...tices an error then it returns an error over NBD to qemu-img. If qemu-img exits with an error then virt-v2v exits. Before virt-v2v exits, it runs any exit handlers. In particular if you're using OCaml's at_exit, C's atexit(3) or wrappers like Tools_utils.unlink_on_exit or Tools_utils.rmdir_on_exit, then those have already run before nbdkit starts to shut down. Nbdkit should receive a signal from the kernel when its parent process (virt-v2v) goes away, because we're using prctl + PR_SET_PDEATHSIG + SIGTERM (via ‘nbdkit --exit-with-parent’). Note this happens *after* virt-v2v has fully e...
2014 Feb 20
4
[PATCH 1/2] mllib: add an hook to cleanup directories on exit
...29 insertions(+) diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml index 3943417..f49ede6 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -386,6 +386,35 @@ let unlink_on_exit = registered_handlers := true ) +(* Remove a temporary directory on exit. *) +let rmdir_on_exit = + let dirs = ref [] in + let registered_handlers = ref false in + + let rec unlink_dirs () = + let rec recursive_rmdir fn = + if Sys.is_directory fn then ( + let names = Array.map (fun d -> fn // d) (Sys.readdir fn) in + Array.iter recursive_rmdir names; + Unix....
2014 Jul 07
2
[PATCH] mllib: introduce Mkdtemp.temp_dir
Add a simple function to ease the usage of Mkdtemp.mkdtemp. --- mllib/mkdtemp.ml | 5 +++++ mllib/mkdtemp.mli | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/mllib/mkdtemp.ml b/mllib/mkdtemp.ml index 2e64862..353b04b 100644 --- a/mllib/mkdtemp.ml +++ b/mllib/mkdtemp.ml @@ -16,4 +16,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) +open Common_utils +
2019 Sep 19
2
[PATCH 1/2] v2v: add optional tmpdir parameter for Python_script
...: string; (* Path to script. *) } -let create ?(name = "script.py") code = +let create ?(name = "script.py") ?tmpdir code = let tmpdir = - let base_dir = (open_guestfs ())#get_cachedir () in - let t = Mkdtemp.temp_dir ~base_dir "v2v." in - rmdir_on_exit t; - t in + match tmpdir with + | None -> + let base_dir = (open_guestfs ())#get_cachedir () in + let t = Mkdtemp.temp_dir ~base_dir "v2v." in + rmdir_on_exit t; + t + | Some dir -> dir in let path = tmpdir // name in with_open_out path (fun cha...
2020 Apr 06
2
Re: [v2v PATCH 2/2] Consolidate handling of temporary files/dirs
...I guess > - * it could be implemented at least for raw). Therefore we have > - * to write to a temporary file. XXX > - *) > - let tmpdir = > - let base_dir = (open_guestfs ())#get_cachedir () in > - let t = Mkdtemp.temp_dir ~base_dir "glance." in > - rmdir_on_exit t; > - t in > object > inherit output > > @@ -60,8 +50,12 @@ object > method supported_firmware = [ TargetBIOS; TargetUEFI ] > > method prepare_targets _ overlays _ = > - (* Write targets to a temporary local file - see above for reason. *) >...
2015 Jul 01
5
[PATCH 1/3] mllib: add an optional filter for rm_rf_only_files
.... --- mllib/common_utils.ml | 8 +++++++- mllib/common_utils.mli | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml index 516cff3..3737b4c 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -640,13 +640,19 @@ let rmdir_on_exit = * without removing the actual directory structure. Also if 'dir' is * not a directory or doesn't exist, ignore it. * + * The optional filter is used to filter out files which will be + * removed: files returning true are not removed. + * * XXX Could be faster with a specific...
2020 Apr 02
6
[PATCH virt-v2v] v2v: Allow temporary directory to be set on a global basis.
...@ -389,8 +389,7 @@ and find_nics vmx = class input_vmx input_password input_transport arg = let tmpdir = - let base_dir = (open_guestfs ())#get_cachedir () in - let t = Mkdtemp.temp_dir ~base_dir "vmx." in + let t = Mkdtemp.temp_dir ~base_dir:tmpdir "vmx." in rmdir_on_exit t; t in object diff --git a/v2v/nbdkit.ml b/v2v/nbdkit.ml index 65317f9b9..188647f65 100644 --- a/v2v/nbdkit.ml +++ b/v2v/nbdkit.ml @@ -105,8 +105,7 @@ let add_filter_if_available cmd filter = let run_unix cmd = (* Create a temporary directory where we place the socket and PID file. *)...
2016 Oct 24
0
[PATCH 2/2] builder: consolidate handling of temporary files/dirs
.../builder.ml @@ -177,8 +177,15 @@ let main () = None in + (* Create a single temporary directory for all the small-or-so + * temporary files that Downloader, Sigchecker, etc, are going + * create. + *) + let tmpdir = Mkdtemp.temp_dir "virt-builder." "" in + rmdir_on_exit tmpdir; + (* Download the sources. *) - let downloader = Downloader.create ~curl:cmdline.curl ~cache in + let downloader = Downloader.create ~curl:cmdline.curl ~cache ~tmpdir in let repos = Sources.read_sources () in let sources = List.map ( fun (source, fingerprint) -> @@ -197,7...
2016 Oct 25
0
[PATCH v2 2/2] builder: consolidate handling of temporary files/dirs
.../builder.ml @@ -177,8 +177,15 @@ let main () = None in + (* Create a single temporary directory for all the small-or-so + * temporary files that Downloader, Sigchecker, etc, are going + * create. + *) + let tmpdir = Mkdtemp.temp_dir "virt-builder." "" in + rmdir_on_exit tmpdir; + (* Download the sources. *) - let downloader = Downloader.create ~curl:cmdline.curl ~cache in + let downloader = Downloader.create ~curl:cmdline.curl ~cache ~tmpdir in let repos = Sources.read_sources () in let sources = List.map ( fun (source, fingerprint) -> @@ -197,7...
2019 Nov 19
5
Re: [PATCH v2 00/11] rvh-upload: Various fixes and cleanups
On Tue, Nov 19, 2019 at 01:48:31PM +0100, Martin Kletzander wrote: >On Tue, Nov 19, 2019 at 02:24:11PM +0200, Nir Soffer wrote: >>On Tue, Nov 19, 2019 at 2:16 PM Martin Kletzander <mkletzan@redhat.com> wrote: >>> On Tue, Nov 19, 2019 at 01:14:23PM +0200, Nir Soffer wrote: >>> >On Tue, Nov 19, 2019 at 11:17 AM Martin Kletzander <mkletzan@redhat.com> wrote:
2016 Oct 25
2
[PATCH v2 1/2] mllib: curl: add optional tmpdir parameter
Add a new optional parameter for the Curl ADT, so temporary files can be created in a specified directory (which is supposed to be temporary, and disposed only when the application quits). --- mllib/curl.ml | 10 ++++++---- mllib/curl.mli | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mllib/curl.ml b/mllib/curl.ml index 376406e..baa75ec 100644 --- a/mllib/curl.ml +++
2016 Oct 24
2
[PATCH 1/2] mllib: curl: add optional tmpdir parameter
Add a new optional parameter for the Curl ADT, so temporary files can be created in a specified directory (which is supposed to be temporary, and disposed only when the application quits). --- mllib/curl.ml | 16 +++++++++++----- mllib/curl.mli | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mllib/curl.ml b/mllib/curl.ml index 376406e..7d07125 100644 --- a/mllib/curl.ml
2017 Dec 08
1
Re: [PATCH v2 2/2] v2v: -i vmx: Enhance VMX support with ability to use ‘-it ssh’ transport.
On Friday, 8 December 2017 17:02:30 CET Richard W.M. Jones wrote: > This enhances the existing VMX input support allowing it to be > used over SSH to the ESXi server. > > The original command (for local .vmx files) was: > > $ virt-v2v -i vmx guest.vmx -o local -os /var/tmp > > Adding ‘-it ssh’ and using an SSH remote path gives the new syntax: > > $ virt-v2v \