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

[Xen-changelog] xenstat/xentop merge.



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 6783e59e1c45c858d76d0e101ac6f9a5a8fef4a7
# Parent  43d91cbb1bfb7cde37f46a00f383c11b24b8d5aa
# Parent  79df8d5fc424e02436a81365872078967b228e7a
xenstat/xentop merge.

diff -r 43d91cbb1bfb -r 6783e59e1c45 
tools/xenstat/libxenstat/src/xen-interface.c
--- a/tools/xenstat/libxenstat/src/xen-interface.c      Mon Aug 22 23:07:37 2005
+++ b/tools/xenstat/libxenstat/src/xen-interface.c      Tue Aug 23 18:25:51 2005
@@ -21,7 +21,9 @@
 #include <sys/mman.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
+#include "version.h"
 #include "privcmd.h"
 #include "xen.h"
 
@@ -56,26 +58,35 @@
        free (handle);
 }
 
-/* Make Xen hypervisor call */
-int xi_make_dom0_op(xi_handle *handle, dom0_op_t *op, int opcode)
+/* Make simple xen version hypervisor calls */
+static int xi_make_xen_version_hypercall(xi_handle *handle, long *vnum, 
xen_extraversion_t *ver)
 {
        privcmd_hypercall_t privcmd;
+       multicall_entry_t multicall[2];
        int ret = 0;
 
        /* set up for doing hypercall */
-       privcmd.op = __HYPERVISOR_dom0_op;
-       privcmd.arg[0] = (unsigned long)op;
-       op->cmd = opcode;
-       op->interface_version = DOM0_INTERFACE_VERSION;
+       privcmd.op = __HYPERVISOR_multicall; 
+       privcmd.arg[0] = (unsigned long)multicall;
+       privcmd.arg[1] = 2;
+
+       /* first one to get xen version number */
+       multicall[0].op = __HYPERVISOR_xen_version;
+       multicall[0].args[0] = (unsigned long)XENVER_version;
+
+       /* second to get xen version flag */
+       multicall[1].op = __HYPERVISOR_xen_version; 
+       multicall[1].args[0] = (unsigned long)XENVER_extraversion;
+       multicall[1].args[1] = (unsigned long)ver;
 
        if (mlock( &privcmd, sizeof(privcmd_hypercall_t)) < 0) {
                perror("Failed to mlock privcmd structure");
                return -1;
        }
 
-       if (mlock( op, sizeof(dom0_op_t)) < 0) {
-               perror("Failed to mlock dom0_op structure");
-               munlock( &privcmd, sizeof(privcmd_hypercall_t));
+       if (mlock( multicall, sizeof(multicall_entry_t)) < 0) {
+               perror("Failed to mlock multicall_entry structure");
+               munlock( &multicall, sizeof(multicall_entry_t));
                return -1;
        }
 
@@ -84,8 +95,44 @@
                ret = -1;
        }
 
+       *vnum = multicall[0].result;
+
        munlock( &privcmd, sizeof(privcmd_hypercall_t));
-       munlock( op, sizeof(dom0_op_t));
+       munlock( &multicall, sizeof(multicall_entry_t));
+
+       return ret;
+}
+
+/* Make Xen Dom0 op hypervisor call */
+static int xi_make_dom0_op(xi_handle *handle, dom0_op_t *dom_op, int 
dom_opcode)
+{
+       privcmd_hypercall_t privcmd;
+       int ret = 0;
+
+       /* set up for doing hypercall */
+       privcmd.op = __HYPERVISOR_dom0_op;
+       privcmd.arg[0] = (unsigned long)dom_op;
+       dom_op->cmd = dom_opcode;
+       dom_op->interface_version = DOM0_INTERFACE_VERSION;
+
+       if (mlock( &privcmd, sizeof(privcmd_hypercall_t)) < 0) {
+               perror("Failed to mlock privcmd structure");
+               return -1;
+       }
+
+       if (mlock( dom_op, sizeof(dom0_op_t)) < 0) {
+               perror("Failed to mlock dom0_op structure");
+               munlock( &privcmd, sizeof(privcmd_hypercall_t));
+               return -1;
+       }
+
+       if (ioctl( handle->fd, IOCTL_PRIVCMD_HYPERCALL, &privcmd) < 0) {
+               perror("Hypercall failed");
+               ret = -1;
+       }
+
+       munlock( &privcmd, sizeof(privcmd_hypercall_t));
+       munlock( dom_op, sizeof(dom0_op_t));
 
        return ret;
 }
@@ -142,3 +189,16 @@
 
        return op.u.getvcpucontext.cpu_time;
 }
+
+/* gets xen version information from hypervisor */
+int xi_get_xen_version(xi_handle *handle, long *vnum, xen_extraversion_t *ver) 
+{
+
+        /* gets the XENVER_version and XENVER_extraversion */
+       if (xi_make_xen_version_hypercall( handle, vnum, ver) < 0) {; 
+               perror("XEN VERSION Hypercall failed");
+               return -1;
+       }
+
+       return 0;
+}
diff -r 43d91cbb1bfb -r 6783e59e1c45 
tools/xenstat/libxenstat/src/xen-interface.h
--- a/tools/xenstat/libxenstat/src/xen-interface.h      Mon Aug 22 23:07:37 2005
+++ b/tools/xenstat/libxenstat/src/xen-interface.h      Tue Aug 23 18:25:51 2005
@@ -27,6 +27,7 @@
 typedef uint64_t u64;
 
 #include "dom0_ops.h"
+#include "version.h"
 
 /* Opaque handles */
 typedef struct xi_handle xi_handle;
@@ -38,6 +39,9 @@
 /* Release the handle to libxc, free resources, etc. */
 void xi_uninit(xi_handle *handle);
 
+/* Obtain xen version information from hypervisor */
+int xi_get_xen_version(xi_handle *, long *vnum, xen_extraversion_t *ver);
+
 /* Obtain physinfo data from dom0 */
 int xi_get_physinfo(xi_handle *, dom0_physinfo_t *);
 
diff -r 43d91cbb1bfb -r 6783e59e1c45 tools/xenstat/libxenstat/src/xenstat.c
--- a/tools/xenstat/libxenstat/src/xenstat.c    Mon Aug 22 23:07:37 2005
+++ b/tools/xenstat/libxenstat/src/xenstat.c    Tue Aug 23 18:25:51 2005
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <xen-interface.h>
 #include "xenstat.h"
+#include "version.h"
 
 /*
  * Types
@@ -32,6 +33,9 @@
        FILE *procnetdev;
 };
 
+#define SHORT_ASC_LEN 5                /* length of 65535 */
+#define VERSION_SIZE (2 * SHORT_ASC_LEN + 1 + sizeof(xen_extraversion_t) + 1)
+
 struct xenstat_node {
        unsigned int flags;
        unsigned long long cpu_hz;
@@ -39,6 +43,7 @@
        unsigned long long tot_mem;
        unsigned long long free_mem;
        unsigned int num_domains;
+       char xen_version[VERSION_SIZE]; /* xen version running on this node */
        xenstat_domain *domains;        /* Array of length num_domains */
 };
 
@@ -47,7 +52,7 @@
        unsigned int state;
        unsigned long long cpu_ns;
        unsigned int num_vcpus;
-       xenstat_vcpu *vcpus;    /* Array of length num_vcpus */
+       xenstat_vcpu *vcpus;            /* Array of length num_vcpus */
        unsigned long long cur_mem;     /* Current memory reservation */
        unsigned long long max_mem;     /* Total memory allowed */
        unsigned int ssid;
@@ -164,6 +169,8 @@
 #define DOMAIN_CHUNK_SIZE 256
        xenstat_node *node;
        dom0_physinfo_t physinfo;
+       xen_extraversion_t version;
+       long vnum = 0; 
        dom0_getdomaininfo_t domaininfo[DOMAIN_CHUNK_SIZE];
        unsigned int num_domains, new_domains;
        unsigned int i;
@@ -178,6 +185,14 @@
                free(node);
                return NULL;
        }
+
+       /* Get the xen version number and xen version tag */
+       if (xi_get_xen_version(handle->xihandle, &vnum, &version) < 0) {
+               free(node); 
+               return NULL;
+       } 
+       snprintf(node->xen_version, VERSION_SIZE,
+               "%ld.%ld%s\n", ((vnum >> 16) & 0xFFFF), vnum & 0xFFFF, (char 
*)version); 
 
        node->cpu_hz = ((unsigned long long)physinfo.cpu_khz) * 1000ULL;
        node->num_cpus =
@@ -247,8 +262,8 @@
                        if(collectors[i].collect(handle, node) == 0) {
                                xenstat_free_node(node);
                                return NULL;
-                        }
-                }
+                       }
+               }
        }
 
        return node;
@@ -289,6 +304,11 @@
        if (0 <= index && index < node->num_domains)
                return &(node->domains[index]);
        return NULL;
+}
+
+const char *xenstat_node_xen_ver(xenstat_node * node)
+{
+       return node->xen_version;
 }
 
 unsigned long long xenstat_node_tot_mem(xenstat_node * node)
@@ -505,7 +525,7 @@
                unsigned int domid;
                int ret = fscanf(handle->procnetdev,
                                 "vif%u.%u:%llu%llu%llu%llu%*u%*u%*u%*u"
-                                "%llu%llu%llu%llu%*u%*u%*u%*u",
+                                "%llu%llu%llu%llu%*u%*u%*u%*u\n",
                                 &domid, &net.id,
                                 &net.tbytes, &net.tpackets, &net.terrs,
                                 &net.tdrop,
diff -r 43d91cbb1bfb -r 6783e59e1c45 tools/xenstat/libxenstat/src/xenstat.h
--- a/tools/xenstat/libxenstat/src/xenstat.h    Mon Aug 22 23:07:37 2005
+++ b/tools/xenstat/libxenstat/src/xenstat.h    Tue Aug 23 18:25:51 2005
@@ -51,6 +51,8 @@
 /* Get the domain with the given index; used to loop over all domains. */
 xenstat_domain *xenstat_node_domain_by_index(xenstat_node * node,
                                             unsigned index);
+/* Get xen version of the node */
+const char *xenstat_node_xen_ver(xenstat_node * node);
 
 /* Get amount of total memory on a node */
 unsigned long long xenstat_node_tot_mem(xenstat_node * node);
diff -r 43d91cbb1bfb -r 6783e59e1c45 tools/xenstat/xentop/xentop.1
--- a/tools/xenstat/xentop/xentop.1     Mon Aug 22 23:07:37 2005
+++ b/tools/xenstat/xentop/xentop.1     Tue Aug 23 18:25:51 2005
@@ -40,7 +40,7 @@
 output version information and exit
 .TP
 \fB\-d\fR, \fB\-\-delay\fR=\fISECONDS\fR
-seconds between updates (default 1)
+seconds between updates (default 3)
 .TP
 \fB\-n\fR, \fB\-\-networks\fR
 output network information
diff -r 43d91cbb1bfb -r 6783e59e1c45 tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c     Mon Aug 22 23:07:37 2005
+++ b/tools/xenstat/xentop/xentop.c     Tue Aug 23 18:25:51 2005
@@ -151,7 +151,7 @@
 xenstat_node *cur_node = NULL;
 field_id sort_field = FIELD_DOMID;
 unsigned int first_domain_index = 0;
-unsigned int delay = 1;
+unsigned int delay = 3;
 int show_vcpus = 0;
 int show_networks = 0;
 int repeat_header = 0;
@@ -174,7 +174,7 @@
               "Displays ongoing information about xen vm resources \n\n"
               "-h, --help           display this help and exit\n"
               "-V, --version        output version information and exit\n"
-              "-d, --delay=SECONDS  seconds between updates (default 1)\n"
+              "-d, --delay=SECONDS  seconds between updates (default 3)\n"
               "-n, --networks       output vif network data\n"
               "-r, --repeat-header  repeat table header before each domain\n"
               "-v, --vcpus          output vcpu data\n"
@@ -254,7 +254,7 @@
 static void set_delay(char *value)
 {
        int new_delay;
-       new_delay = atoi(prompt_val);
+       new_delay = atoi(value);
        if(new_delay > 0)
                delay = new_delay;
 }

_______________________________________________
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®.