[Libvirt-cim] [PATCH 2 of 4] Add methods for setting/getting boolean values from the infostore

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Jul 10 23:52:47 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1247095850 25200
# Node ID f915b6e4d1a3748fe8541cf2a3030a4613675945
# Parent  f609e31b0c17ea550f27426dd8e329c362f4db3e
Add methods for setting/getting boolean values from the infostore

This will be used for determining whether a guest has a VNC password set since
we cannot determine this info from the guest's XML alone.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r f609e31b0c17 -r f915b6e4d1a3 libxkutil/infostore.c
--- a/libxkutil/infostore.c	Wed Jul 08 16:30:50 2009 -0700
+++ b/libxkutil/infostore.c	Wed Jul 08 16:30:50 2009 -0700
@@ -419,6 +419,36 @@
         return xpath_set_string(ctx, key, val);
 }
 
+bool infostore_get_bool(struct infostore_ctx *ctx, const char *key)
+{
+        char *sval = NULL;
+        bool val = false;
+
+        sval = xpath_query_string(ctx, key);
+        if (sval == NULL)
+                goto out;
+
+        if (STREQC(sval, "true"))
+                return true;
+
+ out:
+        free(sval);
+
+        return val;
+}
+
+bool infostore_set_bool(struct infostore_ctx *ctx, const char *key, bool val)
+{
+        bool ret;
+
+        if (val)
+                ret = xpath_set_string(ctx, key, "true");
+        else
+                ret = xpath_set_string(ctx, key, "false");
+
+        return ret;
+}
+
 /*
  * Local Variables:
  * mode: C
diff -r f609e31b0c17 -r f915b6e4d1a3 libxkutil/infostore.h
--- a/libxkutil/infostore.h	Wed Jul 08 16:30:50 2009 -0700
+++ b/libxkutil/infostore.h	Wed Jul 08 16:30:50 2009 -0700
@@ -40,6 +40,9 @@
 bool infostore_set_str(struct infostore_ctx *ctx,
                        const char *key, const char * val);
 
+bool infostore_get_bool(struct infostore_ctx *ctx, const char *key);
+bool infostore_set_bool(struct infostore_ctx *ctx,
+                        const char *key, bool val);
 
 #endif
 




More information about the Libvirt-cim mailing list