Compare commits

...

No commits in common. "imports/c8-stream-rhel/virt-v2v-1.42.0-19.module+el8.6.0+15577+2ffd6ffa" and "c8-beta-stream-rhel" have entirely different histories.

59 changed files with 912 additions and 342 deletions

View File

@ -36,6 +36,3 @@ index 7df17b29..4d0b8639 100644
let get_domain conn name =
let dom =
--
2.27.0

View File

@ -1,34 +0,0 @@
From 96ea18db4a4f2e336145553c0fbbba59ede2221e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 30 Mar 2020 14:34:43 +0100
Subject: [PATCH 1/4] options: Use new cryptsetup-open API if available.
Fall back to luks-open if we're using libguestfs <= 1.43.1.
---
options/decrypt.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/options/decrypt.c b/options/decrypt.c
index 683cf5e..d868f70 100644
--- a/common/options/decrypt.c
+++ b/common/options/decrypt.c
@@ -97,11 +97,15 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
/* Try each key in turn. */
for (j = 0; keys[j] != NULL; ++j) {
- /* XXX Should we call guestfs_luks_open_ro if readonly flag
+ /* XXX Should we set GUESTFS_CRYPTSETUP_OPEN_READONLY if readonly
* is set? This might break 'mount_ro'.
*/
guestfs_push_error_handler (g, NULL, NULL);
+#ifdef GUESTFS_HAVE_CRYPTSETUP_OPEN
+ r = guestfs_cryptsetup_open (g, partitions[i], keys[j], mapname, -1);
+#else
r = guestfs_luks_open (g, partitions[i], keys[j], mapname);
+#endif
guestfs_pop_error_handler (g);
if (r == 0)
goto opened;
--
2.18.4

View File

@ -209,6 +209,3 @@ index 120a52f7..3cbca9d7 100644
-val input_libvirt_xen_ssh : Libvirt.rw Libvirt.Connect.t Lazy.t -> string option -> Xml.uri -> string -> string -> Types.input
+val input_libvirt_xen_ssh : Libvirt.rw Libvirt.Connect.t Lazy.t -> string -> string option -> Xml.uri -> string -> string -> Types.input
--
2.27.0

View File

@ -1,41 +0,0 @@
From f9770058fa3bd8871b8b4ded0b10d4be418224ae Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 7 Sep 2020 10:15:40 +0100
Subject: [PATCH 2/4] options: Use cryptX instead of luksX as the temporary
name.
---
options/decrypt.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/options/decrypt.c b/options/decrypt.c
index d868f70..45de5b2 100644
--- a/common/options/decrypt.c
+++ b/common/options/decrypt.c
@@ -38,18 +38,18 @@
/**
* Make a LUKS map name from the partition name,
- * eg. C<"/dev/vda2" =E<gt> "luksvda2">
+ * eg. C<"/dev/vda2" =E<gt> "cryptvda2">
*/
static void
make_mapname (const char *device, char *mapname, size_t len)
{
size_t i = 0;
- if (len < 5)
+ if (len < 6)
abort ();
- strcpy (mapname, "luks");
- mapname += 4;
- len -= 4;
+ strcpy (mapname, "crypt");
+ mapname += 5;
+ len -= 5;
if (STRPREFIX (device, "/dev/"))
i = 5;
--
2.18.4

View File

@ -1,56 +0,0 @@
From 778c08fe7b7eb00b7f48189dd1a3edf3f3be2625 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 30 Mar 2020 14:40:45 +0100
Subject: [PATCH 3/4] options: Support Windows BitLocker (RHBZ#1808977).
---
mltools/tools_utils.mli | 5 ++---
options/decrypt.c | 9 ++++-----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/mltools/tools_utils.mli b/mltools/tools_utils.mli
index 102abff..1d1ac8a 100644
--- a/common/mltools/tools_utils.mli
+++ b/common/mltools/tools_utils.mli
@@ -195,9 +195,8 @@ val is_btrfs_subvolume : Guestfs.guestfs -> string -> bool
(** Checks if a filesystem is a btrfs subvolume. *)
val inspect_decrypt : Guestfs.guestfs -> key_store -> unit
-(** Simple implementation of decryption: look for any [crypto_LUKS]
- partitions and decrypt them, then rescan for VGs. This only works
- for Fedora whole-disk encryption. *)
+(** Simple implementation of decryption: look for any encrypted
+ partitions and decrypt them, then rescan for VGs. *)
val with_timeout : string -> int -> ?sleep:int -> (unit -> 'a option) -> 'a
(** [with_timeout op timeout ?sleep fn] implements a timeout loop.
diff --git a/options/decrypt.c b/options/decrypt.c
index 45de5b2..8eb24bc 100644
--- a/common/options/decrypt.c
+++ b/common/options/decrypt.c
@@ -65,10 +65,8 @@ make_mapname (const char *device, char *mapname, size_t len)
}
/**
- * Simple implementation of decryption: look for any C<crypto_LUKS>
- * partitions and decrypt them, then rescan for VGs. This only works
- * for Fedora whole-disk encryption. WIP to make this work for other
- * encryption schemes.
+ * Simple implementation of decryption: look for any encrypted
+ * partitions and decrypt them, then rescan for VGs.
*/
void
inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
@@ -82,7 +80,8 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
for (i = 0; partitions[i] != NULL; ++i) {
CLEANUP_FREE char *type = guestfs_vfs_type (g, partitions[i]);
- if (type && STREQ (type, "crypto_LUKS")) {
+ if (type &&
+ (STREQ (type, "crypto_LUKS") || STREQ (type, "BitLocker"))) {
char mapname[32];
make_mapname (partitions[i], mapname, sizeof mapname);
--
2.18.4

View File

@ -29,6 +29,3 @@ index c28a4ced..4c128b0c 100644
let headers =
List.map (
--
2.27.0

View File

@ -1,50 +0,0 @@
From 132c355d3ba10b6ec303cbc059d6732056474695 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 6 Oct 2020 15:04:27 +0100
Subject: [PATCH 4/4] options: Ignore errors from guestfs_luks_uuid.
For BitLocker disks cryptsetup does not (yet? ever?) support reading
UUIDs and this function will fail. Skip reading the UUID in this
case.
Updates commit bb4a2dc17a78b53437896d4215ae82df8e11b788.
---
options/decrypt.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/options/decrypt.c b/options/decrypt.c
index 8eb24bc..434b7d5 100644
--- a/common/options/decrypt.c
+++ b/common/options/decrypt.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <libintl.h>
#include <error.h>
@@ -82,11 +83,19 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
CLEANUP_FREE char *type = guestfs_vfs_type (g, partitions[i]);
if (type &&
(STREQ (type, "crypto_LUKS") || STREQ (type, "BitLocker"))) {
+ bool is_bitlocker = STREQ (type, "BitLocker");
char mapname[32];
make_mapname (partitions[i], mapname, sizeof mapname);
#ifdef GUESTFS_HAVE_LUKS_UUID
- CLEANUP_FREE char *uuid = guestfs_luks_uuid (g, partitions[i]);
+ CLEANUP_FREE char *uuid = NULL;
+
+ /* This fails for Windows BitLocker disks because cryptsetup
+ * luksUUID cannot read a UUID (unclear if this is a limitation
+ * of the format or cryptsetup).
+ */
+ if (!is_bitlocker)
+ uuid = guestfs_luks_uuid (g, partitions[i]);
#else
const char *uuid = NULL;
#endif
--
2.18.4

View File

@ -92,6 +92,3 @@ index 05553c4f..5a1fba0f 100644
] [];
(match pool with
| None ->
--
2.27.0

View File

@ -46,6 +46,3 @@ index 979c3773..402dfd0e 100644
cmd, args
)
else cmd, [] in
--
2.27.0

View File

@ -44,6 +44,3 @@ index 402dfd0e..bfda91a7 100644
(* Caching extents speeds up qemu-img, especially its consecutive
* block_status requests with req_one=1.
--
2.27.0

View File

@ -111,6 +111,3 @@ index bfda91a7..47832011 100644
let run cmd =
let sock, _ = Nbdkit.run_unix cmd in
--
2.27.0

View File

@ -52,6 +52,3 @@ index 47832011..f5e91911 100644
| PasswordFile password_file ->
Nbdkit.add_arg cmd "password" ("+" ^ password_file) in
--
2.27.0

View File

@ -39,6 +39,3 @@ index 1ab6bb4d..497840c2 100644
typedef OsinfoDb *OsinfoDb_t;
typedef OsinfoOs *OsinfoOs_t;
--
2.27.0

View File

@ -11,7 +11,7 @@ Subject: [PATCH] v2v: Use common documentation for --keys-from-stdin.
Submodule common be42b0b8..5ea1baec:
diff --git a/common/options/Makefile.am b/common/options/Makefile.am
index b38fedc..f7ea749 100644
index b38fedc7..f7ea7493 100644
--- a/common/options/Makefile.am
+++ b/common/options/Makefile.am
@@ -19,6 +19,7 @@ include $(top_srcdir)/subdir-rules.mk
@ -24,7 +24,7 @@ index b38fedc..f7ea749 100644
# liboptions.la contains guestfish code which is used in other
diff --git a/common/options/keys-from-stdin-option.pod b/common/options/keys-from-stdin-option.pod
new file mode 100644
index 0000000..03c5339
index 00000000..03c5339b
--- /dev/null
+++ b/common/options/keys-from-stdin-option.pod
@@ -0,0 +1,4 @@
@ -55,6 +55,3 @@ index a00fa8af..74934eb4 100644
=item B<--mac> aa:bb:cc:dd:ee:ffB<:network:>out
--
2.27.0

View File

@ -11,7 +11,7 @@ Subject: [PATCH] docs: Multiple keys must be supplied one per line
Submodule common 5ea1baec..9338df5e:
diff --git a/common/options/keys-from-stdin-option.pod b/common/options/keys-from-stdin-option.pod
index 03c5339..8379039 100644
index 03c5339b..83790394 100644
--- a/common/options/keys-from-stdin-option.pod
+++ b/common/options/keys-from-stdin-option.pod
@@ -2,3 +2,6 @@
@ -21,6 +21,3 @@ index 03c5339..8379039 100644
+
+If there are multiple encrypted devices then you may need to supply
+multiple keys on stdin, one per line.
--
2.27.0

View File

@ -121,6 +121,3 @@ index 249137ab..3b74f307 100644
in
let no_trim_warning _ =
--
2.27.0

View File

@ -28,6 +28,3 @@ index 4d0b8639..1a24b049 100644
List.map (
function
| { Libvirt.Connect.typ = Libvirt.Connect.CredentialPassphrase } -> password
--
2.27.0

View File

@ -28,6 +28,3 @@ index be3a3c5e..85d08265 100644
let flag = Qemuopts.flag cmd
and arg = Qemuopts.arg cmd
--
2.27.0

View File

@ -100,6 +100,3 @@ index 3b74f307..df69e2e0 100644
Output_qemu.output_qemu os qemu_boot,
output_format, output_alloc
--
2.27.0

View File

@ -29,6 +29,3 @@ index ccbb9d68..c2940582 100644
(* Find the UEFI firmware. *)
let find_uefi_firmware guest_arch =
--
2.27.0

View File

@ -74,6 +74,3 @@ index f1da222a..ff94fe39 100755
diff -u "$expected" "$response"
# We also update the Registry several times, for firstboot, and (ONLY
--
2.27.0

View File

@ -281,6 +281,3 @@ index df69e2e0..7b79d462 100644
(* Common error message. *)
let error_option_cannot_be_used_in_output_mode mode opt =
error (f_"-o %s: %s option cannot be used in this output mode") mode opt
--
2.27.0

View File

@ -21,6 +21,3 @@ index d146e84c..4e403003 100644
s_listen = LNoListen; s_port = None };
s_video = None;
s_sound = None;
--
2.27.0

View File

@ -21,6 +21,3 @@ index 3b3cf0f0..32da2848 100644
=head1 INPUT FROM XEN
--
2.27.0

View File

@ -84,6 +84,3 @@ index d3e6260e..471102da 100644
storage_domains=[
types.StorageDomain(
name=params['output_storage'],
--
2.27.0

View File

@ -22,6 +22,3 @@ index 33c5e9a2..b1ea8f9d 100644
type script = {
tmpdir : string; (* Temporary directory. *)
--
2.27.0

View File

@ -120,6 +120,3 @@ index 8333366b..a5150907 100644
=head2 Guest firmware
--
2.27.0

View File

@ -383,6 +383,3 @@ index 73edff2c..a58ff433 100644
rename ov.ov_overlay_file saved_filename;
info (f_"Overlay saved as %s [--debug-overlays]") saved_filename
) overlays
--
2.27.0

View File

@ -29,6 +29,3 @@ index 179b0edf..fdc04b02 100644
(* List of Cinder volume IDs. *)
val mutable volume_ids = []
--
2.27.0

View File

@ -39,6 +39,3 @@ index ba26949f..f2f7b95c 100644
(*----------------------------------------------------------------------*)
(* Perform the conversion of the Windows guest. *)
--
2.27.0

View File

@ -132,6 +132,3 @@ index f2f7b95c..84db742f 100644
(*----------------------------------------------------------------------*)
(* Perform the conversion of the Windows guest. *)
--
2.27.0

View File

@ -57,6 +57,3 @@ index 84db742f..44cef5ed 100644
(*----------------------------------------------------------------------*)
(* Perform the conversion of the Windows guest. *)
--
2.27.0

View File

@ -0,0 +1,447 @@
From 9292a4637e8f4d534f4dde70e8e5451f61ad0162 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 19 Jan 2021 14:22:33 +0000
Subject: [PATCH] Update common/ submodule to latest upstream.
Only for RHEL AV 8.4.0, allowing this branch to be compiled
from git with libguestfs 1.44.
---
common | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Submodule common 9338df5e...be09523d:
diff --git a/common/mlcustomize/SELinux_relabel.ml b/common/mlcustomize/SELinux_relabel.ml
index 44995df6..5ecf7bd7 100644
--- a/common/mlcustomize/SELinux_relabel.ml
+++ b/common/mlcustomize/SELinux_relabel.ml
@@ -28,65 +28,80 @@ module G = Guestfs
let array_find a l =
List.mem a (Array.to_list l)
-let relabel (g : G.guestfs) =
- (* Is the guest using SELinux? *)
- if g#is_file ~followsymlinks:true "/usr/sbin/load_policy" &&
- g#is_file ~followsymlinks:true "/etc/selinux/config" then (
- (* Is setfiles / SELinux relabelling functionality available? *)
- if g#feature_available [| "selinuxrelabel" |] then (
- (* Use Augeas to parse /etc/selinux/config. *)
- g#aug_init "/" (16+32) (* AUG_SAVE_NOOP | AUG_NO_LOAD *);
- (* See: https://bugzilla.redhat.com/show_bug.cgi?id=975412#c0 *)
- ignore (g#aug_rm "/augeas/load/*[\"/etc/selinux/config/\" !~ regexp('^') + glob(incl) + regexp('/.*')]");
- g#aug_load ();
- debug_augeas_errors g;
-
- (* 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
- g#aug_get selinuxtype_path
- else
- "targeted" in
-
- g#aug_close ();
-
- (* Get the spec file name. *)
- let specfile =
- sprintf "/etc/selinux/%s/contexts/files/file_contexts" policy in
-
- (* RHEL 6.2 - 6.5 had a malformed specfile that contained the
- * invalid regular expression "/var/run/spice-vdagentd.\pid"
- * (instead of "\.p"). This stops setfiles from working on
- * the guest.
- *
- * Because an SELinux relabel writes all over the filesystem,
- * it seems reasonable to fix this problem in the specfile
- * at the same time. (RHBZ#1374232)
- *)
- if g#grep ~fixed:true "vdagentd.\\pid" specfile <> [||] then (
- debug "fixing invalid regular expression in %s" specfile;
- let old_specfile = specfile ^ "~" in
- g#mv specfile old_specfile;
- let content = g#read_file old_specfile in
- let content =
- String.replace content "vdagentd.\\pid" "vdagentd\\.pid" in
- g#write specfile content;
- g#copy_attributes ~all:true old_specfile specfile
- );
-
- (* Relabel everything. *)
- g#selinux_relabel ~force:true specfile "/";
-
- (* If that worked, we don't need to autorelabel. *)
+let rec relabel (g : G.guestfs) =
+ (* Is the guest using SELinux? (Otherwise this is a no-op). *)
+ if is_selinux_guest g then (
+ try
+ use_setfiles g;
+ (* That worked, so we don't need to autorelabel. *)
g#rm_f "/.autorelabel"
- )
- else (
- (* SELinux guest, but not SELinux host. Fallback to this. *)
+ with Failure _ ->
+ (* This is the fallback in case something in the setfiles
+ * method didn't work. That includes the case where a non-SELinux
+ * host is processing an SELinux guest, and other things.
+ *)
g#touch "/.autorelabel"
- )
)
+
+and is_selinux_guest g =
+ g#is_file ~followsymlinks:true "/usr/sbin/load_policy" &&
+ g#is_file ~followsymlinks:true "/etc/selinux/config"
+
+and use_setfiles g =
+ (* Is setfiles / SELinux relabelling functionality available? *)
+ if not (g#feature_available [| "selinuxrelabel" |]) then
+ failwith "no selinux relabel feature";
+
+ (* Use Augeas to parse /etc/selinux/config. *)
+ g#aug_init "/" (16+32) (* AUG_SAVE_NOOP | AUG_NO_LOAD *);
+ (* See: https://bugzilla.redhat.com/show_bug.cgi?id=975412#c0 *)
+ ignore (g#aug_rm "/augeas/load/*[\"/etc/selinux/config/\" !~ regexp('^') + glob(incl) + regexp('/.*')]");
+ g#aug_load ();
+ debug_augeas_errors g;
+
+ (* 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
+ g#aug_get selinuxtype_path
+ else
+ "targeted" in
+
+ g#aug_close ();
+
+ (* Get the spec file name. *)
+ let specfile =
+ sprintf "/etc/selinux/%s/contexts/files/file_contexts" policy in
+
+ (* If the spec file doesn't exist then fall back to using
+ * autorelabel (RHBZ#1828952).
+ *)
+ if not (g#is_file ~followsymlinks:true specfile) then
+ failwith "no spec file";
+
+ (* RHEL 6.2 - 6.5 had a malformed specfile that contained the
+ * invalid regular expression "/var/run/spice-vdagentd.\pid"
+ * (instead of "\.p"). This stops setfiles from working on
+ * the guest.
+ *
+ * Because an SELinux relabel writes all over the filesystem,
+ * it seems reasonable to fix this problem in the specfile
+ * at the same time. (RHBZ#1374232)
+ *)
+ if g#grep ~fixed:true "vdagentd.\\pid" specfile <> [||] then (
+ debug "fixing invalid regular expression in %s" specfile;
+ let old_specfile = specfile ^ "~" in
+ g#mv specfile old_specfile;
+ let content = g#read_file old_specfile in
+ let content =
+ String.replace content "vdagentd.\\pid" "vdagentd\\.pid" in
+ g#write specfile content;
+ g#copy_attributes ~all:true old_specfile specfile
+ );
+
+ (* Relabel everything. *)
+ g#selinux_relabel ~force:true specfile "/"
diff --git a/common/mltools/Makefile.am b/common/mltools/Makefile.am
index 3b4172db..aea2dce9 100644
--- a/common/mltools/Makefile.am
+++ b/common/mltools/Makefile.am
@@ -95,6 +95,7 @@ libmltools_a_CPPFLAGS = \
-I$(shell $(OCAMLC) -where) \
-I$(top_srcdir)/common/utils \
-I$(top_srcdir)/lib \
+ $(INCLUDE_DIRECTORY) \
-I$(top_srcdir)/common/options \
-I$(top_srcdir)/common/mlgettext \
-I$(top_srcdir)/common/mlpcre \
diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml
index 12718022..d54ec581 100644
--- a/common/mltools/tools_utils.ml
+++ b/common/mltools/tools_utils.ml
@@ -679,3 +679,53 @@ let with_timeout op timeout ?(sleep = 2) fn =
loop ()
in
loop ()
+
+let run_in_guest_command g root ?logfile ?incompatible_fn cmd =
+ (* Is the host_cpu compatible with the guest arch? ie. Can we
+ * run commands in this guest?
+ *)
+ let guest_arch = g#inspect_get_arch root in
+ let guest_arch_compatible = guest_arch_compatible guest_arch in
+ if not guest_arch_compatible then (
+ match incompatible_fn with
+ | None -> ()
+ | Some fn -> fn ()
+ )
+ else (
+ (* Add a prologue to the scripts:
+ * - Pass environment variables through from the host.
+ * - Optionally send stdout and stderr to a log file so we capture
+ * all output in error messages.
+ * - Use setarch when running x86_64 host + i686 guest.
+ *)
+ let env_vars =
+ List.filter_map (
+ fun name ->
+ try Some (sprintf "export %s=%s" name (quote (Sys.getenv name)))
+ with Not_found -> None
+ ) [ "http_proxy"; "https_proxy"; "ftp_proxy"; "no_proxy" ] in
+ let env_vars = String.concat "\n" env_vars ^ "\n" in
+
+ let cmd =
+ match Guestfs_config.host_cpu, guest_arch with
+ | "x86_64", ("i386"|"i486"|"i586"|"i686") ->
+ sprintf "setarch i686 <<\"__EOCMD\"
+%s
+__EOCMD
+" cmd
+ | _ -> cmd in
+
+ let logfile_redirect =
+ match logfile with
+ | None -> ""
+ | Some logfile -> sprintf "exec >>%s 2>&1" (quote logfile) in
+
+ let cmd = sprintf "\
+%s
+%s
+%s
+" (logfile_redirect) env_vars cmd in
+
+ debug "running command:\n%s" cmd;
+ ignore (g#sh cmd)
+ )
diff --git a/common/mltools/tools_utils.mli b/common/mltools/tools_utils.mli
index ab70f583..1d1ac8a8 100644
--- a/common/mltools/tools_utils.mli
+++ b/common/mltools/tools_utils.mli
@@ -195,9 +195,8 @@ val is_btrfs_subvolume : Guestfs.guestfs -> string -> bool
(** Checks if a filesystem is a btrfs subvolume. *)
val inspect_decrypt : Guestfs.guestfs -> key_store -> unit
-(** Simple implementation of decryption: look for any [crypto_LUKS]
- partitions and decrypt them, then rescan for VGs. This only works
- for Fedora whole-disk encryption. *)
+(** Simple implementation of decryption: look for any encrypted
+ partitions and decrypt them, then rescan for VGs. *)
val with_timeout : string -> int -> ?sleep:int -> (unit -> 'a option) -> 'a
(** [with_timeout op timeout ?sleep fn] implements a timeout loop.
@@ -212,3 +211,13 @@ val with_timeout : string -> int -> ?sleep:int -> (unit -> 'a option) -> 'a
calls {!error} and the program exits. The error message will
contain the diagnostic string [op] to identify the operation
which timed out. *)
+
+val run_in_guest_command : Guestfs.guestfs -> string -> ?logfile:string -> ?incompatible_fn:(unit -> unit) -> string -> unit
+(** [run_in_guest_command g root ?incompatible_archs_fn cmd]
+ runs a command in the guest, which is already mounted for the
+ specified [root]. The command is run directly in case the
+ architecture of the host and the guest are compatible, optionally
+ calling [?incompatible_fn] in case they are not.
+
+ [?logfile] is an optional file in the guest to where redirect
+ stdout and stderr of the command. *)
diff --git a/common/mlutils/unix_utils-c.c b/common/mlutils/unix_utils-c.c
index 33099611..8acf0395 100644
--- a/common/mlutils/unix_utils-c.c
+++ b/common/mlutils/unix_utils-c.c
@@ -77,6 +77,7 @@ extern value guestfs_int_mllib_mkdtemp (value val_pattern);
extern value guestfs_int_mllib_realpath (value pathv);
extern value guestfs_int_mllib_statvfs_statvfs (value pathv);
extern value guestfs_int_mllib_statvfs_is_network_filesystem (value pathv);
+extern value guestfs_int_mllib_sysconf_nr_processors_online (value unitv);
/* NB: This is a "noalloc" call. */
value
@@ -368,3 +369,17 @@ guestfs_int_mllib_statvfs_is_network_filesystem (value pathv)
return Val_bool (0);
#endif
}
+
+/* NB: This is a "noalloc" call. */
+value
+guestfs_int_mllib_sysconf_nr_processors_online (value unitv)
+{
+#ifdef _SC_NPROCESSORS_ONLN
+ long n;
+
+ n = sysconf (_SC_NPROCESSORS_ONLN);
+ if (n > 0) return Val_int (n);
+#endif
+ /* Return a safe value so that callers don't need to deal with errors. */
+ return Val_int (1);
+}
diff --git a/common/mlutils/unix_utils.ml b/common/mlutils/unix_utils.ml
index 52eb824d..2bdda12a 100644
--- a/common/mlutils/unix_utils.ml
+++ b/common/mlutils/unix_utils.ml
@@ -84,3 +84,8 @@ module StatVFS = struct
external is_network_filesystem : string -> bool =
"guestfs_int_mllib_statvfs_is_network_filesystem" "noalloc"
end
+
+module Sysconf = struct
+ external nr_processors_online : unit -> int =
+ "guestfs_int_mllib_sysconf_nr_processors_online" "noalloc"
+end
diff --git a/common/mlutils/unix_utils.mli b/common/mlutils/unix_utils.mli
index 4fcea4a3..aead4df2 100644
--- a/common/mlutils/unix_utils.mli
+++ b/common/mlutils/unix_utils.mli
@@ -121,3 +121,12 @@ module StatVFS : sig
(** [is_network_filesystem path] returns true if [path] is located on
a network filesystem such as NFS or CIFS. *)
end
+
+module Sysconf : sig
+ val nr_processors_online : unit -> int
+ (** [nr_processors_online ()] returns the number of processors
+ currently online, from [sysconf (_SC_NPROCESSORS_ONLN)].
+
+ Note this never fails. In case we cannot get the number of
+ cores it returns 1. *)
+end
diff --git a/common/options/Makefile.am b/common/options/Makefile.am
index f7ea7493..162d143b 100644
--- a/common/options/Makefile.am
+++ b/common/options/Makefile.am
@@ -41,8 +41,9 @@ liboptions_la_SOURCES = \
liboptions_la_CPPFLAGS = \
-DGUESTFS_NO_DEPRECATED=1 \
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
+ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
- -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib
+ $(INCLUDE_DIRECTORY)
liboptions_la_CFLAGS = \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(LIBCONFIG_CFLAGS) \
diff --git a/common/options/decrypt.c b/common/options/decrypt.c
index 683cf5ed..434b7d58 100644
--- a/common/options/decrypt.c
+++ b/common/options/decrypt.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <libintl.h>
#include <error.h>
@@ -38,18 +39,18 @@
/**
* Make a LUKS map name from the partition name,
- * eg. C<"/dev/vda2" =E<gt> "luksvda2">
+ * eg. C<"/dev/vda2" =E<gt> "cryptvda2">
*/
static void
make_mapname (const char *device, char *mapname, size_t len)
{
size_t i = 0;
- if (len < 5)
+ if (len < 6)
abort ();
- strcpy (mapname, "luks");
- mapname += 4;
- len -= 4;
+ strcpy (mapname, "crypt");
+ mapname += 5;
+ len -= 5;
if (STRPREFIX (device, "/dev/"))
i = 5;
@@ -65,10 +66,8 @@ make_mapname (const char *device, char *mapname, size_t len)
}
/**
- * Simple implementation of decryption: look for any C<crypto_LUKS>
- * partitions and decrypt them, then rescan for VGs. This only works
- * for Fedora whole-disk encryption. WIP to make this work for other
- * encryption schemes.
+ * Simple implementation of decryption: look for any encrypted
+ * partitions and decrypt them, then rescan for VGs.
*/
void
inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
@@ -82,12 +81,21 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
for (i = 0; partitions[i] != NULL; ++i) {
CLEANUP_FREE char *type = guestfs_vfs_type (g, partitions[i]);
- if (type && STREQ (type, "crypto_LUKS")) {
+ if (type &&
+ (STREQ (type, "crypto_LUKS") || STREQ (type, "BitLocker"))) {
+ bool is_bitlocker = STREQ (type, "BitLocker");
char mapname[32];
make_mapname (partitions[i], mapname, sizeof mapname);
#ifdef GUESTFS_HAVE_LUKS_UUID
- CLEANUP_FREE char *uuid = guestfs_luks_uuid (g, partitions[i]);
+ CLEANUP_FREE char *uuid = NULL;
+
+ /* This fails for Windows BitLocker disks because cryptsetup
+ * luksUUID cannot read a UUID (unclear if this is a limitation
+ * of the format or cryptsetup).
+ */
+ if (!is_bitlocker)
+ uuid = guestfs_luks_uuid (g, partitions[i]);
#else
const char *uuid = NULL;
#endif
@@ -97,11 +105,15 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
/* Try each key in turn. */
for (j = 0; keys[j] != NULL; ++j) {
- /* XXX Should we call guestfs_luks_open_ro if readonly flag
+ /* XXX Should we set GUESTFS_CRYPTSETUP_OPEN_READONLY if readonly
* is set? This might break 'mount_ro'.
*/
guestfs_push_error_handler (g, NULL, NULL);
+#ifdef GUESTFS_HAVE_CRYPTSETUP_OPEN
+ r = guestfs_cryptsetup_open (g, partitions[i], keys[j], mapname, -1);
+#else
r = guestfs_luks_open (g, partitions[i], keys[j], mapname);
+#endif
guestfs_pop_error_handler (g);
if (r == 0)
goto opened;
diff --git a/common/options/uri.c b/common/options/uri.c
index ac36bccb..6b696fc2 100644
--- a/common/options/uri.c
+++ b/common/options/uri.c
@@ -194,6 +194,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") ||
STREQ (uri->scheme, "rbd") ||
STREQ (uri->scheme, "sheepdog")))
path++;
diff --git a/common/utils/guestfs-stringlists-utils.h b/common/utils/guestfs-stringlists-utils.h
index 0bac1587..ade3b6f3 100644
--- a/common/utils/guestfs-stringlists-utils.h
+++ b/common/utils/guestfs-stringlists-utils.h
@@ -21,7 +21,8 @@
/* stringlists-utils.c */
extern void guestfs_int_free_string_list (char **);
-extern size_t guestfs_int_count_strings (char *const *);
+extern size_t guestfs_int_count_strings (char *const *)
+ __attribute__((__nonnull__ (1)));
extern char *guestfs_int_concat_strings (char *const *);
extern char **guestfs_int_copy_string_list (char *const *);
extern char *guestfs_int_join_strings (const char *sep, char *const *);

View File

@ -78,6 +78,3 @@ index 471102da..7cd6dea6 100644
http = optimize_http(http, host, options)
except:
cancel_transfer(connection, transfer)
--
2.27.0

View File

@ -32,6 +32,3 @@ index 44cef5ed..4d844e2d 100644
"
msi_path msi_path msi_path in
Firstboot.add_firstboot_script g inspect.i_root
--
2.27.0

View File

@ -27,6 +27,3 @@ index 4d844e2d..33fbd410 100644
(* Install RHEV-APT only if appropriate for the output hypervisor. *)
if output#install_rhev_apt then (
--
2.27.0

View File

@ -22,6 +22,3 @@ index a5150907..1ffc0f9d 100644
=item UEFI on oVirt or RHV
--
2.27.0

View File

@ -42,6 +42,3 @@ index 78623d97..f5a3abad 100644
Virt-v2v adds metadata for the guest to Glance, describing such things
as the guest operating system and what drivers it requires. The
--
2.27.0

View File

@ -147,6 +147,3 @@ index a58ff433..1f8d0138 100644
| TargetURI _ ->
(* XXX For the moment we assume that qemu URI outputs
--
2.27.0

View File

@ -37,6 +37,3 @@ index f5e91911..7c177e35 100644
(* Caching extents speeds up qemu-img, especially its consecutive
* block_status requests with req_one=1.
--
2.27.0

View File

@ -32,6 +32,3 @@ index e4df920e..ae8964dd 100644
=head1 SEE ALSO
L<virt-v2v(1)>.
--
2.27.0

View File

@ -126,6 +126,3 @@ index 1f8d0138..bde51885 100644
(* Not all the filesystems have inode counts. *)
if files > 0L && ffree < needed_inodes then
error (f_"not enough available inodes for conversion on filesystem %s. %Ld inodes available < %Ld inodes needed")
--
2.27.0

View File

@ -25,6 +25,3 @@ index 4e00cd61..b8256bad 100644
match rcaps.rcaps_video, has_qxl with
| Some QXL, false ->
error (f_"there is no QXL driver for this version of Windows (%d.%d %s). virt-v2v looks for this driver in %s")
--
2.27.0

View File

@ -23,6 +23,3 @@ index 1ffc0f9d..a9bfffab 100644
=item UEFI on oVirt or RHV
--
2.27.0

View File

@ -55,6 +55,3 @@ index bde51885..8af86687 100644
(* For everything else, just make sure there is some free space. *)
| _ -> 10
in
--
2.27.0

View File

@ -174,6 +174,3 @@ index 7cd6dea6..61ade1a8 100644
def transfer_supports_format():
--
2.27.0

View File

@ -75,6 +75,3 @@ index 33fbd410..13de10cb 100644
)
)
--
2.27.0

View File

@ -270,6 +270,3 @@ index 4c128b0c..ead03364 100644
let qemu_uri = Nbdkit_sources.run nbdkit in
(* Return the struct. *)
--
2.27.0

View File

@ -39,6 +39,3 @@ index 13de10cb..6c7440aa 100644
"
msi_path msi_path msi_path in
Firstboot.add_firstboot_script g inspect.i_root
--
2.27.0

View File

@ -206,6 +206,3 @@ index 8af86687..203b93f1 100644
(* What really happens here is that the call to #disk_create
* below fails if the format is not raw or qcow2. We would
--
2.27.0

View File

@ -39,6 +39,3 @@ index 27e08135..e65fbf4a 100644
(match xpath_string "/volume/@type" with
| None | Some "file" ->
--
2.27.0

View File

@ -0,0 +1,179 @@
From 8036ab4bc8f37030fcaceda14678cb14dbbed547 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= <tgolembi@redhat.com>
Date: Wed, 20 Apr 2022 17:14:26 +0200
Subject: [PATCH] -o rhv-upload: wait for VM creation task
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
oVirt API call for VM creation finishes before the VM is actually
created. Entities may be still locked after virt-v2v terminates and if
user tries to perform (scripted) actions after virt-v2v those operations
may fail. To prevent this it is useful to monitor the task and wait for
the completion. This will also help to prevent some corner case
scenarios (that would be difficult to debug) when the VM creation job
fails after virt-v2v already termintates with success.
Thanks: Nir Soffer
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1985827
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Arik Hadas <ahadas@redhat.com>
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
(cherry picked from commit 291edb363e841e1c555954a070def671a651cfab)
---
.../ovirtsdk4/__init__.py | 10 +++-
.../ovirtsdk4/types.py | 19 +++++++
v2v/rhv-upload-createvm.py | 57 ++++++++++++++++++-
3 files changed, 84 insertions(+), 2 deletions(-)
diff --git a/tests/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py b/tests/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py
index abb7050c..ba0649cb 100644
--- a/tests/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py
+++ b/tests/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py
@@ -63,6 +63,9 @@ class SystemService(object):
def disks_service(self):
return DisksService()
+ def jobs_service(self):
+ return JobsService()
+
def image_transfers_service(self):
return ImageTransfersService()
@@ -108,6 +111,11 @@ class DisksService(object):
return DiskService(disk_id)
+class JobsService(object):
+ def list(self, search=None):
+ return [types.Job()]
+
+
class ImageTransferService(object):
def __init__(self):
self._finalized = False
@@ -139,7 +147,7 @@ class StorageDomainsService(object):
class VmsService(object):
- def add(self, vm):
+ def add(self, vm, query=None):
return vm
def list(self, search=None):
diff --git a/tests/test-v2v-o-rhv-upload-module/ovirtsdk4/types.py b/tests/test-v2v-o-rhv-upload-module/ovirtsdk4/types.py
index 732887aa..8e734756 100644
--- a/tests/test-v2v-o-rhv-upload-module/ovirtsdk4/types.py
+++ b/tests/test-v2v-o-rhv-upload-module/ovirtsdk4/types.py
@@ -138,6 +138,25 @@ class Initialization(object):
pass
+class JobStatus(Enum):
+ ABORTED = "aborted"
+ FAILED = "failed"
+ FINISHED = "finished"
+ STARTED = "started"
+ UNKNOWN = "unknown"
+
+ def __init__(self, image):
+ self._image = image
+
+ def __str__(self):
+ return self._image
+
+
+class Job(object):
+ description = "Fake job"
+ status = JobStatus.FINISHED
+
+
class StorageDomain(object):
def __init__(self, name=None):
pass
diff --git a/v2v/rhv-upload-createvm.py b/v2v/rhv-upload-createvm.py
index 50bb7e34..8887c52b 100644
--- a/v2v/rhv-upload-createvm.py
+++ b/v2v/rhv-upload-createvm.py
@@ -19,12 +19,54 @@
import json
import logging
import sys
+import time
+import uuid
from urllib.parse import urlparse
import ovirtsdk4 as sdk
import ovirtsdk4.types as types
+
+def debug(s):
+ if params['verbose']:
+ print(s, file=sys.stderr)
+ sys.stderr.flush()
+
+
+def jobs_completed(system_service, correlation_id):
+ jobs_service = system_service.jobs_service()
+
+ try:
+ jobs = jobs_service.list(
+ search="correlation_id=%s" % correlation_id)
+ except sdk.Error as e:
+ debug(
+ "Error searching for jobs with correlation id %s: %s" %
+ (correlation_id, e))
+ # We don't know, assume that jobs did not complete yet.
+ return False
+
+ # STARTED is the only "in progress" status, anything else means the job
+ # has already terminated.
+ if all(job.status != types.JobStatus.STARTED for job in jobs):
+ failed_jobs = [(job.description, str(job.status))
+ for job in jobs
+ if job.status != types.JobStatus.FINISHED]
+ if failed_jobs:
+ raise RuntimeError(
+ "Failed to create a VM! Failed jobs: %r" % failed_jobs)
+ return True
+ else:
+ running_jobs = [(job.description, str(job.status)) for job in jobs]
+ debug("Some jobs with correlation id %s are running: %s" %
+ (correlation_id, running_jobs))
+ return False
+
+
+# Seconds to wait for the VM import job to complete in oVirt.
+timeout = 3 * 60
+
# Parameters are passed in via a JSON doc from the OCaml code.
# Because this Python code ships embedded inside virt-v2v there
# is no formal API here.
@@ -67,6 +109,7 @@ system_service = connection.system_service()
cluster = system_service.clusters_service().cluster_service(params['rhv_cluster_uuid'])
cluster = cluster.get()
+correlation_id = str(uuid.uuid4())
vms_service = system_service.vms_service()
vm = vms_service.add(
types.Vm(
@@ -77,5 +120,17 @@ vm = vms_service.add(
data=ovf,
)
)
- )
+ ),
+ query={'correlation_id': correlation_id},
)
+
+# Wait for the import job to finish.
+endt = time.monotonic() + timeout
+while True:
+ time.sleep(10)
+ if jobs_completed(system_service, correlation_id):
+ break
+ if time.monotonic() > endt:
+ raise RuntimeError(
+ "Timed out waiting for VM creation!"
+ " Jobs still running for correlation id %s" % correlation_id)

View File

@ -0,0 +1,93 @@
From 7748be2af952898c9c38d02e9a539c71cbfbb56b Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 25 May 2021 10:13:00 +0100
Subject: [PATCH] tests: Add test of -i ova from a directory.
This was not tested previously.
(cherry picked from commit a00ce662cb33c33706a013ff98ff89244cd14667)
---
tests/Makefile.am | 2 ++
tests/test-v2v-i-ova-directory.sh | 53 +++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
create mode 100755 tests/test-v2v-i-ova-directory.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eee4e1af..e4b907fe 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,6 +58,7 @@ TESTS = \
test-v2v-copy-to-local.sh \
test-v2v-i-ova-bad-sha1.sh \
test-v2v-i-ova-bad-sha256.sh \
+ test-v2v-i-ova-directory.sh \
test-v2v-i-ova-formats.sh \
test-v2v-i-ova-good-checksums.sh \
test-v2v-i-ova-gz.sh \
@@ -185,6 +186,7 @@ EXTRA_DIST += \
test-v2v-i-ova-bad-sha1.sh \
test-v2v-i-ova-bad-sha256.sh \
test-v2v-i-ova-checksums.ovf \
+ test-v2v-i-ova-directory.sh \
test-v2v-i-ova-formats.expected \
test-v2v-i-ova-formats.ovf \
test-v2v-i-ova-formats.sh \
diff --git a/tests/test-v2v-i-ova-directory.sh b/tests/test-v2v-i-ova-directory.sh
new file mode 100755
index 00000000..7c593139
--- /dev/null
+++ b/tests/test-v2v-i-ova-directory.sh
@@ -0,0 +1,53 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014-2021 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Test -i ova option with a directory.
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
+skip_unless_phony_guest windows.img
+
+skip_unless_libvirt_minimum_version 3 1 0
+
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+export VIRTIO_WIN="$top_srcdir/test-data/fake-virtio-win"
+
+d=test-v2v-i-ova-directory.d
+rm -rf $d
+mkdir $d
+
+vmdk=test-ova.vmdk
+ovf=test-v2v-i-ova.ovf
+mf=test-ova.mf
+
+qemu-img convert $top_builddir/test-data/phony-guests/windows.img \
+ -O vmdk $d/$vmdk
+cp "$srcdir/$ovf" $d/$ovf
+sha1=`do_sha1 $d/$ovf`
+echo "SHA1($ovf)= $sha1" > $d/$mf
+sha256=`do_sha256 $d/$vmdk`
+echo "SHA256($vmdk)= $sha256" >> $d/$mf
+
+$VG virt-v2v --debug-gc \
+ -i ova $d \
+ -o null
+
+rm -rf $d

View File

@ -0,0 +1,63 @@
From 9e52e90cf8d570516d4098584c263c9d8b76c447 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 25 May 2021 10:27:53 +0100
Subject: [PATCH] v2v: -i ova: Fix parsing if OVA directory name has a trailing
"/"
If you use an OVA directory with a trailing "/" in the name, virt-v2v
would fail with:
virt-v2v: error: internal error: assertion failed at parse_ova.ml, line 273, char 15
The fix for this is to knock off the trailing "/" if present.
Reported-by: Xiaodai Wang
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1964324
(cherry picked from commit f8428f5eaaff6dedc54a40138f760298a7a3a965)
---
v2v/parse_ova.ml | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/v2v/parse_ova.ml b/v2v/parse_ova.ml
index 568ac5fa..fc413d2a 100644
--- a/v2v/parse_ova.ml
+++ b/v2v/parse_ova.ml
@@ -57,6 +57,13 @@ and ova_type =
*)
| TarOptimized of string (* tarball *)
+let string_of_t { orig_ova; top_dir; ova_type } =
+ sprintf "orig_ova = %s, top_dir = %s, ova_type = %s"
+ orig_ova top_dir
+ (match ova_type with
+ | Directory -> "Directory"
+ | TarOptimized tarball -> "TarOptimized " ^ tarball)
+
type file_ref =
| LocalFile of string
| TarFile of string * string
@@ -122,6 +129,13 @@ let rec parse_ova ova =
(* Exploded path must be absolute (RHBZ#1155121). *)
let top_dir = absolute_path top_dir in
+ (* top_dir must not end with / except if it == "/" (which is
+ * likely not what you want). (RHBZ#1964324)
+ *)
+ let top_dir =
+ if top_dir = "/" || not (String.is_suffix top_dir "/") then top_dir
+ else String.sub top_dir 0 (String.length top_dir - 1) in
+
(* If virt-v2v is running as root, and the backend is libvirt, then
* we have to chmod the directory to 0755 and files to 0644
* so it is readable by qemu.qemu. This is libvirt bug RHBZ#890291.
@@ -136,7 +150,9 @@ let rec parse_ova ova =
ignore (run_command cmd)
);
- { orig_ova = ova; top_dir; ova_type }
+ let ova = { orig_ova = ova; top_dir; ova_type } in
+ debug "ova: %s" (string_of_t ova);
+ ova
(* Return true if [libvirt] supports ["json:"] pseudo-URLs and accepts the
* ["raw"] driver. Function also returns true if [libvirt] backend is not

View File

@ -1,4 +1,4 @@
From 6c1260b543ed5a947481f7b12943494eeea085fb Mon Sep 17 00:00:00 2001
From 87e5404d20ec54d16d22a7bb8f06ea91076c91f7 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 25 May 2022 16:47:04 +0100
Subject: [PATCH] convert: If listing RPM applications fails, rebuild DB and
@ -23,7 +23,6 @@ Reported-by: Xiaodai Wang
Reported-by: Ming Xie
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 31bf5db25bcfd8a9f5a48cc0523abae28861de9a)
(cherry picked from commit 87e5404d20ec54d16d22a7bb8f06ea91076c91f7)
---
v2v/inspect_source.ml | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
@ -94,6 +93,3 @@ index b8a3c8ad..554fde1d 100644
(* See if this guest could use UEFI to boot. It should use GPT and
* it should have an EFI System Partition (ESP).
*
--
2.31.1

View File

@ -0,0 +1,50 @@
From 5852b85eaa174dfb87ce7a03b9f70e2bffac4ca4 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@redhat.com>
Date: Wed, 29 Jun 2022 15:44:27 +0200
Subject: [PATCH] update common submodule for CVE-2022-2211 fix
$ git shortlog 9e990f3e4530..35467027f657
Laszlo Ersek (1):
options: fix buffer overflow in get_keys() [CVE-2022-2211]
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 795d5dfcef77fc54fec4d237bda28571454a6d4e)
---
common | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Submodule common be09523d..1174b443:
diff --git a/common/options/keys.c b/common/options/keys.c
index 798315c2..d27a7123 100644
--- a/common/options/keys.c
+++ b/common/options/keys.c
@@ -128,17 +128,23 @@ read_first_line_from_file (const char *filename)
char **
get_keys (struct key_store *ks, const char *device, const char *uuid)
{
- size_t i, j, len;
+ size_t i, j, nmemb;
char **r;
char *s;
/* We know the returned list must have at least one element and not
* more than ks->nr_keys.
*/
- len = 1;
- if (ks)
- len = MIN (1, ks->nr_keys);
- r = calloc (len+1, sizeof (char *));
+ nmemb = 1;
+ if (ks && ks->nr_keys > nmemb)
+ nmemb = ks->nr_keys;
+
+ /* make room for the terminating NULL */
+ if (nmemb == (size_t)-1)
+ error (EXIT_FAILURE, 0, _("size_t overflow"));
+ nmemb++;
+
+ r = calloc (nmemb, sizeof (char *));
if (r == NULL)
error (EXIT_FAILURE, errno, "calloc");

View File

@ -0,0 +1,32 @@
From 217a74ad09bad781ee9efd5599f4323bdf9e3cff Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 3 Apr 2023 09:41:37 +0100
Subject: [PATCH] RHEL 8: If setfiles fails fall back to autorelabel
SFDC case 03473932, RHEL 8 only.
See discussion in private email thread "Customer case requiring our
assistance" in 2023.
---
common | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Submodule common 1174b443..c4841a70:
diff --git a/common/mlcustomize/SELinux_relabel.ml b/common/mlcustomize/SELinux_relabel.ml
index 5ecf7bd7..f0630db1 100644
--- a/common/mlcustomize/SELinux_relabel.ml
+++ b/common/mlcustomize/SELinux_relabel.ml
@@ -35,11 +35,12 @@ let rec relabel (g : G.guestfs) =
use_setfiles g;
(* That worked, so we don't need to autorelabel. *)
g#rm_f "/.autorelabel"
- with Failure _ ->
+ with Failure _
(* This is the fallback in case something in the setfiles
* method didn't work. That includes the case where a non-SELinux
* host is processing an SELinux guest, and other things.
*)
+ | Guestfs.Error _ -> (* this is for SFDC case 03473932 in RHEL 8 only *)
g#touch "/.autorelabel"
)

View File

@ -6,7 +6,7 @@ set -e
# directory. Use it like this:
# ./copy-patches.sh
rhel_version=8.6.0
rhel_version=8.8.0
# Check we're in the right directory.
if [ ! -f virt-v2v.spec ]; then
@ -31,7 +31,28 @@ git rm -f [0-9]*.patch ||:
rm -f [0-9]*.patch
# Get the patches.
(cd $git_checkout; rm -f [0-9]*.patch; git format-patch -N --submodule=diff $tag)
(
cd $git_checkout
rm -f [0-9]*.patch
# Ignore some directories in common/ which are not in the virt-v2v tarball.
ignoredirs="edit mlvisit parallel progress structs visit windows"
rm -f common/.gitattributes
for i in $ignoredirs; do
echo "$i/* -diff" >> common/.gitattributes
done
git -c core.abbrev=8 format-patch -O/dev/null --subject-prefix=PATCH -N \
--submodule=diff --no-signature --patience $tag
# However the .gitattributes doesn't completely ignore them but produces
# Binary files a/... and b/... differ
# which prevents the patches from being applied so we must remove that too.
for i in $ignoredirs; do
sed -i "/^diff --git a\/common\/$i/,/^Binary files a\/common\/$i/{d;}" [0-9]*.patch
done
rm common/.gitattributes
)
mv $git_checkout/[0-9]*.patch .
# Remove any not to be applied.

View File

@ -10,7 +10,7 @@
Name: virt-v2v
Epoch: 1
Version: 1.42.0
Release: 19%{?dist}
Release: 22%{?dist}
Summary: Convert a virtual machine to run on KVM
License: GPLv2+
@ -64,7 +64,7 @@ Patch0025: 0025-v2v-o-openstack-Allow-guests-to-be-converted-to-UEFI.patch
Patch0026: 0026-v2v-Fix-spelling-mistake-in-uninstall-function-name.patch
Patch0027: 0027-v2v-windows-Refactor-uninstallation_commands-functio.patch
Patch0028: 0028-v2v-Replace-broken-VMware-Tools-uninstall-command-ms.patch
#Patch0029: 0029-Update-common-submodule-to-latest-upstream.patch
Patch0029: 0029-Update-common-submodule-to-latest-upstream.patch
Patch0030: 0030-v2v-rhv-upload-plugin-Defer-imageio-connection.patch
Patch0031: 0031-v2v-windows-Fix-schtasks-SD-parameter.patch
Patch0032: 0032-v2v-Turn-pnp_wait.exe-warning-into-a-debug-message.patch
@ -83,14 +83,12 @@ Patch0044: 0044-v2v-vcenter-Implement-cookie-scripts.patch
Patch0045: 0045-convert-convert_windows.ml-Handle-date-formats-with-.patch
Patch0046: 0046-v2v-Force-format-of-input-to-be-specified.patch
Patch0047: 0047-v2v-Cope-with-libvirt-vpx-esx-driver-which-does-not-.patch
Patch0048: 0048-convert-If-listing-RPM-applications-fails-rebuild-DB.patch
# Patches which apply to the common/ submodule.
# These have to be hand-modified.
Patch1001: 0001-options-Use-new-cryptsetup-open-API-if-available.patch
Patch1002: 0002-options-Use-cryptX-instead-of-luksX-as-the-temporary.patch
Patch1003: 0003-options-Support-Windows-BitLocker-RHBZ-1808977.patch
Patch1004: 0004-options-Ignore-errors-from-guestfs_luks_uuid.patch
Patch0048: 0048-o-rhv-upload-wait-for-VM-creation-task.patch
Patch0049: 0049-tests-Add-test-of-i-ova-from-a-directory.patch
Patch0050: 0050-v2v-i-ova-Fix-parsing-if-OVA-directory-name-has-a-tr.patch
Patch0051: 0051-convert-If-listing-RPM-applications-fails-rebuild-DB.patch
Patch0052: 0052-update-common-submodule-for-CVE-2022-2211-fix.patch
Patch0053: 0053-RHEL-8-If-setfiles-fails-fall-back-to-autorelabel.patch
# Use git for patch management.
BuildRequires: git
@ -327,9 +325,19 @@ rm $RPM_BUILD_ROOT%{_mandir}/man1/virt-v2v-test-harness.1*
%changelog
* Tue Jun 07 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.42.0-19
- If listing RPM applications fails, rebuild DB and retry
resolves: rhbz#2093415
* Mon Apr 03 2023 Richard W.M. Jones <rjones@redhat.com> - 1:1.42.0-22
- RHEL 8: If setfiles fails fall back to autorelabel
resolves: rhbz#XXX
- Reapply patches since we are using git format-patch --submodule=diff
* Tue Jul 05 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.42.0-21
- Fix assertion failure when parsing OVA dir with trailing slash
resolves: rhbz#2028823
- For -o rhv-upload wait for VM creation task
resolves: rhbz#1985827
- If listing RPM applications fails, rebuild DB and retry (2089623)
- Fix CVE-2022-2211 Denial of Service in --key parameter
resolves: rhbz#2102720
* Wed Nov 24 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.42.0-18
- Additional fix for backing file specified without backing format