Rebase to virt-v2v 2.3.7

Implement --key all:...
  resolves: RHEL-18142
Fix off-by-one error causing rare crash
  resolves: RHEL-19061
This commit is contained in:
Richard W.M. Jones 2023-12-11 17:20:47 +00:00
parent 09f3b77799
commit 29228bce64
31 changed files with 109 additions and 1012 deletions

View File

@ -0,0 +1,31 @@
From ec542c5cc09c49a7af9072581d5090bc18bfb6ec Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 9 Dec 2023 12:22:40 +0000
Subject: [PATCH] ocaml-dep.sh: Add common/mlcustomize to list of directories
to search
Avoids this error when you change a file under common/mlcustomize and
then rebuild virt-v2v:
Error: Files ../convert/mlconvert.cmxa
and ../common/mlcustomize/mlcustomize.cmxa
make inconsistent assumptions over implementation Inject_virtio_win
Fixes: commit 4b9c8e1560d67ac17e287450f61f4903d237fc47
See-also: commit c30df7ffb8fc04142b99cbb7ec1bebbb32ffb654
---
ocaml-dep.sh.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/ocaml-dep.sh.in b/ocaml-dep.sh.in
index 1e191d6d..7f3130e5 100755
--- a/ocaml-dep.sh.in
+++ b/ocaml-dep.sh.in
@@ -33,6 +33,7 @@ set -e
# directories must have unique names (eg. not Utils) else
# dependencies don't get built right.
include_dirs="
+common/mlcustomize
common/mldrivers
common/mlgettext
common/mlpcre

View File

@ -0,0 +1,26 @@
From 056401c8c6db33536c477078008649054f347a9c Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 9 Dec 2023 12:59:13 +0000
Subject: [PATCH] Update common submodule
Pick up this bug fix:
mltools/libosinfo-c.c: Fix off-by-one error
---
common | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Submodule common cd29aee9..0dba002c:
diff --git a/common/mltools/libosinfo-c.c b/common/mltools/libosinfo-c.c
index 93357fd9..a48c8989 100644
--- a/common/mltools/libosinfo-c.c
+++ b/common/mltools/libosinfo-c.c
@@ -296,7 +296,7 @@ v2v_osinfo_os_get_device_drivers (value osv)
driver = OSINFO_DEVICE_DRIVER(osinfo_list_get_nth (OSINFO_LIST(list), i));
- vi = caml_alloc (6, 0);
+ vi = caml_alloc (7, 0);
str = osinfo_device_driver_get_architecture (driver);
copyv = caml_copy_string (str);
Store_field (vi, 0, copyv);

View File

@ -1,4 +1,4 @@
From 3447e87d922d9d0bec765ce9ffeb21d13646bec2 Mon Sep 17 00:00:00 2001
From 714eb855ca5924245c5831f5f008306b7d1f6a2a Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 28 Sep 2014 19:14:43 +0100
Subject: [PATCH] RHEL: v2v: Select correct qemu binary for -o qemu mode
@ -16,7 +16,7 @@ support cases.
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/output/output_qemu.ml b/output/output_qemu.ml
index 57b1e58d..bb6b55c8 100644
index 1a5f7f71..97cf59a8 100644
--- a/output/output_qemu.ml
+++ b/output/output_qemu.ml
@@ -142,7 +142,7 @@ module QEMU = struct

View File

@ -1,4 +1,4 @@
From ebaa8a444b44e93e45ccbc2cddadffd19be6f19d Mon Sep 17 00:00:00 2001
From 419ab62f882db17dcbe32c1f1c80be51dfb00fec Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 30 Sep 2014 10:50:27 +0100
Subject: [PATCH] RHEL: v2v: Disable the --qemu-boot / -oo qemu-boot option
@ -44,7 +44,7 @@ index d2a1c270..0be37f5e 100644
=item B<-o null>
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
index 4d2f241a..de27b795 100644
index ac15108a..e993e21a 100644
--- a/docs/virt-v2v.pod
+++ b/docs/virt-v2v.pod
@@ -144,11 +144,6 @@ Since F<guest-domain.xml> contains the path(s) to the guest disk
@ -59,7 +59,7 @@ index 4d2f241a..de27b795 100644
=head1 OPTIONS
=over 4
@@ -517,9 +512,6 @@ This is similar to I<-o local>, except that a shell script is written
@@ -520,9 +515,6 @@ This is similar to I<-o local>, except that a shell script is written
which you can use to boot the guest in qemu. The converted disks and
shell script are written to the directory specified by I<-os>.
@ -69,7 +69,7 @@ index 4d2f241a..de27b795 100644
=item B<-o> B<rhev>
This is the same as I<-o rhv>.
@@ -598,11 +590,6 @@ For I<-o openstack> (L<virt-v2v-output-openstack(1)>) only, set a guest ID
@@ -601,11 +593,6 @@ For I<-o openstack> (L<virt-v2v-output-openstack(1)>) only, set a guest ID
which is saved on each Cinder volume in the C<virt_v2v_guest_id>
volume property.
@ -81,7 +81,7 @@ index 4d2f241a..de27b795 100644
=item B<-oo verify-server-certificate>
=item B<-oo verify-server-certificate=>C<true|false>
@@ -773,10 +760,6 @@ Print information about the source guest and stop. This option is
@@ -776,10 +763,6 @@ Print information about the source guest and stop. This option is
useful when you are setting up network and bridge maps.
See L</Networks and bridges>.
@ -93,7 +93,7 @@ index 4d2f241a..de27b795 100644
=item B<--quiet>
diff --git a/output/output_qemu.ml b/output/output_qemu.ml
index bb6b55c8..ae93fb89 100644
index 97cf59a8..ad3eb897 100644
--- a/output/output_qemu.ml
+++ b/output/output_qemu.ml
@@ -65,6 +65,9 @@ module QEMU = struct

View File

@ -1,4 +1,4 @@
From 389c370a34f805e744cb8352e3e980fbd0b52044 Mon Sep 17 00:00:00 2001
From dc27eb1d7634879fdd666b4526382d35718e8d61 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 24 Apr 2015 09:45:41 -0400
Subject: [PATCH] RHEL: Fix list of supported sound cards to match RHEL qemu
@ -9,7 +9,7 @@ Subject: [PATCH] RHEL: Fix list of supported sound cards to match RHEL qemu
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/utils.ml b/lib/utils.ml
index 174c01b1..54431307 100644
index 19c5ba91..7b3aa2e2 100644
--- a/lib/utils.ml
+++ b/lib/utils.ml
@@ -60,13 +60,14 @@ let kvm_arch = function

View File

@ -1,4 +1,4 @@
From c0bb624a151be3291e0c10c1002577615b98e74c Mon Sep 17 00:00:00 2001
From 8a04c776067ea059092d2e6435b3f1a34eadd42f Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 30 Aug 2015 03:21:57 -0400
Subject: [PATCH] RHEL: Fixes for libguestfs-winsupport.

View File

@ -1,4 +1,4 @@
From eaf5279f486590d24843ff63c9f95af33abffe39 Mon Sep 17 00:00:00 2001
From 249864cdb71388d9ffa18b32f2dc68ee38446c0b Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 2 Mar 2017 14:21:37 +0100
Subject: [PATCH] RHEL: v2v: -i disk: force VNC as display (RHBZ#1372671)

View File

@ -1,4 +1,4 @@
From 71ab7854f53b0b9338de12d7dadb2c4754dfcff6 Mon Sep 17 00:00:00 2001
From 6f681ece3f020326a472055e343847ee4e865a13 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Wed, 8 Mar 2017 11:03:40 +0100
Subject: [PATCH] RHEL: v2v: do not mention SUSE Xen hosts (RHBZ#1430203)

View File

@ -1,4 +1,4 @@
From 134fb5cd6925e8af155d1f84db55d3742f2f256f Mon Sep 17 00:00:00 2001
From 53ab6bfebc6c9b6076ca40d8e295215d59a3ff2e Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 26 Mar 2019 09:42:25 +0100
Subject: [PATCH] RHEL: point to KB for supported v2v hypervisors/guests

View File

@ -1,4 +1,4 @@
From e4ffc4800bd8a4bbec56b374cc6d21dff88f15ae Mon Sep 17 00:00:00 2001
From 26a872919340dc1b319b9b9d00f818154a544b1f Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 30 Jun 2021 11:15:52 +0100
Subject: [PATCH] RHEL: Disable -o glance
@ -98,10 +98,10 @@ index cd4862b1..54cd276e 100644
=head1 AUTHOR
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
index de27b795..e5400ca7 100644
index e993e21a..a5c844f1 100644
--- a/docs/virt-v2v.pod
+++ b/docs/virt-v2v.pod
@@ -431,14 +431,6 @@ See L</Networks and bridges> below.
@@ -433,14 +433,6 @@ See L</Networks and bridges> below.
This is the same as I<-o local>.
@ -116,7 +116,7 @@ index de27b795..e5400ca7 100644
=item B<-o> B<kubevirt>
Set the output method to I<kubevirt>. B<Note the way this mode works
@@ -1182,11 +1174,6 @@ and output methods may use disk space, as outlined in the table below.
@@ -1185,11 +1177,6 @@ and output methods may use disk space, as outlined in the table below.
This temporarily places a full copy of the uncompressed source disks
in C<$VIRT_V2V_TMPDIR> (or F</var/tmp>).
@ -128,7 +128,7 @@ index de27b795..e5400ca7 100644
=item I<-o local>
=item I<-o qemu>
@@ -1370,13 +1357,6 @@ instance.
@@ -1375,13 +1362,6 @@ See also L</Starting the libvirt system instance>.
Because of how Cinder volumes are presented as F</dev> block devices,
using I<-o openstack> normally requires that virt-v2v is run as root.

View File

@ -1,4 +1,4 @@
From 8eb1f90c3e894da7f528dbc1c54960ebcf0f759b Mon Sep 17 00:00:00 2001
From eec1c6b2e7fe8a9dec3f1d7092ea6738fd166885 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 2 Dec 2021 11:56:05 +0000
Subject: [PATCH] RHEL: Remove the --in-place option
@ -12,7 +12,7 @@ wish to support in RHEL.
3 files changed, 17 deletions(-)
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
index e5400ca7..fc7e0d82 100644
index a5c844f1..d85a2029 100644
--- a/docs/virt-v2v.pod
+++ b/docs/virt-v2v.pod
@@ -24,9 +24,6 @@ virtualize those machines (physical to virtual, or p2v).
@ -36,7 +36,7 @@ index e5400ca7..fc7e0d82 100644
=head2 Other virt-v2v topics
L<virt-v2v-support(1)> — Supported hypervisors, virtualization
@@ -1622,7 +1615,6 @@ L<https://rwmj.wordpress.com/2015/09/18/importing-kvm-guests-to-ovirt-or-rhev/#c
@@ -1643,7 +1636,6 @@ L<https://rwmj.wordpress.com/2015/09/18/importing-kvm-guests-to-ovirt-or-rhev/#c
L<virt-p2v(1)>,
L<virt-v2v-inspector(1)>,

View File

@ -1,4 +1,4 @@
From dbf8c50d6d0e157c13e505a22f6f397cb991139c Mon Sep 17 00:00:00 2001
From 9bb2e6380eaa0131c43a8cc5e6b4bbdb02380b96 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 5 Jul 2022 11:56:54 +0100
Subject: [PATCH] RHEL 9: -oo compressed: Remove nbdcopy version check and test

View File

@ -1,4 +1,4 @@
From 81b28218e676cdc57bd6f8427cfd5faf85162d4a Mon Sep 17 00:00:00 2001
From 4db6cbedc3e71b05e9defd356e7289bf01e2b985 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 5 Jul 2022 11:58:09 +0100
Subject: [PATCH] RHEL 9: tests: Remove btrfs test

View File

@ -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

View File

@ -1,4 +1,4 @@
From 9c18f8772f7c8801ef47126f55b0313dc2188b03 Mon Sep 17 00:00:00 2001
From e8def768b455b6e09c00fa48265a876acbc75837 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 28 Apr 2023 12:28:19 +0100
Subject: [PATCH] RHEL 9: Remove --block-driver option
@ -37,7 +37,7 @@ index ce57e229..6e1c5363 100644
=item B<--colours>
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
index fc7e0d82..0394b421 100644
index d85a2029..058eb800 100644
--- a/docs/virt-v2v.pod
+++ b/docs/virt-v2v.pod
@@ -195,16 +195,6 @@ The options are silently ignored for other input methods.

View File

@ -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/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;
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);

View File

@ -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[@]}"

View File

@ -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[@]}"

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,99 +0,0 @@
From 35c987dcaaca7eb546ca35875f94623cca68c8b4 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 25 Sep 2023 14:14:18 +0100
Subject: [PATCH] types: Add gcaps_rtc_utc to record if the RTC is set to UTC
or localtime
Almost every Linux guest expects the motherboard Real Time Clock (RTC)
to be set to UTC and they adjust the time displayed based on their
timezone (which may be different for each user).
Most Windows guests expect the RTC to be set to the local time.
Windows can be configured to use a UTC clock. We can detect this by
looking at the Windows registry.
To cope with this difference we need to add a guestcaps flag based on
what we think the guest is expecting. (We might also use the source
hypervisor RTC setting, but it is not thought to be as reliable as
inspecting the guest.)
This change simply adds the flag to guestcaps, and sets it to always
true, so there is no change to the output.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 69d73c251a71586c870bf0cb185107f80caee270)
---
convert/convert_linux.ml | 1 +
convert/convert_windows.ml | 1 +
lib/types.ml | 3 +++
lib/types.mli | 5 +++++
4 files changed, 10 insertions(+)
diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml
index 8d702084..bd54568b 100644
--- a/convert/convert_linux.ml
+++ b/convert/convert_linux.ml
@@ -220,6 +220,7 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ =
gcaps_arch = Utils.kvm_arch inspect.i_arch;
gcaps_arch_min_version = arch_min_version;
gcaps_virtio_1_0 = virtio_1_0;
+ gcaps_rtc_utc = true; (* almost all Linux expect RTC to be UTC *)
} in
guestcaps
diff --git a/convert/convert_windows.ml b/convert/convert_windows.ml
index 122d9546..7e3aa8d7 100644
--- a/convert/convert_windows.ml
+++ b/convert/convert_windows.ml
@@ -275,6 +275,7 @@ let convert (g : G.guestfs) _ inspect i_firmware block_driver _ static_ips =
gcaps_arch = Utils.kvm_arch inspect.i_arch;
gcaps_arch_min_version = 0;
gcaps_virtio_1_0 = virtio_win_installed.Inject_virtio_win.virtio_1_0;
+ gcaps_rtc_utc = true;
} in
guestcaps
diff --git a/lib/types.ml b/lib/types.ml
index 75c14fd4..d6f9a266 100644
--- a/lib/types.ml
+++ b/lib/types.ml
@@ -399,6 +399,7 @@ type guestcaps = {
gcaps_arch : string;
gcaps_arch_min_version : int;
gcaps_virtio_1_0 : bool;
+ gcaps_rtc_utc : bool;
}
and guestcaps_block_type = Virtio_blk | Virtio_SCSI | IDE
and guestcaps_net_type = Virtio_net | E1000 | RTL8139
@@ -429,6 +430,7 @@ let string_of_guestcaps gcaps =
gcaps_arch = %s\n\
gcaps_arch_min_version = %d\n\
gcaps_virtio_1_0 = %b\n\
+ gcaps_rtc_utc = %b\n\
"
(string_of_block_type gcaps.gcaps_block_bus)
(string_of_net_type gcaps.gcaps_net_bus)
@@ -440,6 +442,7 @@ let string_of_guestcaps gcaps =
gcaps.gcaps_arch
gcaps.gcaps_arch_min_version
gcaps.gcaps_virtio_1_0
+ gcaps.gcaps_rtc_utc
type target_buses = {
target_virtio_blk_bus : target_bus_slot array;
diff --git a/lib/types.mli b/lib/types.mli
index 65ef2e35..3446bb64 100644
--- a/lib/types.mli
+++ b/lib/types.mli
@@ -277,6 +277,11 @@ type guestcaps = {
gcaps_virtio_1_0 : bool;
(** The guest supports the virtio devices that it does at the virtio-1.0
protocol level. *)
+
+ gcaps_rtc_utc : bool;
+ (** Is the RTC set to UTC ([true]) or localtime ([false])? For
+ Linux guests this is always true. For Windows we find out
+ what the guest is expecting by looking at the registry. *)
}
(** Guest capabilities after conversion. eg. Was virtio found or installed? *)

View File

@ -1,28 +0,0 @@
From 6964d1efbea560918c07bf99dcac81549947aadf Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 25 Sep 2023 14:31:17 +0100
Subject: [PATCH] -o kubevirt: Add comment about future support for clock =
localtime
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit dfb44983a801fb57016298c79db6271262f78455)
---
output/create_kubevirt_yaml.ml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/output/create_kubevirt_yaml.ml b/output/create_kubevirt_yaml.ml
index 689555e4..e3a3f422 100644
--- a/output/create_kubevirt_yaml.ml
+++ b/output/create_kubevirt_yaml.ml
@@ -54,6 +54,11 @@ let create_kubevirt_yaml source inspect
"pit", Assoc [ "tickPolicy", String "delay" ];
"rtc", Assoc [ "tickPolicy", String "catchup" ];
];
+ (* XXX Note that we may need to set "localtime" here
+ * depending on guestcaps.gcaps_rtc_utc. However that
+ * requires the following PR to be merged in Kubevirt:
+ * https://github.com/kubevirt/kubevirt/pull/9587
+ *)
"utc", List []
]
)

View File

@ -1,31 +0,0 @@
From 3e6b4edc09972f311e2561fbac101f2a23001396 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 25 Sep 2023 16:58:35 +0100
Subject: [PATCH] output/create_libvirt_xml.ml: Refactor os_section
Minor refactoring of how <os> section is generated in XML output.
There is no change in the output.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit baaeead927eb72e78c7b09fd285427e9b048ee31)
---
output/create_libvirt_xml.ml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/output/create_libvirt_xml.ml b/output/create_libvirt_xml.ml
index 964acd25..12586fde 100644
--- a/output/create_libvirt_xml.ml
+++ b/output/create_libvirt_xml.ml
@@ -292,10 +292,10 @@ let create_libvirt_xml ?pool source inspect
e "nvram" ["template", vars_template] [] ] in
List.push_back_list os loader;
- !os in
+ e "os" [] !os in
List.push_back_list body [
- e "os" [] os_section;
+ os_section;
e "on_poweroff" [] [PCData "destroy"];
e "on_reboot" [] [PCData "restart"];

View File

@ -1,44 +0,0 @@
From f6b05e26cf6622d1010122b56848511b1ecd660e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 25 Sep 2023 14:35:37 +0100
Subject: [PATCH] -o libvirt: Add <clock offset="utc|localtime"/> to libvirt
XML
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 93b86b8634428c1e3210d10cffa548ee5473418a)
---
output/create_libvirt_xml.ml | 6 ++++++
tests/test-v2v-i-ova.xml | 1 +
2 files changed, 7 insertions(+)
diff --git a/output/create_libvirt_xml.ml b/output/create_libvirt_xml.ml
index 12586fde..30119d13 100644
--- a/output/create_libvirt_xml.ml
+++ b/output/create_libvirt_xml.ml
@@ -294,8 +294,14 @@ let create_libvirt_xml ?pool source inspect
List.push_back_list os loader;
e "os" [] !os in
+ (* The <clock> section. *)
+ let clock_section =
+ let offset = if guestcaps.gcaps_rtc_utc then "utc" else "localtime" in
+ e "clock" [ "offset", offset ] [] in
+
List.push_back_list body [
os_section;
+ clock_section;
e "on_poweroff" [] [PCData "destroy"];
e "on_reboot" [] [PCData "restart"];
diff --git a/tests/test-v2v-i-ova.xml b/tests/test-v2v-i-ova.xml
index e5907ea1..a41827bf 100644
--- a/tests/test-v2v-i-ova.xml
+++ b/tests/test-v2v-i-ova.xml
@@ -18,6 +18,7 @@
<os>
<type arch='x86_64' machine='q35'>hvm</type>
</os>
+ <clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

View File

@ -1,28 +0,0 @@
From dff314e22ba2d5666ba6a4f3440a7c9e1a658bb3 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 25 Sep 2023 14:41:58 +0100
Subject: [PATCH] -o qemu: Set -rtc base=localtime when guest expects RTC set
to localtime
I didn't set the -rtc flag in the normal (UTC) case as that is the
default.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 482d75bbe5cd242576cf3f8cb9062d13d511871e)
---
output/output_qemu.ml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/output/output_qemu.ml b/output/output_qemu.ml
index ae93fb89..ad3eb897 100644
--- a/output/output_qemu.ml
+++ b/output/output_qemu.ml
@@ -161,6 +161,8 @@ module QEMU = struct
arg_list "-device" ["vmgenid"; sprintf "guid=%s" genid; "id=vmgenid0"]
);
+ if not guestcaps.gcaps_rtc_utc then arg "-rtc" "base=localtime";
+
arg_list "-machine" (machine_str ::
(if smm then ["smm=on"] else []) @
["accel=kvm:tcg"]);

View File

@ -1,89 +0,0 @@
From e7fe97447e5abb1f3343dde1710b0cffdd443e00 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 25 Sep 2023 15:00:12 +0100
Subject: [PATCH] convert: Find out if Windows guest is expecting RTC set to
UTC
Read HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation key
"RealTimeIsUniversal" to see if the Windows guest is expecting RTC
set to localtime (not present) or UTC (present and set to 1).
See: https://wiki.archlinux.org/title/System_time#UTC_in_Microsoft_Windows
See: https://listman.redhat.com/archives/libguestfs/2023-September/thread.html#32556
Reported-by: Lee Garrett
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 5f58def90a4485627e8207782165db5a2899b72a)
---
convert/convert_windows.ml | 38 +++++++++++++++++++++++++++++++++++++-
tests/test-v2v-i-ova.xml | 2 +-
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/convert/convert_windows.ml b/convert/convert_windows.ml
index 7e3aa8d7..34cf341b 100644
--- a/convert/convert_windows.ml
+++ b/convert/convert_windows.ml
@@ -103,6 +103,42 @@ let convert (g : G.guestfs) _ inspect i_firmware block_driver _ static_ips =
(* If the Windows guest has AV installed. *)
let has_antivirus = Windows.detect_antivirus inspect in
+ (* Does the guest expect the RTC to be set to UTC or localtime?
+ * See https://wiki.archlinux.org/title/System_time#UTC_in_Microsoft_Windows
+ * Note this might be a QWORD on 64 bit Windows instances.
+ *)
+ let rtc_utc =
+ Registry.with_hive_readonly g inspect.i_windows_system_hive
+ (fun reg ->
+ try
+ let key_path = [ "Control"; "TimeZoneInformation" ] in
+ let path = inspect.i_windows_current_control_set :: key_path in
+ let node =
+ match Registry.get_node reg path with
+ | None -> raise Not_found
+ | Some node -> node in
+ let valueh = g#hivex_node_get_value node "RealTimeIsUniversal" in
+ if valueh = 0L then raise Not_found;
+ let t = g#hivex_value_type valueh in
+ let data = g#hivex_value_value valueh in
+ let is_utc =
+ match t with
+ | 0_L (* REG_NONE *) -> false (* localtime *)
+ | 4_L (* REG_DWORD *) -> data = "\001\000\000\000"
+ | 11_L (* REG_QWORD *) -> data = "\001\000\000\000\000\000\000\000"
+ | _ (* who knows ... *) ->
+ warning (f_"unknown CurrentControlSet\\Control\\\
+ TimeZoneInformation key RealTimeIsUniversal \
+ type 0x%Lx, assuming RTC set to UTC") t;
+ true in
+ is_utc
+ with Not_found ->
+ (* If the key is not found then by default we assume
+ * that Windows is expecting the RTC to be set to localtime.
+ *)
+ false
+ ) in
+
(* Open the software hive (readonly) and find the Xen PV uninstaller,
* if it exists.
*)
@@ -275,7 +311,7 @@ let convert (g : G.guestfs) _ inspect i_firmware block_driver _ static_ips =
gcaps_arch = Utils.kvm_arch inspect.i_arch;
gcaps_arch_min_version = 0;
gcaps_virtio_1_0 = virtio_win_installed.Inject_virtio_win.virtio_1_0;
- gcaps_rtc_utc = true;
+ gcaps_rtc_utc = rtc_utc;
} in
guestcaps
diff --git a/tests/test-v2v-i-ova.xml b/tests/test-v2v-i-ova.xml
index a41827bf..fa7b4dbf 100644
--- a/tests/test-v2v-i-ova.xml
+++ b/tests/test-v2v-i-ova.xml
@@ -18,7 +18,7 @@
<os>
<type arch='x86_64' machine='q35'>hvm</type>
</os>
- <clock offset='utc'/>
+ <clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

View File

@ -1,38 +0,0 @@
From 450e6c712b65eed91427fb9ac8c8e19b4e8eb9ad Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 2 Oct 2023 10:00:10 +0100
Subject: [PATCH] -it ssh: Double quote ssh command which tests remote file
exists
Double quoting was removed in
commit e2af12ba69c4463bb73d30db63290a887cdd41eb ("input: -i vmx:
Remove support for openssh scp < 8.8", Nov 2021). However it should
only have been removed from scp commands, not for this ssh command
where it is still required.
See: https://github.com/libguestfs/virt-v2v/issues/35
Thanks: Laszlo Ersek for diagnosis and suggesting the fix
Reported-by: Bill Sanders
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 22c5b98ab78c734b478c26e14ee62e2a065aaa0c)
---
input/parse_domain_from_vmx.ml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml
index 15ee093f..2e75e785 100644
--- a/input/parse_domain_from_vmx.ml
+++ b/input/parse_domain_from_vmx.ml
@@ -97,7 +97,11 @@ let remote_file_exists uri path =
| None -> ""
| Some user -> quote user ^ "@")
(quote (server_of_uri uri))
- (quote path) in
+ (* 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

View File

@ -1,2 +1,2 @@
SHA512 (virt-v2v-2.3.4.tar.gz) = 0ed49b4bcfc17d1ef769eb740fc70f16d1c8a53b0f6135e758bbc7bbad619302ec158db17bba7673bcfcf702c90f324c34135a4fc3221f7324af0b1780d9d75f
SHA512 (virt-v2v-2.3.4.tar.gz.sig) = 6a59411c1a9fa14ee065076d1e96df4071eccbef6415c70889f02234fd3fe4daba854e70b1b7c761d3017f1c8ebf640fa4c1663da35b1c5763e350f1eb6adf10
SHA512 (virt-v2v-2.3.7.tar.gz) = 7b17319c2dbcb594a98d0f2b0605ea9fd6cd6c01fd9cc21f8964b438a280d2c39cb5badb7d992e65d3823a44c8d662a00bdf8b7922991c078cd34d5943db4c1f
SHA512 (virt-v2v-2.3.7.tar.gz.sig) = 2b66218532f8e85804b4cdf059cabb9b64b4619c4c238cca41682581af073fba2389ebad6874ad756c0d382f09e1ca7bc4b89441f7c298406c44ea2a6729dc25

View File

@ -15,11 +15,11 @@
Name: virt-v2v
Epoch: 1
Version: 2.3.4
Release: 6%{?dist}
Version: 2.3.7
Release: 1%{?dist}
Summary: Convert a virtual machine to run on KVM
License: GPLv2+
License: GPL-2.0-or-later AND LGPL-2.0-or-later
URL: https://github.com/libguestfs/virt-v2v
Source0: http://download.libguestfs.org/virt-v2v/%{source_directory}/%{name}-%{version}.tar.gz
@ -33,36 +33,23 @@ Source2: libguestfs.keyring
Source3: copy-patches.sh
# Patches are maintained in the following repository:
# https://github.com/libguestfs/virt-v2v/commits/rhel-9.3
# https://github.com/libguestfs/virt-v2v/commits/rhel-9.4
# Patches.
Patch0001: 0001-RHEL-v2v-Select-correct-qemu-binary-for-o-qemu-mode-.patch
Patch0002: 0002-RHEL-v2v-Disable-the-qemu-boot-oo-qemu-boot-option-R.patch
Patch0003: 0003-RHEL-Fix-list-of-supported-sound-cards-to-match-RHEL.patch
Patch0004: 0004-RHEL-Fixes-for-libguestfs-winsupport.patch
Patch0005: 0005-RHEL-v2v-i-disk-force-VNC-as-display-RHBZ-1372671.patch
Patch0006: 0006-RHEL-v2v-do-not-mention-SUSE-Xen-hosts-RHBZ-1430203.patch
Patch0007: 0007-RHEL-point-to-KB-for-supported-v2v-hypervisors-guest.patch
Patch0008: 0008-RHEL-Disable-o-glance.patch
Patch0009: 0009-RHEL-Remove-the-in-place-option.patch
Patch0010: 0010-RHEL-9-oo-compressed-Remove-nbdcopy-version-check-an.patch
Patch0011: 0011-RHEL-9-tests-Remove-btrfs-test.patch
Patch0012: 0012-RHEL-9-Remove-block-driver-option.patch
Patch0013: 0013-Update-common-submodule.patch
Patch0014: 0014-update-common-submodule.patch
Patch0015: 0015-LUKS-on-LVM-conversion-test-rename-VGs-and-LVs.patch
Patch0016: 0016-LUKS-on-LVM-conversion-test-test-dev-mapper-VG-LV-tr.patch
Patch0017: 0017-test-data-phony-guests-fix-prerequisite-list-of-fedo.patch
Patch0018: 0018-lib-utils-fix-typo.patch
Patch0019: 0019-lib-utils-make-chown_for_libvirt_rhbz_1045069-fail-h.patch
Patch0020: 0020-docs-virt-v2v-document-libvirt-system-instance-start.patch
Patch0021: 0021-types-Add-gcaps_rtc_utc-to-record-if-the-RTC-is-set-.patch
Patch0022: 0022-o-kubevirt-Add-comment-about-future-support-for-cloc.patch
Patch0023: 0023-output-create_libvirt_xml.ml-Refactor-os_section.patch
Patch0024: 0024-o-libvirt-Add-clock-offset-utc-localtime-to-libvirt-.patch
Patch0025: 0025-o-qemu-Set-rtc-base-localtime-when-guest-expects-RTC.patch
Patch0026: 0026-convert-Find-out-if-Windows-guest-is-expecting-RTC-s.patch
Patch0027: 0027-it-ssh-Double-quote-ssh-command-which-tests-remote-f.patch
Patch0001: 0001-ocaml-dep.sh-Add-common-mlcustomize-to-list-of-direc.patch
Patch0002: 0002-Update-common-submodule.patch
Patch0003: 0003-RHEL-v2v-Select-correct-qemu-binary-for-o-qemu-mode-.patch
Patch0004: 0004-RHEL-v2v-Disable-the-qemu-boot-oo-qemu-boot-option-R.patch
Patch0005: 0005-RHEL-Fix-list-of-supported-sound-cards-to-match-RHEL.patch
Patch0006: 0006-RHEL-Fixes-for-libguestfs-winsupport.patch
Patch0007: 0007-RHEL-v2v-i-disk-force-VNC-as-display-RHBZ-1372671.patch
Patch0008: 0008-RHEL-v2v-do-not-mention-SUSE-Xen-hosts-RHBZ-1430203.patch
Patch0009: 0009-RHEL-point-to-KB-for-supported-v2v-hypervisors-guest.patch
Patch0010: 0010-RHEL-Disable-o-glance.patch
Patch0011: 0011-RHEL-Remove-the-in-place-option.patch
Patch0012: 0012-RHEL-9-oo-compressed-Remove-nbdcopy-version-check-an.patch
Patch0013: 0013-RHEL-9-tests-Remove-btrfs-test.patch
Patch0014: 0014-RHEL-9-Remove-block-driver-option.patch
%if !0%{?rhel}
# libguestfs hasn't been built on i686 for a while since there is no
@ -366,9 +353,14 @@ make -C tests TESTS=test-v2v-fedora-luks-on-lvm-conversion.sh check
%changelog
* Fri Nov 10 2023 Richard W.M. Jones <rjones@redhat.com> - 1:2.3.4-6
* Mon Dec 11 2023 Richard W.M. Jones <rjones@redhat.com> - 1:2.3.7-1
- Rebase to virt-v2v 2.3.7
- -it ssh: Double quote ssh command which tests remote file exists
resolves: RHEL-12105
- Implement --key all:...
resolves: RHEL-18142
- Fix off-by-one error causing rare crash
resolves: RHEL-19061
* Mon Jul 03 2023 Laszlo Ersek <lersek@redhat.com> - 1:2.3.4-5
- improve UX when running as root and we can't chown v2v tmpdir or socks