forked from pool/libguestfs
- bsc#1167131 - virt-v2v fails importing ubuntu 18.04 LTS ova
500acb15-v2v-linux-fix-kernel-detection-when-split-in-different-packages.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=450
This commit is contained in:
parent
7ea970047b
commit
e746a46e6f
@ -0,0 +1,101 @@
|
|||||||
|
Subject: v2v: linux: fix kernel detection when split in different packages
|
||||||
|
From: Pino Toscano ptoscano@redhat.com Tue May 22 10:46:21 2018 +0200
|
||||||
|
Date: Tue May 22 10:46:21 2018 +0200:
|
||||||
|
Git: 500acb15f8f777e9fe99a60c4216daf84a92aae3
|
||||||
|
|
||||||
|
The current detection code for Linux kernels assumes that a kernel
|
||||||
|
package contains everything in it, i.e. the kernel itself, its modules,
|
||||||
|
and its configuration. However, since recent Ubuntu versions (e.g.
|
||||||
|
starting from 18.04) modules & config (with few more files) are split in
|
||||||
|
an own package, thus not detecting the modpath from installed vmlinuz
|
||||||
|
files.
|
||||||
|
|
||||||
|
To overcome this situation, rework this detection a bit:
|
||||||
|
1) find the vmlinuz file as before, but then immediately make sure it
|
||||||
|
exists by stat'ing it
|
||||||
|
2) find the modules path from the package as before:
|
||||||
|
2a) if found, extract the version in the same step
|
||||||
|
2b) if not found, get the kernel version from the vmlinuz filename,
|
||||||
|
and use it to detect the modules path
|
||||||
|
3) check that the modules path exists
|
||||||
|
|
||||||
|
The detection done in (2b) is based on the current packaging scheme
|
||||||
|
found in the most important Linux distributions (Fedora, RHEL, CentOS,
|
||||||
|
Debian, Ubuntu, openSUSE, AltLinux, and possibly more). The notable
|
||||||
|
exception is Arch Linux.
|
||||||
|
|
||||||
|
As additional change, do not assume the config file is in the same
|
||||||
|
package as vmlinuz, but directly look into the filesystem using the
|
||||||
|
version we already have.
|
||||||
|
|
||||||
|
diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml
|
||||||
|
index c047d6deb..24f61429d 100644
|
||||||
|
--- a/v2v/linux_kernels.ml
|
||||||
|
+++ b/v2v/linux_kernels.ml
|
||||||
|
@@ -103,27 +103,42 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
|
||||||
|
None
|
||||||
|
)
|
||||||
|
else (
|
||||||
|
- (* Which of these is the kernel itself? *)
|
||||||
|
+ (* Which of these is the kernel itself? Also, make sure to check
|
||||||
|
+ * it exists by stat'ing it.
|
||||||
|
+ *)
|
||||||
|
let vmlinuz = List.find (
|
||||||
|
fun filename -> String.is_prefix filename "/boot/vmlinuz-"
|
||||||
|
) files in
|
||||||
|
- (* Which of these is the modpath? *)
|
||||||
|
- let modpath = List.find (
|
||||||
|
- fun filename ->
|
||||||
|
- String.length filename >= 14 &&
|
||||||
|
- String.is_prefix filename "/lib/modules/"
|
||||||
|
- ) files in
|
||||||
|
-
|
||||||
|
- (* Check vmlinuz & modpath exist. *)
|
||||||
|
- if not (g#is_dir ~followsymlinks:true modpath) then
|
||||||
|
- raise Not_found;
|
||||||
|
let vmlinuz_stat =
|
||||||
|
try g#statns vmlinuz with G.Error _ -> raise Not_found in
|
||||||
|
|
||||||
|
- (* Get/construct the version. XXX Read this from kernel file. *)
|
||||||
|
- let version =
|
||||||
|
- let prefix_len = String.length "/lib/modules/" in
|
||||||
|
- String.sub modpath prefix_len (String.length modpath - prefix_len) in
|
||||||
|
+ (* Determine the modpath from the package, falling back to the
|
||||||
|
+ * version in the vmlinuz file name.
|
||||||
|
+ *)
|
||||||
|
+ let modpath, version =
|
||||||
|
+ let prefix = "/lib/modules/" in
|
||||||
|
+ try
|
||||||
|
+ let prefix_len = String.length prefix in
|
||||||
|
+ List.find_map (
|
||||||
|
+ fun filename ->
|
||||||
|
+ let filename_len = String.length filename in
|
||||||
|
+ if filename_len > prefix_len &&
|
||||||
|
+ String.is_prefix filename prefix then (
|
||||||
|
+ let version = String.sub filename prefix_len
|
||||||
|
+ (filename_len - prefix_len) in
|
||||||
|
+ Some (filename, version)
|
||||||
|
+ ) else
|
||||||
|
+ None
|
||||||
|
+ ) files
|
||||||
|
+ with Not_found ->
|
||||||
|
+ let version =
|
||||||
|
+ String.sub vmlinuz 14 (String.length vmlinuz - 14) in
|
||||||
|
+ let modpath = prefix ^ version in
|
||||||
|
+ modpath, version in
|
||||||
|
+
|
||||||
|
+ (* Check that the modpath exists. *)
|
||||||
|
+ if not (g#is_dir ~followsymlinks:true modpath) then
|
||||||
|
+ raise Not_found;
|
||||||
|
|
||||||
|
(* Find the initramfs which corresponds to the kernel.
|
||||||
|
* Since the initramfs is built at runtime, and doesn't have
|
||||||
|
@@ -188,7 +203,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
|
||||||
|
|
||||||
|
let config_file =
|
||||||
|
let cfg = "/boot/config-" ^ version in
|
||||||
|
- if List.mem cfg files then Some cfg
|
||||||
|
+ if g#is_file ~followsymlinks:true cfg then Some cfg
|
||||||
|
else None in
|
||||||
|
|
||||||
|
let kernel_supports what kconf =
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Mar 19 10:25:01 MDT 2020 - carnold@suse.com
|
||||||
|
|
||||||
|
- bsc#1167131 - virt-v2v fails importing ubuntu 18.04 LTS ova
|
||||||
|
500acb15-v2v-linux-fix-kernel-detection-when-split-in-different-packages.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Jan 21 18:54:11 UTC 2020 - Larry Dewey <ldewey@suse.com>
|
Tue Jan 21 18:54:11 UTC 2020 - Larry Dewey <ldewey@suse.com>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package libguestfs
|
# spec file for package libguestfs
|
||||||
#
|
#
|
||||||
# Copyright (c) 2020 SUSE LLC
|
# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||||
# Copyright (c) 2011 Michal Hrusecky <mhrusecky@novell.com>
|
# Copyright (c) 2011 Michal Hrusecky <mhrusecky@novell.com>
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
@ -13,7 +13,7 @@
|
|||||||
# license that conforms to the Open Source Definition (Version 1.9)
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||||||
# published by the Open Source Initiative.
|
# published by the Open Source Initiative.
|
||||||
|
|
||||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||||
#
|
#
|
||||||
# needsbinariesforbuild
|
# needsbinariesforbuild
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ BuildRequires: hivex-devel
|
|||||||
BuildRequires: gtk2-devel
|
BuildRequires: gtk2-devel
|
||||||
%endif
|
%endif
|
||||||
#
|
#
|
||||||
URL: http://libguestfs.org/
|
Url: http://libguestfs.org/
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
Summary: Compatibility package for guestfs-tools
|
Summary: Compatibility package for guestfs-tools
|
||||||
# Upstream patches
|
# Upstream patches
|
||||||
@ -147,6 +147,7 @@ Patch1: 0a55098f-builder-repository-fix-compute_short_id-for-sles-X.0.pa
|
|||||||
Patch2: fd43730e-error-with-uninstall-option-on-SUSE.patch
|
Patch2: fd43730e-error-with-uninstall-option-on-SUSE.patch
|
||||||
Patch3: 70407cd622-inspection-Parse-os-release-opensuse-leap-as-opensus.patch
|
Patch3: 70407cd622-inspection-Parse-os-release-opensuse-leap-as-opensus.patch
|
||||||
Patch4: 28bd06227b-inspect-handle-os-release-opensuse-tumbleweed-as-ope.patch
|
Patch4: 28bd06227b-inspect-handle-os-release-opensuse-tumbleweed-as-ope.patch
|
||||||
|
Patch5: 500acb15-v2v-linux-fix-kernel-detection-when-split-in-different-packages.patch
|
||||||
|
|
||||||
# Pending upstram review
|
# Pending upstram review
|
||||||
Patch50: 0001-Introduce-a-wrapper-around-xmlParseURI.patch
|
Patch50: 0001-Introduce-a-wrapper-around-xmlParseURI.patch
|
||||||
@ -567,6 +568,7 @@ It can import a variety of guest operating systems from libvirt-managed hosts.
|
|||||||
%patch2 -p1
|
%patch2 -p1
|
||||||
%patch3 -p1
|
%patch3 -p1
|
||||||
%patch4 -p1
|
%patch4 -p1
|
||||||
|
%patch5 -p1
|
||||||
%patch50 -p1
|
%patch50 -p1
|
||||||
%patch51 -p1
|
%patch51 -p1
|
||||||
%patch52 -p1
|
%patch52 -p1
|
||||||
|
Loading…
Reference in New Issue
Block a user