[Libosinfo] [libosinfo PATCH v2 06/15] loader: Deal with "removed" devices for an OS

Fabiano Fidêncio fidencio at redhat.com
Mon Nov 12 10:30:53 UTC 2018


Let's make the loader aware of the "removed" attribute that can be set
for a device linked from an OS entry.

https://gitlab.com/libosinfo/osinfo-db/issues/13

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 osinfo/osinfo_devicelink.h | 1 +
 osinfo/osinfo_loader.c     | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/osinfo/osinfo_devicelink.h b/osinfo/osinfo_devicelink.h
index 1ca6402..a4bc8ec 100644
--- a/osinfo/osinfo_devicelink.h
+++ b/osinfo/osinfo_devicelink.h
@@ -45,6 +45,7 @@ typedef struct _OsinfoDeviceLinkClass   OsinfoDeviceLinkClass;
 typedef struct _OsinfoDeviceLinkPrivate OsinfoDeviceLinkPrivate;
 
 #define OSINFO_DEVICELINK_PROP_DRIVER   "driver"
+#define OSINFO_DEVICELINK_PROP_REMOVED  "removed"
 
 /* object */
 struct _OsinfoDeviceLink
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index d1bf61d..a8d995a 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -637,6 +637,15 @@ static void osinfo_loader_device_link(OsinfoLoader *loader,
             devlink = osinfo_deployment_add_device(OSINFO_DEPLOYMENT(entity), dev);
         }
 
+        gchar *removed = (gchar *)xmlGetProp(related[i],
+                                             BAD_CAST OSINFO_DEVICELINK_PROP_REMOVED);
+        if (removed != NULL) {
+            osinfo_entity_set_param_boolean(OSINFO_ENTITY(devlink),
+                                            OSINFO_DEVICELINK_PROP_REMOVED,
+                                            g_str_equal(removed, "true") ? TRUE : FALSE);
+            xmlFree(removed);
+        }
+
         xmlNodePtr saved = ctxt->node;
         ctxt->node = related[i];
         osinfo_loader_entity(loader, OSINFO_ENTITY(devlink), keys, ctxt, root, err);
-- 
2.19.1




More information about the Libosinfo mailing list