Initially this is a like-for-like replacement, but in future commits
this will allow us to implement:
- password authentication (instead of SSH agent)
- bandwidth throttling
- readahead
Note this requires nbdkit >= 1.12.
---
docs/guestfs-building.pod | 5 +++-
v2v/input_libvirt_xen_ssh.ml | 48 +++++++++---------------------------
v2v/nbdkit.ml | 4 +--
3 files changed, 17 insertions(+), 40 deletions(-)
diff --git a/docs/guestfs-building.pod b/docs/guestfs-building.pod
index 94ec079a5..de45098bd 100644
--- a/docs/guestfs-building.pod
+++ b/docs/guestfs-building.pod
@@ -268,7 +268,7 @@ Optional. Used only for testing.
=item qemu-nbd
-=item nbdkit
+=item nbdkit E<ge> 1.12
Optional. qemu-nbd is used for testing.
@@ -276,6 +276,9 @@ L<virt-p2v(1)> requires either qemu-nbd or nbdkit, but these
only need
to be present on the virt-p2v ISO, they do not need to be installed at
compile time.
+L<virt-v2v(1)> requires nbdkit E<ge> 1.12 for various input and output
+modes.
+
=item uml_mkcow
Optional. For the L<UML backend|guestfs(3)/BACKEND>.
diff --git a/v2v/input_libvirt_xen_ssh.ml b/v2v/input_libvirt_xen_ssh.ml
index 8f6a05867..975253e44 100644
--- a/v2v/input_libvirt_xen_ssh.ml
+++ b/v2v/input_libvirt_xen_ssh.ml
@@ -45,18 +45,15 @@ object (self)
let source, disks, _ = parse_libvirt_domain self#conn guest in
+ let port =
+ match parsed_uri.uri_port with
+ | 0 | 22 -> None
+ | i -> Some (string_of_int i) in
+
+ let user = parsed_uri.uri_user in
+
(* Map the <source/> filename (which is relative to the remote
- * Xen server) to an ssh URI. This is a JSON URI looking something
- * like this:
- *
- * json: {
- * "file.driver": "ssh",
- * "file.user": "username",
- * "file.host": "xen-host",
- * "file.port": 1022,
- * "file.path": <remote-path>,
- * "file.host_key_check": "no"
- * }
+ * Xen server) to an ssh URI pointing to nbdkit.
*)
let disks = List.map (
function
@@ -64,32 +61,9 @@ object (self)
disk
| { p_source_disk = disk; p_source = P_source_dev path }
| { p_source_disk = disk; p_source = P_source_file path } ->
- (* 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 parsed_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 (Int64.of_int i)) :: json_params in
-
- let json_params =
- match parsed_uri.uri_user with
- | None -> json_params
- | Some user -> ("file.user", JSON.String user) :: json_params in
-
- debug "ssh: json parameters: %s" (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
-
+ let nbdkit = Nbdkit.create_ssh ~password:NoPassword
+ ?port ~server ?user path in
+ let qemu_uri = Nbdkit.run nbdkit in
{ disk with s_qemu_uri = qemu_uri }
) disks in
diff --git a/v2v/nbdkit.ml b/v2v/nbdkit.ml
index 44fe0e8e7..d21c862b3 100644
--- a/v2v/nbdkit.ml
+++ b/v2v/nbdkit.ml
@@ -26,8 +26,8 @@ open Unix_utils
open Utils
-let nbdkit_min_version = (1, 2)
-let nbdkit_min_version_string = "1.2"
+let nbdkit_min_version = (1, 12)
+let nbdkit_min_version_string = "1.12"
type password =
| NoPassword (* no password option at all *)
--
2.22.0