[Libguestfs] [v2v PATCH v2 2/7] convert/windows_virtio: map 32-bit arch name from libguestfs to osinfo

Laszlo Ersek lersek at redhat.com
Tue Feb 1 12:32:14 UTC 2022


For Windows guests, the "inspect.i_arch" field is ultimately determined in
libguestfs, on the following call path:

  inspect_os                             [daemon/inspect.ml]
    check_for_filesystem_on              [daemon/inspect_fs.ml]
      check_filesystem                   [daemon/inspect_fs.ml]
        check_windows_root               [daemon/inspect_fs_windows.ml]
          check_windows_arch             [daemon/inspect_fs_windows.ml]
            file_architecture            [daemon/filearch.ml]
              file_architecture_of_magic [daemon/filearch.ml]

where the last function maps "PE32 executable" to "i386".

(As of libguestfs commit 5858c2cf6c24.)

However, in osinfo-db (as of commit 72c69622e6db), the
"data/schema/osinfo.rng.in" schema calls the same architecture "i686".

Perform this mapping in the "copy_from_libosinfo" function explicitly: the
filter currently throws away all "i686" drivers from libosinfo because
they don't match "i386" from libguestfs.

(There is no such problem with "x86_64".)

Fixes: 258e4b718d5d80c79634fe864c8c52b12e41777c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2043333
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
Acked-by: Richard W.M. Jones <rjones at redhat.com>
---

Notes:
    v2:
    - pick up Rich's ACK

 convert/windows_virtio.ml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/convert/windows_virtio.ml b/convert/windows_virtio.ml
index d21ee6814458..1faba8a874c0 100644
--- a/convert/windows_virtio.ml
+++ b/convert/windows_virtio.ml
@@ -412,12 +412,17 @@ and copy_from_libosinfo g inspect destdir =
     List.iter (
       fun d ->
         debug "\t%s" (Libosinfo_utils.string_of_osinfo_device_driver d)
     )
   in
   let { i_osinfo = osinfo; i_arch = arch } = inspect in
+  (* The architecture that "inspect.i_arch" from libguestfs
+   * ("daemon/filearch.ml") calls "i386", the osinfo-db schema
+   * ("data/schema/osinfo.rng.in") calls "i686".
+   *)
+  let arch = if arch = "i386" then "i686" else arch in
   try
     let os = Libosinfo_utils.get_os_by_short_id osinfo in
     let drivers = os#get_device_drivers () in
     debug "libosinfo drivers before filtering:"; debug_drivers drivers;
     (*
      * Filter out drivers that we cannot use:
-- 
2.19.1.3.g30247aa5d201




More information about the Libguestfs mailing list