virt-v2v/0029-convert-libosinfo-retr...

131 lines
3.8 KiB
Diff

From a90a23fe48225775bef65829b83c14b3c940d093 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@redhat.com>
Date: Tue, 1 Feb 2022 13:32:16 +0100
Subject: [PATCH] convert/libosinfo: retrieve the device list for
OsinfoDeviceDriver
The OsinfoDeviceDriver class supports the
osinfo_device_driver_get_devices() method, we've just had no use for that
thus far.
Using the previously extracted v2v_osinfo_device_list_to_value_list()
function, we can now relatively easily OCaml-ify the list of devices that
a driver supports. (We'll use this functionality in a subsequent patch.)
(Notably, osinfo_device_driver_get_devices() is marked "transfer none",
unlike osinfo_os_get_all_devices(), which is marked "transfer full".)
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2043333
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20220201123219.9317-5-lersek@redhat.com>
(cherry picked from commit 27816bd952b609b45e98670fe538b621f3d254e4)
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
convert/libosinfo-c.c | 6 ++++++
convert/libosinfo.ml | 19 ++++++++++---------
convert/libosinfo.mli | 19 ++++++++++---------
3 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/convert/libosinfo-c.c b/convert/libosinfo-c.c
index bc5816f6..93357fd9 100644
--- a/convert/libosinfo-c.c
+++ b/convert/libosinfo-c.c
@@ -292,6 +292,7 @@ v2v_osinfo_os_get_device_drivers (value osv)
gboolean b;
GList *l;
gint64 i64;
+ OsinfoDeviceList *dev_list;
driver = OSINFO_DEVICE_DRIVER(osinfo_list_get_nth (OSINFO_LIST(list), i));
@@ -317,6 +318,11 @@ v2v_osinfo_os_get_device_drivers (value osv)
l = osinfo_device_driver_get_files (driver);
Store_field (vi, 5, glist_to_value_list (l));
g_list_free (l);
+ dev_list = osinfo_device_driver_get_devices (driver);
+ v = (dev_list == NULL) ?
+ Val_emptylist :
+ v2v_osinfo_device_list_to_value_list (dev_list);
+ Store_field (vi, 6, v);
v = caml_alloc (2, 0);
Store_field (v, 0, vi);
diff --git a/convert/libosinfo.ml b/convert/libosinfo.ml
index 78271be2..8ea0a279 100644
--- a/convert/libosinfo.ml
+++ b/convert/libosinfo.ml
@@ -23,15 +23,6 @@ open Common_gettext.Gettext
type osinfo_db_t
type osinfo_os_t
-type osinfo_device_driver = {
- architecture : string;
- location : string;
- pre_installable : bool;
- signed : bool;
- priority : int64;
- files : string list;
-}
-
type osinfo_device = {
id : string;
vendor : string;
@@ -44,6 +35,16 @@ type osinfo_device = {
subsystem : string;
}
+type osinfo_device_driver = {
+ architecture : string;
+ location : string;
+ pre_installable : bool;
+ signed : bool;
+ priority : int64;
+ files : string list;
+ devices : osinfo_device list;
+}
+
external osinfo_os_get_id : osinfo_os_t -> string = "v2v_osinfo_os_get_id"
external osinfo_os_get_device_drivers : osinfo_os_t -> osinfo_device_driver list = "v2v_osinfo_os_get_device_drivers"
external osinfo_os_get_devices : osinfo_os_t -> osinfo_device list = "v2v_osinfo_os_get_all_devices"
diff --git a/convert/libosinfo.mli b/convert/libosinfo.mli
index 1ece7b41..aa436370 100644
--- a/convert/libosinfo.mli
+++ b/convert/libosinfo.mli
@@ -20,15 +20,6 @@
type osinfo_os_t
-type osinfo_device_driver = {
- architecture : string;
- location : string;
- pre_installable : bool;
- signed : bool;
- priority : int64;
- files : string list;
-}
-
type osinfo_device = {
id : string;
vendor : string;
@@ -41,6 +32,16 @@ type osinfo_device = {
subsystem : string;
}
+type osinfo_device_driver = {
+ architecture : string;
+ location : string;
+ pre_installable : bool;
+ signed : bool;
+ priority : int64;
+ files : string list;
+ devices : osinfo_device list;
+}
+
class osinfo_os : osinfo_os_t -> object
method get_id : unit -> string
(** Return the ID. *)
--
2.19.1.3.g30247aa5d201