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(a)redhat.com>
---
convert/libosinfo.mli | 19 ++++++++++---------
convert/libosinfo.ml | 19 ++++++++++---------
convert/libosinfo-c.c | 6 ++++++
3 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/convert/libosinfo.mli b/convert/libosinfo.mli
index 1ece7b41a310..aa436370e46d 100644
--- a/convert/libosinfo.mli
+++ b/convert/libosinfo.mli
@@ -17,33 +17,34 @@
*)
(** This module implements a minimal libosinfo API. *)
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;
vendor_id : string;
product : string;
product_id : string;
name : string;
class_ : string;
bus_type : string;
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. *)
method get_device_drivers : unit -> osinfo_device_driver list
(** Return the list of device drivers. *)
method get_devices : unit -> osinfo_device list
diff --git a/convert/libosinfo.ml b/convert/libosinfo.ml
index 78271be248ea..8ea0a279ca27 100644
--- a/convert/libosinfo.ml
+++ b/convert/libosinfo.ml
@@ -20,33 +20,34 @@ open Std_utils
open Tools_utils
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;
vendor_id : string;
product : string;
product_id : string;
name : string;
class_ : string;
bus_type : string;
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"
class osinfo_os h =
object (self)
diff --git a/convert/libosinfo-c.c b/convert/libosinfo-c.c
index bc5816f6dacb..93357fd91b7f 100644
--- a/convert/libosinfo-c.c
+++ b/convert/libosinfo-c.c
@@ -289,12 +289,13 @@ v2v_osinfo_os_get_device_drivers (value osv)
for (i = len - 1; i >= 0; --i) {
OsinfoDeviceDriver *driver;
const gchar *str;
gboolean b;
GList *l;
gint64 i64;
+ OsinfoDeviceList *dev_list;
driver = OSINFO_DEVICE_DRIVER(osinfo_list_get_nth (OSINFO_LIST(list), i));
vi = caml_alloc (6, 0);
str = osinfo_device_driver_get_architecture (driver);
copyv = caml_copy_string (str);
@@ -314,12 +315,17 @@ v2v_osinfo_os_get_device_drivers (value osv)
#endif
copyv = caml_copy_int64 (i64);
Store_field (vi, 4, copyv);
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);
Store_field (v, 1, rv);
rv = v;
}
Seems simple enough, ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.