parent
163b386dc7
commit
1cc830317c
@ -1,2 +1,2 @@
|
|||||||
SOURCES/libguestfs.keyring
|
SOURCES/libguestfs.keyring
|
||||||
SOURCES/virt-v2v-2.3.4.tar.gz
|
SOURCES/virt-v2v-2.4.0.tar.gz
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
1bbc40f501a7fef9eef2a39b701a71aee2fea7c4 SOURCES/libguestfs.keyring
|
1bbc40f501a7fef9eef2a39b701a71aee2fea7c4 SOURCES/libguestfs.keyring
|
||||||
6c170400aeacfe53828b4fdbfdcbca2423b9e753 SOURCES/virt-v2v-2.3.4.tar.gz
|
52029cc7c3f9e05ec9685995ad86955154d7b28e SOURCES/virt-v2v-2.4.0.tar.gz
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
From af68f253d1a11c4abaa30ae348ee3855cdec74e9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 11 Jan 2024 15:33:08 +0000
|
||||||
|
Subject: [PATCH] virt-v2v: -i vmx: Remove scp -T option
|
||||||
|
|
||||||
|
This reverts the following commit:
|
||||||
|
|
||||||
|
commit d265639c2ab31418cfdbdedd0cc3e68cf290d834
|
||||||
|
Author: Richard W.M. Jones <rjones@redhat.com>
|
||||||
|
Date: Thu Jul 25 14:52:42 2019 +0100
|
||||||
|
|
||||||
|
v2v: -i vmx: Use scp -T option if available to unbreak scp (RHBZ#1733168).
|
||||||
|
|
||||||
|
See also the referenced bug:
|
||||||
|
https://bugzilla.redhat.com/show_bug.cgi?id=1733168
|
||||||
|
|
||||||
|
My rationale for removing this option is that since we now require
|
||||||
|
OpenSSH 8.8 we must be using sftp for file transfer so we no longer
|
||||||
|
need to defeat the check for correct expansion of wildcards. That
|
||||||
|
check was only relevant for OpenSSH <= 8.7 using the old scp protocol.
|
||||||
|
|
||||||
|
Reverts: commit d265639c2ab31418cfdbdedd0cc3e68cf290d834
|
||||||
|
---
|
||||||
|
input/parse_domain_from_vmx.ml | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml
|
||||||
|
index 2e75e785..f24990f8 100644
|
||||||
|
--- a/input/parse_domain_from_vmx.ml
|
||||||
|
+++ b/input/parse_domain_from_vmx.ml
|
||||||
|
@@ -68,7 +68,7 @@ let scp_from_remote_to_temporary uri tmpdir filename =
|
||||||
|
let localfile = tmpdir // filename in
|
||||||
|
|
||||||
|
let cmd =
|
||||||
|
- sprintf "scp -T%s%s %s%s:%s %s"
|
||||||
|
+ sprintf "scp%s%s %s%s:%s %s"
|
||||||
|
(if verbose () then "" else " -q")
|
||||||
|
(match port_of_uri uri with
|
||||||
|
| None -> ""
|
@ -0,0 +1,48 @@
|
|||||||
|
From 60d4a517e43f0715fb9dc4f87cbd2f5c88ab662a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Weblate Translation Memory
|
||||||
|
<noreply-mt-weblate-translation-memory@weblate.org>
|
||||||
|
Date: Mon, 15 Jan 2024 14:37:13 +0100
|
||||||
|
Subject: [PATCH] Translated using Weblate (Polish)
|
||||||
|
|
||||||
|
Currently translated at 7.2% (35 of 481 strings)
|
||||||
|
|
||||||
|
Translation: libguestfs/virt-v2v-master
|
||||||
|
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/virt-v2v-master/pl/
|
||||||
|
---
|
||||||
|
po/pl.po | 9 +++++----
|
||||||
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/po/pl.po b/po/pl.po
|
||||||
|
index d4bee25f..e3a5b11d 100644
|
||||||
|
--- a/po/pl.po
|
||||||
|
+++ b/po/pl.po
|
||||||
|
@@ -14,8 +14,9 @@ msgstr ""
|
||||||
|
"Report-Msgid-Bugs-To: https://bugzilla.redhat.com/enter_bug."
|
||||||
|
"cgi?component=libguestfs&product=Virtualization+Tools\n"
|
||||||
|
"POT-Creation-Date: 2023-11-02 11:07+0000\n"
|
||||||
|
-"PO-Revision-Date: 2023-11-26 21:01+0000\n"
|
||||||
|
-"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||||
|
+"PO-Revision-Date: 2024-01-15 13:36+0000\n"
|
||||||
|
+"Last-Translator: Weblate Translation Memory <noreply-mt-weblate-translation-"
|
||||||
|
+"memory@weblate.org>\n"
|
||||||
|
"Language-Team: Polish <https://translate.fedoraproject.org/projects/"
|
||||||
|
"libguestfs/virt-v2v-master/pl/>\n"
|
||||||
|
"Language: pl\n"
|
||||||
|
@@ -24,7 +25,7 @@ msgstr ""
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
|
||||||
|
"|| n%100>=20) ? 1 : 2;\n"
|
||||||
|
-"X-Generator: Weblate 5.2.1\n"
|
||||||
|
+"X-Generator: Weblate 5.3.1\n"
|
||||||
|
|
||||||
|
#: input/input_ova.ml:136 common/mltools/tools_utils.ml:235
|
||||||
|
msgid "%s"
|
||||||
|
@@ -735,7 +736,7 @@ msgstr ""
|
||||||
|
#. common/mlcustomize/customize_cmdline.ml:245
|
||||||
|
#: common/mlcustomize/customize_cmdline.ml:453
|
||||||
|
msgid "PATH"
|
||||||
|
-msgstr ""
|
||||||
|
+msgstr "ŚCIEŻKA"
|
||||||
|
|
||||||
|
#: common/mlcustomize/customize_cmdline.ml:191
|
||||||
|
msgid "PERMISSIONS:FILE"
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,301 @@
|
|||||||
|
From cddd07669d18a5a848f82dbde27b84ef405ef9fa Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 15 Jan 2024 14:24:35 +0000
|
||||||
|
Subject: [PATCH] virt-v2v: -i vmx: Refactor ssh/scp code into a new module
|
||||||
|
|
||||||
|
This is a straight refactor of the existing code that handles ssh/scp
|
||||||
|
into a new module. In this commit I just copy the code around without
|
||||||
|
doing any cleanup; cleanup will follow in subsequent commits.
|
||||||
|
|
||||||
|
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
||||||
|
---
|
||||||
|
input/Makefile.am | 6 ++-
|
||||||
|
input/input_vmx.ml | 8 ++--
|
||||||
|
input/parse_domain_from_vmx.ml | 60 ++-----------------------
|
||||||
|
input/parse_domain_from_vmx.mli | 6 ---
|
||||||
|
input/ssh.ml | 78 +++++++++++++++++++++++++++++++++
|
||||||
|
input/ssh.mli | 34 ++++++++++++++
|
||||||
|
6 files changed, 123 insertions(+), 69 deletions(-)
|
||||||
|
create mode 100644 input/ssh.ml
|
||||||
|
create mode 100644 input/ssh.mli
|
||||||
|
|
||||||
|
diff --git a/input/Makefile.am b/input/Makefile.am
|
||||||
|
index de016d60..4153f878 100644
|
||||||
|
--- a/input/Makefile.am
|
||||||
|
+++ b/input/Makefile.am
|
||||||
|
@@ -39,6 +39,7 @@ SOURCES_MLI = \
|
||||||
|
parse_domain_from_vmx.mli \
|
||||||
|
parse_libvirt_xml.mli \
|
||||||
|
parse_vmx.mli \
|
||||||
|
+ ssh.mli \
|
||||||
|
vCenter.mli
|
||||||
|
|
||||||
|
SOURCES_ML = \
|
||||||
|
@@ -46,11 +47,12 @@ SOURCES_ML = \
|
||||||
|
parse_libvirt_xml.ml \
|
||||||
|
OVF.ml \
|
||||||
|
OVA.ml \
|
||||||
|
- parse_vmx.ml \
|
||||||
|
- parse_domain_from_vmx.ml \
|
||||||
|
nbdkit_curl.ml \
|
||||||
|
nbdkit_ssh.ml \
|
||||||
|
nbdkit_vddk.ml \
|
||||||
|
+ ssh.ml \
|
||||||
|
+ parse_vmx.ml \
|
||||||
|
+ parse_domain_from_vmx.ml \
|
||||||
|
vCenter.ml \
|
||||||
|
input.ml \
|
||||||
|
input_disk.ml \
|
||||||
|
diff --git a/input/input_vmx.ml b/input/input_vmx.ml
|
||||||
|
index eed8a433..bd20420c 100644
|
||||||
|
--- a/input/input_vmx.ml
|
||||||
|
+++ b/input/input_vmx.ml
|
||||||
|
@@ -79,21 +79,21 @@ module VMX = struct
|
||||||
|
let socket = sprintf "%s/in%d" dir i in
|
||||||
|
On_exit.unlink socket;
|
||||||
|
|
||||||
|
- let vmx_path = path_of_uri uri in
|
||||||
|
+ let vmx_path = Ssh.path_of_uri uri in
|
||||||
|
let abs_path = absolute_path_from_other_file vmx_path filename in
|
||||||
|
let flat_vmdk = PCRE.replace (PCRE.compile "\\.vmdk$")
|
||||||
|
"-flat.vmdk" abs_path in
|
||||||
|
|
||||||
|
(* RHBZ#1774386 *)
|
||||||
|
- if not (remote_file_exists uri flat_vmdk) then
|
||||||
|
+ if not (Ssh.remote_file_exists uri flat_vmdk) then
|
||||||
|
error (f_"This transport does not support guests with snapshots. \
|
||||||
|
Either collapse the snapshots for this guest and try \
|
||||||
|
the conversion again, or use one of the alternate \
|
||||||
|
conversion methods described in \
|
||||||
|
virt-v2v-input-vmware(1) section \"NOTES\".");
|
||||||
|
|
||||||
|
- let server = server_of_uri uri in
|
||||||
|
- let port = Option.map string_of_int (port_of_uri uri) in
|
||||||
|
+ let server = Ssh.server_of_uri uri in
|
||||||
|
+ let port = Option.map string_of_int (Ssh.port_of_uri uri) in
|
||||||
|
let user = uri.Xml.uri_user in
|
||||||
|
let password =
|
||||||
|
match options.input_password with
|
||||||
|
diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml
|
||||||
|
index f24990f8..8cf5893c 100644
|
||||||
|
--- a/input/parse_domain_from_vmx.ml
|
||||||
|
+++ b/input/parse_domain_from_vmx.ml
|
||||||
|
@@ -51,61 +51,6 @@ let vmx_source_of_arg input_transport arg =
|
||||||
|
error (f_"vmx URI path component looks incorrect");
|
||||||
|
SSH uri
|
||||||
|
|
||||||
|
-(* Return various fields from the URI. The checks in vmx_source_of_arg
|
||||||
|
- * should ensure that none of these assertions fail.
|
||||||
|
- *)
|
||||||
|
-let port_of_uri { Xml.uri_port } =
|
||||||
|
- match uri_port with i when i <= 0 -> None | i -> Some i
|
||||||
|
-let server_of_uri { Xml.uri_server } =
|
||||||
|
- match uri_server with None -> assert false | Some s -> s
|
||||||
|
-let path_of_uri { Xml.uri_path } =
|
||||||
|
- match uri_path with None -> assert false | Some p -> p
|
||||||
|
-
|
||||||
|
-(* 'scp' a remote file into a temporary local file, returning the path
|
||||||
|
- * of the temporary local file.
|
||||||
|
- *)
|
||||||
|
-let scp_from_remote_to_temporary uri tmpdir filename =
|
||||||
|
- let localfile = tmpdir // filename in
|
||||||
|
-
|
||||||
|
- let cmd =
|
||||||
|
- sprintf "scp%s%s %s%s:%s %s"
|
||||||
|
- (if verbose () then "" else " -q")
|
||||||
|
- (match port_of_uri uri with
|
||||||
|
- | None -> ""
|
||||||
|
- | Some port -> sprintf " -P %d" port)
|
||||||
|
- (match uri.Xml.uri_user with
|
||||||
|
- | None -> ""
|
||||||
|
- | Some user -> quote user ^ "@")
|
||||||
|
- (quote (server_of_uri uri))
|
||||||
|
- (quote (path_of_uri uri))
|
||||||
|
- (quote localfile) in
|
||||||
|
- if verbose () then
|
||||||
|
- eprintf "%s\n%!" cmd;
|
||||||
|
- if Sys.command cmd <> 0 then
|
||||||
|
- error (f_"could not copy the VMX file from the remote server, \
|
||||||
|
- see earlier error messages");
|
||||||
|
- localfile
|
||||||
|
-
|
||||||
|
-(* Test if [path] exists on the remote server. *)
|
||||||
|
-let remote_file_exists uri path =
|
||||||
|
- let cmd =
|
||||||
|
- sprintf "ssh%s %s%s test -f %s"
|
||||||
|
- (match port_of_uri uri with
|
||||||
|
- | None -> ""
|
||||||
|
- | Some port -> sprintf " -p %d" port)
|
||||||
|
- (match uri.Xml.uri_user with
|
||||||
|
- | None -> ""
|
||||||
|
- | Some user -> quote user ^ "@")
|
||||||
|
- (quote (server_of_uri uri))
|
||||||
|
- (* Double quoting is necessary for 'ssh', first to protect
|
||||||
|
- * from the local shell, second to protect from the remote
|
||||||
|
- * shell. https://github.com/libguestfs/virt-v2v/issues/35#issuecomment-1741730963
|
||||||
|
- *)
|
||||||
|
- (quote (quote path)) in
|
||||||
|
- if verbose () then
|
||||||
|
- eprintf "%s\n%!" cmd;
|
||||||
|
- Sys.command cmd = 0
|
||||||
|
-
|
||||||
|
let rec find_disks vmx vmx_source =
|
||||||
|
(* Set the s_disk_id field to an incrementing number. *)
|
||||||
|
List.mapi
|
||||||
|
@@ -390,7 +335,8 @@ let parse_domain_from_vmx vmx_source =
|
||||||
|
match vmx_source with
|
||||||
|
| File filename -> Parse_vmx.parse_file filename
|
||||||
|
| SSH uri ->
|
||||||
|
- let filename = scp_from_remote_to_temporary uri tmpdir "source.vmx" in
|
||||||
|
+ let filename = Ssh.scp_from_remote_to_temporary uri tmpdir
|
||||||
|
+ "source.vmx" in
|
||||||
|
Parse_vmx.parse_file filename in
|
||||||
|
|
||||||
|
let name =
|
||||||
|
@@ -400,7 +346,7 @@ let parse_domain_from_vmx vmx_source =
|
||||||
|
warning (f_"no displayName key found in VMX file");
|
||||||
|
match vmx_source with
|
||||||
|
| File filename -> name_from_disk filename
|
||||||
|
- | SSH uri -> name_from_disk (path_of_uri uri) in
|
||||||
|
+ | SSH uri -> name_from_disk (Ssh.path_of_uri uri) in
|
||||||
|
|
||||||
|
let genid =
|
||||||
|
(* See: https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html *)
|
||||||
|
diff --git a/input/parse_domain_from_vmx.mli b/input/parse_domain_from_vmx.mli
|
||||||
|
index e354b32e..42f8100e 100644
|
||||||
|
--- a/input/parse_domain_from_vmx.mli
|
||||||
|
+++ b/input/parse_domain_from_vmx.mli
|
||||||
|
@@ -22,9 +22,3 @@ type vmx_source =
|
||||||
|
|
||||||
|
val vmx_source_of_arg : [`SSH] option -> string -> vmx_source
|
||||||
|
val parse_domain_from_vmx : vmx_source -> Types.source * string list
|
||||||
|
-
|
||||||
|
-(* XXX Exporting these is a hack. *)
|
||||||
|
-val path_of_uri : Xml.uri -> string
|
||||||
|
-val server_of_uri : Xml.uri -> string
|
||||||
|
-val port_of_uri : Xml.uri -> int option
|
||||||
|
-val remote_file_exists : Xml.uri -> string -> bool
|
||||||
|
diff --git a/input/ssh.ml b/input/ssh.ml
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000..5e689d29
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/input/ssh.ml
|
||||||
|
@@ -0,0 +1,78 @@
|
||||||
|
+(* virt-v2v
|
||||||
|
+ * Copyright (C) 2009-2024 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 Std_utils
|
||||||
|
+open Tools_utils
|
||||||
|
+open Common_gettext.Gettext
|
||||||
|
+
|
||||||
|
+open Printf
|
||||||
|
+
|
||||||
|
+(* Return various fields from the URI. The checks in vmx_source_of_arg
|
||||||
|
+ * should ensure that none of these assertions fail.
|
||||||
|
+ *)
|
||||||
|
+let port_of_uri { Xml.uri_port } =
|
||||||
|
+ match uri_port with i when i <= 0 -> None | i -> Some i
|
||||||
|
+let server_of_uri { Xml.uri_server } =
|
||||||
|
+ match uri_server with None -> assert false | Some s -> s
|
||||||
|
+let path_of_uri { Xml.uri_path } =
|
||||||
|
+ match uri_path with None -> assert false | Some p -> p
|
||||||
|
+
|
||||||
|
+(* 'scp' a remote file into a temporary local file, returning the path
|
||||||
|
+ * of the temporary local file.
|
||||||
|
+ *)
|
||||||
|
+let scp_from_remote_to_temporary uri tmpdir filename =
|
||||||
|
+ let localfile = tmpdir // filename in
|
||||||
|
+
|
||||||
|
+ let cmd =
|
||||||
|
+ sprintf "scp%s%s %s%s:%s %s"
|
||||||
|
+ (if verbose () then "" else " -q")
|
||||||
|
+ (match port_of_uri uri with
|
||||||
|
+ | None -> ""
|
||||||
|
+ | Some port -> sprintf " -P %d" port)
|
||||||
|
+ (match uri.Xml.uri_user with
|
||||||
|
+ | None -> ""
|
||||||
|
+ | Some user -> quote user ^ "@")
|
||||||
|
+ (quote (server_of_uri uri))
|
||||||
|
+ (quote (path_of_uri uri))
|
||||||
|
+ (quote localfile) in
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "%s\n%!" cmd;
|
||||||
|
+ if Sys.command cmd <> 0 then
|
||||||
|
+ error (f_"could not copy the VMX file from the remote server, \
|
||||||
|
+ see earlier error messages");
|
||||||
|
+ localfile
|
||||||
|
+
|
||||||
|
+(* Test if [path] exists on the remote server. *)
|
||||||
|
+let remote_file_exists uri path =
|
||||||
|
+ let cmd =
|
||||||
|
+ sprintf "ssh%s %s%s test -f %s"
|
||||||
|
+ (match port_of_uri uri with
|
||||||
|
+ | None -> ""
|
||||||
|
+ | Some port -> sprintf " -p %d" port)
|
||||||
|
+ (match uri.Xml.uri_user with
|
||||||
|
+ | None -> ""
|
||||||
|
+ | Some user -> quote user ^ "@")
|
||||||
|
+ (quote (server_of_uri uri))
|
||||||
|
+ (* Double quoting is necessary for 'ssh', first to protect
|
||||||
|
+ * from the local shell, second to protect from the remote
|
||||||
|
+ * shell. https://github.com/libguestfs/virt-v2v/issues/35#issuecomment-1741730963
|
||||||
|
+ *)
|
||||||
|
+ (quote (quote path)) in
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "%s\n%!" cmd;
|
||||||
|
+ Sys.command cmd = 0
|
||||||
|
diff --git a/input/ssh.mli b/input/ssh.mli
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000..e9a1a6a8
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/input/ssh.mli
|
||||||
|
@@ -0,0 +1,34 @@
|
||||||
|
+(* virt-v2v
|
||||||
|
+ * Copyright (C) 2009-2024 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.
|
||||||
|
+ *)
|
||||||
|
+
|
||||||
|
+(** Wrappers for finding and downloading remote files over ssh. *)
|
||||||
|
+
|
||||||
|
+val path_of_uri : Xml.uri -> string
|
||||||
|
+val server_of_uri : Xml.uri -> string
|
||||||
|
+val port_of_uri : Xml.uri -> int option
|
||||||
|
+
|
||||||
|
+(** [remote_file_exists ssh_uri path] checks that [path] exists
|
||||||
|
+ on the remote server [ssh_uri] (note any path inside [ssh_uri]
|
||||||
|
+ is ignored). *)
|
||||||
|
+val remote_file_exists : Xml.uri -> string -> bool
|
||||||
|
+
|
||||||
|
+(** [scp_from_remote_to_temporary ssh_uri tmpdir filename]
|
||||||
|
+ uses scp to copy the single remote file at [ssh_uri] to
|
||||||
|
+ the local file called [tmpdir/filename]. It returns the
|
||||||
|
+ final path [tmpdir/filename]. *)
|
||||||
|
+val scp_from_remote_to_temporary : Xml.uri -> string -> string -> string
|
@ -0,0 +1,84 @@
|
|||||||
|
From a0b22af28782a485cc2241dce55b8f435d8aaefc Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 15 Jan 2024 14:35:57 +0000
|
||||||
|
Subject: [PATCH] virt-v2v: -i vmx: Simplify scp wrapper
|
||||||
|
|
||||||
|
The existing 'scp_from_remote_to_temporary' wrapper around scp was
|
||||||
|
pretty weird (I think from much patching without refactoring).
|
||||||
|
Simplify it so it no longer generates the output filename, and rename
|
||||||
|
it accordingly to 'download_file' (as we will soon remove the need for
|
||||||
|
and dependency on 'scp').
|
||||||
|
|
||||||
|
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
||||||
|
---
|
||||||
|
input/parse_domain_from_vmx.ml | 4 ++--
|
||||||
|
input/ssh.ml | 13 ++++---------
|
||||||
|
input/ssh.mli | 7 +++----
|
||||||
|
3 files changed, 9 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml
|
||||||
|
index 8cf5893c..e6500da6 100644
|
||||||
|
--- a/input/parse_domain_from_vmx.ml
|
||||||
|
+++ b/input/parse_domain_from_vmx.ml
|
||||||
|
@@ -335,8 +335,8 @@ let parse_domain_from_vmx vmx_source =
|
||||||
|
match vmx_source with
|
||||||
|
| File filename -> Parse_vmx.parse_file filename
|
||||||
|
| SSH uri ->
|
||||||
|
- let filename = Ssh.scp_from_remote_to_temporary uri tmpdir
|
||||||
|
- "source.vmx" in
|
||||||
|
+ let filename = tmpdir // "source.vmx" in
|
||||||
|
+ Ssh.download_file uri filename;
|
||||||
|
Parse_vmx.parse_file filename in
|
||||||
|
|
||||||
|
let name =
|
||||||
|
diff --git a/input/ssh.ml b/input/ssh.ml
|
||||||
|
index 5e689d29..63ffeb12 100644
|
||||||
|
--- a/input/ssh.ml
|
||||||
|
+++ b/input/ssh.ml
|
||||||
|
@@ -32,12 +32,8 @@ let server_of_uri { Xml.uri_server } =
|
||||||
|
let path_of_uri { Xml.uri_path } =
|
||||||
|
match uri_path with None -> assert false | Some p -> p
|
||||||
|
|
||||||
|
-(* 'scp' a remote file into a temporary local file, returning the path
|
||||||
|
- * of the temporary local file.
|
||||||
|
- *)
|
||||||
|
-let scp_from_remote_to_temporary uri tmpdir filename =
|
||||||
|
- let localfile = tmpdir // filename in
|
||||||
|
-
|
||||||
|
+(* 'scp' a remote file into a local file. *)
|
||||||
|
+let download_file uri output =
|
||||||
|
let cmd =
|
||||||
|
sprintf "scp%s%s %s%s:%s %s"
|
||||||
|
(if verbose () then "" else " -q")
|
||||||
|
@@ -49,13 +45,12 @@ let scp_from_remote_to_temporary uri tmpdir filename =
|
||||||
|
| Some user -> quote user ^ "@")
|
||||||
|
(quote (server_of_uri uri))
|
||||||
|
(quote (path_of_uri uri))
|
||||||
|
- (quote localfile) in
|
||||||
|
+ (quote output) in
|
||||||
|
if verbose () then
|
||||||
|
eprintf "%s\n%!" cmd;
|
||||||
|
if Sys.command cmd <> 0 then
|
||||||
|
error (f_"could not copy the VMX file from the remote server, \
|
||||||
|
- see earlier error messages");
|
||||||
|
- localfile
|
||||||
|
+ see earlier error messages")
|
||||||
|
|
||||||
|
(* Test if [path] exists on the remote server. *)
|
||||||
|
let remote_file_exists uri path =
|
||||||
|
diff --git a/input/ssh.mli b/input/ssh.mli
|
||||||
|
index e9a1a6a8..62e78bd3 100644
|
||||||
|
--- a/input/ssh.mli
|
||||||
|
+++ b/input/ssh.mli
|
||||||
|
@@ -27,8 +27,7 @@ val port_of_uri : Xml.uri -> int option
|
||||||
|
is ignored). *)
|
||||||
|
val remote_file_exists : Xml.uri -> string -> bool
|
||||||
|
|
||||||
|
-(** [scp_from_remote_to_temporary ssh_uri tmpdir filename]
|
||||||
|
+(** [download_file ssh_uri output]
|
||||||
|
uses scp to copy the single remote file at [ssh_uri] to
|
||||||
|
- the local file called [tmpdir/filename]. It returns the
|
||||||
|
- final path [tmpdir/filename]. *)
|
||||||
|
-val scp_from_remote_to_temporary : Xml.uri -> string -> string -> string
|
||||||
|
+ the local file called [output]. *)
|
||||||
|
+val download_file : Xml.uri -> string -> unit
|
@ -0,0 +1,205 @@
|
|||||||
|
From 40730615d2f691bc72777b4cb7356e2177edc1e1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 15 Jan 2024 14:48:56 +0000
|
||||||
|
Subject: [PATCH] virt-v2v: -i vmx: Remove dependency of ssh.ml on Xml.uri
|
||||||
|
|
||||||
|
Xml.uri is a convenient way to pass the multiple ssh fields to
|
||||||
|
virt-v2v and is still used internally by the -i vmx code. However
|
||||||
|
don't leak this awkward implementation into the new ssh.ml module.
|
||||||
|
|
||||||
|
Like Nbdkit_ssh, we'll only deal with the explicit (password, port,
|
||||||
|
server, user, path) fields separately.
|
||||||
|
|
||||||
|
Note after this refactoring:
|
||||||
|
|
||||||
|
- The new Ssh module interface looks broadly similar to the
|
||||||
|
Nbdkit_ssh interface.
|
||||||
|
|
||||||
|
- vmx_source_of_arg assertions are no longer required inside the new
|
||||||
|
Ssh module, which was a mild layering violation before.
|
||||||
|
|
||||||
|
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
||||||
|
---
|
||||||
|
input/input_vmx.ml | 21 ++++++++++++++++-----
|
||||||
|
input/parse_domain_from_vmx.ml | 22 +++++++++++++++++++---
|
||||||
|
input/ssh.ml | 32 +++++++++++---------------------
|
||||||
|
input/ssh.mli | 21 ++++++++++-----------
|
||||||
|
4 files changed, 56 insertions(+), 40 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/input/input_vmx.ml b/input/input_vmx.ml
|
||||||
|
index b9cce10f..b3426fa2 100644
|
||||||
|
--- a/input/input_vmx.ml
|
||||||
|
+++ b/input/input_vmx.ml
|
||||||
|
@@ -83,22 +83,33 @@ module VMX = struct
|
||||||
|
let socket = sprintf "%s/in%d" dir i in
|
||||||
|
On_exit.unlink socket;
|
||||||
|
|
||||||
|
- let vmx_path = Ssh.path_of_uri uri in
|
||||||
|
+ let vmx_path =
|
||||||
|
+ match uri.uri_path with
|
||||||
|
+ | None -> assert false (* checked by vmx_source_of_arg *)
|
||||||
|
+ | Some path -> path in
|
||||||
|
let abs_path = absolute_path_from_other_file vmx_path filename in
|
||||||
|
let flat_vmdk = PCRE.replace (PCRE.compile "\\.vmdk$")
|
||||||
|
"-flat.vmdk" abs_path in
|
||||||
|
|
||||||
|
+ let server =
|
||||||
|
+ match uri.uri_server with
|
||||||
|
+ | None -> assert false (* checked by vmx_source_of_arg *)
|
||||||
|
+ | Some server -> server in
|
||||||
|
+ let port =
|
||||||
|
+ match uri.uri_port with
|
||||||
|
+ | i when i <= 0 -> None
|
||||||
|
+ | i -> Some (string_of_int i) in
|
||||||
|
+ let user = uri.Xml.uri_user in
|
||||||
|
+
|
||||||
|
(* RHBZ#1774386 *)
|
||||||
|
- if not (Ssh.remote_file_exists uri flat_vmdk) then
|
||||||
|
+ if not (Ssh.remote_file_exists ~password ?port ~server ?user
|
||||||
|
+ flat_vmdk) then
|
||||||
|
error (f_"This transport does not support guests with snapshots. \
|
||||||
|
Either collapse the snapshots for this guest and try \
|
||||||
|
the conversion again, or use one of the alternate \
|
||||||
|
conversion methods described in \
|
||||||
|
virt-v2v-input-vmware(1) section \"NOTES\".");
|
||||||
|
|
||||||
|
- let server = Ssh.server_of_uri uri in
|
||||||
|
- let port = Option.map string_of_int (Ssh.port_of_uri uri) in
|
||||||
|
- let user = uri.Xml.uri_user in
|
||||||
|
let cor = dir // "convert" in
|
||||||
|
let bandwidth = options.bandwidth in
|
||||||
|
let nbdkit = Nbdkit_ssh.create_ssh ?bandwidth ~cor ~password
|
||||||
|
diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml
|
||||||
|
index 0719738c..99c86b1a 100644
|
||||||
|
--- a/input/parse_domain_from_vmx.ml
|
||||||
|
+++ b/input/parse_domain_from_vmx.ml
|
||||||
|
@@ -334,9 +334,22 @@ let parse_domain_from_vmx vmx_source =
|
||||||
|
let vmx =
|
||||||
|
match vmx_source with
|
||||||
|
| File filename -> Parse_vmx.parse_file filename
|
||||||
|
- | SSH (_, uri) ->
|
||||||
|
+ | SSH (password, uri) ->
|
||||||
|
+ let server =
|
||||||
|
+ match uri.uri_server with
|
||||||
|
+ | None -> assert false (* checked by vmx_source_of_arg *)
|
||||||
|
+ | Some server -> server in
|
||||||
|
+ let port =
|
||||||
|
+ match uri.uri_port with
|
||||||
|
+ | i when i <= 0 -> None
|
||||||
|
+ | i -> Some (string_of_int i) in
|
||||||
|
+ let user = uri.Xml.uri_user in
|
||||||
|
+ let path =
|
||||||
|
+ match uri.uri_path with
|
||||||
|
+ | None -> assert false (* checked by vmx_source_of_arg *)
|
||||||
|
+ | Some path -> path in
|
||||||
|
let filename = tmpdir // "source.vmx" in
|
||||||
|
- Ssh.download_file uri filename;
|
||||||
|
+ Ssh.download_file ~password ?port ~server ?user path filename;
|
||||||
|
Parse_vmx.parse_file filename in
|
||||||
|
|
||||||
|
let name =
|
||||||
|
@@ -346,7 +359,10 @@ let parse_domain_from_vmx vmx_source =
|
||||||
|
warning (f_"no displayName key found in VMX file");
|
||||||
|
match vmx_source with
|
||||||
|
| File filename -> name_from_disk filename
|
||||||
|
- | SSH (_, uri) -> name_from_disk (Ssh.path_of_uri uri) in
|
||||||
|
+ | SSH (_, uri) ->
|
||||||
|
+ match uri.uri_path with
|
||||||
|
+ | None -> assert false (* checked by vmx_source_of_arg *)
|
||||||
|
+ | Some path -> name_from_disk path in
|
||||||
|
|
||||||
|
let genid =
|
||||||
|
(* See: https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html *)
|
||||||
|
diff --git a/input/ssh.ml b/input/ssh.ml
|
||||||
|
index 63ffeb12..127e818c 100644
|
||||||
|
--- a/input/ssh.ml
|
||||||
|
+++ b/input/ssh.ml
|
||||||
|
@@ -22,29 +22,19 @@ open Common_gettext.Gettext
|
||||||
|
|
||||||
|
open Printf
|
||||||
|
|
||||||
|
-(* Return various fields from the URI. The checks in vmx_source_of_arg
|
||||||
|
- * should ensure that none of these assertions fail.
|
||||||
|
- *)
|
||||||
|
-let port_of_uri { Xml.uri_port } =
|
||||||
|
- match uri_port with i when i <= 0 -> None | i -> Some i
|
||||||
|
-let server_of_uri { Xml.uri_server } =
|
||||||
|
- match uri_server with None -> assert false | Some s -> s
|
||||||
|
-let path_of_uri { Xml.uri_path } =
|
||||||
|
- match uri_path with None -> assert false | Some p -> p
|
||||||
|
-
|
||||||
|
(* 'scp' a remote file into a local file. *)
|
||||||
|
-let download_file uri output =
|
||||||
|
+let download_file ~password:_ ?port ~server ?user path output =
|
||||||
|
let cmd =
|
||||||
|
sprintf "scp%s%s %s%s:%s %s"
|
||||||
|
(if verbose () then "" else " -q")
|
||||||
|
- (match port_of_uri uri with
|
||||||
|
+ (match port with
|
||||||
|
| None -> ""
|
||||||
|
- | Some port -> sprintf " -P %d" port)
|
||||||
|
- (match uri.Xml.uri_user with
|
||||||
|
+ | Some port -> sprintf " -P %s" port)
|
||||||
|
+ (match user with
|
||||||
|
| None -> ""
|
||||||
|
| Some user -> quote user ^ "@")
|
||||||
|
- (quote (server_of_uri uri))
|
||||||
|
- (quote (path_of_uri uri))
|
||||||
|
+ (quote server)
|
||||||
|
+ (quote path)
|
||||||
|
(quote output) in
|
||||||
|
if verbose () then
|
||||||
|
eprintf "%s\n%!" cmd;
|
||||||
|
@@ -53,16 +43,16 @@ let download_file uri output =
|
||||||
|
see earlier error messages")
|
||||||
|
|
||||||
|
(* Test if [path] exists on the remote server. *)
|
||||||
|
-let remote_file_exists uri path =
|
||||||
|
+let remote_file_exists ~password:_ ?port ~server ?user path =
|
||||||
|
let cmd =
|
||||||
|
sprintf "ssh%s %s%s test -f %s"
|
||||||
|
- (match port_of_uri uri with
|
||||||
|
+ (match port with
|
||||||
|
| None -> ""
|
||||||
|
- | Some port -> sprintf " -p %d" port)
|
||||||
|
- (match uri.Xml.uri_user with
|
||||||
|
+ | Some port -> sprintf " -p %s" port)
|
||||||
|
+ (match user with
|
||||||
|
| None -> ""
|
||||||
|
| Some user -> quote user ^ "@")
|
||||||
|
- (quote (server_of_uri uri))
|
||||||
|
+ (quote server)
|
||||||
|
(* Double quoting is necessary for 'ssh', first to protect
|
||||||
|
* from the local shell, second to protect from the remote
|
||||||
|
* shell. https://github.com/libguestfs/virt-v2v/issues/35#issuecomment-1741730963
|
||||||
|
diff --git a/input/ssh.mli b/input/ssh.mli
|
||||||
|
index 62e78bd3..1f39cd1b 100644
|
||||||
|
--- a/input/ssh.mli
|
||||||
|
+++ b/input/ssh.mli
|
||||||
|
@@ -18,16 +18,15 @@
|
||||||
|
|
||||||
|
(** Wrappers for finding and downloading remote files over ssh. *)
|
||||||
|
|
||||||
|
-val path_of_uri : Xml.uri -> string
|
||||||
|
-val server_of_uri : Xml.uri -> string
|
||||||
|
-val port_of_uri : Xml.uri -> int option
|
||||||
|
+(** [remote_file_exists password ?port server ?user path]
|
||||||
|
+ checks that [path] exists on the remote server. *)
|
||||||
|
+val remote_file_exists : password:Nbdkit_ssh.password ->
|
||||||
|
+ ?port:string -> server:string -> ?user:string ->
|
||||||
|
+ string -> bool
|
||||||
|
|
||||||
|
-(** [remote_file_exists ssh_uri path] checks that [path] exists
|
||||||
|
- on the remote server [ssh_uri] (note any path inside [ssh_uri]
|
||||||
|
- is ignored). *)
|
||||||
|
-val remote_file_exists : Xml.uri -> string -> bool
|
||||||
|
-
|
||||||
|
-(** [download_file ssh_uri output]
|
||||||
|
- uses scp to copy the single remote file at [ssh_uri] to
|
||||||
|
+(** [download_file password ?port server ?user path output]
|
||||||
|
+ uses scp to copy the single remote file at [path] to
|
||||||
|
the local file called [output]. *)
|
||||||
|
-val download_file : Xml.uri -> string -> unit
|
||||||
|
+val download_file : password:Nbdkit_ssh.password ->
|
||||||
|
+ ?port:string -> server:string -> ?user:string -> string ->
|
||||||
|
+ string -> unit
|
@ -0,0 +1,55 @@
|
|||||||
|
From 72c9734050f0235c80ff7d685282a57836a70bd5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 15 Jan 2024 16:21:34 +0000
|
||||||
|
Subject: [PATCH] input/nbdkit_ssh: Make retry filter optional
|
||||||
|
|
||||||
|
This filter retries a request on failure. Add a flag to make this
|
||||||
|
filter optional, but default to using it if available (so there's no
|
||||||
|
change to default behaviour).
|
||||||
|
|
||||||
|
The reason we want to make this optional is that the next commit will
|
||||||
|
want to use nbdkit-ssh-plugin to probe to see if a remote file is
|
||||||
|
present, and we don't want to retry that probe on failure.
|
||||||
|
|
||||||
|
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
||||||
|
---
|
||||||
|
input/nbdkit_ssh.ml | 6 ++++--
|
||||||
|
input/nbdkit_ssh.mli | 1 +
|
||||||
|
2 files changed, 5 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/input/nbdkit_ssh.ml b/input/nbdkit_ssh.ml
|
||||||
|
index 3f6da9b6..3b72d3ad 100644
|
||||||
|
--- a/input/nbdkit_ssh.ml
|
||||||
|
+++ b/input/nbdkit_ssh.ml
|
||||||
|
@@ -44,7 +44,8 @@ let error_unless_nbdkit_min_version config =
|
||||||
|
error_unless_nbdkit_version_ge config nbdkit_min_version
|
||||||
|
|
||||||
|
(* Create an nbdkit module specialized for reading from SSH sources. *)
|
||||||
|
-let create_ssh ?bandwidth ?cor ~password ?port ~server ?user path =
|
||||||
|
+let create_ssh ?bandwidth ?cor ?(retry=true)
|
||||||
|
+ ~password ?port ~server ?user path =
|
||||||
|
if not (Nbdkit.is_installed ()) then
|
||||||
|
error (f_"nbdkit is not installed or not working");
|
||||||
|
|
||||||
|
@@ -67,7 +68,8 @@ let create_ssh ?bandwidth ?cor ~password ?port ~server ?user path =
|
||||||
|
(* Retry filter (if it exists) can be used to get around brief
|
||||||
|
* interruptions in service. It must be closest to the plugin.
|
||||||
|
*)
|
||||||
|
- Nbdkit.add_filter_if_available cmd "retry";
|
||||||
|
+ if retry then
|
||||||
|
+ Nbdkit.add_filter_if_available cmd "retry";
|
||||||
|
|
||||||
|
(* Caching extents speeds up qemu-img, especially its consecutive
|
||||||
|
* block_status requests with req_one=1.
|
||||||
|
diff --git a/input/nbdkit_ssh.mli b/input/nbdkit_ssh.mli
|
||||||
|
index bc798c5a..daa20bb2 100644
|
||||||
|
--- a/input/nbdkit_ssh.mli
|
||||||
|
+++ b/input/nbdkit_ssh.mli
|
||||||
|
@@ -25,6 +25,7 @@ type password =
|
||||||
|
|
||||||
|
val create_ssh : ?bandwidth:Types.bandwidth ->
|
||||||
|
?cor:string ->
|
||||||
|
+ ?retry:bool ->
|
||||||
|
password:password ->
|
||||||
|
?port:string ->
|
||||||
|
server:string ->
|
@ -0,0 +1,167 @@
|
|||||||
|
From fb72e059863a60503b6011b8590c25c3a010a58f Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 15 Jan 2024 15:38:30 +0000
|
||||||
|
Subject: [PATCH] virt-v2v: -i vmx: Replace external ssh/scp with
|
||||||
|
nbdkit-ssh-plugin
|
||||||
|
|
||||||
|
If you use a -i vmx ssh filename containing '*' then it will expand
|
||||||
|
the glob at the remote side. New scp is weird and silently creates a
|
||||||
|
directory on the local side. For example suppose there's a remote
|
||||||
|
file literally called "/tmp/test*" (ie. the '*' is part of the
|
||||||
|
filename) and you thought you could copy that to local using:
|
||||||
|
|
||||||
|
scp 'remote:/tmp/test*' '/tmp/test*'
|
||||||
|
|
||||||
|
scp treats the first parameter (only) as a wildcard and if there are
|
||||||
|
multiple files matching the wildcard /tmp/test*, will create a local
|
||||||
|
directory literally called "/tmp/test*/" and put the files into it.
|
||||||
|
Who expected any of that?
|
||||||
|
|
||||||
|
You might think that double quoting (as we used to use) might work,
|
||||||
|
but that breaks with spaces and quotes. I guess scp is using
|
||||||
|
different code paths internally for glob versus everything else.
|
||||||
|
|
||||||
|
The only way to really make this work is to stop using scp entirely
|
||||||
|
and just use sftp directly. The easiest way to use sftp is to use
|
||||||
|
nbdkit-ssh-plugin. We already depend on nbdkit-ssh-plugin, nbdcopy
|
||||||
|
and nbdinfo for other parts of virt-v2v, so might as well use the
|
||||||
|
whole lot here.
|
||||||
|
|
||||||
|
One advantage of this change is that now the -ip (input password)
|
||||||
|
parameter actually works in -i vmx -it ssh mode.
|
||||||
|
|
||||||
|
Other approaches that would have been possible:
|
||||||
|
|
||||||
|
- Use the OCaml NBD library instead of nbdcopy/nbdinfo
|
||||||
|
|
||||||
|
- Use 'nbdkit -U - ssh --run ...'
|
||||||
|
|
||||||
|
- Direct binding to libssh.
|
||||||
|
|
||||||
|
See also commit e2af12ba69c4463bb73d30db63290a887cdd41eb
|
||||||
|
("input: -i vmx: Remove support for openssh scp < 8.8")
|
||||||
|
|
||||||
|
See also commit 22c5b98ab78c734b478c26e14ee62e2a065aaa0c
|
||||||
|
("-it ssh: Double quote ssh command which tests remote file exists")
|
||||||
|
|
||||||
|
See also https://unix.stackexchange.com/a/587710
|
||||||
|
|
||||||
|
Reported-by: Ming Xie
|
||||||
|
Fixes: https://issues.redhat.com/browse/RHEL-21365
|
||||||
|
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
||||||
|
---
|
||||||
|
input/ssh.ml | 70 +++++++++++++++++++++++++--------------------------
|
||||||
|
input/ssh.mli | 7 ++++--
|
||||||
|
2 files changed, 40 insertions(+), 37 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/input/ssh.ml b/input/ssh.ml
|
||||||
|
index 127e818c..71ebbf2a 100644
|
||||||
|
--- a/input/ssh.ml
|
||||||
|
+++ b/input/ssh.ml
|
||||||
|
@@ -18,46 +18,46 @@
|
||||||
|
|
||||||
|
open Std_utils
|
||||||
|
open Tools_utils
|
||||||
|
+open Unix_utils
|
||||||
|
open Common_gettext.Gettext
|
||||||
|
|
||||||
|
open Printf
|
||||||
|
|
||||||
|
-(* 'scp' a remote file into a local file. *)
|
||||||
|
-let download_file ~password:_ ?port ~server ?user path output =
|
||||||
|
- let cmd =
|
||||||
|
- sprintf "scp%s%s %s%s:%s %s"
|
||||||
|
- (if verbose () then "" else " -q")
|
||||||
|
- (match port with
|
||||||
|
- | None -> ""
|
||||||
|
- | Some port -> sprintf " -P %s" port)
|
||||||
|
- (match user with
|
||||||
|
- | None -> ""
|
||||||
|
- | Some user -> quote user ^ "@")
|
||||||
|
- (quote server)
|
||||||
|
- (quote path)
|
||||||
|
- (quote output) in
|
||||||
|
- if verbose () then
|
||||||
|
- eprintf "%s\n%!" cmd;
|
||||||
|
- if Sys.command cmd <> 0 then
|
||||||
|
+let start_nbdkit ~password ?port ~server ?user path =
|
||||||
|
+ (* Create a random location for the socket used to talk to nbdkit. *)
|
||||||
|
+ let sockdir = Mkdtemp.temp_dir "v2vssh." in
|
||||||
|
+ On_exit.rm_rf sockdir;
|
||||||
|
+ let id = unique () in
|
||||||
|
+ let socket = sockdir // sprintf "nbdkit%d.sock" id in
|
||||||
|
+
|
||||||
|
+ (* Note: Disabling the retry filter helps in the missing file case,
|
||||||
|
+ * otherwise nbdkit takes ages to time out. We're not expecting that
|
||||||
|
+ * the VMX file is large, so using this filter isn't necessary.
|
||||||
|
+ *)
|
||||||
|
+ let nbdkit =
|
||||||
|
+ Nbdkit_ssh.create_ssh ~retry:false ~password ~server ?port ?user path in
|
||||||
|
+ Nbdkit.set_readonly nbdkit true;
|
||||||
|
+ let _, pid = Nbdkit.run_unix socket nbdkit in
|
||||||
|
+ On_exit.kill pid;
|
||||||
|
+
|
||||||
|
+ (* Return the URI of nbdkit. *)
|
||||||
|
+ "nbd+unix://?socket=" ^ socket
|
||||||
|
+
|
||||||
|
+(* Download a remote file into a local file. *)
|
||||||
|
+let download_file ~password ?port ~server ?user path output =
|
||||||
|
+ let uri = start_nbdkit ~password ?port ~server ?user path in
|
||||||
|
+
|
||||||
|
+ let cmd = [ "nbdcopy"; uri; output ] in
|
||||||
|
+ if run_command cmd <> 0 then
|
||||||
|
error (f_"could not copy the VMX file from the remote server, \
|
||||||
|
see earlier error messages")
|
||||||
|
|
||||||
|
(* Test if [path] exists on the remote server. *)
|
||||||
|
-let remote_file_exists ~password:_ ?port ~server ?user path =
|
||||||
|
- let cmd =
|
||||||
|
- sprintf "ssh%s %s%s test -f %s"
|
||||||
|
- (match port with
|
||||||
|
- | None -> ""
|
||||||
|
- | Some port -> sprintf " -p %s" port)
|
||||||
|
- (match user with
|
||||||
|
- | None -> ""
|
||||||
|
- | Some user -> quote user ^ "@")
|
||||||
|
- (quote server)
|
||||||
|
- (* Double quoting is necessary for 'ssh', first to protect
|
||||||
|
- * from the local shell, second to protect from the remote
|
||||||
|
- * shell. https://github.com/libguestfs/virt-v2v/issues/35#issuecomment-1741730963
|
||||||
|
- *)
|
||||||
|
- (quote (quote path)) in
|
||||||
|
- if verbose () then
|
||||||
|
- eprintf "%s\n%!" cmd;
|
||||||
|
- Sys.command cmd = 0
|
||||||
|
+let remote_file_exists ~password ?port ~server ?user path =
|
||||||
|
+ let uri = start_nbdkit ~password ?port ~server ?user path in
|
||||||
|
+
|
||||||
|
+ (* Testing for remote size using nbdinfo should be sufficient to
|
||||||
|
+ * prove the remote file exists.
|
||||||
|
+ *)
|
||||||
|
+ let cmd = [ "nbdinfo"; "--size"; uri ] in
|
||||||
|
+ run_command cmd = 0
|
||||||
|
diff --git a/input/ssh.mli b/input/ssh.mli
|
||||||
|
index 1f39cd1b..40843024 100644
|
||||||
|
--- a/input/ssh.mli
|
||||||
|
+++ b/input/ssh.mli
|
||||||
|
@@ -16,7 +16,10 @@
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*)
|
||||||
|
|
||||||
|
-(** Wrappers for finding and downloading remote files over ssh. *)
|
||||||
|
+(** Wrappers for finding and downloading remote files over ssh.
|
||||||
|
+
|
||||||
|
+ Internally this uses nbdkit-ssh-plugin (which uses sftp) as
|
||||||
|
+ that is much more predictable than running external ssh / scp. *)
|
||||||
|
|
||||||
|
(** [remote_file_exists password ?port server ?user path]
|
||||||
|
checks that [path] exists on the remote server. *)
|
||||||
|
@@ -25,7 +28,7 @@ val remote_file_exists : password:Nbdkit_ssh.password ->
|
||||||
|
string -> bool
|
||||||
|
|
||||||
|
(** [download_file password ?port server ?user path output]
|
||||||
|
- uses scp to copy the single remote file at [path] to
|
||||||
|
+ downloads the single remote file at [path] to
|
||||||
|
the local file called [output]. *)
|
||||||
|
val download_file : password:Nbdkit_ssh.password ->
|
||||||
|
?port:string -> server:string -> ?user:string -> string ->
|
@ -0,0 +1,104 @@
|
|||||||
|
From 4f0758a95a4b32a5c837cf86d2fa4442d3e136ec Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Tue, 16 Jan 2024 10:31:50 +0000
|
||||||
|
Subject: [PATCH] input/ssh: Rearrange parameters specifying ssh server
|
||||||
|
|
||||||
|
---
|
||||||
|
input/nbdkit_ssh.ml | 2 +-
|
||||||
|
input/nbdkit_ssh.mli | 4 ++--
|
||||||
|
input/ssh.ml | 10 +++++-----
|
||||||
|
input/ssh.mli | 13 +++++++------
|
||||||
|
4 files changed, 15 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/input/nbdkit_ssh.ml b/input/nbdkit_ssh.ml
|
||||||
|
index bc96df13..ae93e4e8 100644
|
||||||
|
--- a/input/nbdkit_ssh.ml
|
||||||
|
+++ b/input/nbdkit_ssh.ml
|
||||||
|
@@ -44,7 +44,7 @@ let error_unless_nbdkit_min_version config =
|
||||||
|
|
||||||
|
(* Create an nbdkit module specialized for reading from SSH sources. *)
|
||||||
|
let create_ssh ?bandwidth ?cor ?(retry=true)
|
||||||
|
- ?password ?port ~server ?user path =
|
||||||
|
+ ~server ?port ?user ?password path =
|
||||||
|
if not (Nbdkit.is_installed ()) then
|
||||||
|
error (f_"nbdkit is not installed or not working");
|
||||||
|
|
||||||
|
diff --git a/input/nbdkit_ssh.mli b/input/nbdkit_ssh.mli
|
||||||
|
index 8ea8dea4..c26f539a 100644
|
||||||
|
--- a/input/nbdkit_ssh.mli
|
||||||
|
+++ b/input/nbdkit_ssh.mli
|
||||||
|
@@ -25,10 +25,10 @@ type password = (** Use [None] for no password *)
|
||||||
|
val create_ssh : ?bandwidth:Types.bandwidth ->
|
||||||
|
?cor:string ->
|
||||||
|
?retry:bool ->
|
||||||
|
- ?password:password ->
|
||||||
|
- ?port:string ->
|
||||||
|
server:string ->
|
||||||
|
+ ?port:string ->
|
||||||
|
?user:string ->
|
||||||
|
+ ?password:password ->
|
||||||
|
string -> Nbdkit.cmd
|
||||||
|
(** Create a nbdkit object using the SSH plugin. The required
|
||||||
|
string parameter is the remote path.
|
||||||
|
diff --git a/input/ssh.ml b/input/ssh.ml
|
||||||
|
index 10c61bbf..d3b6dc0c 100644
|
||||||
|
--- a/input/ssh.ml
|
||||||
|
+++ b/input/ssh.ml
|
||||||
|
@@ -23,7 +23,7 @@ open Common_gettext.Gettext
|
||||||
|
|
||||||
|
open Printf
|
||||||
|
|
||||||
|
-let start_nbdkit ?password ?port ~server ?user path =
|
||||||
|
+let start_nbdkit ~server ?port ?user ?password path =
|
||||||
|
(* Create a random location for the socket used to talk to nbdkit. *)
|
||||||
|
let sockdir = Mkdtemp.temp_dir "v2vssh." in
|
||||||
|
On_exit.rm_rf sockdir;
|
||||||
|
@@ -44,8 +44,8 @@ let start_nbdkit ?password ?port ~server ?user path =
|
||||||
|
"nbd+unix://?socket=" ^ socket
|
||||||
|
|
||||||
|
(* Download a remote file into a local file. *)
|
||||||
|
-let download_file ?password ?port ~server ?user path output =
|
||||||
|
- let uri = start_nbdkit ?password ?port ~server ?user path in
|
||||||
|
+let download_file ~server ?port ?user ?password path output =
|
||||||
|
+ let uri = start_nbdkit ~server ?port ?user ?password path in
|
||||||
|
|
||||||
|
let cmd = [ "nbdcopy"; uri; output ] in
|
||||||
|
if run_command cmd <> 0 then
|
||||||
|
@@ -53,8 +53,8 @@ let download_file ?password ?port ~server ?user path output =
|
||||||
|
see earlier error messages")
|
||||||
|
|
||||||
|
(* Test if [path] exists on the remote server. *)
|
||||||
|
-let remote_file_exists ?password ?port ~server ?user path =
|
||||||
|
- let uri = start_nbdkit ?password ?port ~server ?user path in
|
||||||
|
+let remote_file_exists ~server ?port ?user ?password path =
|
||||||
|
+ let uri = start_nbdkit ~server ?port ?user ?password path in
|
||||||
|
|
||||||
|
(* Testing for remote size using nbdinfo should be sufficient to
|
||||||
|
* prove the remote file exists.
|
||||||
|
diff --git a/input/ssh.mli b/input/ssh.mli
|
||||||
|
index 6d9f1370..ebce46ff 100644
|
||||||
|
--- a/input/ssh.mli
|
||||||
|
+++ b/input/ssh.mli
|
||||||
|
@@ -21,15 +21,16 @@
|
||||||
|
Internally this uses nbdkit-ssh-plugin (which uses sftp) as
|
||||||
|
that is much more predictable than running external ssh / scp. *)
|
||||||
|
|
||||||
|
-(** [remote_file_exists ?password ?port server ?user path]
|
||||||
|
+(** [remote_file_exists server ?port ?user ?password path]
|
||||||
|
checks that [path] exists on the remote server. *)
|
||||||
|
-val remote_file_exists : ?password:Nbdkit_ssh.password ->
|
||||||
|
- ?port:string -> server:string -> ?user:string ->
|
||||||
|
+val remote_file_exists : server:string -> ?port:string ->
|
||||||
|
+ ?user:string -> ?password:Nbdkit_ssh.password ->
|
||||||
|
string -> bool
|
||||||
|
|
||||||
|
-(** [download_file ?password ?port server ?user path output]
|
||||||
|
+(** [download_file server ?port ?user ?password path output]
|
||||||
|
downloads the single remote file at [path] to
|
||||||
|
the local file called [output]. *)
|
||||||
|
-val download_file : ?password:Nbdkit_ssh.password ->
|
||||||
|
- ?port:string -> server:string -> ?user:string -> string ->
|
||||||
|
+val download_file : server:string -> ?port:string ->
|
||||||
|
+ ?user:string -> ?password:Nbdkit_ssh.password ->
|
||||||
|
+ string ->
|
||||||
|
string -> unit
|
@ -0,0 +1,54 @@
|
|||||||
|
From 67fcf66904c7f1f6da858eba35e95dad670427c0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Wed, 17 Jan 2024 14:16:10 +0000
|
||||||
|
Subject: [PATCH] docs: Remove paragraph about -ip passwords and ssh/scp
|
||||||
|
|
||||||
|
The documentation suggested (correctly) that the -ip option did not
|
||||||
|
cover all cases where we make an ssh connection to either VMware or
|
||||||
|
Xen. However with the recent change where we use nbdkit-ssh-plugin in
|
||||||
|
preference to ssh/scp (commit fb72e05986, "virt-v2v: -i vmx: Replace
|
||||||
|
external ssh/scp with nbdkit-ssh-plugin") this should no longer be
|
||||||
|
true for VMware. And I don't think it was true for Xen for a while.
|
||||||
|
|
||||||
|
Therefore remove this paragraph in the documentation (in two places).
|
||||||
|
|
||||||
|
See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1854275
|
||||||
|
See-also: https://lists.libguestfs.org/archives/list/guestfs@lists.libguestfs.org/thread/CKBEYJHUZWLDUUDWAJM2JU6QIKZGTD6F/
|
||||||
|
Suggested-by: Laszlo Ersek
|
||||||
|
---
|
||||||
|
docs/virt-v2v-input-vmware.pod | 5 -----
|
||||||
|
docs/virt-v2v-input-xen.pod | 5 -----
|
||||||
|
2 files changed, 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/docs/virt-v2v-input-vmware.pod b/docs/virt-v2v-input-vmware.pod
|
||||||
|
index 48849f88..fe59222a 100644
|
||||||
|
--- a/docs/virt-v2v-input-vmware.pod
|
||||||
|
+++ b/docs/virt-v2v-input-vmware.pod
|
||||||
|
@@ -155,11 +155,6 @@ virt-v2v server to the ESXi hypervisor. For example:
|
||||||
|
$ ssh root@esxi.example.com
|
||||||
|
[ logs straight into the shell, no password is requested ]
|
||||||
|
|
||||||
|
-Note that support for non-interactive authentication via the I<-ip>
|
||||||
|
-option is incomplete. Some operations remain that still require the
|
||||||
|
-user to enter the password manually. Therefore ssh-agent is recommended
|
||||||
|
-over the I<-ip> option. See L<https://bugzilla.redhat.com/1854275>.
|
||||||
|
-
|
||||||
|
=head3 VMX: Construct the SSH URI
|
||||||
|
|
||||||
|
When using the SSH input transport you must specify a remote
|
||||||
|
diff --git a/docs/virt-v2v-input-xen.pod b/docs/virt-v2v-input-xen.pod
|
||||||
|
index 4a0544f8..38dc8f7b 100644
|
||||||
|
--- a/docs/virt-v2v-input-xen.pod
|
||||||
|
+++ b/docs/virt-v2v-input-xen.pod
|
||||||
|
@@ -32,11 +32,6 @@ server to the Xen host. For example:
|
||||||
|
$ ssh root@xen.example.com
|
||||||
|
[ logs straight into the shell, no password is requested ]
|
||||||
|
|
||||||
|
-Note that support for non-interactive authentication via the I<-ip>
|
||||||
|
-option is incomplete. Some operations remain that still require the
|
||||||
|
-user to enter the password manually. Therefore ssh-agent is recommended
|
||||||
|
-over the I<-ip> option. See L<https://bugzilla.redhat.com/1854275>.
|
||||||
|
-
|
||||||
|
With some modern ssh implementations, legacy crypto algorithms required
|
||||||
|
to interoperate with RHEL 5 sshd are disabled. To enable them, you may
|
||||||
|
need to add the following C<Host> stanza to your F<~/.ssh/config>:
|
@ -1,60 +0,0 @@
|
|||||||
From 6dea82d823c344af0277bb35de789828cfd3e413 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
||||||
Date: Sat, 22 Apr 2023 09:06:01 +0100
|
|
||||||
Subject: [PATCH] Update common submodule
|
|
||||||
|
|
||||||
Richard W.M. Jones (1):
|
|
||||||
mlcustomize/SELinux_relabel.ml: Use Array.mem
|
|
||||||
|
|
||||||
Roman Kagan (1):
|
|
||||||
mlcustomize: skip SELinux relabeling if it's disabled
|
|
||||||
|
|
||||||
(cherry picked from commit e83de8abe6c5388585885cef28d7a198b7bfc90c)
|
|
||||||
---
|
|
||||||
common | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
Submodule common 70c10a07..38e6988c:
|
|
||||||
diff --git a/common/mlcustomize/SELinux_relabel.ml b/common/mlcustomize/SELinux_relabel.ml
|
|
||||||
index 5ecf7bd7..2f3a09bf 100644
|
|
||||||
--- a/common/mlcustomize/SELinux_relabel.ml
|
|
||||||
+++ b/common/mlcustomize/SELinux_relabel.ml
|
|
||||||
@@ -24,10 +24,6 @@ open Printf
|
|
||||||
|
|
||||||
module G = Guestfs
|
|
||||||
|
|
||||||
-(* Simple reimplementation of Array.mem, available only with OCaml >= 4.03. *)
|
|
||||||
-let array_find a l =
|
|
||||||
- List.mem a (Array.to_list l)
|
|
||||||
-
|
|
||||||
let rec relabel (g : G.guestfs) =
|
|
||||||
(* Is the guest using SELinux? (Otherwise this is a no-op). *)
|
|
||||||
if is_selinux_guest g then (
|
|
||||||
@@ -59,14 +55,24 @@ and use_setfiles g =
|
|
||||||
g#aug_load ();
|
|
||||||
debug_augeas_errors g;
|
|
||||||
|
|
||||||
+ let config_path = "/files/etc/selinux/config" in
|
|
||||||
+ let config_keys = g#aug_ls config_path in
|
|
||||||
+ (* SELinux may be disabled via a setting in config file *)
|
|
||||||
+ let selinux_disabled =
|
|
||||||
+ let selinuxmode_path = config_path ^ "/SELINUX" in
|
|
||||||
+ if Array.mem selinuxmode_path config_keys then
|
|
||||||
+ g#aug_get selinuxmode_path = "disabled"
|
|
||||||
+ else
|
|
||||||
+ false in
|
|
||||||
+ if selinux_disabled then
|
|
||||||
+ failwith "selinux disabled";
|
|
||||||
+
|
|
||||||
(* Get the SELinux policy name, eg. "targeted", "minimum".
|
|
||||||
* Use "targeted" if not specified, just like libselinux does.
|
|
||||||
*)
|
|
||||||
let policy =
|
|
||||||
- let config_path = "/files/etc/selinux/config" in
|
|
||||||
let selinuxtype_path = config_path ^ "/SELINUXTYPE" in
|
|
||||||
- let keys = g#aug_ls config_path in
|
|
||||||
- if array_find selinuxtype_path keys then
|
|
||||||
+ if Array.mem selinuxtype_path config_keys then
|
|
||||||
g#aug_get selinuxtype_path
|
|
||||||
else
|
|
||||||
"targeted" in
|
|
@ -0,0 +1,62 @@
|
|||||||
|
From 970d7123c2025bc148870f4bc6fa75fa9e95905f Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 18 Jan 2024 17:22:26 +0000
|
||||||
|
Subject: [PATCH] input/ssh: Use nbdinfo --can connect (instead of --size)
|
||||||
|
|
||||||
|
nbdinfo --size prints the size on stdout, causing it to appear in
|
||||||
|
virt-v2v output. Using --can connect instead is silent.
|
||||||
|
|
||||||
|
Note that nbdinfo --can connect was added in libnbd 1.9.2 (Jul 2021)
|
||||||
|
and our previous minimum version of libnbd was 1.9.3 so we're OK.
|
||||||
|
However since neither of these was a stable version I also updated the
|
||||||
|
minimum libnbd requirement to 1.10 (Sep 2021), and added a proper
|
||||||
|
check in ./configure
|
||||||
|
|
||||||
|
Fixes: commit fb72e059863a60503b6011b8590c25c3a010a58f
|
||||||
|
---
|
||||||
|
README | 2 +-
|
||||||
|
input/ssh.ml | 4 ++--
|
||||||
|
m4/guestfs-libraries.m4 | 2 +-
|
||||||
|
3 files changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/README b/README
|
||||||
|
index 5810f77d..f94bd6de 100644
|
||||||
|
--- a/README
|
||||||
|
+++ b/README
|
||||||
|
@@ -51,7 +51,7 @@ REQUIREMENTS
|
||||||
|
|
||||||
|
* OCaml bindings for libvirt (https://gitlab.com/libvirt/libvirt-ocaml)
|
||||||
|
|
||||||
|
-* libnbd >= 1.9.3 (https://gitlab.com/nbdkit/libnbd)
|
||||||
|
+* libnbd >= 1.10 (https://gitlab.com/nbdkit/libnbd)
|
||||||
|
|
||||||
|
* OCaml bindings for libnbd
|
||||||
|
|
||||||
|
diff --git a/input/ssh.ml b/input/ssh.ml
|
||||||
|
index d3b6dc0c..e35a2b5a 100644
|
||||||
|
--- a/input/ssh.ml
|
||||||
|
+++ b/input/ssh.ml
|
||||||
|
@@ -56,8 +56,8 @@ let download_file ~server ?port ?user ?password path output =
|
||||||
|
let remote_file_exists ~server ?port ?user ?password path =
|
||||||
|
let uri = start_nbdkit ~server ?port ?user ?password path in
|
||||||
|
|
||||||
|
- (* Testing for remote size using nbdinfo should be sufficient to
|
||||||
|
+ (* Testing that we can connect to the nbdkit server is enough to
|
||||||
|
* prove the remote file exists.
|
||||||
|
*)
|
||||||
|
- let cmd = [ "nbdinfo"; "--size"; uri ] in
|
||||||
|
+ let cmd = [ "nbdinfo"; "--can"; "connect"; uri ] in
|
||||||
|
run_command cmd = 0
|
||||||
|
diff --git a/m4/guestfs-libraries.m4 b/m4/guestfs-libraries.m4
|
||||||
|
index 33b5100e..6789a2cb 100644
|
||||||
|
--- a/m4/guestfs-libraries.m4
|
||||||
|
+++ b/m4/guestfs-libraries.m4
|
||||||
|
@@ -21,7 +21,7 @@ dnl Of course we need libguestfs.
|
||||||
|
PKG_CHECK_MODULES([LIBGUESTFS], [libguestfs >= 1.44])
|
||||||
|
|
||||||
|
dnl And libnbd.
|
||||||
|
-PKG_CHECK_MODULES([LIBNBD], [libnbd])
|
||||||
|
+PKG_CHECK_MODULES([LIBNBD], [libnbd >= 1.10])
|
||||||
|
|
||||||
|
dnl Test if it's GNU or XSI strerror_r.
|
||||||
|
AC_FUNC_STRERROR_R
|
@ -0,0 +1,43 @@
|
|||||||
|
From aafcd0d11453d8d58a32e66285f12ec3ba3440de Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 18 Jan 2024 17:32:01 +0000
|
||||||
|
Subject: [PATCH] build: Document that nbdinfo and nbdcopy are required, and
|
||||||
|
check
|
||||||
|
|
||||||
|
Update README to document that these tools have been needed (ever
|
||||||
|
since virt-v2v 2.0), and update ./configure to check it.
|
||||||
|
---
|
||||||
|
README | 2 ++
|
||||||
|
m4/guestfs-progs.m4 | 6 ++++++
|
||||||
|
2 files changed, 8 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/README b/README
|
||||||
|
index f94bd6de..4354754f 100644
|
||||||
|
--- a/README
|
||||||
|
+++ b/README
|
||||||
|
@@ -53,6 +53,8 @@ REQUIREMENTS
|
||||||
|
|
||||||
|
* libnbd >= 1.10 (https://gitlab.com/nbdkit/libnbd)
|
||||||
|
|
||||||
|
+* The 'nbdinfo' and 'nbdcopy' programs from libnbd.
|
||||||
|
+
|
||||||
|
* OCaml bindings for libnbd
|
||||||
|
|
||||||
|
* nbdkit >= 1.27.4 (https://gitlab.com/nbdkit/nbdkit)
|
||||||
|
diff --git a/m4/guestfs-progs.m4 b/m4/guestfs-progs.m4
|
||||||
|
index 7c5f0d81..ae5094ce 100644
|
||||||
|
--- a/m4/guestfs-progs.m4
|
||||||
|
+++ b/m4/guestfs-progs.m4
|
||||||
|
@@ -59,6 +59,12 @@ AM_CONDITIONAL([HAVE_ZIP],[test "x$ZIP" != "xno"])
|
||||||
|
AC_PATH_PROGS([UNZIP],[unzip],[no])
|
||||||
|
AC_DEFINE_UNQUOTED([UNZIP],["$UNZIP"],[Name of unzip program.])
|
||||||
|
|
||||||
|
+dnl nbdinfo, nbdcopy, required by virt-v2v
|
||||||
|
+AC_CHECK_PROG([NBDINFO], [nbdinfo], [nbdinfo], [no])
|
||||||
|
+AC_CHECK_PROG([NBDCOPY], [nbdcopy], [nbdcopy], [no])
|
||||||
|
+AS_IF([test "x$NBDINFO" = "xno" || test "x$NBDCOPY" = "xno"],
|
||||||
|
+ [AC_MSG_ERROR([nbdinfo and nbdcopy (from libnbd) must be installed])])
|
||||||
|
+
|
||||||
|
dnl Check for valgrind
|
||||||
|
AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[no])
|
||||||
|
AS_IF([test "x$VALGRIND" != "xno"],[
|
@ -1,152 +0,0 @@
|
|||||||
From 1d69132b7b7209dbf231a4668b3a6531a6f9cdf3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Fri, 19 May 2023 11:34:18 +0200
|
|
||||||
Subject: [PATCH] update common submodule
|
|
||||||
|
|
||||||
Laszlo Ersek (2):
|
|
||||||
options/keys: key_store_import_key(): un-constify "key" parameter
|
|
||||||
options/keys: introduce unescape_device_mapper_lvm()
|
|
||||||
|
|
||||||
https://bugzilla.redhat.com/show_bug.cgi?id=2168506
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
(cherry picked from commit b0dbe7c7728579d6c2128c733491755eee1a91b5)
|
|
||||||
---
|
|
||||||
common | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
Submodule common 38e6988c..b636c3f2:
|
|
||||||
diff --git a/common/options/options.h b/common/options/options.h
|
|
||||||
index 94573ee0..94e8b9ee 100644
|
|
||||||
--- a/common/options/options.h
|
|
||||||
+++ b/common/options/options.h
|
|
||||||
@@ -169,7 +169,8 @@ extern struct matching_key *get_keys (struct key_store *ks, const char *device,
|
|
||||||
const char *uuid, size_t *nr_matches);
|
|
||||||
extern void free_keys (struct matching_key *keys, size_t nr_matches);
|
|
||||||
extern struct key_store *key_store_add_from_selector (struct key_store *ks, const char *selector);
|
|
||||||
-extern struct key_store *key_store_import_key (struct key_store *ks, const struct key_store_key *key);
|
|
||||||
+extern struct key_store *key_store_import_key (struct key_store *ks,
|
|
||||||
+ struct key_store_key *key);
|
|
||||||
extern bool key_store_requires_network (const struct key_store *ks);
|
|
||||||
extern void free_key_store (struct key_store *ks);
|
|
||||||
|
|
||||||
diff --git a/common/options/keys.c b/common/options/keys.c
|
|
||||||
index 48f1bc7c..52b27369 100644
|
|
||||||
--- a/common/options/keys.c
|
|
||||||
+++ b/common/options/keys.c
|
|
||||||
@@ -260,8 +260,107 @@ key_store_add_from_selector (struct key_store *ks, const char *selector)
|
|
||||||
return key_store_import_key (ks, &key);
|
|
||||||
}
|
|
||||||
|
|
||||||
+/* Turn /dev/mapper/VG-LV into /dev/VG/LV, in-place. */
|
|
||||||
+static void
|
|
||||||
+unescape_device_mapper_lvm (char *id)
|
|
||||||
+{
|
|
||||||
+ static const char dev[] = "/dev/", dev_mapper[] = "/dev/mapper/";
|
|
||||||
+ const char *input_start;
|
|
||||||
+ char *output;
|
|
||||||
+ enum { M_SCAN, M_FILL, M_DONE } mode;
|
|
||||||
+
|
|
||||||
+ if (!STRPREFIX (id, dev_mapper))
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ /* Start parsing "VG-LV" from "id" after "/dev/mapper/". */
|
|
||||||
+ input_start = id + (sizeof dev_mapper - 1);
|
|
||||||
+
|
|
||||||
+ /* Start writing the unescaped "VG/LV" output after "/dev/". */
|
|
||||||
+ output = id + (sizeof dev - 1);
|
|
||||||
+
|
|
||||||
+ for (mode = M_SCAN; mode < M_DONE; ++mode) {
|
|
||||||
+ char c;
|
|
||||||
+ const char *input = input_start;
|
|
||||||
+ const char *hyphen_buffered = NULL;
|
|
||||||
+ bool single_hyphen_seen = false;
|
|
||||||
+
|
|
||||||
+ do {
|
|
||||||
+ c = *input;
|
|
||||||
+
|
|
||||||
+ switch (c) {
|
|
||||||
+ case '-':
|
|
||||||
+ if (hyphen_buffered == NULL)
|
|
||||||
+ /* This hyphen may start an escaped hyphen, or it could be the
|
|
||||||
+ * separator in VG-LV.
|
|
||||||
+ */
|
|
||||||
+ hyphen_buffered = input;
|
|
||||||
+ else {
|
|
||||||
+ /* This hyphen completes an escaped hyphen; unescape it. */
|
|
||||||
+ if (mode == M_FILL)
|
|
||||||
+ *output++ = '-';
|
|
||||||
+ hyphen_buffered = NULL;
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ case '/':
|
|
||||||
+ /* Slash characters are forbidden in VG-LV anywhere. If there's any,
|
|
||||||
+ * we'll find it in the first (i.e., scanning) phase, before we output
|
|
||||||
+ * anything back to "id".
|
|
||||||
+ */
|
|
||||||
+ assert (mode == M_SCAN);
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ default:
|
|
||||||
+ /* Encountered a non-slash, non-hyphen character -- which also may be
|
|
||||||
+ * the terminating NUL.
|
|
||||||
+ */
|
|
||||||
+ if (hyphen_buffered != NULL) {
|
|
||||||
+ /* The non-hyphen character comes after a buffered hyphen, so the
|
|
||||||
+ * buffered hyphen is supposed to be the single hyphen that separates
|
|
||||||
+ * VG from LV in VG-LV. There are three requirements for this
|
|
||||||
+ * separator: (a) it must be unique (we must not have seen another
|
|
||||||
+ * such separator earlier), (b) it must not be at the start of VG-LV
|
|
||||||
+ * (because VG would be empty that way), (c) it must not be at the end
|
|
||||||
+ * of VG-LV (because LV would be empty that way). Should any of these
|
|
||||||
+ * be violated, we'll catch that during the first (i.e., scanning)
|
|
||||||
+ * phase, before modifying "id".
|
|
||||||
+ */
|
|
||||||
+ if (single_hyphen_seen || hyphen_buffered == input_start ||
|
|
||||||
+ c == '\0') {
|
|
||||||
+ assert (mode == M_SCAN);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* Translate the separator hyphen to a slash character. */
|
|
||||||
+ if (mode == M_FILL)
|
|
||||||
+ *output++ = '/';
|
|
||||||
+ hyphen_buffered = NULL;
|
|
||||||
+ single_hyphen_seen = true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* Output the non-hyphen character (including the terminating NUL)
|
|
||||||
+ * regardless of whether there was a buffered hyphen separator (which,
|
|
||||||
+ * by now, we'll have attempted to translate and flush).
|
|
||||||
+ */
|
|
||||||
+ if (mode == M_FILL)
|
|
||||||
+ *output++ = c;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ ++input;
|
|
||||||
+ } while (c != '\0');
|
|
||||||
+
|
|
||||||
+ /* We must have seen the VG-LV separator. If that's not the case, we'll
|
|
||||||
+ * catch it before modifying "id".
|
|
||||||
+ */
|
|
||||||
+ if (!single_hyphen_seen) {
|
|
||||||
+ assert (mode == M_SCAN);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
struct key_store *
|
|
||||||
-key_store_import_key (struct key_store *ks, const struct key_store_key *key)
|
|
||||||
+key_store_import_key (struct key_store *ks, struct key_store_key *key)
|
|
||||||
{
|
|
||||||
struct key_store_key *new_keys;
|
|
||||||
|
|
||||||
@@ -278,6 +377,7 @@ key_store_import_key (struct key_store *ks, const struct key_store_key *key)
|
|
||||||
error (EXIT_FAILURE, errno, "realloc");
|
|
||||||
|
|
||||||
ks->keys = new_keys;
|
|
||||||
+ unescape_device_mapper_lvm (key->id);
|
|
||||||
ks->keys[ks->nr_keys] = *key;
|
|
||||||
++ks->nr_keys;
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
|||||||
From 2558084d081c3dd9b0d681f3cf6789b48485cb62 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Mon, 15 May 2023 19:55:28 +0200
|
|
||||||
Subject: [PATCH] LUKS-on-LVM conversion test: rename VGs and LVs
|
|
||||||
|
|
||||||
In preparation for a subsequent patch, rename "VG" to "Volume-Group", and
|
|
||||||
"LV<n>" to "Logical-Volume-<n>", in the LUKS-on-LVM conversion test.
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20230515175529.290724-2-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 0ecbe09c09cace1fe0d03cad3ac53000bfeb3cb6)
|
|
||||||
---
|
|
||||||
test-data/phony-guests/make-fedora-img.pl | 30 +++++++++++--------
|
|
||||||
.../test-v2v-fedora-luks-on-lvm-conversion.sh | 8 ++---
|
|
||||||
2 files changed, 21 insertions(+), 17 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/test-data/phony-guests/make-fedora-img.pl b/test-data/phony-guests/make-fedora-img.pl
|
|
||||||
index c30c0b53..830accfc 100755
|
|
||||||
--- a/test-data/phony-guests/make-fedora-img.pl
|
|
||||||
+++ b/test-data/phony-guests/make-fedora-img.pl
|
|
||||||
@@ -224,23 +224,27 @@ EOF
|
|
||||||
|
|
||||||
# Create the Volume Group on /dev/sda2.
|
|
||||||
$g->pvcreate ('/dev/sda2');
|
|
||||||
- $g->vgcreate ('VG', ['/dev/sda2']);
|
|
||||||
- $g->lvcreate ('Root', 'VG', 256);
|
|
||||||
- $g->lvcreate ('LV1', 'VG', 32);
|
|
||||||
- $g->lvcreate ('LV2', 'VG', 32);
|
|
||||||
- $g->lvcreate ('LV3', 'VG', 64);
|
|
||||||
+ $g->vgcreate ('Volume-Group', ['/dev/sda2']);
|
|
||||||
+ $g->lvcreate ('Root', 'Volume-Group', 256);
|
|
||||||
+ $g->lvcreate ('Logical-Volume-1', 'Volume-Group', 32);
|
|
||||||
+ $g->lvcreate ('Logical-Volume-2', 'Volume-Group', 32);
|
|
||||||
+ $g->lvcreate ('Logical-Volume-3', 'Volume-Group', 64);
|
|
||||||
|
|
||||||
# Format each Logical Group as a LUKS device, with a different password.
|
|
||||||
- $g->luks_format ('/dev/VG/Root', 'FEDORA-Root', 0);
|
|
||||||
- $g->luks_format ('/dev/VG/LV1', 'FEDORA-LV1', 0);
|
|
||||||
- $g->luks_format ('/dev/VG/LV2', 'FEDORA-LV2', 0);
|
|
||||||
- $g->luks_format ('/dev/VG/LV3', 'FEDORA-LV3', 0);
|
|
||||||
+ $g->luks_format ('/dev/Volume-Group/Root', 'FEDORA-Root', 0);
|
|
||||||
+ $g->luks_format ('/dev/Volume-Group/Logical-Volume-1', 'FEDORA-LV1', 0);
|
|
||||||
+ $g->luks_format ('/dev/Volume-Group/Logical-Volume-2', 'FEDORA-LV2', 0);
|
|
||||||
+ $g->luks_format ('/dev/Volume-Group/Logical-Volume-3', 'FEDORA-LV3', 0);
|
|
||||||
|
|
||||||
# Open the LUKS devices. This creates nodes like /dev/mapper/*-luks.
|
|
||||||
- $g->cryptsetup_open ('/dev/VG/Root', 'FEDORA-Root', 'Root-luks');
|
|
||||||
- $g->cryptsetup_open ('/dev/VG/LV1', 'FEDORA-LV1', 'LV1-luks');
|
|
||||||
- $g->cryptsetup_open ('/dev/VG/LV2', 'FEDORA-LV2', 'LV2-luks');
|
|
||||||
- $g->cryptsetup_open ('/dev/VG/LV3', 'FEDORA-LV3', 'LV3-luks');
|
|
||||||
+ $g->cryptsetup_open ('/dev/Volume-Group/Root',
|
|
||||||
+ 'FEDORA-Root', 'Root-luks');
|
|
||||||
+ $g->cryptsetup_open ('/dev/Volume-Group/Logical-Volume-1',
|
|
||||||
+ 'FEDORA-LV1', 'LV1-luks');
|
|
||||||
+ $g->cryptsetup_open ('/dev/Volume-Group/Logical-Volume-2',
|
|
||||||
+ 'FEDORA-LV2', 'LV2-luks');
|
|
||||||
+ $g->cryptsetup_open ('/dev/Volume-Group/Logical-Volume-3',
|
|
||||||
+ 'FEDORA-LV3', 'LV3-luks');
|
|
||||||
|
|
||||||
# Phony root filesystem.
|
|
||||||
$g->mkfs ('ext2', '/dev/mapper/Root-luks', blocksize => 4096, label => 'ROOT');
|
|
||||||
diff --git a/tests/test-v2v-fedora-luks-on-lvm-conversion.sh b/tests/test-v2v-fedora-luks-on-lvm-conversion.sh
|
|
||||||
index 1a4068cf..7ad17e0d 100755
|
|
||||||
--- a/tests/test-v2v-fedora-luks-on-lvm-conversion.sh
|
|
||||||
+++ b/tests/test-v2v-fedora-luks-on-lvm-conversion.sh
|
|
||||||
@@ -28,9 +28,9 @@ skip_if_skipped
|
|
||||||
f=../test-data/phony-guests/fedora-luks-on-lvm.img
|
|
||||||
requires test -f $f
|
|
||||||
|
|
||||||
-keys=(--key /dev/VG/Root:key:FEDORA-Root
|
|
||||||
- --key /dev/VG/LV1:key:FEDORA-LV1
|
|
||||||
- --key /dev/VG/LV2:key:FEDORA-LV2
|
|
||||||
- --key /dev/VG/LV3:key:FEDORA-LV3)
|
|
||||||
+keys=(--key /dev/Volume-Group/Root:key:FEDORA-Root
|
|
||||||
+ --key /dev/Volume-Group/Logical-Volume-1:key:FEDORA-LV1
|
|
||||||
+ --key /dev/Volume-Group/Logical-Volume-2:key:FEDORA-LV2
|
|
||||||
+ --key /dev/Volume-Group/Logical-Volume-3:key:FEDORA-LV3)
|
|
||||||
|
|
||||||
$VG virt-v2v --debug-gc -i disk $f -o null "${keys[@]}"
|
|
@ -1,34 +0,0 @@
|
|||||||
From c8902c551014bc0163122d9fd2005d97d3cb38a5 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Mon, 15 May 2023 19:55:29 +0200
|
|
||||||
Subject: [PATCH] LUKS-on-LVM conversion test: test /dev/mapper/VG-LV
|
|
||||||
translation
|
|
||||||
|
|
||||||
In the LUKS-on-LVM conversion test, repeat the null conversion with such
|
|
||||||
"--key" options that exercise the recent "/dev/mapper/VG-LV" ->
|
|
||||||
"/dev/VG/LV" translation (unescaping) from libguestfs-common.
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20230515175529.290724-3-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 3060af01e87fbffe1cb413938c3c5431f2242bd4)
|
|
||||||
---
|
|
||||||
tests/test-v2v-fedora-luks-on-lvm-conversion.sh | 7 +++++++
|
|
||||||
1 file changed, 7 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/tests/test-v2v-fedora-luks-on-lvm-conversion.sh b/tests/test-v2v-fedora-luks-on-lvm-conversion.sh
|
|
||||||
index 7ad17e0d..605b19fb 100755
|
|
||||||
--- a/tests/test-v2v-fedora-luks-on-lvm-conversion.sh
|
|
||||||
+++ b/tests/test-v2v-fedora-luks-on-lvm-conversion.sh
|
|
||||||
@@ -34,3 +34,10 @@ keys=(--key /dev/Volume-Group/Root:key:FEDORA-Root
|
|
||||||
--key /dev/Volume-Group/Logical-Volume-3:key:FEDORA-LV3)
|
|
||||||
|
|
||||||
$VG virt-v2v --debug-gc -i disk $f -o null "${keys[@]}"
|
|
||||||
+
|
|
||||||
+keys=(--key /dev/mapper/Volume--Group-Root:key:FEDORA-Root
|
|
||||||
+ --key /dev/mapper/Volume--Group-Logical--Volume--1:key:FEDORA-LV1
|
|
||||||
+ --key /dev/mapper/Volume--Group-Logical--Volume--2:key:FEDORA-LV2
|
|
||||||
+ --key /dev/mapper/Volume--Group-Logical--Volume--3:key:FEDORA-LV3)
|
|
||||||
+
|
|
||||||
+$VG virt-v2v --debug-gc -i disk $f -o null "${keys[@]}"
|
|
@ -1,63 +0,0 @@
|
|||||||
From 10192f8ee3a7900e76d5c9a0fb330eb5ff1fe22c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Mon, 19 Jun 2023 18:27:29 +0200
|
|
||||||
Subject: [PATCH] test-data/phony-guests: fix prerequisite list of
|
|
||||||
"fedora-luks-on-lvm.img"
|
|
||||||
|
|
||||||
In the virt-v2v repo, commit 1e75569aa074 ("test-data/phony-guests: Allow
|
|
||||||
virt-v2v to work against phony Fedora") is an ancestor of commit
|
|
||||||
e4efe4b7d240 ("tests: add LUKS-on-LVM test"). The latter created a state
|
|
||||||
where "fedora-static-bin" and LUKS on LVM testing would coexist (i.e.,
|
|
||||||
where "fedora-static-bin" would be uploaded to the LUKS-on-LVM disk image
|
|
||||||
as well), but the commit didn't spell out the dependency in
|
|
||||||
"test-data/phony-guests/Makefile.am".
|
|
||||||
|
|
||||||
Do that now.
|
|
||||||
|
|
||||||
The problem can be triggered with:
|
|
||||||
|
|
||||||
> autoreconf -i
|
|
||||||
> ./configure
|
|
||||||
> make
|
|
||||||
> make -C test-data/phony-guests fedora-luks-on-lvm.img
|
|
||||||
|
|
||||||
where the last command fails with
|
|
||||||
|
|
||||||
> make: Entering directory '.../test-data/phony-guests'
|
|
||||||
> SRCDIR=. LAYOUT=luks-on-lvm ../../run --test ./make-fedora-img.pl
|
|
||||||
> open: fedora-static-bin: No such file or directory at
|
|
||||||
> .../test-data/phony-guests/make-fedora-img.pl line 373.
|
|
||||||
|
|
||||||
(In the guestfs-tools repo, the relative order (the descendancy) between
|
|
||||||
both commits is the opposite. There, commit 27da4b0c4991 ("inspector: add
|
|
||||||
LUKS-on-LVM test") came first, and commit eb0ff1859eb6
|
|
||||||
("test-data/phony-guests: Allow virt-v2v to work against phony Fedora"),
|
|
||||||
came second. The latter commit, in fact being a port of virt-v2v commit
|
|
||||||
1e75569aa074, brought together "fedora-static-bin" with "LUKS on LVM"
|
|
||||||
testing, and it correctly added "fedora-static-bin" as a pre-requisite
|
|
||||||
for building "fedora-luks-on-lvm.img".)
|
|
||||||
|
|
||||||
Fixes: e4efe4b7d240b66b1d53fbe5a127f4f5966f6903
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20230619162729.153334-1-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 13a6f4b9686e3fc385663bffc31c08d2c2bb7959)
|
|
||||||
---
|
|
||||||
test-data/phony-guests/Makefile.am | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/test-data/phony-guests/Makefile.am b/test-data/phony-guests/Makefile.am
|
|
||||||
index 29dbd4d0..10c0241b 100644
|
|
||||||
--- a/test-data/phony-guests/Makefile.am
|
|
||||||
+++ b/test-data/phony-guests/Makefile.am
|
|
||||||
@@ -103,7 +103,8 @@ fedora-btrfs.img: make-fedora-img.pl \
|
|
||||||
# Make a (dummy) Fedora image with LUKS-on-LVM.
|
|
||||||
fedora-luks-on-lvm.img: make-fedora-img.pl \
|
|
||||||
fedora-journal.tar.xz \
|
|
||||||
- fedora.db
|
|
||||||
+ fedora.db \
|
|
||||||
+ fedora-static-bin
|
|
||||||
SRCDIR=$(srcdir) LAYOUT=luks-on-lvm $(top_builddir)/run --test ./$<
|
|
||||||
|
|
||||||
# Make a (dummy) Fedora image with LVM-on-LUKS.
|
|
@ -1,4 +1,4 @@
|
|||||||
From c0bb624a151be3291e0c10c1002577615b98e74c Mon Sep 17 00:00:00 2001
|
From 7374efa8aecb97a83a1ec6d4d606651a4eb569e4 Mon Sep 17 00:00:00 2001
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
Date: Sun, 30 Aug 2015 03:21:57 -0400
|
Date: Sun, 30 Aug 2015 03:21:57 -0400
|
||||||
Subject: [PATCH] RHEL: Fixes for libguestfs-winsupport.
|
Subject: [PATCH] RHEL: Fixes for libguestfs-winsupport.
|
@ -1,30 +0,0 @@
|
|||||||
From 7a370cc7fcf4ba664eef73d4bac03dfc4d7041b3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Thu, 29 Jun 2023 14:34:41 +0200
|
|
||||||
Subject: [PATCH] lib/utils: fix typo
|
|
||||||
|
|
||||||
Fix a small comment typo from commit 4e7f20684373 ("lib: Improve security
|
|
||||||
of in/out sockets when running virt-v2v as root", 2022-03-23).
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2182024
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20230629123443.188350-2-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit dab9629c01915efc3678885e8bb0ccc5da1802a3)
|
|
||||||
---
|
|
||||||
lib/utils.mli | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/lib/utils.mli b/lib/utils.mli
|
|
||||||
index 5687bf75..cf88a467 100644
|
|
||||||
--- a/lib/utils.mli
|
|
||||||
+++ b/lib/utils.mli
|
|
||||||
@@ -62,7 +62,7 @@ val backend_is_libvirt : unit -> bool
|
|
||||||
(** Return true iff the current backend is libvirt. *)
|
|
||||||
|
|
||||||
val chown_for_libvirt_rhbz_1045069 : string -> unit
|
|
||||||
-(** If running and root, and if the backend is libvirt, libvirt
|
|
||||||
+(** If running as root, and if the backend is libvirt, libvirt
|
|
||||||
will run qemu as a non-root user. This prevents access
|
|
||||||
to root-owned files and directories. To fix this, provide
|
|
||||||
a function to chown things we might need to qemu:root so
|
|
@ -1,4 +1,4 @@
|
|||||||
From eaf5279f486590d24843ff63c9f95af33abffe39 Mon Sep 17 00:00:00 2001
|
From 8b2bb3c153b44634fb3f93aae1c0c40655213506 Mon Sep 17 00:00:00 2001
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
Date: Thu, 2 Mar 2017 14:21:37 +0100
|
Date: Thu, 2 Mar 2017 14:21:37 +0100
|
||||||
Subject: [PATCH] RHEL: v2v: -i disk: force VNC as display (RHBZ#1372671)
|
Subject: [PATCH] RHEL: v2v: -i disk: force VNC as display (RHBZ#1372671)
|
@ -1,96 +0,0 @@
|
|||||||
From 522a927257cfa55ac87775165be23779e00076bb Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Thu, 29 Jun 2023 14:34:42 +0200
|
|
||||||
Subject: [PATCH] lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
|
|
||||||
|
|
||||||
Currently "chown_for_libvirt_rhbz_1045069" is best effort; if it fails, we
|
|
||||||
suppress the exception (we log it in verbose mode only, even).
|
|
||||||
|
|
||||||
That's not proved helpful: it almost certainly leads to later errors, but
|
|
||||||
those errors are less clear than the original (suppressed) exception.
|
|
||||||
Namely, the user sees something like
|
|
||||||
|
|
||||||
> Failed to connect to '/tmp/v2v.sKlulY/in0': Permission denied
|
|
||||||
|
|
||||||
rather than
|
|
||||||
|
|
||||||
> Failed to connect socket to '/var/run/libvirt/virtqemud-sock-ro':
|
|
||||||
> Connection refused
|
|
||||||
|
|
||||||
So just allow the exception to propagate outwards.
|
|
||||||
|
|
||||||
And then, now that "chown_for_libvirt_rhbz_1045069" will be able to fail,
|
|
||||||
hoist the call to "On_exit.rm_rf" before the call to
|
|
||||||
"chown_for_libvirt_rhbz_1045069", after creating the v2v temporary
|
|
||||||
directory. In the current order, if "chown_for_libvirt_rhbz_1045069" threw
|
|
||||||
an exception, then we'd leak the temp dir in the filesystem.
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2182024
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20230629123443.188350-3-lersek@redhat.com>
|
|
||||||
[lersek@redhat.com: reinstate parens under "then" [Rich]]
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 8bcf383510a3d9deaa9b4c069a45c1604c9d5f53)
|
|
||||||
---
|
|
||||||
lib/utils.ml | 23 +++++++++--------------
|
|
||||||
lib/utils.mli | 5 +----
|
|
||||||
2 files changed, 10 insertions(+), 18 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/lib/utils.ml b/lib/utils.ml
|
|
||||||
index 54431307..7b3aa2e2 100644
|
|
||||||
--- a/lib/utils.ml
|
|
||||||
+++ b/lib/utils.ml
|
|
||||||
@@ -151,19 +151,14 @@ let backend_is_libvirt () =
|
|
||||||
let rec chown_for_libvirt_rhbz_1045069 file =
|
|
||||||
let running_as_root = Unix.geteuid () = 0 in
|
|
||||||
if running_as_root && backend_is_libvirt () then (
|
|
||||||
- try
|
|
||||||
- let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in
|
|
||||||
- let uid =
|
|
||||||
- if String.is_prefix user "+" then
|
|
||||||
- int_of_string (String.sub user 1 (String.length user - 1))
|
|
||||||
- else
|
|
||||||
- (Unix.getpwnam user).pw_uid in
|
|
||||||
- debug "setting owner of %s to %d:root" file uid;
|
|
||||||
- Unix.chown file uid 0
|
|
||||||
- with
|
|
||||||
- | exn -> (* Print exception, but continue. *)
|
|
||||||
- debug "could not set owner of %s: %s"
|
|
||||||
- file (Printexc.to_string exn)
|
|
||||||
+ let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in
|
|
||||||
+ let uid =
|
|
||||||
+ if String.is_prefix user "+" then
|
|
||||||
+ int_of_string (String.sub user 1 (String.length user - 1))
|
|
||||||
+ else
|
|
||||||
+ (Unix.getpwnam user).pw_uid in
|
|
||||||
+ debug "setting owner of %s to %d:root" file uid;
|
|
||||||
+ Unix.chown file uid 0
|
|
||||||
)
|
|
||||||
|
|
||||||
(* Get the local user that libvirt uses to run qemu when we are
|
|
||||||
@@ -206,8 +201,8 @@ let error_if_no_ssh_agent () =
|
|
||||||
(* Create the directory containing inX and outX sockets. *)
|
|
||||||
let create_v2v_directory () =
|
|
||||||
let d = Mkdtemp.temp_dir "v2v." in
|
|
||||||
- chown_for_libvirt_rhbz_1045069 d;
|
|
||||||
On_exit.rm_rf d;
|
|
||||||
+ chown_for_libvirt_rhbz_1045069 d;
|
|
||||||
d
|
|
||||||
|
|
||||||
(* Wait for a file to appear until a timeout. *)
|
|
||||||
diff --git a/lib/utils.mli b/lib/utils.mli
|
|
||||||
index cf88a467..391a2a35 100644
|
|
||||||
--- a/lib/utils.mli
|
|
||||||
+++ b/lib/utils.mli
|
|
||||||
@@ -67,10 +67,7 @@ val chown_for_libvirt_rhbz_1045069 : string -> unit
|
|
||||||
to root-owned files and directories. To fix this, provide
|
|
||||||
a function to chown things we might need to qemu:root so
|
|
||||||
qemu can access them. Note that root normally ignores
|
|
||||||
- permissions so can still access the resource.
|
|
||||||
-
|
|
||||||
- This is best-effort. If something fails then we carry
|
|
||||||
- on and hope for the best. *)
|
|
||||||
+ permissions so can still access the resource. *)
|
|
||||||
|
|
||||||
val error_if_no_ssh_agent : unit -> unit
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
|||||||
From f2e233b9e073327b1881ef17695380bc02a51f68 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Thu, 29 Jun 2023 14:34:43 +0200
|
|
||||||
Subject: [PATCH] docs/virt-v2v: document libvirt system instance startup
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
It has frequently tripped us up that on RHEL / Fedora, installing the
|
|
||||||
right set of libvirt RPMs (such as the one pulled in by
|
|
||||||
"libvirt-daemon-kvm") does not result in an immediately running libvirt
|
|
||||||
system instance. Document the need, and the simplest method, for starting
|
|
||||||
libvirt up manually.
|
|
||||||
|
|
||||||
Thanks: Daniel Berrangé
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2182024
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20230629123443.188350-4-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit dcfea1b9b5d0f237f49c9eb870af93527093b40b)
|
|
||||||
---
|
|
||||||
docs/virt-v2v.pod | 23 ++++++++++++++++++++++-
|
|
||||||
1 file changed, 22 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
|
|
||||||
index 0394b421..058eb800 100644
|
|
||||||
--- a/docs/virt-v2v.pod
|
|
||||||
+++ b/docs/virt-v2v.pod
|
|
||||||
@@ -237,6 +237,8 @@ In this mode you have to specify a libvirt guest name or UUID on the
|
|
||||||
command line. You may also specify a libvirt connection URI (see
|
|
||||||
I<-ic>).
|
|
||||||
|
|
||||||
+See L</Starting the libvirt system instance> below.
|
|
||||||
+
|
|
||||||
=item B<-i> B<libvirtxml>
|
|
||||||
|
|
||||||
Set the input method to I<libvirtxml>.
|
|
||||||
@@ -440,7 +442,8 @@ Set the output method to I<libvirt>. This is the default.
|
|
||||||
In this mode, the converted guest is created as a libvirt guest. You
|
|
||||||
may also specify a libvirt connection URI (see I<-oc>).
|
|
||||||
|
|
||||||
-See L<virt-v2v-output-local(1)>.
|
|
||||||
+See L</Starting the libvirt system instance> below, and
|
|
||||||
+L<virt-v2v-output-local(1)>.
|
|
||||||
|
|
||||||
=item B<-o> B<local>
|
|
||||||
|
|
||||||
@@ -1335,6 +1338,8 @@ see L<http://libvirt.org/auth.html>. Alternatively, use
|
|
||||||
I<-oc qemu:///session>, which will write to your per-user libvirt
|
|
||||||
instance.
|
|
||||||
|
|
||||||
+See also L</Starting the libvirt system instance>.
|
|
||||||
+
|
|
||||||
=item Writing to Openstack
|
|
||||||
|
|
||||||
Because of how Cinder volumes are presented as F</dev> block devices,
|
|
||||||
@@ -1476,6 +1481,22 @@ option at all. The option was added when virt-v2v was rewritten in 2014.
|
|
||||||
It is possible to specify a format string for controlling the output;
|
|
||||||
see L<guestfs(3)/ADVANCED MACHINE READABLE OUTPUT>.
|
|
||||||
|
|
||||||
+=head2 Starting the libvirt system instance
|
|
||||||
+
|
|
||||||
+ Failed to connect socket to '/var/run/libvirt/virtqemud-sock': No such file or directory
|
|
||||||
+ Failed to connect socket to '/var/run/libvirt/virtqemud-sock-ro': Connection refused
|
|
||||||
+
|
|
||||||
+If you have just installed libvirt and virt-v2v, then you may see the
|
|
||||||
+errors above. This is caused by libvirt daemons that provide various
|
|
||||||
+services not running straight after installation. (This may depend on
|
|
||||||
+your distribution and vendor presets).
|
|
||||||
+
|
|
||||||
+To fix this on systemd-based distributions, do:
|
|
||||||
+
|
|
||||||
+ systemctl isolate multi-user.target
|
|
||||||
+
|
|
||||||
+See also L<https://bugzilla.redhat.com/2182024>.
|
|
||||||
+
|
|
||||||
=head1 FILES
|
|
||||||
|
|
||||||
=over 4
|
|
@ -1,4 +1,4 @@
|
|||||||
From 134fb5cd6925e8af155d1f84db55d3742f2f256f Mon Sep 17 00:00:00 2001
|
From a2e7cf38ee640e9e806a680cf55f78d33a3c0ee8 Mon Sep 17 00:00:00 2001
|
||||||
From: Pino Toscano <ptoscano@redhat.com>
|
From: Pino Toscano <ptoscano@redhat.com>
|
||||||
Date: Tue, 26 Mar 2019 09:42:25 +0100
|
Date: Tue, 26 Mar 2019 09:42:25 +0100
|
||||||
Subject: [PATCH] RHEL: point to KB for supported v2v hypervisors/guests
|
Subject: [PATCH] RHEL: point to KB for supported v2v hypervisors/guests
|
@ -1,4 +1,4 @@
|
|||||||
From dbf8c50d6d0e157c13e505a22f6f397cb991139c Mon Sep 17 00:00:00 2001
|
From aec57da776543ede26a2f751594686ad36b51bad Mon Sep 17 00:00:00 2001
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
Date: Tue, 5 Jul 2022 11:56:54 +0100
|
Date: Tue, 5 Jul 2022 11:56:54 +0100
|
||||||
Subject: [PATCH] RHEL 9: -oo compressed: Remove nbdcopy version check and test
|
Subject: [PATCH] RHEL 9: -oo compressed: Remove nbdcopy version check and test
|
@ -1,4 +1,4 @@
|
|||||||
From 81b28218e676cdc57bd6f8427cfd5faf85162d4a Mon Sep 17 00:00:00 2001
|
From d9c11fcfdf832f9d3d35855e7e7458efc1908515 Mon Sep 17 00:00:00 2001
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
Date: Tue, 5 Jul 2022 11:58:09 +0100
|
Date: Tue, 5 Jul 2022 11:58:09 +0100
|
||||||
Subject: [PATCH] RHEL 9: tests: Remove btrfs test
|
Subject: [PATCH] RHEL 9: tests: Remove btrfs test
|
@ -0,0 +1,68 @@
|
|||||||
|
From 88e4e0213f5dc9e60720f6a84edf36bffbea723e Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 16 May 2024 12:32:00 +0100
|
||||||
|
Subject: [PATCH] Update common submodule
|
||||||
|
|
||||||
|
Pulls in these commits, but they are not thought to be relevant to
|
||||||
|
virt-v2v.
|
||||||
|
|
||||||
|
Ben Brown (1):
|
||||||
|
Initialise bar->fp as NULL
|
||||||
|
|
||||||
|
Richard W.M. Jones (2):
|
||||||
|
mlcustomize: Update virt-customize generated files
|
||||||
|
options: Allow nbd+unix:// URIs
|
||||||
|
|
||||||
|
(cherry picked from commit 6513fcbec9a10652cb8b5690936e7265e9c8851c)
|
||||||
|
---
|
||||||
|
common | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
Submodule common 0dba002c..93a7f3af:
|
||||||
|
diff --git a/common/mlcustomize/customize_cmdline.ml b/common/mlcustomize/customize_cmdline.ml
|
||||||
|
index 245d9960..48ee3344 100644
|
||||||
|
--- a/common/mlcustomize/customize_cmdline.ml
|
||||||
|
+++ b/common/mlcustomize/customize_cmdline.ml
|
||||||
|
@@ -157,7 +157,7 @@ let rec argspec () =
|
||||||
|
let len = String.length arg in
|
||||||
|
String.sub arg 0 i, String.sub arg (i+1) (len-(i+1))
|
||||||
|
and split_string_triplet option_name arg =
|
||||||
|
- match String.nsplit ~max:3 "," arg with
|
||||||
|
+ match String.nsplit ~max:3 ":" arg with
|
||||||
|
| [a; b; c] -> a, b, c
|
||||||
|
| _ ->
|
||||||
|
error (f_"invalid format for '--%s' parameter, see the man page")
|
||||||
|
diff --git a/common/options/uri.c b/common/options/uri.c
|
||||||
|
index 84d393c1..9180d6a2 100644
|
||||||
|
--- a/common/options/uri.c
|
||||||
|
+++ b/common/options/uri.c
|
||||||
|
@@ -99,7 +99,7 @@ is_uri (const char *arg)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (p--; p >= arg; p--) {
|
||||||
|
- if (!c_islower (*p))
|
||||||
|
+ if (! (c_islower (*p) || *p == '+'))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -148,7 +148,10 @@ parse (const char *arg, char **path_ret, char **protocol_ret,
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
- *protocol_ret = strdup (uri->scheme);
|
||||||
|
+ if (STREQ (uri->scheme, "nbd+unix"))
|
||||||
|
+ *protocol_ret = strdup ("nbd");
|
||||||
|
+ else
|
||||||
|
+ *protocol_ret = strdup (uri->scheme);
|
||||||
|
if (*protocol_ret == NULL) {
|
||||||
|
perror ("strdup: protocol");
|
||||||
|
return -1;
|
||||||
|
@@ -194,7 +197,7 @@ parse (const char *arg, char **path_ret, char **protocol_ret,
|
||||||
|
if (path && path[0] == '/' &&
|
||||||
|
(STREQ (uri->scheme, "gluster") ||
|
||||||
|
STREQ (uri->scheme, "iscsi") ||
|
||||||
|
- STREQ (uri->scheme, "nbd") ||
|
||||||
|
+ STRPREFIX (uri->scheme, "nbd") ||
|
||||||
|
STREQ (uri->scheme, "rbd") ||
|
||||||
|
STREQ (uri->scheme, "sheepdog")))
|
||||||
|
path++;
|
@ -0,0 +1,109 @@
|
|||||||
|
From 006bdf2599f4d56e0612192291b846b384675e96 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 25 Jul 2024 09:08:41 +0100
|
||||||
|
Subject: [PATCH] Update common submodule
|
||||||
|
|
||||||
|
This pulls in the commits below which simplify the installation of
|
||||||
|
Qemu Guest Agent on Windows.
|
||||||
|
|
||||||
|
Richard W.M. Jones (4):
|
||||||
|
mlcustomize: firstboot: Use Linux path for Powershell script path
|
||||||
|
mlcustomize: firstboot: Use powershell.exe instead of path
|
||||||
|
mlcustomize: firstboot: Use Powershell -NoProfile flag
|
||||||
|
mlcustomize: Revert delay installation of qemu-ga MSI
|
||||||
|
|
||||||
|
Fixes: https://issues.redhat.com/browse/RHEL-49761
|
||||||
|
(cherry picked from commit 4ba18d2d6d1155db7cd83641a650477c0a13dbec)
|
||||||
|
---
|
||||||
|
common | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
Submodule common 830cbdcf..5d1f5b84:
|
||||||
|
diff --git a/common/mlcustomize/firstboot.ml b/common/mlcustomize/firstboot.ml
|
||||||
|
index 5dc01234..4b9b910b 100644
|
||||||
|
--- a/common/mlcustomize/firstboot.ml
|
||||||
|
+++ b/common/mlcustomize/firstboot.ml
|
||||||
|
@@ -387,16 +387,10 @@ let add_firstboot_powershell g root ?prio name code =
|
||||||
|
(* Create the temporary directory to put the Powershell file. *)
|
||||||
|
let tempdir = sprintf "%s/Temp" windows_systemroot in
|
||||||
|
g#mkdir_p tempdir;
|
||||||
|
+ let ps_path = sprintf "%s/%s" tempdir name in
|
||||||
|
let code = String.concat "\r\n" code ^ "\r\n" in
|
||||||
|
- g#write (sprintf "%s/%s" tempdir name) code;
|
||||||
|
+ g#write ps_path code;
|
||||||
|
|
||||||
|
- (* Powershell interpreter. Should we check this exists? XXX *)
|
||||||
|
- let ps_exe =
|
||||||
|
- windows_systemroot ^
|
||||||
|
- "\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" in
|
||||||
|
-
|
||||||
|
- (* Windows path to the Powershell script. *)
|
||||||
|
- let ps_path = windows_systemroot ^ "\\Temp\\" ^ name in
|
||||||
|
-
|
||||||
|
- let fb = sprintf "%s -ExecutionPolicy ByPass -file %s" ps_exe ps_path in
|
||||||
|
+ let fb = sprintf "powershell.exe -ExecutionPolicy ByPass -NoProfile -file %s"
|
||||||
|
+ ps_path in
|
||||||
|
add_firstboot_script g root ?prio name fb
|
||||||
|
diff --git a/common/mlcustomize/inject_virtio_win.ml b/common/mlcustomize/inject_virtio_win.ml
|
||||||
|
index 4e0ed0e0..eee93669 100644
|
||||||
|
--- a/common/mlcustomize/inject_virtio_win.ml
|
||||||
|
+++ b/common/mlcustomize/inject_virtio_win.ml
|
||||||
|
@@ -575,40 +575,28 @@ and copy_from_libosinfo { g; i_osinfo; i_arch } destdir =
|
||||||
|
) driver.Libosinfo.files
|
||||||
|
with Not_found -> []
|
||||||
|
|
||||||
|
+(* Install qemu-ga. [files] is the non-empty list of possible qemu-ga
|
||||||
|
+ * installers we detected.
|
||||||
|
+ *)
|
||||||
|
and configure_qemu_ga t files =
|
||||||
|
+ let script = ref [] in
|
||||||
|
+ let add = List.push_back script in
|
||||||
|
+
|
||||||
|
+ add "# Virt-v2v script which installs QEMU Guest Agent";
|
||||||
|
+ add "";
|
||||||
|
+ add "# Uncomment this line for lots of debug output.";
|
||||||
|
+ add "# Set-PSDebug -Trace 2";
|
||||||
|
+ add "";
|
||||||
|
+ add "Write-Host Installing QEMU Guest Agent";
|
||||||
|
+ add "";
|
||||||
|
+ add "# Run qemu-ga installers";
|
||||||
|
List.iter (
|
||||||
|
fun msi_path ->
|
||||||
|
- (* Windows is a trashfire.
|
||||||
|
- * https://stackoverflow.com/a/18730884
|
||||||
|
- * https://bugzilla.redhat.com/show_bug.cgi?id=1895323
|
||||||
|
- *)
|
||||||
|
- let psh_script = ref [] in
|
||||||
|
- let add = List.push_back psh_script in
|
||||||
|
+ add (sprintf "C:\\%s /norestart /qn /l+*vx C:\\%s.log"
|
||||||
|
+ msi_path msi_path)
|
||||||
|
+ ) files;
|
||||||
|
|
||||||
|
- add "# Uncomment this line for lots of debug output.";
|
||||||
|
- add "# Set-PSDebug -Trace 2";
|
||||||
|
- add "";
|
||||||
|
- add "Write-Host Removing any previously scheduled qemu-ga installation";
|
||||||
|
- add "schtasks.exe /Delete /TN Firstboot-qemu-ga /F";
|
||||||
|
- add "";
|
||||||
|
- add (sprintf
|
||||||
|
- "Write-Host Scheduling delayed installation of qemu-ga from %s"
|
||||||
|
- msi_path);
|
||||||
|
- add "$d = (get-date).AddSeconds(120)";
|
||||||
|
- add "$dtfinfo = [System.Globalization.DateTimeFormatInfo]::CurrentInfo";
|
||||||
|
- add "$sdp = $dtfinfo.ShortDatePattern";
|
||||||
|
- add "$sdp = $sdp -replace 'y+', 'yyyy'";
|
||||||
|
- add "$sdp = $sdp -replace 'M+', 'MM'";
|
||||||
|
- add "$sdp = $sdp -replace 'd+', 'dd'";
|
||||||
|
- add "schtasks.exe /Create /SC ONCE `";
|
||||||
|
- add " /ST $d.ToString('HH:mm') /SD $d.ToString($sdp) `";
|
||||||
|
- add " /RU SYSTEM /TN Firstboot-qemu-ga `";
|
||||||
|
- add (sprintf " /TR \"C:\\%s /forcerestart /qn /l+*vx C:\\%s.log\""
|
||||||
|
- msi_path msi_path);
|
||||||
|
-
|
||||||
|
- Firstboot.add_firstboot_powershell t.g t.root
|
||||||
|
- (sprintf "install-%s.ps1" msi_path) !psh_script;
|
||||||
|
- ) files
|
||||||
|
+ Firstboot.add_firstboot_powershell t.g t.root "install-qemu-ga.ps1" !script
|
||||||
|
|
||||||
|
and configure_blnsvr t blnsvr =
|
||||||
|
let cmd = sprintf "\
|
@ -0,0 +1,124 @@
|
|||||||
|
From 22691e516898b0d54ad4100c9f04beb1e70f9dc0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Sun, 28 Jul 2024 14:49:42 +0100
|
||||||
|
Subject: [PATCH] v2v: --mac: Allow gw and len fields to be empty
|
||||||
|
|
||||||
|
Even if these appear in the middle of the list, allow them to be
|
||||||
|
empty. For example this is now permitted whereas previously it was an
|
||||||
|
error:
|
||||||
|
|
||||||
|
virt-v2v --mac <MAC>:ip:<ADDR>,,,nameserver
|
||||||
|
|
||||||
|
Reported-by: Arik Hadas
|
||||||
|
(cherry picked from commit 159fda411d2f75b087106e7293d273ae142c9fbe)
|
||||||
|
---
|
||||||
|
in-place/in_place.ml | 12 +++++++-----
|
||||||
|
inspector/inspector.ml | 12 +++++++-----
|
||||||
|
v2v/v2v.ml | 12 +++++++-----
|
||||||
|
3 files changed, 21 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/in-place/in_place.ml b/in-place/in_place.ml
|
||||||
|
index 2049db16..a61d9795 100644
|
||||||
|
--- a/in-place/in_place.ml
|
||||||
|
+++ b/in-place/in_place.ml
|
||||||
|
@@ -90,10 +90,10 @@ let rec main () =
|
||||||
|
| "ip" ->
|
||||||
|
(match String.nsplit "," out with
|
||||||
|
| [] -> error (f_"invalid --mac ip option")
|
||||||
|
- | [ip] -> add_static_ip mac ip None None []
|
||||||
|
- | [ip; gw] -> add_static_ip mac ip (Some gw) None []
|
||||||
|
+ | [ip] -> add_static_ip mac ip "" "" []
|
||||||
|
+ | [ip; gw] -> add_static_ip mac ip gw "" []
|
||||||
|
| ip :: gw :: len :: nameservers ->
|
||||||
|
- add_static_ip mac ip (Some gw) (Some len) nameservers
|
||||||
|
+ add_static_ip mac ip gw len nameservers
|
||||||
|
)
|
||||||
|
| _ -> assert false
|
||||||
|
and add_static_ip if_mac_addr if_ip_address if_default_gateway
|
||||||
|
@@ -108,12 +108,14 @@ let rec main () =
|
||||||
|
an IP address") what addr
|
||||||
|
in
|
||||||
|
error_unless_ip_addr "ipaddr" if_ip_address;
|
||||||
|
+ let if_default_gateway =
|
||||||
|
+ match if_default_gateway with "" -> None | gw -> Some gw in
|
||||||
|
Option.iter (error_unless_ip_addr "gw") if_default_gateway;
|
||||||
|
List.iter (error_unless_ip_addr "nameserver") if_nameservers;
|
||||||
|
let if_prefix_length =
|
||||||
|
match if_prefix_length_str with
|
||||||
|
- | None -> None
|
||||||
|
- | Some len ->
|
||||||
|
+ | "" -> None
|
||||||
|
+ | len ->
|
||||||
|
let len =
|
||||||
|
try int_of_string len with
|
||||||
|
| Failure _ -> error (f_"cannot parse --mac ip prefix length \
|
||||||
|
diff --git a/inspector/inspector.ml b/inspector/inspector.ml
|
||||||
|
index 02d1a0e7..417b31c5 100644
|
||||||
|
--- a/inspector/inspector.ml
|
||||||
|
+++ b/inspector/inspector.ml
|
||||||
|
@@ -97,10 +97,10 @@ let rec main () =
|
||||||
|
| "ip" ->
|
||||||
|
(match String.nsplit "," out with
|
||||||
|
| [] -> error (f_"invalid --mac ip option")
|
||||||
|
- | [ip] -> add_static_ip mac ip None None []
|
||||||
|
- | [ip; gw] -> add_static_ip mac ip (Some gw) None []
|
||||||
|
+ | [ip] -> add_static_ip mac ip "" "" []
|
||||||
|
+ | [ip; gw] -> add_static_ip mac ip gw "" []
|
||||||
|
| ip :: gw :: len :: nameservers ->
|
||||||
|
- add_static_ip mac ip (Some gw) (Some len) nameservers
|
||||||
|
+ add_static_ip mac ip gw len nameservers
|
||||||
|
)
|
||||||
|
| _ -> assert false
|
||||||
|
and add_static_ip if_mac_addr if_ip_address if_default_gateway
|
||||||
|
@@ -115,12 +115,14 @@ let rec main () =
|
||||||
|
is an IP address") what addr
|
||||||
|
in
|
||||||
|
error_unless_ip_addr "ipaddr" if_ip_address;
|
||||||
|
+ let if_default_gateway =
|
||||||
|
+ match if_default_gateway with "" -> None | gw -> Some gw in
|
||||||
|
Option.iter (error_unless_ip_addr "gw") if_default_gateway;
|
||||||
|
List.iter (error_unless_ip_addr "nameserver") if_nameservers;
|
||||||
|
let if_prefix_length =
|
||||||
|
match if_prefix_length_str with
|
||||||
|
- | None -> None
|
||||||
|
- | Some len ->
|
||||||
|
+ | "" -> None
|
||||||
|
+ | len ->
|
||||||
|
let len =
|
||||||
|
try int_of_string len with
|
||||||
|
| Failure _ -> error (f_"cannot parse --mac ip prefix \
|
||||||
|
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
|
||||||
|
index 89c08fc5..6d9e3792 100644
|
||||||
|
--- a/v2v/v2v.ml
|
||||||
|
+++ b/v2v/v2v.ml
|
||||||
|
@@ -109,10 +109,10 @@ let rec main () =
|
||||||
|
| "ip" ->
|
||||||
|
(match String.nsplit "," out with
|
||||||
|
| [] -> error (f_"invalid --mac ip option")
|
||||||
|
- | [ip] -> add_static_ip mac ip None None []
|
||||||
|
- | [ip; gw] -> add_static_ip mac ip (Some gw) None []
|
||||||
|
+ | [ip] -> add_static_ip mac ip "" "" []
|
||||||
|
+ | [ip; gw] -> add_static_ip mac ip gw "" []
|
||||||
|
| ip :: gw :: len :: nameservers ->
|
||||||
|
- add_static_ip mac ip (Some gw) (Some len) nameservers
|
||||||
|
+ add_static_ip mac ip gw len nameservers
|
||||||
|
)
|
||||||
|
| _ -> assert false
|
||||||
|
and add_static_ip if_mac_addr if_ip_address if_default_gateway
|
||||||
|
@@ -127,12 +127,14 @@ let rec main () =
|
||||||
|
is an IP address") what addr
|
||||||
|
in
|
||||||
|
error_unless_ip_addr "ipaddr" if_ip_address;
|
||||||
|
+ let if_default_gateway =
|
||||||
|
+ match if_default_gateway with "" -> None | gw -> Some gw in
|
||||||
|
Option.iter (error_unless_ip_addr "gw") if_default_gateway;
|
||||||
|
List.iter (error_unless_ip_addr "nameserver") if_nameservers;
|
||||||
|
let if_prefix_length =
|
||||||
|
match if_prefix_length_str with
|
||||||
|
- | None -> None
|
||||||
|
- | Some len ->
|
||||||
|
+ | "" -> None
|
||||||
|
+ | len ->
|
||||||
|
let len =
|
||||||
|
try int_of_string len with
|
||||||
|
| Failure _ -> error (f_"cannot parse --mac ip prefix length field \
|
@ -0,0 +1,29 @@
|
|||||||
|
From 48c49139b94b1081c6392ab3b14fbb72c024f18d Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Wed, 31 Jul 2024 10:09:50 +0100
|
||||||
|
Subject: [PATCH] docs: Note that --mac len field is now optional
|
||||||
|
|
||||||
|
Reported-by: Ming Xie
|
||||||
|
Updates: commit 159fda411d2f75b087106e7293d273ae142c9fbe
|
||||||
|
(cherry picked from commit 7800049c5612e6ffb30be7f8862d147d82976ae8)
|
||||||
|
---
|
||||||
|
docs/virt-v2v.pod | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
|
||||||
|
index 021ac897..c173563b 100644
|
||||||
|
--- a/docs/virt-v2v.pod
|
||||||
|
+++ b/docs/virt-v2v.pod
|
||||||
|
@@ -372,9 +372,9 @@ Force a particular interface (controlled by its MAC address) to have a
|
||||||
|
static IP address after boot.
|
||||||
|
|
||||||
|
The fields in the parameter are: C<ipaddr> is the IP address. C<gw>
|
||||||
|
-is the optional gateway IP address. C<len> is the subnet mask length
|
||||||
|
-(an integer). The final parameters are zero or more nameserver IP
|
||||||
|
-addresses.
|
||||||
|
+is the optional gateway IP address. C<len> is the optional subnet
|
||||||
|
+mask length (an integer). The final parameters are zero or more
|
||||||
|
+nameserver IP addresses.
|
||||||
|
|
||||||
|
This option can be supplied zero or more times.
|
||||||
|
|
@ -0,0 +1,240 @@
|
|||||||
|
From bebc18c317a46cc99f50d1f6932c81df4e7da1fb Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 1 Aug 2024 09:01:47 +0100
|
||||||
|
Subject: [PATCH] convert: More robust qemu-ga installation, change paths
|
||||||
|
|
||||||
|
Add a commit from the common submodule to attempt to make qemu-ga
|
||||||
|
installation more robust on Windows.
|
||||||
|
|
||||||
|
Rename network configuration Powershell script from "v2vnetcf" to
|
||||||
|
"network-configuration". I also dropped the ".ps1" extension as the
|
||||||
|
modified Firstboot.add_firstboot_powershell function now adds this.
|
||||||
|
|
||||||
|
Update the common submodule to get these changes:
|
||||||
|
|
||||||
|
Richard W.M. Jones (3):
|
||||||
|
mlcustomize: Use Start-Process -Wait to run qemu-ga installer
|
||||||
|
mlcustomize: Add Firstboot.firstboot_dir function
|
||||||
|
mlcustomize: Place powershell scripts into <firstboot_dir>\Temp
|
||||||
|
|
||||||
|
(cherry picked from commit c57ec4fd5d4942d2320aec4a6b01977dabb87f83)
|
||||||
|
---
|
||||||
|
common | 2 +-
|
||||||
|
convert/convert_windows.ml | 4 ++--
|
||||||
|
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
Submodule common 5d1f5b84..d489469f:
|
||||||
|
diff --git a/common/mlcustomize/firstboot.ml b/common/mlcustomize/firstboot.ml
|
||||||
|
index 4b9b910b..3bbba714 100644
|
||||||
|
--- a/common/mlcustomize/firstboot.ml
|
||||||
|
+++ b/common/mlcustomize/firstboot.ml
|
||||||
|
@@ -239,7 +239,22 @@ WantedBy=%s
|
||||||
|
end
|
||||||
|
|
||||||
|
module Windows = struct
|
||||||
|
- let rec install_service (g : Guestfs.guestfs) root =
|
||||||
|
+ (* Create and return the firstboot directory. *)
|
||||||
|
+ let create_firstboot_dir (g : Guestfs.guestfs) =
|
||||||
|
+ let rec loop firstboot_dir firstboot_dir_win = function
|
||||||
|
+ | [] -> firstboot_dir, firstboot_dir_win
|
||||||
|
+ | dir :: path ->
|
||||||
|
+ let firstboot_dir =
|
||||||
|
+ if firstboot_dir = "" then "/" ^ dir else firstboot_dir // dir in
|
||||||
|
+ let firstboot_dir_win = firstboot_dir_win ^ "\\" ^ dir in
|
||||||
|
+ let firstboot_dir = g#case_sensitive_path firstboot_dir in
|
||||||
|
+ g#mkdir_p firstboot_dir;
|
||||||
|
+ loop firstboot_dir firstboot_dir_win path
|
||||||
|
+ in
|
||||||
|
+ loop "" "C:" ["Program Files"; "Guestfs"; "Firstboot"]
|
||||||
|
+
|
||||||
|
+ let rec install_service (g : Guestfs.guestfs) root
|
||||||
|
+ firstboot_dir firstboot_dir_win =
|
||||||
|
(* Either rhsrvany.exe or pvvxsvc.exe must exist.
|
||||||
|
*
|
||||||
|
* (Check also that it's not a dangling symlink but a real file).
|
||||||
|
@@ -254,20 +269,7 @@ module Windows = struct
|
||||||
|
error (f_"One of rhsrvany.exe or pvvxsvc.exe is missing in %s. One of them is required in order to install Windows firstboot scripts. You can get one by building rhsrvany (https://github.com/rwmjones/rhsrvany)")
|
||||||
|
(virt_tools_data_dir ()) in
|
||||||
|
|
||||||
|
- (* Create a directory for firstboot files in the guest. *)
|
||||||
|
- let firstboot_dir, firstboot_dir_win =
|
||||||
|
- let rec loop firstboot_dir firstboot_dir_win = function
|
||||||
|
- | [] -> firstboot_dir, firstboot_dir_win
|
||||||
|
- | dir :: path ->
|
||||||
|
- let firstboot_dir =
|
||||||
|
- if firstboot_dir = "" then "/" ^ dir else firstboot_dir // dir in
|
||||||
|
- let firstboot_dir_win = firstboot_dir_win ^ "\\" ^ dir in
|
||||||
|
- let firstboot_dir = g#case_sensitive_path firstboot_dir in
|
||||||
|
- g#mkdir_p firstboot_dir;
|
||||||
|
- loop firstboot_dir firstboot_dir_win path
|
||||||
|
- in
|
||||||
|
- loop "" "C:" ["Program Files"; "Guestfs"; "Firstboot"] in
|
||||||
|
-
|
||||||
|
+ (* Create a directory for firstboot scripts in the guest. *)
|
||||||
|
g#mkdir_p (firstboot_dir // "scripts");
|
||||||
|
|
||||||
|
(* Copy pvvxsvc or rhsrvany to the guest. *)
|
||||||
|
@@ -339,11 +341,25 @@ echo uninstalling firstboot service
|
||||||
|
"PWD", REG_SZ firstboot_dir_win ];
|
||||||
|
] in
|
||||||
|
reg_import reg regedits
|
||||||
|
- );
|
||||||
|
-
|
||||||
|
- firstboot_dir
|
||||||
|
+ )
|
||||||
|
end
|
||||||
|
|
||||||
|
+let firstboot_dir (g : Guestfs.guestfs) root =
|
||||||
|
+ let typ = g#inspect_get_type root in
|
||||||
|
+
|
||||||
|
+ match typ with
|
||||||
|
+ | "linux" ->
|
||||||
|
+ let dir = Linux.firstboot_dir in
|
||||||
|
+ g#mkdir_p dir;
|
||||||
|
+ dir, None
|
||||||
|
+
|
||||||
|
+ | "windows" ->
|
||||||
|
+ let dir, dir_win = Windows.create_firstboot_dir g in
|
||||||
|
+ dir, Some dir_win
|
||||||
|
+
|
||||||
|
+ | _ ->
|
||||||
|
+ error (f_"guest type %s is not supported") typ
|
||||||
|
+
|
||||||
|
let script_count = ref 0
|
||||||
|
|
||||||
|
let add_firstboot_script (g : Guestfs.guestfs) root ?(prio = 5000) name
|
||||||
|
@@ -363,7 +379,8 @@ let add_firstboot_script (g : Guestfs.guestfs) root ?(prio = 5000) name
|
||||||
|
g#chmod 0o755 filename
|
||||||
|
|
||||||
|
| "windows", _ ->
|
||||||
|
- let firstboot_dir = Windows.install_service g root in
|
||||||
|
+ let firstboot_dir, firstboot_dir_win = Windows.create_firstboot_dir g in
|
||||||
|
+ Windows.install_service g root firstboot_dir firstboot_dir_win;
|
||||||
|
let filename = firstboot_dir // "scripts" // filename ^ ".bat" in
|
||||||
|
g#write filename (String.unix2dos content)
|
||||||
|
|
||||||
|
@@ -382,15 +399,18 @@ let add_firstboot_powershell g root ?prio name code =
|
||||||
|
*)
|
||||||
|
assert (g#inspect_get_type root = "windows");
|
||||||
|
|
||||||
|
- let windows_systemroot = g#inspect_get_windows_systemroot root in
|
||||||
|
-
|
||||||
|
- (* Create the temporary directory to put the Powershell file. *)
|
||||||
|
- let tempdir = sprintf "%s/Temp" windows_systemroot in
|
||||||
|
+ (* Place the Powershell script into firstboot_dir/Temp *)
|
||||||
|
+ let firstboot_dir, firstboot_dir_win = Windows.create_firstboot_dir g in
|
||||||
|
+ let tempdir = sprintf "%s/Temp" firstboot_dir in
|
||||||
|
g#mkdir_p tempdir;
|
||||||
|
- let ps_path = sprintf "%s/%s" tempdir name in
|
||||||
|
+
|
||||||
|
+ let ps_path = sprintf "%s/%s.ps1" tempdir name in
|
||||||
|
+ let ps_path_win = sprintf "%s\\Temp\\%s.ps1" firstboot_dir_win name in
|
||||||
|
let code = String.concat "\r\n" code ^ "\r\n" in
|
||||||
|
g#write ps_path code;
|
||||||
|
|
||||||
|
- let fb = sprintf "powershell.exe -ExecutionPolicy ByPass -NoProfile -file %s"
|
||||||
|
- ps_path in
|
||||||
|
+ (* Create a regular firstboot bat that just invokes powershell *)
|
||||||
|
+ let fb =
|
||||||
|
+ sprintf "powershell.exe -ExecutionPolicy ByPass -NoProfile -file \"%s\""
|
||||||
|
+ ps_path_win in
|
||||||
|
add_firstboot_script g root ?prio name fb
|
||||||
|
diff --git a/common/mlcustomize/firstboot.mli b/common/mlcustomize/firstboot.mli
|
||||||
|
index 8231af65..34ff0690 100644
|
||||||
|
--- a/common/mlcustomize/firstboot.mli
|
||||||
|
+++ b/common/mlcustomize/firstboot.mli
|
||||||
|
@@ -16,6 +16,23 @@
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*)
|
||||||
|
|
||||||
|
+val firstboot_dir : Guestfs.guestfs -> string -> string * string option
|
||||||
|
+(** [firstboot_dir g root]
|
||||||
|
+ returns the path of the firstboot directory, creating it in
|
||||||
|
+ the guest if necessary.
|
||||||
|
+
|
||||||
|
+ This returns the name of the directory as a guestfs path, and
|
||||||
|
+ optionally the name as a Windows path (only for Windows guests).
|
||||||
|
+
|
||||||
|
+ For Linux this could be [/usr/lib/virt-sysprep, None]
|
||||||
|
+
|
||||||
|
+ For Windows this could be ["/Program Files/Guestfs/Firstboot",
|
||||||
|
+ Some "C:\Program Files\Guestfs\Firstboot"]
|
||||||
|
+
|
||||||
|
+ Additional files that are used during firstboot can be placed
|
||||||
|
+ in this directory, but be careful not to conflict with files
|
||||||
|
+ and scripts added by the firstboot process itself. *)
|
||||||
|
+
|
||||||
|
val add_firstboot_script : Guestfs.guestfs -> string -> ?prio:int -> string ->
|
||||||
|
string -> unit
|
||||||
|
(** [add_firstboot_script g root prio name content] adds a firstboot
|
||||||
|
diff --git a/common/mlcustomize/inject_virtio_win.ml b/common/mlcustomize/inject_virtio_win.ml
|
||||||
|
index eee93669..b04a3b38 100644
|
||||||
|
--- a/common/mlcustomize/inject_virtio_win.ml
|
||||||
|
+++ b/common/mlcustomize/inject_virtio_win.ml
|
||||||
|
@@ -592,11 +592,11 @@ and configure_qemu_ga t files =
|
||||||
|
add "# Run qemu-ga installers";
|
||||||
|
List.iter (
|
||||||
|
fun msi_path ->
|
||||||
|
- add (sprintf "C:\\%s /norestart /qn /l+*vx C:\\%s.log"
|
||||||
|
+ add (sprintf "Start-Process -Wait -FilePath \"C:\\%s\" -ArgumentList \"/norestart\",\"/qn\",\"/l+*vx\",\"C:\\%s.log\""
|
||||||
|
msi_path msi_path)
|
||||||
|
) files;
|
||||||
|
|
||||||
|
- Firstboot.add_firstboot_powershell t.g t.root "install-qemu-ga.ps1" !script
|
||||||
|
+ Firstboot.add_firstboot_powershell t.g t.root "install-qemu-ga" !script
|
||||||
|
|
||||||
|
and configure_blnsvr t blnsvr =
|
||||||
|
let cmd = sprintf "\
|
||||||
|
diff --git a/common/mldrivers/linux_kernels.ml b/common/mldrivers/linux_kernels.ml
|
||||||
|
index 23ff76a5..e0b6b8a0 100644
|
||||||
|
--- a/common/mldrivers/linux_kernels.ml
|
||||||
|
+++ b/common/mldrivers/linux_kernels.ml
|
||||||
|
@@ -102,7 +102,7 @@ let detect_kernels (g : G.guestfs) root bootloader apps =
|
||||||
|
) apps in
|
||||||
|
if verbose () then (
|
||||||
|
let names = List.map (fun { G.app2_name = name } -> name) kernel_pkgs in
|
||||||
|
- eprintf "candidate kernel packages in this guest: %s%!\n"
|
||||||
|
+ eprintf "info: candidate kernel packages in this guest: %s%!\n"
|
||||||
|
(String.concat " " names)
|
||||||
|
);
|
||||||
|
List.filter_map (
|
||||||
|
@@ -306,7 +306,7 @@ let detect_kernels (g : G.guestfs) root bootloader apps =
|
||||||
|
) kernel_pkgs in
|
||||||
|
|
||||||
|
if verbose () then (
|
||||||
|
- eprintf "installed kernel packages in this guest:\n";
|
||||||
|
+ eprintf "info: installed kernel packages in this guest:\n";
|
||||||
|
List.iter (print_kernel_info stderr "\t") installed_kernels;
|
||||||
|
flush stderr
|
||||||
|
);
|
||||||
|
@@ -343,7 +343,7 @@ let detect_kernels (g : G.guestfs) root bootloader apps =
|
||||||
|
) vmlinuzes in
|
||||||
|
|
||||||
|
if verbose () then (
|
||||||
|
- eprintf "kernels offered by the bootloader in this guest (first in list is default):\n";
|
||||||
|
+ eprintf "info: kernels offered by the bootloader in this guest (first in list is default):\n";
|
||||||
|
List.iter (print_kernel_info stderr "\t") bootloader_kernels;
|
||||||
|
flush stderr
|
||||||
|
);
|
||||||
|
diff --git a/convert/convert_windows.ml b/convert/convert_windows.ml
|
||||||
|
index 34cf341b..2ff60bad 100644
|
||||||
|
--- a/convert/convert_windows.ml
|
||||||
|
+++ b/convert/convert_windows.ml
|
||||||
|
@@ -391,7 +391,7 @@ let convert (g : G.guestfs) _ inspect i_firmware block_driver _ static_ips =
|
||||||
|
%systemroot%\\Sysnative\\PnPutil -i -a \
|
||||||
|
%systemroot%\\Drivers\\Virtio\\*.inf" in
|
||||||
|
|
||||||
|
- (* Set priority higher than that of "v2vnetcf.ps1" firstboot script. *)
|
||||||
|
+ (* Set priority higher than that of "network-configure" firstboot script. *)
|
||||||
|
Firstboot.add_firstboot_script g inspect.i_root ~prio:2000
|
||||||
|
"pnputil install drivers" fb_script;
|
||||||
|
|
||||||
|
@@ -668,7 +668,7 @@ let convert (g : G.guestfs) _ inspect i_firmware block_driver _ static_ips =
|
||||||
|
* Powershell script which runs at boot.
|
||||||
|
*)
|
||||||
|
if static_ips <> [] then (
|
||||||
|
- let psh_filename = "v2vnetcf.ps1" in
|
||||||
|
+ let psh_filename = "network-configure" in
|
||||||
|
let psh = ref [] in
|
||||||
|
let add = List.push_back psh in
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
From 696060ba5e89da4d60a7ee1187c8cfd298d50031 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 5 Aug 2024 10:08:34 +0100
|
||||||
|
Subject: [PATCH] docs: Add a note about removal of VMware Tools on Windows
|
||||||
|
|
||||||
|
We use VMware's recommended method for removal, but we know from
|
||||||
|
experience that this rarely works. The alternate method being
|
||||||
|
proposed involves making very invasive changes to the Registry and
|
||||||
|
filesystem, which are inappropriate for virt-v2v to do and highly
|
||||||
|
risky. Therefore simply document this, with notes for the virt-v2v
|
||||||
|
user if they want to try the risky method.
|
||||||
|
|
||||||
|
Fixes: https://issues.redhat.com/browse/RHEL-51169
|
||||||
|
Thanks: Yan Vugenfirer
|
||||||
|
Reported-by: Ming Xie
|
||||||
|
(cherry picked from commit c952f310c902e438a8b0b5240a4b486b698bede8)
|
||||||
|
---
|
||||||
|
docs/virt-v2v.pod | 15 +++++++++++++++
|
||||||
|
1 file changed, 15 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
|
||||||
|
index c173563b..6df9d88b 100644
|
||||||
|
--- a/docs/virt-v2v.pod
|
||||||
|
+++ b/docs/virt-v2v.pod
|
||||||
|
@@ -1248,6 +1248,21 @@ B<N.B.> Take care not to interrupt the automatic driver installation
|
||||||
|
process when logging in to the guest for the first time, as this may
|
||||||
|
prevent the guest from subsequently booting correctly.
|
||||||
|
|
||||||
|
+=head3 Removing VMware Tools from Windows guests
|
||||||
|
+
|
||||||
|
+Virt-v2v attempts to remove VMware Tools. For Windows guests this is
|
||||||
|
+supposed to happen during the first boot after conversion.
|
||||||
|
+
|
||||||
|
+We use VMware's recommended uninstallation method as that is the
|
||||||
|
+safest choice. However our experience has shown that this method
|
||||||
|
+usually fails. If so, VMware Tools must be removed by some other
|
||||||
|
+method.
|
||||||
|
+
|
||||||
|
+One possible method is described here:
|
||||||
|
+L<https://gist.github.com/broestls/f872872a00acee2fca02017160840624>
|
||||||
|
+You should carefully check this script since it makes very invasive
|
||||||
|
+changes to the Windows Registry and filesystem.
|
||||||
|
+
|
||||||
|
=head2 Free space for conversion
|
||||||
|
|
||||||
|
=head3 Free space in the guest
|
@ -0,0 +1,27 @@
|
|||||||
|
From 03249203b25d946358e73d0e418805f293bb43bb Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 5 Aug 2024 10:18:31 +0100
|
||||||
|
Subject: [PATCH] Update common submodule
|
||||||
|
|
||||||
|
Richard W.M. Jones (1):
|
||||||
|
mlcustomize: Write qemu-ga log file name to log.txt
|
||||||
|
|
||||||
|
(cherry picked from commit 7bc9b115baba6df2969451cd6907e2d7543ef22d)
|
||||||
|
---
|
||||||
|
common | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
Submodule common 04116678..7b84a370:
|
||||||
|
diff --git a/common/mlcustomize/inject_virtio_win.ml b/common/mlcustomize/inject_virtio_win.ml
|
||||||
|
index 2981bff5..afec1e45 100644
|
||||||
|
--- a/common/mlcustomize/inject_virtio_win.ml
|
||||||
|
+++ b/common/mlcustomize/inject_virtio_win.ml
|
||||||
|
@@ -606,6 +606,8 @@ and configure_qemu_ga t tempdir_win files =
|
||||||
|
add "# Run qemu-ga installers";
|
||||||
|
List.iter (
|
||||||
|
fun msi ->
|
||||||
|
+ add (sprintf "Write-Host \"Writing log to %s\\%s.log\""
|
||||||
|
+ tempdir_win msi);
|
||||||
|
(* [`] is an escape char for quotes *)
|
||||||
|
add (sprintf "Start-Process -Wait -FilePath \"%s\\%s\" -ArgumentList \"/norestart\",\"/qn\",\"/l+*vx\",\"`\"%s\\%s.log`\"\""
|
||||||
|
tempdir_win msi tempdir_win msi)
|
@ -0,0 +1,80 @@
|
|||||||
|
From a6b8794cd8b90b7f100964ff8534eb24a1b32d4b Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 8 Aug 2024 10:40:24 +0100
|
||||||
|
Subject: [PATCH] Pull in a fix to make Windows firstboot more reliable.
|
||||||
|
|
||||||
|
Update the common submodule to get:
|
||||||
|
|
||||||
|
Richard W.M. Jones (2):
|
||||||
|
mlcustomize: Add some comments to firstboot batch file
|
||||||
|
mlcustomize: Reboot Windows between each firstboot script
|
||||||
|
|
||||||
|
Document that Windows may now reboot several times after conversion.
|
||||||
|
|
||||||
|
(cherry picked from commit 50f005f8b7034916588855c15b10a0195bf54b23)
|
||||||
|
---
|
||||||
|
common | 2 +-
|
||||||
|
docs/virt-v2v.pod | 9 ++++++---
|
||||||
|
2 files changed, 7 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
Submodule common 7b84a370..a7883967:
|
||||||
|
diff --git a/common/mlcustomize/firstboot.ml b/common/mlcustomize/firstboot.ml
|
||||||
|
index 3bbba714..52e76401 100644
|
||||||
|
--- a/common/mlcustomize/firstboot.ml
|
||||||
|
+++ b/common/mlcustomize/firstboot.ml
|
||||||
|
@@ -278,6 +278,9 @@ module Windows = struct
|
||||||
|
(* Write a firstboot.bat control script which just runs the other
|
||||||
|
* scripts in the directory. Note we need to use CRLF line endings
|
||||||
|
* in this script.
|
||||||
|
+ *
|
||||||
|
+ * XXX It would be better to use powershell here. For some ideas see
|
||||||
|
+ * https://github.com/HCK-CI/HLK-Setup-Scripts/
|
||||||
|
*)
|
||||||
|
let firstboot_script = sprintf "\
|
||||||
|
@echo off
|
||||||
|
@@ -299,6 +302,7 @@ if not exist \"%%scripts_done%%\" (
|
||||||
|
mkdir \"%%scripts_done%%\"
|
||||||
|
)
|
||||||
|
|
||||||
|
+:: Pick the next script to run.
|
||||||
|
for %%%%f in (\"%%scripts%%\"\\*.bat) do (
|
||||||
|
echo running \"%%%%f\"
|
||||||
|
move \"%%%%f\" \"%%scripts_done%%\"
|
||||||
|
@@ -307,8 +311,17 @@ for %%%%f in (\"%%scripts%%\"\\*.bat) do (
|
||||||
|
set elvl=!errorlevel!
|
||||||
|
echo .... exit code !elvl!
|
||||||
|
popd
|
||||||
|
+
|
||||||
|
+ :: Reboot the computer. This is necessary to free any locked
|
||||||
|
+ :: files which may prevent later scripts from running.
|
||||||
|
+ shutdown /r /t 0 /y
|
||||||
|
+
|
||||||
|
+ :: Exit the script (in case shutdown returns before rebooting).
|
||||||
|
+ :: On next boot, the whole firstboot service will be called again.
|
||||||
|
+ exit /b
|
||||||
|
)
|
||||||
|
|
||||||
|
+:: Fallthrough here if there are no scripts.
|
||||||
|
echo uninstalling firstboot service
|
||||||
|
\"%%firstboot%%\\%s\" -s firstboot uninstall
|
||||||
|
" firstboot_dir_win srvany in
|
||||||
|
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
|
||||||
|
index 6df9d88b..7912c6b1 100644
|
||||||
|
--- a/docs/virt-v2v.pod
|
||||||
|
+++ b/docs/virt-v2v.pod
|
||||||
|
@@ -1244,9 +1244,12 @@ The guest will be bootable after the offline conversion stage, but
|
||||||
|
will not yet have all necessary drivers installed to work correctly.
|
||||||
|
These will be installed automatically the first time the guest boots.
|
||||||
|
|
||||||
|
-B<N.B.> Take care not to interrupt the automatic driver installation
|
||||||
|
-process when logging in to the guest for the first time, as this may
|
||||||
|
-prevent the guest from subsequently booting correctly.
|
||||||
|
+B<N.B.> Windows may reboot 4 or more times the first time after
|
||||||
|
+conversion. This is required to install the required drivers, guest
|
||||||
|
+agents, remove VMware Tools, and configure the network. Take care not
|
||||||
|
+to interrupt the automatic driver installation process when logging in
|
||||||
|
+to the guest for the first time, as this may prevent the guest from
|
||||||
|
+subsequently booting correctly.
|
||||||
|
|
||||||
|
=head3 Removing VMware Tools from Windows guests
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
From 8bcdddcaa612feb05c4ae5033bf9440b046ef63e Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 8 Aug 2024 10:56:16 +0100
|
||||||
|
Subject: [PATCH] docs: Restate position on removal of VMware Tools
|
||||||
|
|
||||||
|
With the "reboot after every step" change made in the previous commit,
|
||||||
|
it seems removal of VMware Tools is now more reliable. Update the
|
||||||
|
notes about this.
|
||||||
|
|
||||||
|
Updates: commit c952f310c902e438a8b0b5240a4b486b698bede8
|
||||||
|
(cherry picked from commit e9c0d63b22bcb4c31cfaac00fc1271713c8bd3b3)
|
||||||
|
---
|
||||||
|
docs/virt-v2v.pod | 5 ++---
|
||||||
|
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
|
||||||
|
index 7912c6b1..50285cad 100644
|
||||||
|
--- a/docs/virt-v2v.pod
|
||||||
|
+++ b/docs/virt-v2v.pod
|
||||||
|
@@ -1257,9 +1257,8 @@ Virt-v2v attempts to remove VMware Tools. For Windows guests this is
|
||||||
|
supposed to happen during the first boot after conversion.
|
||||||
|
|
||||||
|
We use VMware's recommended uninstallation method as that is the
|
||||||
|
-safest choice. However our experience has shown that this method
|
||||||
|
-usually fails. If so, VMware Tools must be removed by some other
|
||||||
|
-method.
|
||||||
|
+safest choice. If this fails, VMware Tools must be manually removed
|
||||||
|
+by some other method.
|
||||||
|
|
||||||
|
One possible method is described here:
|
||||||
|
L<https://gist.github.com/broestls/f872872a00acee2fca02017160840624>
|
@ -1,17 +0,0 @@
|
|||||||
-----BEGIN PGP SIGNATURE-----
|
|
||||||
|
|
||||||
iQJFBAABCAAvFiEE93dPsa0HSn6Mh2fqkXOPc+G3aKAFAmQ/zVsRHHJpY2hAYW5u
|
|
||||||
ZXhpYS5vcmcACgkQkXOPc+G3aKDvNw//T5RStZ4lypgFgeCqM8HUce8AvEBmp2Bu
|
|
||||||
eCFMsSHjyWvA5S9mw+D6EOhDIZiIyGoESbYzpXZxrXE8YYWKW51rlOaGcVxmU5ld
|
|
||||||
mz3bz2iGRGpFsKzF1v0WDaLzhg8KX6Fw7hFlnDjTLjYqnwSgySf/aXVrPEZPwmwj
|
|
||||||
iGqpCNokG5HmJNQ36x2JMmQxa135nbYXh/nvPTXU2gzx7i5By3D9ir2k6B/iLDPf
|
|
||||||
NbQ7PDO9mSBKljeRvhrmM2zxXiAhb3WG9XWM/I4aHASh76BhR7lCg4GS94NbTNPj
|
|
||||||
KAWAIGZN0TFRLOHsFwvOz9pibJQeDdjimakwDzSv9+gS+TlwU1isahpW8Ic/tIlC
|
|
||||||
2BEucjM7MVuyLLqoGq5tKGbO/OZ7Rheg/wR0j2y+1afvCRgRupyAjtwlYjFpB/sp
|
|
||||||
1tNmYAW9zOtJtp3MLfMCO820ZsBifprTk9dZqDCeH3HW9aJ8e1pJcpYF5G3gpVD/
|
|
||||||
m32J9YFudmAV0Z3ePUnH/C5ZAzvE1u55SexnfZEqdyKZ+KOujZBrg4b/nID1xmo1
|
|
||||||
jBZbYprNJTRluJCmIvY5/79Oob2GqAqOgjdUrQlEzPVRf6Kd5lAGIqkKr+5RlQvg
|
|
||||||
9OmIvQu1wgiqpmxEuev/RDb8b8M632YAv5+6TACxpqhfZxkmSZ04XFKCZZw1/pDd
|
|
||||||
NXR/cUUWEBI=
|
|
||||||
=XPmg
|
|
||||||
-----END PGP SIGNATURE-----
|
|
@ -0,0 +1,17 @@
|
|||||||
|
-----BEGIN PGP SIGNATURE-----
|
||||||
|
|
||||||
|
iQJFBAABCAAvFiEE93dPsa0HSn6Mh2fqkXOPc+G3aKAFAmWW5kYRHHJpY2hAYW5u
|
||||||
|
ZXhpYS5vcmcACgkQkXOPc+G3aKBddxAAvM08lmWH0IlpLwKX06TwnVERt8fXD++p
|
||||||
|
bjRrfj2mOoayoN/B1oE61laCdZgCzPtN6MC/aW94LITaGJWHi7YYqdgdRgL1NqeC
|
||||||
|
n0tu8t14XsCT1xTIOa1ndb018+a5ppIcOnmGAj4naM5uA50rgRwChdSOTP/H10+J
|
||||||
|
93M2rvvak8aVdeWEhnMJyqWG2mFJ0YselJ+cMu66XFBkK7wg4UwCzzJ4Blqb1Igd
|
||||||
|
W/wctLDLqPVAxI85P/2p2dt+N4vzOnT/jr+dFxXOJg99E6iwa3qPCdzGHmszjhyC
|
||||||
|
uNhq/pWMt5tSk34IwYduyk1b9mlx9dCQsyREwrVomsdZD+XrUZHhrGrlcVJDfT07
|
||||||
|
2DCkVnGAoH0DRmz3t69KJS9U1JgzkaTDNaezkLlIZ7VZOdaC5nK74efnN0yinBkJ
|
||||||
|
9GhmR0qbk4/QVKeNWSftu4Rd9OUtRSaEMH0kO/S42vl3fW59u+ZGMEz26Ar4x/q7
|
||||||
|
jLx3vKfduJbpvberc3kQ2p9jQbUjlyFOTtnTAf84ckyIkvEMwpEhlyfchctPji/K
|
||||||
|
IaJ4Yd0KnKiLg/GH9Eon79cadAV2hzvYb2FZYI1RcrbRH+nZvGLgSbvHobqESERT
|
||||||
|
hBBXrAhaazRdxbOVqwMV9d+lq4llzUJJMOVCsK/PLnigrl5OCLQNQ2IVBbPv8WFD
|
||||||
|
VMg/9mGiUj0=
|
||||||
|
=lbFv
|
||||||
|
-----END PGP SIGNATURE-----
|
Loading…
Reference in new issue