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

[Xen-changelog] Fix perfc array range on reset.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 7af8039b3c571af038277ab6d7d288d1f2a7acf6
# Parent  24dbb153ab391f9860f05b9044ed18945a0e89fc
Fix perfc array range on reset.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

diff -r 24dbb153ab39 -r 7af8039b3c57 xen/common/perfc.c
--- a/xen/common/perfc.c        Tue May 02 15:12:06 2006 +0100
+++ b/xen/common/perfc.c        Tue May 02 15:21:19 2006 +0100
@@ -116,7 +116,7 @@ void perfc_reset(unsigned char key)
             counters += NR_CPUS;
             break;
         case TYPE_ARRAY:
-            for ( j = 0; j < NR_CPUS; j++ )
+            for ( j = 0; j < perfc_info[i].nr_elements; j++ )
                 atomic_set(&counters[j],0);
         case TYPE_S_ARRAY:
             counters += perfc_info[i].nr_elements;
diff -r 24dbb153ab39 -r 7af8039b3c57 
tools/xenstat/libxenstat/src/xen-interface.c
--- a/tools/xenstat/libxenstat/src/xen-interface.c      Tue May 02 15:12:06 
2006 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,201 +0,0 @@
-/* xen-interface.c
- *
- * Copyright (C) International Business Machines Corp., 2005
- * Authors: Josh Triplett <josht@xxxxxxxxxx>
- *          Judy Fischbach <jfisch@xxxxxxxxxx>
- *
- * 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.
- */
-
-#include "xen-interface.h"
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <xen/linux/privcmd.h>
-
-struct xi_handle {
-       int fd;
-};
-
-/* Initialize for xen-interface.  Returns a handle to be used with subsequent
- * calls to the xen-interface functions or NULL if an error occurs. */
-xi_handle *xi_init(void)
-{
-       xi_handle *handle;
-
-       handle = (xi_handle *)calloc(1, sizeof(xi_handle));
-       if (handle == NULL)
-               return NULL;
-
-       handle->fd = open("/proc/xen/privcmd", O_RDWR);
-       if (handle->fd < 0) {
-               perror("Couldn't open /proc/xen/privcmd");
-               free(handle);
-               return NULL;
-       }
-
-       return handle;
-}
-
-/* Release the handle to libxc, free resources, etc. */
-void xi_uninit(xi_handle *handle)
-{
-       close (handle->fd);
-       free (handle);
-}
-
-/* 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;
-       int ret = 0;
-
-       if (mlock(&privcmd, sizeof(privcmd)) < 0) {
-               perror("Failed to mlock privcmd structure");
-               return -1;
-       }
-
-       if (mlock(ver, sizeof(*ver)) < 0) {
-               perror("Failed to mlock extraversion structure");
-               munlock(&privcmd, sizeof(privcmd));
-               return -1;
-       }
-
-       privcmd.op = __HYPERVISOR_xen_version;
-       privcmd.arg[0] = (unsigned long)XENVER_version;
-       privcmd.arg[1] = 0;
-
-       *vnum = ioctl(handle->fd, IOCTL_PRIVCMD_HYPERCALL, &privcmd);
-       if (*vnum < 0) {
-               perror("Hypercall failed");
-               ret = -1;
-       }
-
-       privcmd.op = __HYPERVISOR_xen_version;
-       privcmd.arg[0] = (unsigned long)XENVER_extraversion;
-       privcmd.arg[1] = (unsigned long)ver;
-
-       if (ioctl(handle->fd, IOCTL_PRIVCMD_HYPERCALL, &privcmd) < 0) {
-               perror("Hypercall failed");
-               ret = -1;
-       }
-
-       munlock(&privcmd, sizeof(privcmd));
-       munlock(ver, sizeof(*ver));
-
-       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;
-}
-
-/* Obtain domain data from dom0 */
-int xi_get_physinfo(xi_handle *handle, dom0_physinfo_t *physinfo)
-{
-       dom0_op_t op;
-
-       if (xi_make_dom0_op(handle, &op, DOM0_PHYSINFO) < 0) {
-               perror("DOM0_PHYSINFO Hypercall failed");
-               return -1;
-       }
-
-       *physinfo = op.u.physinfo;
-       return 0;
-}
-
-/* Obtain domain data from dom0 */
-int xi_get_domaininfolist(xi_handle *handle, dom0_getdomaininfo_t *info,
-                          unsigned int first_domain, unsigned int max_domains)
-{
-       dom0_op_t op;
-       op.u.getdomaininfolist.first_domain = first_domain;
-       op.u.getdomaininfolist.max_domains = max_domains;
-       set_xen_guest_handle(op.u.getdomaininfolist.buffer, info);
-
-       if (mlock( info, max_domains * sizeof(dom0_getdomaininfo_t)) < 0) {
-               perror("Failed to mlock domaininfo array");
-               return -1;
-       }
-
-       if (xi_make_dom0_op(handle, &op, DOM0_GETDOMAININFOLIST) < 0) {
-               perror("DOM0_GETDOMAININFOLIST Hypercall failed");
-               return -1;
-       }
-
-       return op.u.getdomaininfolist.num_domains;
-}
-
-/* Get vcpu info from a domain */
-int xi_get_domain_vcpu_info(xi_handle *handle, unsigned int domain, 
-                            unsigned int vcpu, dom0_getvcpuinfo_t *info)
-{
-       dom0_op_t op;
-       op.u.getvcpuinfo.domain = domain;
-       op.u.getvcpuinfo.vcpu   = vcpu;
-
-       if (xi_make_dom0_op(handle, &op, DOM0_GETVCPUINFO) < 0) {
-               perror("DOM0_GETVCPUINFO Hypercall failed");
-               return -1;
-       }
-
-       memcpy(info, &op.u.getvcpuinfo, sizeof(dom0_getvcpuinfo_t));
-
-       return 0;
-}
-
-/* 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 24dbb153ab39 -r 7af8039b3c57 
tools/xenstat/libxenstat/src/xen-interface.h
--- a/tools/xenstat/libxenstat/src/xen-interface.h      Tue May 02 15:12:06 
2006 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/* xen-interface.h
- *
- * Copyright (C) International Business Machines Corp., 2005
- * Authors: Josh Triplett <josht@xxxxxxxxxx>
- *          Judy Fischbach <jfisch@xxxxxxxxxx>
- *
- * 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.
- */
-
-#include <stdint.h>
-#include <xen/xen.h>
-#include <xen/dom0_ops.h>
-#include <xen/sched.h>
-#include <xen/version.h>
-
-/* Opaque handles */
-typedef struct xi_handle xi_handle;
-
-/* Initialize for xen-interface.  Returns a handle to be used with subsequent
- * calls to the xen-interface functions or NULL if an error occurs. */
-xi_handle *xi_init(void);
-
-/* 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 *);
-
-/* Obtain domain data from dom0 */
-int xi_get_domaininfolist(xi_handle *, dom0_getdomaininfo_t *, unsigned int,
-                          unsigned int);
-
-/* Get vcpu info from a domain */
-int xi_get_domain_vcpu_info(xi_handle *, unsigned int, unsigned int,
-                            dom0_getvcpuinfo_t *);

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