[Libvir] PATCH: Compatability with Xen 3.2.0
Daniel P. Berrange
berrange at redhat.com
Mon Dec 17 19:19:04 UTC 2007
In Xen 3.2.0 the physinfo hypercall was changed to remove the field
'sockets_per_node' and add in 'nr_cpus'. We use the sockets_per_node field
in livirt for the virNodeInfo struct :-( This patch re-calculates its
value in terms of 'nr_cpus / (nodes*cores*threads)' which is how older
Xen used to figure it out.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
-------------- next part --------------
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.157
diff -u -p -r1.157 xend_internal.c
--- src/xend_internal.c 5 Dec 2007 18:28:05 -0000 1.157
+++ src/xend_internal.c 17 Dec 2007 19:16:32 -0000
@@ -1893,11 +1893,11 @@ sexpr_to_xend_node_info(struct sexpr *ro
return (-1);
machine = sexpr_node(root, "node/machine");
- if (machine == NULL)
+ if (machine == NULL) {
info->model[0] = 0;
- else {
+ } else {
snprintf(&info->model[0], sizeof(info->model) - 1, "%s", machine);
- info->model[sizeof(info->model) - 1] = 0;
+ info->model[sizeof(info->model) - 1] = 0;
}
info->memory = (unsigned long) sexpr_u64(root, "node/total_memory") << 10;
@@ -1905,6 +1905,20 @@ sexpr_to_xend_node_info(struct sexpr *ro
info->mhz = sexpr_int(root, "node/cpu_mhz");
info->nodes = sexpr_int(root, "node/nr_nodes");
info->sockets = sexpr_int(root, "node/sockets_per_node");
+ /* Xen 3.2.0 replaces sockets_per_node with 'nr_cpus'.
+ * Old Xen calculated sockets_per_node using its internal
+ * nr_cpus / (nodes*cores*threads), so fake it ourselves
+ * in the same way
+ */
+ if (info->sockets == 0) {
+ int nr_cpus = sexpr_int(root, "node/nr_cpus");
+ info->sockets = nr_cpus / (info->nodes * info->cores * info->threads);
+ /* Should already be fine, but for sanity make
+ * sure we have at least one socket
+ */
+ if (info->sockets == 0)
+ info->sockets = 1;
+ }
info->cores = sexpr_int(root, "node/cores_per_socket");
info->threads = sexpr_int(root, "node/threads_per_core");
return (0);
More information about the libvir-list
mailing list