WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 2/5] libxl: add xlu_cfg_get_type function

To: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 2/5] libxl: add xlu_cfg_get_type function
From: Andre Przywara <andre.przywara@xxxxxxx>
Date: Wed, 8 Sep 2010 11:20:35 +0200
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Wed, 08 Sep 2010 02:41:52 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.23 (X11/20090820)
As cpuid= can be used with two syntaxes (one as a list, the other as a
string), we need to distinguish them without an error message. Introduce a helper function to detect the type of entry used before issuing a warning.

Signed-off-by: Andre Przywara

--
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 448-3567-12
>From ae2a1dda7829a38bb891f560d9fc458a4d8c9fba Mon Sep 17 00:00:00 2001
From: Andre Przywara <andre.przywara@xxxxxxx>
Date: Wed, 1 Sep 2010 14:11:54 +0200
Subject: [PATCH 2/5] libxl: add xlu_cfg_get_type function

cpuid= can be used with two syntaxes, one as a list, the other as a
string. Introduce a helper function to detect the type of entry used
before issuing a warning.

Signed-off-by: Andre Przywara
---
 tools/libxl/libxlu_cfg.c |   18 ++++++++++++++++++
 tools/libxl/libxlutil.h  |    6 ++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c
index 09a7c71..b9018d5 100644
--- a/tools/libxl/libxlu_cfg.c
+++ b/tools/libxl/libxlu_cfg.c
@@ -124,6 +124,24 @@ static XLU_ConfigSetting *find(const XLU_Config *cfg, 
const char *n) {
     return 0;
 }
 
+int xlu_cfg_get_type(const XLU_Config *cfg, const char *n)
+{
+    XLU_ConfigSetting *set;
+    char *endptr;
+    long l;
+
+    set = find(cfg, n);
+    if (set == NULL)
+        return XLU_CFG_NOTFOUND;
+    if (set->avalues > 1)
+        return XLU_CFG_LIST;
+    errno = 0;
+    l = strtol(set->values[0], &endptr, 0);
+    if (errno == EINVAL || endptr == set->values[0])
+        return XLU_CFG_STRING;
+    return XLU_CFG_LONG;
+}
+
 static int find_atom(const XLU_Config *cfg, const char *n,
                      XLU_ConfigSetting **set_r) {
     XLU_ConfigSetting *set;
diff --git a/tools/libxl/libxlutil.h b/tools/libxl/libxlutil.h
index 0262e55..0d7ae91 100644
--- a/tools/libxl/libxlutil.h
+++ b/tools/libxl/libxlutil.h
@@ -24,6 +24,11 @@
 typedef struct XLU_Config XLU_Config;
 typedef struct XLU_ConfigList XLU_ConfigList;
 
+#define XLU_CFG_NOTFOUND 0
+#define XLU_CFG_LIST     1
+#define XLU_CFG_LONG     2
+#define XLU_CFG_STRING   3
+
 XLU_Config *xlu_cfg_init(FILE *report, const char *report_filename);
   /* 0 means we got ENOMEM. */
   /* report_filename is copied; report is saved and must remain valid
@@ -45,6 +50,7 @@ void xlu_cfg_destroy(XLU_Config*);
  *   ERANGE   value out of range (from strtol)
  */
 
+int xlu_cfg_get_type(const XLU_Config *cfg, const char *n);
 int xlu_cfg_get_string(const XLU_Config*, const char *n, const char **value_r);
 int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r);
 
-- 
1.6.4

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>