[Libguestfs] [PATCH 1/2] package handlers: add possibility for final teardown
Richard W.M. Jones
rjones at redhat.com
Wed Sep 17 12:17:38 UTC 2014
On Wed, Sep 17, 2014 at 01:58:24PM +0200, Pino Toscano wrote:
> Add a ph_fini callback to package handlers, so they can do teardown
> operations, if needed, at the very end of the supermin run.
>
> Currently all of the current package handlers do nothing.
> ---
> src/dpkg.ml | 1 +
> src/package_handler.ml | 10 ++++++++++
> src/package_handler.mli | 10 ++++++++++
> src/pacman.ml | 1 +
> src/rpm.ml | 1 +
> src/supermin.ml | 4 +++-
> 6 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/src/dpkg.ml b/src/dpkg.ml
> index 1bb3f7f..ed899cf 100644
> --- a/src/dpkg.ml
> +++ b/src/dpkg.ml
> @@ -191,6 +191,7 @@ let () =
> let ph = {
> ph_detect = dpkg_detect;
> ph_init = dpkg_init;
> + ph_fini = PHNoFini;
> ph_package_of_string = dpkg_package_of_string;
> ph_package_to_string = dpkg_package_to_string;
> ph_package_name = dpkg_package_name;
> diff --git a/src/package_handler.ml b/src/package_handler.ml
> index b1dffc0..74d68f4 100644
> --- a/src/package_handler.ml
> +++ b/src/package_handler.ml
> @@ -59,6 +59,7 @@ let file_source file =
> type package_handler = {
> ph_detect : unit -> bool;
> ph_init : settings -> unit;
> + ph_fini : ph_fini;
> ph_package_of_string : string -> package option;
> ph_package_to_string : package -> string;
> ph_package_name : package -> string;
> @@ -76,6 +77,9 @@ and ph_get_files =
> and ph_download_package =
> | PHDownloadPackage of (package -> string -> unit)
> | PHDownloadAllPackages of (PackageSet.t -> string -> unit)
> +and ph_fini =
> +| PHNoFini
> +| PHFini of (unit -> unit)
This is unnecessary, since you can write the default (no handler) as:
ph_fini = fun () -> ()
and thus avoid all the other special cases below.
ACK to the patch, but please remove the ph_fini type before committing.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
More information about the Libguestfs
mailing list