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_domain {
56 	unsigned int id;
57 	char *name;
58 	unsigned int state;
59 	unsigned long long cpu_ns;
60 	unsigned int num_vcpus;		/* No. vcpus configured for domain */
61 	xenstat_vcpu *vcpus;		/* Array of length num_vcpus */
62 	unsigned long long cur_mem;	/* Current memory reservation */
63 	unsigned long long max_mem;	/* Total memory allowed */
64 	unsigned int ssid;
65 	unsigned int num_networks;
66 	xenstat_network *networks;	/* Array of length num_networks */
67 	unsigned int num_vbds;
68 	xenstat_vbd *vbds;
69 };
70 
71 struct xenstat_vcpu {
72 	unsigned int online;
73 	unsigned long long ns;
74 };
75 
76 struct xenstat_network {
77 	unsigned int id;
78 	/* Received */
79 	unsigned long long rbytes;
80 	unsigned long long rpackets;
81 	unsigned long long rerrs;
82 	unsigned long long rdrop;
83 	/* Transmitted */
84 	unsigned long long tbytes;
85 	unsigned long long tpackets;
86 	unsigned long long terrs;
87 	unsigned long long tdrop;
88 };
89 
90 struct xenstat_vbd {
91 	unsigned int back_type;
92 	unsigned int dev;
93 	unsigned int error;
94 	unsigned long long oo_reqs;
95 	unsigned long long rd_reqs;
96 	unsigned long long wr_reqs;
97 	unsigned long long rd_sects;
98 	unsigned long long wr_sects;
99 };
100 
101 extern int xenstat_collect_networks(xenstat_node * node);
102 extern void xenstat_uninit_networks(xenstat_handle * handle);
103 extern int xenstat_collect_vbds(xenstat_node * node);
104 extern void xenstat_uninit_vbds(xenstat_handle * handle);
105 extern void read_attributes_qdisk(xenstat_node * node);
106 extern xenstat_vbd *xenstat_save_vbd(xenstat_domain * domain, xenstat_vbd * vbd);
107 
108 #endif /* XENSTAT_PRIV_H */
109