1 /* libxenstat: statistics-collection library for Xen
2  * Copyright (C) International Business Machines Corp., 2005
3  * Authors: Josh Triplett <josh@kernel.org>
4  *          Judy Fischbach <jfisch@cs.pdx.edu>
5  *          David Hendricks <cro_marmot@comcast.net>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  */
17 
18 /*
19  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
20  * Use is subject to license terms.
21  */
22 
23 #ifndef XENSTAT_PRIV_H
24 #define XENSTAT_PRIV_H
25 
26 #include <sys/types.h>
27 #include <xenstore.h>
28 #include "xenstat.h"
29 
30 #include "xenctrl.h"
31 
32 #define SHORT_ASC_LEN 5                 /* length of 65535 */
33 #define VERSION_SIZE (2 * SHORT_ASC_LEN + 1 + sizeof(xen_extraversion_t) + 1)
34 
35 struct xenstat_handle {
36 	xc_interface *xc_handle;
37 	struct xs_handle *xshandle; /* xenstore handle */
38 	int page_size;
39 	void *priv;
40 	char xen_version[VERSION_SIZE]; /* xen version running on this node */
41 };
42 
43 struct xenstat_node {
44 	xenstat_handle *handle;
45 	unsigned int flags;
46 	unsigned long long cpu_hz;
47 	unsigned int num_cpus;
48 	unsigned long long tot_mem;
49 	unsigned long long free_mem;
50 	unsigned int num_domains;
51 	xenstat_domain *domains;	/* Array of length num_domains */
52 	long freeable_mb;
53 };
54 
55 struct xenstat_tmem {
56 	unsigned long long curr_eph_pages;
57 	unsigned long long succ_eph_gets;
58 	unsigned long long succ_pers_puts;
59 	unsigned long long succ_pers_gets;
60 };
61 
62 struct xenstat_domain {
63 	unsigned int id;
64 	char *name;
65 	unsigned int state;
66 	unsigned long long cpu_ns;
67 	unsigned int num_vcpus;		/* No. vcpus configured for domain */
68 	xenstat_vcpu *vcpus;		/* Array of length num_vcpus */
69 	unsigned long long cur_mem;	/* Current memory reservation */
70 	unsigned long long max_mem;	/* Total memory allowed */
71 	unsigned int ssid;
72 	unsigned int num_networks;
73 	xenstat_network *networks;	/* Array of length num_networks */
74 	unsigned int num_vbds;
75 	xenstat_vbd *vbds;
76 	xenstat_tmem tmem_stats;
77 };
78 
79 struct xenstat_vcpu {
80 	unsigned int online;
81 	unsigned long long ns;
82 };
83 
84 struct xenstat_network {
85 	unsigned int id;
86 	/* Received */
87 	unsigned long long rbytes;
88 	unsigned long long rpackets;
89 	unsigned long long rerrs;
90 	unsigned long long rdrop;
91 	/* Transmitted */
92 	unsigned long long tbytes;
93 	unsigned long long tpackets;
94 	unsigned long long terrs;
95 	unsigned long long tdrop;
96 };
97 
98 struct xenstat_vbd {
99 	unsigned int back_type;
100 	unsigned int dev;
101 	unsigned long long oo_reqs;
102 	unsigned long long rd_reqs;
103 	unsigned long long wr_reqs;
104 	unsigned long long rd_sects;
105 	unsigned long long wr_sects;
106 };
107 
108 extern int xenstat_collect_networks(xenstat_node * node);
109 extern void xenstat_uninit_networks(xenstat_handle * handle);
110 extern int xenstat_collect_vbds(xenstat_node * node);
111 extern void xenstat_uninit_vbds(xenstat_handle * handle);
112 extern void read_attributes_qdisk(xenstat_node * node);
113 extern xenstat_vbd *xenstat_save_vbd(xenstat_domain * domain, xenstat_vbd * vbd);
114 
115 #endif /* XENSTAT_PRIV_H */
116