Lines Matching refs:node

38 typedef int (*xenstat_collect_func)(xenstat_node * node);
42 typedef void (*xenstat_free_func)(xenstat_node * node);
55 static int xenstat_collect_vcpus(xenstat_node * node);
56 static int xenstat_collect_xen_version(xenstat_node * node);
57 static void xenstat_free_vcpus(xenstat_node * node);
58 static void xenstat_free_networks(xenstat_node * node);
59 static void xenstat_free_xen_version(xenstat_node * node);
60 static void xenstat_free_vbds(xenstat_node * node);
64 static void xenstat_prune_domain(xenstat_node *node, unsigned int entry);
137 xenstat_node *node; in xenstat_get_node() local
144 node = (xenstat_node *) calloc(1, sizeof(xenstat_node)); in xenstat_get_node()
145 if (node == NULL) in xenstat_get_node()
149 node->handle = handle; in xenstat_get_node()
153 free(node); in xenstat_get_node()
158 node->cpu_hz = ((unsigned long long)physinfo.cpu_khz) * 1000ULL; in xenstat_get_node()
159 node->num_cpus = physinfo.nr_cpus; in xenstat_get_node()
160 node->tot_mem = ((unsigned long long)physinfo.total_pages) in xenstat_get_node()
162 node->free_mem = ((unsigned long long)physinfo.free_pages) in xenstat_get_node()
165 node->freeable_mb = 0; in xenstat_get_node()
168 node->domains = malloc(sizeof(xenstat_domain)); in xenstat_get_node()
169 if (node->domains == NULL) { in xenstat_get_node()
170 free(node); in xenstat_get_node()
174 node->num_domains = 0; in xenstat_get_node()
179 node->num_domains, in xenstat_get_node()
185 tmp = realloc(node->domains, in xenstat_get_node()
186 (node->num_domains + new_domains) in xenstat_get_node()
191 node->domains = tmp; in xenstat_get_node()
193 domain = node->domains + node->num_domains; in xenstat_get_node()
206 xenstat_free_node(node); in xenstat_get_node()
235 node->num_domains++; in xenstat_get_node()
241 node->flags = 0; in xenstat_get_node()
244 node->flags |= collectors[i].flag; in xenstat_get_node()
245 if(collectors[i].collect(node) == 0) { in xenstat_get_node()
246 xenstat_free_node(node); in xenstat_get_node()
252 return node; in xenstat_get_node()
254 free(node->domains); in xenstat_get_node()
255 free(node); in xenstat_get_node()
259 void xenstat_free_node(xenstat_node * node) in xenstat_free_node() argument
263 if (node) { in xenstat_free_node()
264 if (node->domains) { in xenstat_free_node()
265 for (i = 0; i < node->num_domains; i++) in xenstat_free_node()
266 free(node->domains[i].name); in xenstat_free_node()
269 if((node->flags & collectors[i].flag) in xenstat_free_node()
271 collectors[i].free(node); in xenstat_free_node()
272 free(node->domains); in xenstat_free_node()
274 free(node); in xenstat_free_node()
278 xenstat_domain *xenstat_node_domain(xenstat_node * node, unsigned int domid) in xenstat_node_domain() argument
284 for (i = 0; i < node->num_domains; i++) { in xenstat_node_domain()
285 if (node->domains[i].id == domid) in xenstat_node_domain()
286 return &(node->domains[i]); in xenstat_node_domain()
291 xenstat_domain *xenstat_node_domain_by_index(xenstat_node * node, in xenstat_node_domain_by_index() argument
294 if (index < node->num_domains) in xenstat_node_domain_by_index()
295 return &(node->domains[index]); in xenstat_node_domain_by_index()
299 const char *xenstat_node_xen_version(xenstat_node * node) in xenstat_node_xen_version() argument
301 return node->handle->xen_version; in xenstat_node_xen_version()
304 unsigned long long xenstat_node_tot_mem(xenstat_node * node) in xenstat_node_tot_mem() argument
306 return node->tot_mem; in xenstat_node_tot_mem()
309 unsigned long long xenstat_node_free_mem(xenstat_node * node) in xenstat_node_free_mem() argument
311 return node->free_mem; in xenstat_node_free_mem()
314 long xenstat_node_freeable_mb(xenstat_node * node) in xenstat_node_freeable_mb() argument
316 return node->freeable_mb; in xenstat_node_freeable_mb()
319 unsigned int xenstat_node_num_domains(xenstat_node * node) in xenstat_node_num_domains() argument
321 return node->num_domains; in xenstat_node_num_domains()
324 unsigned int xenstat_node_num_cpus(xenstat_node * node) in xenstat_node_num_cpus() argument
326 return node->num_cpus; in xenstat_node_num_cpus()
330 unsigned long long xenstat_node_cpu_hz(xenstat_node * node) in xenstat_node_cpu_hz() argument
332 return node->cpu_hz; in xenstat_node_cpu_hz()
453 static int xenstat_collect_vcpus(xenstat_node * node) in xenstat_collect_vcpus() argument
458 for (i = 0; i < node->num_domains; i+=inc_index) { in xenstat_collect_vcpus()
461 node->domains[i].vcpus = malloc(node->domains[i].num_vcpus in xenstat_collect_vcpus()
463 if (node->domains[i].vcpus == NULL) in xenstat_collect_vcpus()
466 for (vcpu = 0; vcpu < node->domains[i].num_vcpus; vcpu++) { in xenstat_collect_vcpus()
470 if (xc_vcpu_getinfo(node->handle->xc_handle, in xenstat_collect_vcpus()
471 node->domains[i].id, vcpu, &info) != 0) { in xenstat_collect_vcpus()
479 xenstat_prune_domain(node, i); in xenstat_collect_vcpus()
487 node->domains[i].vcpus[vcpu].online = info.online; in xenstat_collect_vcpus()
488 node->domains[i].vcpus[vcpu].ns = info.cpu_time; in xenstat_collect_vcpus()
496 static void xenstat_free_vcpus(xenstat_node * node) in xenstat_free_vcpus() argument
499 for (i = 0; i < node->num_domains; i++) in xenstat_free_vcpus()
500 free(node->domains[i].vcpus); in xenstat_free_vcpus()
525 static void xenstat_free_networks(xenstat_node * node) in xenstat_free_networks() argument
528 for (i = 0; i < node->num_domains; i++) in xenstat_free_networks()
529 free(node->domains[i].networks); in xenstat_free_networks()
591 static int xenstat_collect_xen_version(xenstat_node * node) in xenstat_collect_xen_version() argument
597 if (node->handle->xen_version[0] == '\0') { in xenstat_collect_xen_version()
599 vnum = xc_version(node->handle->xc_handle, in xenstat_collect_xen_version()
605 if (xc_version(node->handle->xc_handle, XENVER_extraversion, in xenstat_collect_xen_version()
609 snprintf(node->handle->xen_version, VERSION_SIZE, "%ld.%ld%s", in xenstat_collect_xen_version()
617 static void xenstat_free_xen_version(xenstat_node * node) in xenstat_free_xen_version() argument
652 static void xenstat_free_vbds(xenstat_node * node) in xenstat_free_vbds() argument
655 for (i = 0; i < node->num_domains; i++) in xenstat_free_vbds()
656 free(node->domains[i].vbds); in xenstat_free_vbds()
717 static void xenstat_prune_domain(xenstat_node *node, unsigned int entry) in xenstat_prune_domain() argument
720 if (node->num_domains == 0 || entry >= node->num_domains) in xenstat_prune_domain()
724 node->num_domains--; in xenstat_prune_domain()
727 if (entry < node->num_domains) { in xenstat_prune_domain()
728 xenstat_domain *domain = &node->domains[entry]; in xenstat_prune_domain()
729 memmove(domain,domain+1,(node->num_domains - entry) * sizeof(xenstat_domain) ); in xenstat_prune_domain()
734 memset(&node->domains[node->num_domains], 0, sizeof(xenstat_domain)); in xenstat_prune_domain()