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

[Xen-changelog] [xen-unstable] Added documentation, C bindings, and test for VM_metrics.VCPUs_flags.



# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1176484446 -3600
# Node ID 249de074617f259f456de3a9d60c108182044efa
# Parent  456c611ada027df8b38a5373dba3eee1e4b6c252
Added documentation, C bindings, and test for VM_metrics.VCPUs_flags.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 docs/xen-api/xenapi-datamodel.tex             |   33 ++++++++++++++++
 tools/libxen/include/xen_int_string_set_map.h |   53 ++++++++++++++++++++++++++
 tools/libxen/include/xen_internal.h           |    1 
 tools/libxen/include/xen_vm_metrics.h         |    9 ++++
 tools/libxen/src/xen_common.c                 |   19 +++++++++
 tools/libxen/src/xen_int_string_set_map.c     |   52 +++++++++++++++++++++++++
 tools/libxen/src/xen_vm_metrics.c             |   22 ++++++++++
 tools/libxen/test/test_bindings.c             |   20 +++++++++
 8 files changed, 209 insertions(+)

diff -r 456c611ada02 -r 249de074617f docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Thu Apr 12 22:49:02 2007 +0100
+++ b/docs/xen-api/xenapi-datamodel.tex Fri Apr 13 18:14:06 2007 +0100
@@ -4289,6 +4289,7 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/utilisation} & (int $\rightarrow$ 
float) Map & Utilisation for all of guest's current VCPUs \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/CPU} & (int $\rightarrow$ int) Map & 
VCPU to PCPU map \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/params} & (string $\rightarrow$ 
string) Map & The live equivalent to VM.VCPUs\_params \\
+$\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/flags} & (int $\rightarrow$ string 
Set) Map & CPU flags (blocked,online,running) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt state} & string Set & The state of the 
guest, eg blocked, dying etc \\
 $\mathit{RO}_\mathit{run}$ &  {\tt start\_time} & datetime & Time at which 
this VM was last booted \\
 $\mathit{RO}_\mathit{run}$ &  {\tt last\_updated} & datetime & Time at which 
this information was last updated \\
@@ -4501,6 +4502,38 @@ Get the VCPUs/params field of the given 
  \noindent {\bf Return Type:} 
 {\tt 
 (string $\rightarrow$ string) Map
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_VCPUs\_flags}
+
+{\bf Overview:} 
+Get the VCPUs/flags field of the given VM\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} ((int -> string Set) Map) get_VCPUs_flags (session_id s, 
VM_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+(int $\rightarrow$ string Set) Map
 }
 
 
diff -r 456c611ada02 -r 249de074617f 
tools/libxen/include/xen_int_string_set_map.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen_int_string_set_map.h     Fri Apr 13 18:14:06 
2007 +0100
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+#ifndef XEN_INT_STRING_SET_MAP_H
+#define XEN_INT_STRING_SET_MAP_H
+
+
+#include "xen_common.h"
+
+
+typedef struct xen_int_string_set_map_contents
+{
+  int64_t key;
+  struct xen_string_set *val;
+} xen_int_string_set_map_contents;
+
+
+typedef struct xen_int_string_set_map
+{
+    size_t size;
+    xen_int_string_set_map_contents contents[];
+} xen_int_string_set_map;
+
+/**
+ * Allocate a xen_int_string_set_map of the given size.
+ */
+extern xen_int_string_set_map *
+xen_int_string_set_map_alloc(size_t size);
+
+/**
+ * Free the given xen_int_string_set_map, and all referenced values. 
+ * The given map must have been allocated by this library.
+ */
+extern void
+xen_int_string_set_map_free(xen_int_string_set_map *map);
+
+
+#endif
diff -r 456c611ada02 -r 249de074617f tools/libxen/include/xen_internal.h
--- a/tools/libxen/include/xen_internal.h       Thu Apr 12 22:49:02 2007 +0100
+++ b/tools/libxen/include/xen_internal.h       Fri Apr 13 18:14:06 2007 +0100
@@ -87,6 +87,7 @@ extern const abstract_type abstract_type
 extern const abstract_type abstract_type_string_string_map;
 extern const abstract_type abstract_type_int_float_map;
 extern const abstract_type abstract_type_int_int_map;
+extern const abstract_type abstract_type_int_string_set_map;
 
 
 typedef struct abstract_value
diff -r 456c611ada02 -r 249de074617f tools/libxen/include/xen_vm_metrics.h
--- a/tools/libxen/include/xen_vm_metrics.h     Thu Apr 12 22:49:02 2007 +0100
+++ b/tools/libxen/include/xen_vm_metrics.h     Fri Apr 13 18:14:06 2007 +0100
@@ -22,6 +22,7 @@
 #include "xen_common.h"
 #include "xen_int_float_map.h"
 #include "xen_int_int_map.h"
+#include "xen_int_string_set_map.h"
 #include "xen_string_set.h"
 #include "xen_string_string_map.h"
 #include "xen_vm_metrics_decl.h"
@@ -71,6 +72,7 @@ typedef struct xen_vm_metrics_record
     xen_int_float_map *vcpus_utilisation;
     xen_int_int_map *vcpus_cpu;
     xen_string_string_map *vcpus_params;
+    xen_int_string_set_map *vcpus_flags;
     struct xen_string_set *state;
     time_t start_time;
     time_t last_updated;
@@ -212,6 +214,13 @@ xen_vm_metrics_get_vcpus_params(xen_sess
 
 
 /**
+ * Get the VCPUs/flags field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_vcpus_flags(xen_session *session, xen_int_string_set_map 
**result, xen_vm_metrics vm_metrics);
+
+
+/**
  * Get the state field of the given VM_metrics.
  */
 extern bool
diff -r 456c611ada02 -r 249de074617f tools/libxen/src/xen_common.c
--- a/tools/libxen/src/xen_common.c     Thu Apr 12 22:49:02 2007 +0100
+++ b/tools/libxen/src/xen_common.c     Fri Apr 13 18:14:06 2007 +0100
@@ -36,6 +36,7 @@
 #include "xen_internal.h"
 #include "xen_int_float_map.h"
 #include "xen_int_int_map.h"
+#include "xen_int_string_set_map.h"
 #include "xen_string_string_map.h"
 
 
@@ -1716,3 +1717,21 @@ const abstract_type abstract_type_int_in
         .struct_size = sizeof(xen_int_int_map_contents),
         .members = int_int_members
     };
+
+static struct struct_member int_string_set_members[] =
+{
+    {
+        .type = &abstract_type_int,
+        .offset = offsetof(xen_int_string_set_map_contents, key)
+    },
+    {
+        .type = &abstract_type_string_set,
+        .offset = offsetof(xen_int_string_set_map_contents, val)
+    }
+};
+const abstract_type abstract_type_int_string_set_map =
+    {
+        .typename = MAP,
+        .struct_size = sizeof(xen_int_string_set_map_contents),
+        .members = int_string_set_members
+    };
diff -r 456c611ada02 -r 249de074617f tools/libxen/src/xen_int_string_set_map.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/src/xen_int_string_set_map.c Fri Apr 13 18:14:06 2007 +0100
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+
+#include "xen_common.h"
+#include "xen_int_string_set_map.h"
+#include "xen_internal.h"
+#include "xen_string_set.h"
+
+
+xen_int_string_set_map *
+xen_int_string_set_map_alloc(size_t size)
+{
+    xen_int_string_set_map *result = calloc(1, sizeof(xen_int_string_set_map) +
+                                            size * sizeof(struct 
xen_int_string_set_map_contents));
+    result->size = size;
+    return result;
+}
+
+
+void
+xen_int_string_set_map_free(xen_int_string_set_map *map)
+{
+    if (map == NULL)
+    {
+        return;
+    }
+
+    size_t n = map->size;
+    for (size_t i = 0; i < n; i++)
+    {
+        
+        xen_string_set_free(map->contents[i].val);
+    }
+
+    free(map);
+}
diff -r 456c611ada02 -r 249de074617f tools/libxen/src/xen_vm_metrics.c
--- a/tools/libxen/src/xen_vm_metrics.c Thu Apr 12 22:49:02 2007 +0100
+++ b/tools/libxen/src/xen_vm_metrics.c Fri Apr 13 18:14:06 2007 +0100
@@ -23,6 +23,7 @@
 #include "xen_common.h"
 #include "xen_int_float_map.h"
 #include "xen_int_int_map.h"
+#include "xen_int_string_set_map.h"
 #include "xen_internal.h"
 #include "xen_string_string_map.h"
 #include "xen_vm_metrics.h"
@@ -57,6 +58,9 @@ static const struct_member xen_vm_metric
         { .key = "VCPUs_params",
           .type = &abstract_type_string_string_map,
           .offset = offsetof(xen_vm_metrics_record, vcpus_params) },
+        { .key = "VCPUs_flags",
+          .type = &abstract_type_int_string_set_map,
+          .offset = offsetof(xen_vm_metrics_record, vcpus_flags) },
         { .key = "state",
           .type = &abstract_type_string_set,
           .offset = offsetof(xen_vm_metrics_record, state) },
@@ -90,6 +94,7 @@ xen_vm_metrics_record_free(xen_vm_metric
     xen_int_float_map_free(record->vcpus_utilisation);
     xen_int_int_map_free(record->vcpus_cpu);
     xen_string_string_map_free(record->vcpus_params);
+    xen_int_string_set_map_free(record->vcpus_flags);
     xen_string_set_free(record->state);
     free(record);
 }
@@ -219,6 +224,23 @@ xen_vm_metrics_get_vcpus_params(xen_sess
 
 
 bool
+xen_vm_metrics_get_vcpus_flags(xen_session *session, xen_int_string_set_map 
**result, xen_vm_metrics vm_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm_metrics }
+        };
+
+    abstract_type result_type = abstract_type_int_string_set_map;
+
+    *result = NULL;
+    XEN_CALL_("VM_metrics.get_VCPUs_flags");
+    return session->ok;
+}
+
+
+bool
 xen_vm_metrics_get_state(xen_session *session, struct xen_string_set **result, 
xen_vm_metrics vm_metrics)
 {
     abstract_value param_values[] =
diff -r 456c611ada02 -r 249de074617f tools/libxen/test/test_bindings.c
--- a/tools/libxen/test/test_bindings.c Thu Apr 12 22:49:02 2007 +0100
+++ b/tools/libxen/test/test_bindings.c Fri Apr 13 18:14:06 2007 +0100
@@ -684,6 +684,8 @@ static void print_session_info(xen_sessi
 
     if (!session->ok)
     {
+        free(uuid);
+        free(this_user);
         xen_session_record_free(record);
         print_error(session);
         return;
@@ -692,6 +694,8 @@ static void print_session_info(xen_sessi
     assert(!strcmp(record->uuid, uuid));
     assert(!strcmp(record->this_user, this_user));
 
+    free(uuid);
+    free(this_user);
     xen_session_record_free(record);
 
     fflush(stdout);
@@ -784,6 +788,22 @@ static void print_vm_metrics(xen_session
                vm_metrics_record->vcpus_params->contents[i].val);
     }
 
+    for (size_t i = 0; i < vm_metrics_record->vcpus_flags->size; i++)
+    {
+        printf("%"PRId64" -> ",
+               vm_metrics_record->vcpus_flags->contents[i].key);
+        xen_string_set *s = vm_metrics_record->vcpus_flags->contents[i].val;
+        for (size_t j = 0; j < s->size; j++)
+        {
+            printf("%s", s->contents[j]);
+            if (j + 1 != s->size)
+            {
+                printf(", ");
+            }
+        }
+        printf("\n");
+    }
+
     xen_vm_metrics_record_free(vm_metrics_record);
     xen_vm_metrics_free(vm_metrics);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.