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