Use the common open_guestfs to open Guestfs handles, so we get debugging, tracing, and other common options set. --- v2v/convert_windows.ml | 4 +--- v2v/input_disk.ml | 2 +- v2v/input_libvirt_other.ml | 2 +- v2v/input_ova.ml | 2 +- v2v/output_glance.ml | 2 +- v2v/output_null.ml | 2 +- v2v/output_rhev.ml | 2 +- v2v/output_vdsm.ml | 2 +- v2v/types.ml | 2 +- v2v/v2v.ml | 4 ++-- 10 files changed, 11 insertions(+), 13 deletions(-) diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml index 6402a63..099ced2 100644 --- a/v2v/convert_windows.ml +++ b/v2v/convert_windows.ml @@ -295,10 +295,8 @@ echo uninstalling Xen PV driver ) else if is_regular_file virtio_win then ( try - let g2 = new Guestfs.guestfs () in + let g2 = open_guestfs () in g#set_identifier "virtio_win"; - if trace () then g2#set_trace true; - if verbose () then g2#set_verbose true; g2#add_drive_opts virtio_win ~readonly:true; g2#launch (); let vio_root = "/" in diff --git a/v2v/input_disk.ml b/v2v/input_disk.ml index 970f552..4b75262 100644 --- a/v2v/input_disk.ml +++ b/v2v/input_disk.ml @@ -60,7 +60,7 @@ class input_disk input_format disk = object match input_format with | Some format -> format | None -> - match (new Guestfs.guestfs ())#disk_format disk with + match (open_guestfs ())#disk_format disk with | "unknown" -> error (f_"cannot detect the input disk format; use the -if parameter") | format -> format in diff --git a/v2v/input_libvirt_other.ml b/v2v/input_libvirt_other.ml index 0a137c1..bb97bc6 100644 --- a/v2v/input_libvirt_other.ml +++ b/v2v/input_libvirt_other.ml @@ -28,7 +28,7 @@ open Utils * (RHBZ#1134592). This can be removed once the libvirt bug is fixed. *) let error_if_libvirt_backend () - let libguestfs_backend = (new Guestfs.guestfs ())#get_backend () in + let libguestfs_backend = (open_guestfs ())#get_backend () in if libguestfs_backend = "libvirt" then ( error (f_"because of libvirt bug https://bugzilla.redhat.com/show_bug.cgi?id=1134592 you must set this environment variable:\n\nexport LIBGUESTFS_BACKEND=direct\n\nand then rerun the virt-v2v command.") ) diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml index cd26160..f2dc28b 100644 --- a/v2v/input_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.guestfs ())#get_cachedir () in + let base_dir = (open_guestfs ())#get_cachedir () in let t = Mkdtemp.temp_dir ~base_dir "glance." "" in rmdir_on_exit t; t in diff --git a/v2v/output_null.ml b/v2v/output_null.ml index 2cada46..b201baa 100644 --- a/v2v/output_null.ml +++ b/v2v/output_null.ml @@ -30,7 +30,7 @@ class output_null * temporary directory which is always deleted at exit. *) 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 "null." "" in rmdir_on_exit t; t in diff --git a/v2v/output_rhev.ml b/v2v/output_rhev.ml index 4b46f83..2878e13 100644 --- a/v2v/output_rhev.ml +++ b/v2v/output_rhev.ml @@ -262,7 +262,7 @@ object ?clustersize path format size Changeuid.func changeuid_t ( fun () -> - let g = new Guestfs.guestfs () in + let g = open_guestfs () in g#set_identifier "rhev_disk_create"; (* For qcow2, override v2v-supplied compat option, because RHEL 6 * nodes cannot handle qcow2 v3 (RHBZ#1145582). diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml index 1134e5b..079b47f 100644 --- a/v2v/output_vdsm.ml +++ b/v2v/output_vdsm.ml @@ -156,7 +156,7 @@ object method disk_create ?backingfile ?backingformat ?preallocation ?compat ?clustersize path format size - let g = new Guestfs.guestfs () in + let g = open_guestfs () in g#set_identifier "vdsm_disk_create"; (* For qcow2, override v2v-supplied compat option, because RHEL 6 * nodes cannot handle qcow2 v3 (RHBZ#1145582). diff --git a/v2v/types.ml b/v2v/types.ml index a295172..038d259 100644 --- a/v2v/types.ml +++ b/v2v/types.ml @@ -401,7 +401,7 @@ class virtual output = object method virtual supported_firmware : target_firmware list method check_target_firmware (_ : guestcaps) (_ : target_firmware) = () method check_target_free_space (_ : source) (_ : target list) = () - method disk_create = (new Guestfs.guestfs ())#disk_create + method disk_create = (open_guestfs ())#disk_create method virtual create_metadata : source -> target list -> target_buses -> guestcaps -> inspect -> target_firmware -> unit method keep_serial_console = true end diff --git a/v2v/v2v.ml b/v2v/v2v.ml index 88ae409..2f473eb 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -217,7 +217,7 @@ and create_overlays src_disks * data over the wire. *) message (f_"Creating an overlay to protect the source from being modified"); - let overlay_dir = (new Guestfs.guestfs ())#get_cachedir () in + let overlay_dir = (open_guestfs ())#get_cachedir () in List.mapi ( fun i ({ s_qemu_uri = qemu_uri; s_format = format } as source) -> let overlay_file @@ -944,7 +944,7 @@ and target_bus_assignment source targets guestcaps and preserve_overlays overlays src_name (* Save overlays if --debug-overlays option was used. *) - let overlay_dir = (new Guestfs.guestfs ())#get_cachedir () in + let overlay_dir = (open_guestfs ())#get_cachedir () in List.iter ( fun ov -> let saved_filename -- 2.1.0
Richard W.M. Jones
2015-Oct-21 18:31 UTC
Re: [Libguestfs] [PATCH] v2v: use open_guestfs everywhere
On Wed, Oct 21, 2015 at 03:53:33PM +0200, Pino Toscano wrote:> Use the common open_guestfs to open Guestfs handles, so we get > debugging, tracing, and other common options set. > --- > v2v/convert_windows.ml | 4 +--- > v2v/input_disk.ml | 2 +- > v2v/input_libvirt_other.ml | 2 +- > v2v/input_ova.ml | 2 +- > v2v/output_glance.ml | 2 +- > v2v/output_null.ml | 2 +- > v2v/output_rhev.ml | 2 +- > v2v/output_vdsm.ml | 2 +- > v2v/types.ml | 2 +- > v2v/v2v.ml | 4 ++-- > 10 files changed, 11 insertions(+), 13 deletions(-)I guess it sets the network flag unnecessarily, but that doesn't matter much so ACK. Rich.> diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml > index 6402a63..099ced2 100644 > --- a/v2v/convert_windows.ml > +++ b/v2v/convert_windows.ml > @@ -295,10 +295,8 @@ echo uninstalling Xen PV driver > ) > else if is_regular_file virtio_win then ( > try > - let g2 = new Guestfs.guestfs () in > + let g2 = open_guestfs () in > g#set_identifier "virtio_win"; > - if trace () then g2#set_trace true; > - if verbose () then g2#set_verbose true; > g2#add_drive_opts virtio_win ~readonly:true; > g2#launch (); > let vio_root = "/" in > diff --git a/v2v/input_disk.ml b/v2v/input_disk.ml > index 970f552..4b75262 100644 > --- a/v2v/input_disk.ml > +++ b/v2v/input_disk.ml > @@ -60,7 +60,7 @@ class input_disk input_format disk = object > match input_format with > | Some format -> format > | None -> > - match (new Guestfs.guestfs ())#disk_format disk with > + match (open_guestfs ())#disk_format disk with > | "unknown" -> > error (f_"cannot detect the input disk format; use the -if parameter") > | format -> format in > diff --git a/v2v/input_libvirt_other.ml b/v2v/input_libvirt_other.ml > index 0a137c1..bb97bc6 100644 > --- a/v2v/input_libvirt_other.ml > +++ b/v2v/input_libvirt_other.ml > @@ -28,7 +28,7 @@ open Utils > * (RHBZ#1134592). This can be removed once the libvirt bug is fixed. > *) > let error_if_libvirt_backend () > - let libguestfs_backend = (new Guestfs.guestfs ())#get_backend () in > + let libguestfs_backend = (open_guestfs ())#get_backend () in > if libguestfs_backend = "libvirt" then ( > error (f_"because of libvirt bug https://bugzilla.redhat.com/show_bug.cgi?id=1134592 you must set this environment variable:\n\nexport LIBGUESTFS_BACKEND=direct\n\nand then rerun the virt-v2v command.") > ) > diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml > index cd26160..f2dc28b 100644 > --- a/v2v/input_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.guestfs ())#get_cachedir () in > + let base_dir = (open_guestfs ())#get_cachedir () in > let t = Mkdtemp.temp_dir ~base_dir "glance." "" in > rmdir_on_exit t; > t in > diff --git a/v2v/output_null.ml b/v2v/output_null.ml > index 2cada46..b201baa 100644 > --- a/v2v/output_null.ml > +++ b/v2v/output_null.ml > @@ -30,7 +30,7 @@ class output_null > * temporary directory which is always deleted at exit. > *) > 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 "null." "" in > rmdir_on_exit t; > t in > diff --git a/v2v/output_rhev.ml b/v2v/output_rhev.ml > index 4b46f83..2878e13 100644 > --- a/v2v/output_rhev.ml > +++ b/v2v/output_rhev.ml > @@ -262,7 +262,7 @@ object > ?clustersize path format size > Changeuid.func changeuid_t ( > fun () -> > - let g = new Guestfs.guestfs () in > + let g = open_guestfs () in > g#set_identifier "rhev_disk_create"; > (* For qcow2, override v2v-supplied compat option, because RHEL 6 > * nodes cannot handle qcow2 v3 (RHBZ#1145582). > diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml > index 1134e5b..079b47f 100644 > --- a/v2v/output_vdsm.ml > +++ b/v2v/output_vdsm.ml > @@ -156,7 +156,7 @@ object > > method disk_create ?backingfile ?backingformat ?preallocation ?compat > ?clustersize path format size > - let g = new Guestfs.guestfs () in > + let g = open_guestfs () in > g#set_identifier "vdsm_disk_create"; > (* For qcow2, override v2v-supplied compat option, because RHEL 6 > * nodes cannot handle qcow2 v3 (RHBZ#1145582). > diff --git a/v2v/types.ml b/v2v/types.ml > index a295172..038d259 100644 > --- a/v2v/types.ml > +++ b/v2v/types.ml > @@ -401,7 +401,7 @@ class virtual output = object > method virtual supported_firmware : target_firmware list > method check_target_firmware (_ : guestcaps) (_ : target_firmware) = () > method check_target_free_space (_ : source) (_ : target list) = () > - method disk_create = (new Guestfs.guestfs ())#disk_create > + method disk_create = (open_guestfs ())#disk_create > method virtual create_metadata : source -> target list -> target_buses -> guestcaps -> inspect -> target_firmware -> unit > method keep_serial_console = true > end > diff --git a/v2v/v2v.ml b/v2v/v2v.ml > index 88ae409..2f473eb 100644 > --- a/v2v/v2v.ml > +++ b/v2v/v2v.ml > @@ -217,7 +217,7 @@ and create_overlays src_disks > * data over the wire. > *) > message (f_"Creating an overlay to protect the source from being modified"); > - let overlay_dir = (new Guestfs.guestfs ())#get_cachedir () in > + let overlay_dir = (open_guestfs ())#get_cachedir () in > List.mapi ( > fun i ({ s_qemu_uri = qemu_uri; s_format = format } as source) -> > let overlay_file > @@ -944,7 +944,7 @@ and target_bus_assignment source targets guestcaps > > and preserve_overlays overlays src_name > (* Save overlays if --debug-overlays option was used. *) > - let overlay_dir = (new Guestfs.guestfs ())#get_cachedir () in > + let overlay_dir = (open_guestfs ())#get_cachedir () in > List.iter ( > fun ov -> > let saved_filename > -- > 2.1.0 > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Pino Toscano
2015-Oct-22 08:17 UTC
Re: [Libguestfs] [PATCH] v2v: use open_guestfs everywhere
On Wednesday 21 October 2015 19:31:41 Richard W.M. Jones wrote:> On Wed, Oct 21, 2015 at 03:53:33PM +0200, Pino Toscano wrote: > > Use the common open_guestfs to open Guestfs handles, so we get > > debugging, tracing, and other common options set. > > --- > > v2v/convert_windows.ml | 4 +--- > > v2v/input_disk.ml | 2 +- > > v2v/input_libvirt_other.ml | 2 +- > > v2v/input_ova.ml | 2 +- > > v2v/output_glance.ml | 2 +- > > v2v/output_null.ml | 2 +- > > v2v/output_rhev.ml | 2 +- > > v2v/output_vdsm.ml | 2 +- > > v2v/types.ml | 2 +- > > v2v/v2v.ml | 4 ++-- > > 10 files changed, 11 insertions(+), 13 deletions(-) > > I guess it sets the network flag unnecessarily, but that > doesn't matter much so ACK.Hm no, it doesn't, network is still explicitly enabled on the "main" handle. -- Pino Toscano
Possibly Parallel Threads
- Re: [PATCH] v2v: use open_guestfs everywhere
- [v2v PATCH 1/2] v2v: nbdkit: change base dir for nbdkit sockets/pidfiles
- [PATCH virt-v2v v2 0/2] v2v: Large temporary directory handling.
- [PATCH 0/4] Only tell people to use -v -x when reporting bugs if they're not using those flags.
- [PATCH v2 0/4] Only tell people to use -v -x when reporting bugs if they're not using those flags.