[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v4 04/17] util: Introduce virObjectLookupKeys*Active API's



Add a 'bool active' field to the virObjectLookupKeys object and then
virObjectLookupKeysIsActive and virObjectLookupKeysSetActive API's
to manage it.

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/libvirt_private.syms |  2 ++
 src/util/virobject.c     | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/util/virobject.h     | 11 +++++++++++
 3 files changed, 64 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 66cf865..9eb0589 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2332,7 +2332,9 @@ virObjectListFreeCount;
 virObjectLock;
 virObjectLockableNew;
 virObjectLookupHashNew;
+virObjectLookupKeysIsActive;
 virObjectLookupKeysNew;
+virObjectLookupKeysSetActive;
 virObjectNew;
 virObjectRef;
 virObjectRWLockableNew;
diff --git a/src/util/virobject.c b/src/util/virobject.c
index f677b5f..657597f 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -807,3 +807,54 @@ virObjectListFreeCount(void *list,
 
     VIR_FREE(list);
 }
+
+
+static virObjectLookupKeysPtr
+virObjectGetLookupKeysObj(void *anyobj)
+{
+    if (virObjectIsClass(anyobj, virObjectLookupKeysClass))
+        return anyobj;
+
+    VIR_OBJECT_USAGE_PRINT_ERROR(anyobj, virObjectLookupKeysClass);
+
+    return NULL;
+}
+
+
+/**
+ * virObjectLookupKeysIsActive
+ * @anyobj: Pointer to a locked LookupKeys object
+ *
+ * Returns: True if object is active, false if not
+ */
+bool
+virObjectLookupKeysIsActive(void *anyobj)
+{
+    virObjectLookupKeysPtr obj = virObjectGetLookupKeysObj(anyobj);
+
+    if (!obj)
+        return false;
+
+    return obj->active;
+}
+
+
+/**
+ * virObjectLookupKeysSetActive
+ * @anyobj: Pointer to a locked LookupKeys object
+ * @active: New active setting
+ *
+ * Set the lookup keys active bool value; value not changed if object
+ * is not a lookup keys object
+ */
+void
+virObjectLookupKeysSetActive(void *anyobj,
+                             bool active)
+{
+    virObjectLookupKeysPtr obj = virObjectGetLookupKeysObj(anyobj);
+
+    if (!obj)
+        return;
+
+    obj->active = active;
+}
diff --git a/src/util/virobject.h b/src/util/virobject.h
index a5c03be..0d3b90b 100644
--- a/src/util/virobject.h
+++ b/src/util/virobject.h
@@ -79,6 +79,8 @@ struct _virObjectLookupKeys {
 
     char *key1;
     char *key2;
+
+    bool active;           /* true if object is active */
 };
 
 struct _virObjectLookupHash {
@@ -188,4 +190,13 @@ void
 virObjectListFreeCount(void *list,
                        size_t count);
 
+bool
+virObjectLookupKeysIsActive(void *anyobj)
+    ATTRIBUTE_NONNULL(1);
+
+void
+virObjectLookupKeysSetActive(void *anyobj,
+                             bool active)
+    ATTRIBUTE_NONNULL(1);
+
 #endif /* __VIR_OBJECT_H */
-- 
2.9.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]