[Pkg-libvirt-commits] [libguestfs] 30/63: v2v: Add support for access to remote RHEL 5 Xen hosts over ssh.
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 3 14:43:27 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.39-1
in repository libguestfs.
commit f243418d2300bf2bb7fdb64045544f6420ba90a3
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Thu Sep 4 11:32:33 2014 +0100
v2v: Add support for access to remote RHEL 5 Xen hosts over ssh.
---
po/POTFILES-ml | 1 +
v2v/Makefile.am | 2 ++
v2v/TODO | 1 -
v2v/input_libvirt.ml | 28 +++++++++++++-------
v2v/lib_xen.ml | 71 +++++++++++++++++++++++++++++++++++++++++++++++++
v2v/lib_xen.mli | 22 ++++++++++++++++
v2v/virt-v2v.pod | 74 +++++++++++++++++++++++++++++++++++++++++++++++++---
7 files changed, 184 insertions(+), 15 deletions(-)
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
index 70e1c9c..f570337 100644
--- a/po/POTFILES-ml
+++ b/po/POTFILES-ml
@@ -94,6 +94,7 @@ v2v/input_libvirtxml.ml
v2v/input_ova.ml
v2v/lib_esx.ml
v2v/lib_linux.ml
+v2v/lib_xen.ml
v2v/modules_list.ml
v2v/output_RHEV.ml
v2v/output_glance.ml
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 416f00b..e053e80 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -37,6 +37,7 @@ SOURCES_MLI = \
JSON.mli \
lib_esx.mli \
lib_linux.mli \
+ lib_xen.mli \
modules_list.mli \
output_glance.mli \
input_ova.mli \
@@ -55,6 +56,7 @@ SOURCES_ML = \
DOM.ml \
JSON.ml \
lib_esx.ml \
+ lib_xen.ml \
lib_linux.ml \
modules_list.ml \
input_disk.ml \
diff --git a/v2v/TODO b/v2v/TODO
index 016521b..bc8986b 100644
--- a/v2v/TODO
+++ b/v2v/TODO
@@ -3,7 +3,6 @@ Missing features compared to Perl version:
- user-custom in virt-v2v.conf to install custom packages (virt-customize?)
- Fix configure_kernel on SUSE (see Mike Latimer's email)
- testing
- - xen+ssh://remote, supported by old virt-v2v
virt-v2v bash (tab) completion
diff --git a/v2v/input_libvirt.ml b/v2v/input_libvirt.ml
index b899d59..6d78976 100644
--- a/v2v/input_libvirt.ml
+++ b/v2v/input_libvirt.ml
@@ -24,6 +24,15 @@ open Common_utils
open Types
open Utils
+(* Check the backend is not libvirt. Works around a libvirt bug
+ * (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
+ 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.")
+ )
+
class input_libvirt verbose libvirt_uri guest =
object
inherit input verbose
@@ -62,19 +71,18 @@ object
None, None
| Some server, Some ("esx"|"gsx"|"vpx" as scheme) -> (* ESX *)
- (* Check the backend is not libvirt. Works around a libvirt bug
- * (RHBZ#1134592).
- *)
- let libguestfs_backend = (new Guestfs.guestfs ())#get_backend () in
- if libguestfs_backend = "libvirt" then (
- error (f_"ESX: 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.")
- );
-
+ error_if_libvirt_backend ();
let f = Lib_esx.map_path_to_uri verbose uri scheme server in
Some f, Some f
- (* XXX Missing: Look for qemu+ssh://, xen+ssh:// and use an ssh
- * connection. This was supported in old virt-v2v.
+ | Some server, Some ("xen+ssh" as scheme) -> (* Xen over SSH *)
+ error_if_libvirt_backend ();
+ let f = Lib_xen.map_path_to_uri verbose uri scheme server in
+ Some f, Some f
+
+ (* Old virt-v2v also supported qemu+ssh://. However I am
+ * deliberately not supporting this in new virt-v2v. Don't
+ * use virt-v2v if a guest already runs on KVM.
*)
| Some _, Some _ -> (* Unknown remote scheme. *)
warning ~prog (f_"no support for remote libvirt connections to '-ic %s'. The conversion may fail when it tries to read the source disks.")
diff --git a/v2v/lib_xen.ml b/v2v/lib_xen.ml
new file mode 100644
index 0000000..332cdd6
--- /dev/null
+++ b/v2v/lib_xen.ml
@@ -0,0 +1,71 @@
+(* 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.
+ *)
+
+(** Functions for dealing with Xen. *)
+
+open Common_gettext.Gettext
+open Common_utils
+
+open Xml
+open Utils
+
+open Printf
+
+(* Map a Xen <source/> to a qemu URI using the SSH driver in qemu.
+ * This code assumes (and the caller checks) that the Xen URI is
+ * remotely accessible over ssh, so we can map the path to the qemu
+ * URI:
+ *
+ * json: {
+ * "file.driver": "ssh",
+ * "file.user": "username",
+ * "file.host": "xen-host",
+ * "file.port": 123,
+ * "file.path": "path",
+ * "file.host_key_check": "no"
+ * }
+ *)
+let rec map_path_to_uri verbose uri scheme server path format =
+ (* Construct the JSON parameters. *)
+ let json_params = [
+ "file.driver", JSON.String "ssh";
+ "file.path", JSON.String path;
+ "file.host", JSON.String server;
+ "file.host_key_check", JSON.String "no";
+ ] in
+
+ let json_params =
+ match uri.uri_port with
+ | 0 | 22 -> json_params
+ (* qemu will actually assert-fail if you send the port number as a
+ * string ...
+ *)
+ | i -> ("file.port", JSON.Int i) :: json_params in
+
+ let json_params =
+ match uri.uri_user with
+ | None -> json_params
+ | Some user -> ("file.user", JSON.String user) :: json_params in
+
+ if verbose then
+ printf "ssh: json parameters: %s\n" (JSON.string_of_doc json_params);
+
+ (* Turn the JSON parameters into a 'json:' protocol string. *)
+ let qemu_uri = "json: " ^ JSON.string_of_doc json_params in
+
+ qemu_uri, format
diff --git a/v2v/lib_xen.mli b/v2v/lib_xen.mli
new file mode 100644
index 0000000..440d226
--- /dev/null
+++ b/v2v/lib_xen.mli
@@ -0,0 +1,22 @@
+(* 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.
+ *)
+
+(** Functions for dealing with Xen. *)
+
+val map_path_to_uri : bool -> Xml.uri -> string -> string -> string -> string option -> string * string option
+(** Map a Xen path to the SSH URL where we can fetch the data. *)
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index f8cc030..b7ee594 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -193,10 +193,12 @@ This is the same as I<-i disk>.
Specify a libvirt connection URI to use when reading the guest. This
is only used when S<I<-i libvirt>>.
-Only local libvirt connections and ESX connections can be used.
-Remote libvirt connections will not work in general.
+Only local libvirt connections, ESX connections, or RHEL 5 Xen remote
+connections can be used. Other remote libvirt connections will not
+work in general.
-See also L</INPUT FROM VMWARE VCENTER SERVER> below.
+See also L</INPUT FROM VMWARE VCENTER SERVER>,
+L</INPUT FROM RHEL 5 XEN> below.
=item B<-if> format
@@ -642,7 +644,71 @@ virt-v2v itself connects directly to the server.
In this case the output flags are set to write the converted guest to
a temporary directory as this is just an example, but you can also
-write to libvirt or RHEV.
+write to libvirt or any other supported target.
+
+=head1 INPUT FROM RHEL 5 XEN
+
+Virt-v2v is able to import Xen guests from RHEL 5 Xen hosts.
+
+Virt-v2v uses libvirt for access to the remote Xen host, and therefore
+the input mode should be I<-i libvirt>. As this is the default, you
+don't need to specify it on the command line.
+
+=head2 XEN: SET UP SSH-AGENT ACCESS TO XEN HOST
+
+Currently you must enable passwordless SSH access to the remote Xen host
+from the virt-v2v conversion server.
+
+You must also use ssh-agent, and add your ssh public key to
+C</root/.ssh/authorized_keys> (on the Xen host).
+
+After doing this, you should check that passwordless access works
+from the virt-v2v server to the Xen host. For example:
+
+ $ ssh root at xen.example.com
+ [ logs straight into the shell, no password is requested ]
+
+Note that password-interactive and Kerberos access are B<not>
+supported. You B<have> to set up ssh access using ssh-agent and
+authorized_keys.
+
+=head2 XEN: TEST LIBVIRT CONNECTION TO REMOTE XEN HOST
+
+Use the L<virsh(1)> command to list the guests on the remote Xen host:
+
+ $ virsh -c xen+ssh://root@xen.example.com list --all
+ Id Name State
+ ----------------------------------------------------
+ 0 Domain-0 running
+ - rhel49-x86_64-pv shut off
+
+You should also try dumping the metadata from any guest on your
+server, like this:
+
+ $ virsh -c xen+ssh://root@xen.example.com dumpxml rhel49-x86_64-pv
+ <domain type='xen'>
+ <name>rhel49-x86_64-pv</name>
+ [...]
+ </domain>
+
+B<If the above commands do not work, then virt-v2v is not going to
+work either>. Fix your libvirt configuration or the remote server
+before continuing.
+
+=head2 XEN: IMPORTING A GUEST
+
+To import a particular guest from a Xen server, do:
+
+ $ virt-v2v -ic 'xen+ssh://root@xen.example.com' \
+ rhel49-x86_64-pv \
+ -o local -os /var/tmp
+
+where C<rhel49-x86_64-pv> is the name of the guest (which must be shut
+down).
+
+In this case the output flags are set to write the converted guest to
+a temporary directory as this is just an example, but you can also
+write to libvirt or any other supported target.
=head1 OUTPUT TO LIBVIRT
--
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