[Pkg-libvirt-commits] [libguestfs] 31/40: v2v: Add -o null mode.
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 3 14:44:53 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag debian/1%1.27.44-1
in repository libguestfs.
commit 7836aa523bbcd223e3ebb23b3d174197b614b30f
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Fri Sep 12 20:06:49 2014 +0100
v2v: Add -o null mode.
In theory this discards the output. Unfortunately in practice we have
to write the output to a temporary file and delete it (because of
limitations in qemu-img convert).
---
po/POTFILES-ml | 1 +
v2v/Makefile.am | 3 +++
v2v/cmdline.ml | 10 ++++++++++
v2v/output_null.ml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
v2v/output_null.mli | 23 ++++++++++++++++++++++
v2v/test-v2v-o-null.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
v2v/virt-v2v.pod | 17 ++++++++++++----
7 files changed, 155 insertions(+), 4 deletions(-)
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
index 8a169ab..76fe681 100644
--- a/po/POTFILES-ml
+++ b/po/POTFILES-ml
@@ -100,6 +100,7 @@ v2v/modules_list.ml
v2v/output_glance.ml
v2v/output_libvirt.ml
v2v/output_local.ml
+v2v/output_null.ml
v2v/output_rhev.ml
v2v/output_vdsm.ml
v2v/stringMap.ml
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 5447877..7807735 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -45,6 +45,7 @@ SOURCES_MLI = \
input_ova.mli \
output_libvirt.mli \
output_local.mli \
+ output_null.mli \
output_rhev.mli \
output_vdsm.mli \
types.mli \
@@ -69,6 +70,7 @@ SOURCES_ML = \
input_ova.ml \
convert_linux.ml \
convert_windows.ml \
+ output_null.ml \
output_glance.ml \
output_libvirt.ml \
output_local.ml \
@@ -213,6 +215,7 @@ TESTS = \
test-v2v-no-copy.sh \
test-v2v-o-glance.sh \
test-v2v-o-libvirt.sh \
+ test-v2v-o-null.sh \
test-v2v-o-rhev.sh \
test-v2v-o-vdsm-options.sh \
test-v2v-of-option.sh \
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index 9640516..adea40c 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -83,6 +83,7 @@ let parse_cmdline () =
| "glance" -> output_mode := `Glance
| "libvirt" -> output_mode := `Libvirt
| "disk" | "local" -> output_mode := `Local
+ | "null" -> output_mode := `Null
| "ovirt" | "rhev" -> output_mode := `RHEV
| "vdsm" -> output_mode := `VDSM
| s ->
@@ -296,6 +297,15 @@ read the man page virt-v2v(1).
error (f_"--vmtype option cannot be used with '-o local'");
Output_local.output_local verbose output_storage
+ | `Null ->
+ if output_conn <> None then
+ error (f_"-o null: -oc option cannot be used in this output mode");
+ if output_storage <> "" then
+ error (f_"-o null: -os option cannot be used in this output mode");
+ if vmtype <> None then
+ error (f_"--vmtype option cannot be used with '-o null'");
+ Output_null.output_null verbose
+
| `RHEV ->
if output_storage = "" then
error (f_"-o rhev: output storage was not specified, use '-os'");
diff --git a/v2v/output_null.ml b/v2v/output_null.ml
new file mode 100644
index 0000000..97495e6
--- /dev/null
+++ b/v2v/output_null.ml
@@ -0,0 +1,53 @@
+(* virt-v2v
+ * Copyright (C) 2009-2014 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+open Printf
+
+open Common_gettext.Gettext
+open Common_utils
+
+open Types
+open Utils
+
+class output_null verbose =
+ (* It would be nice to be able to write to /dev/null.
+ * Unfortunately qemu-img convert cannot do that. Instead create a
+ * temporary directory which is always deleted at exit.
+ *)
+ let tmpdir =
+ let base_dir = (new Guestfs.guestfs ())#get_cachedir () in
+ let t = Mkdtemp.temp_dir ~base_dir "null." "" in
+ rmdir_on_exit t;
+ t in
+object
+ inherit output verbose
+
+ method as_options = "-o null"
+
+ method prepare_targets source targets =
+ List.map (
+ fun t ->
+ let target_file = tmpdir // t.target_overlay.ov_sd in
+ { t with target_file = target_file }
+ ) targets
+
+ method create_metadata _ _ _ _ = ()
+end
+
+let output_null = new output_null
+let () = Modules_list.register_output_module "null"
diff --git a/v2v/output_null.mli b/v2v/output_null.mli
new file mode 100644
index 0000000..63b7039
--- /dev/null
+++ b/v2v/output_null.mli
@@ -0,0 +1,23 @@
+(* virt-v2v
+ * Copyright (C) 2009-2014 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+(** [-o null] target. *)
+
+val output_null : bool -> Types.output
+(** [output_null filename] creates and returns a new {!Types.output}
+ object specialized discarding output. *)
diff --git a/v2v/test-v2v-o-null.sh b/v2v/test-v2v-o-null.sh
new file mode 100755
index 0000000..8b2c612
--- /dev/null
+++ b/v2v/test-v2v-o-null.sh
@@ -0,0 +1,52 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Test -o null.
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_O_NULL_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+if [ "$(../fish/guestfish get-backend)" = "uml" ]; then
+ echo "$0: test skipped because UML backend does not support network"
+ exit 77
+fi
+
+abs_top_builddir="$(cd ..; pwd)"
+libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml"
+
+f=../tests/guests/windows.img
+if ! test -f $f || ! test -s $f; then
+ echo "$0: test skipped because phony Windows image was not created"
+ exit 77
+fi
+
+virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools}
+if ! test -r $virt_tools_data_dir/rhsrvany.exe; then
+ echo "$0: test skipped because rhsrvany.exe is not installed"
+ exit 77
+fi
+
+$VG ./virt-v2v --debug-gc \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o null
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index 5aa1c91..ceb9950 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -30,9 +30,9 @@ libguestfs E<ge> 1.28.
=head1 INPUT AND OUTPUT MODES
- ┌────────────┐
- -i disk ───────────┐ │ │ ┌───────▶ -o local
- -i ova ─────────┐ └──▶ │ virt-v2v │ │
+ ┌────────────┐ ┌─────────▶ -o null
+ -i disk ───────────┐ │ │ │┌───────▶ -o local
+ -i ova ─────────┐ └──▶ │ virt-v2v │ ─┘│
└────▶ │ conversion │ ──┘┌────────────┐
ESX ──▶┌────────────┐ │ server │ ───▶ -o libvirt │─▶ KVM
Xen ──▶│ -i libvirt ──▶ │ │ │ (default) │
@@ -231,7 +231,8 @@ See L</NETWORKS AND BRIDGES> below.
=item B<--no-copy>
Don't copy the disks. Instead, conversion is performed (and thrown
-away), and metadata is written, but no disks are created.
+away), and metadata is written, but no disks are created. See
+also discussion of S<I<-o null>> below.
This is useful in two cases: Either you want to test if conversion is
likely to succeed, without the long copying process. Or you are only
@@ -279,6 +280,14 @@ and a libvirt XML file is created containing guest metadata:
where C<name> is the guest name.
+=item B<-o null>
+
+Set the output method to I<null>.
+
+The guest is converted and copied (unless you also specify
+I<--no-copy>), but the results are thrown away and no metadata is
+written.
+
=item B<-o ovirt>
This is the same as I<-o rhev>.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list