78 lines
2.8 KiB
Diff
78 lines
2.8 KiB
Diff
|
From 2a2d7e9e1376084670dbf8587549948713341153 Mon Sep 17 00:00:00 2001
|
||
|
From: Laszlo Ersek <lersek@redhat.com>
|
||
|
Date: Thu, 6 Jan 2022 15:09:09 +0100
|
||
|
Subject: [PATCH] convert/libosinfo_utils: introduce
|
||
|
"os_support_of_osinfo_device_list"
|
||
|
|
||
|
Add a helper function for calculating q35 support and virtio-1.0 support
|
||
|
from the list of devices returned by the previously introduced
|
||
|
"osinfo_os#get_devices" method.
|
||
|
|
||
|
(Rather than folding the list into a record of bools, implement the
|
||
|
function explicitly, recursively. Folding wouldn't stop (without abusing
|
||
|
exceptions) once all fields in the record turned "true", but a recursive
|
||
|
function can just return the accumulator at that point.)
|
||
|
|
||
|
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1942325
|
||
|
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
||
|
Message-Id: <20220106140910.13695-9-lersek@redhat.com>
|
||
|
[lersek@redhat.com: don't break "in" to a new line after a "let" that
|
||
|
defines a non-function (Rich)]
|
||
|
Acked-by: Richard W.M. Jones <rjones@redhat.com>
|
||
|
---
|
||
|
convert/libosinfo_utils.ml | 18 ++++++++++++++++++
|
||
|
convert/libosinfo_utils.mli | 14 ++++++++++++++
|
||
|
2 files changed, 32 insertions(+)
|
||
|
|
||
|
diff --git a/convert/libosinfo_utils.ml b/convert/libosinfo_utils.ml
|
||
|
index d5eb082b..77f22272 100644
|
||
|
--- a/convert/libosinfo_utils.ml
|
||
|
+++ b/convert/libosinfo_utils.ml
|
||
|
@@ -77,3 +77,21 @@ let string_of_osinfo_device_list dev_list =
|
||
|
*)
|
||
|
String.concat "\n"
|
||
|
(List.map (fun dev -> columnate (listify dev) max_widths) dev_list)
|
||
|
+
|
||
|
+type os_support = {
|
||
|
+ q35 : bool;
|
||
|
+ vio10 : bool;
|
||
|
+}
|
||
|
+
|
||
|
+let os_support_of_osinfo_device_list =
|
||
|
+ let rec next accu left =
|
||
|
+ match accu, left with
|
||
|
+ | { q35 = true; vio10 = true }, _
|
||
|
+ | _ , [] ->
|
||
|
+ accu
|
||
|
+ | { q35; vio10 }, { Libosinfo.id } :: tail ->
|
||
|
+ let q35 = q35 || id = "http://qemu.org/chipset/x86/q35"
|
||
|
+ and vio10 = vio10 || id = "http://pcisig.com/pci/1af4/1041" in
|
||
|
+ next { q35; vio10 } tail
|
||
|
+ in
|
||
|
+ next { q35 = false; vio10 = false }
|
||
|
diff --git a/convert/libosinfo_utils.mli b/convert/libosinfo_utils.mli
|
||
|
index 5a703334..ab77ec97 100644
|
||
|
--- a/convert/libosinfo_utils.mli
|
||
|
+++ b/convert/libosinfo_utils.mli
|
||
|
@@ -30,3 +30,17 @@ val string_of_osinfo_device_driver : Libosinfo.osinfo_device_driver -> string
|
||
|
|
||
|
val string_of_osinfo_device_list : Libosinfo.osinfo_device list -> string
|
||
|
(** Convert an [osinfo_device] list to a printable string for debugging. *)
|
||
|
+
|
||
|
+type os_support = {
|
||
|
+ q35 : bool;
|
||
|
+ vio10 : bool;
|
||
|
+}
|
||
|
+(** Tell whether the operating system supports the Q35 board type and/or
|
||
|
+ non-transitional (virtio-1.0-only) virtio devices. (Internally, the
|
||
|
+ virtio-1.0-net device is used as a proxy for the general statement about
|
||
|
+ virtio-1.0.)
|
||
|
+ *)
|
||
|
+
|
||
|
+val os_support_of_osinfo_device_list : Libosinfo.osinfo_device list ->
|
||
|
+ os_support
|
||
|
+(** Get [os_support] from an [osinfo_device] list. *)
|
||
|
--
|
||
|
2.31.1
|
||
|
|