The 2.x series of numactl releases changed the ABI/API for certain
libnuma.so functions we use. Fortunately it turns out that they provide
back-compatability of both ABI and API with a combo of linker script
magic, and header file inline compat functions. So, all we need todo
is #define NUMA_VERSION1_COMPATIBILITY before include numa.h in our
code.
This new code did, however, expose a bug in our use of the existing
API. We were calculating size in bytes, instead of size in longs, so
were passing a buffer that was 8 times to large. Harmless, but the
new libnuma validates that the buffer is expected size. So this patch
also fixes us to pass & allocate correct buffer size.
Finally, also add a missing BuildRequire on numactl-devel, and fixes
the libvirtd automake build dependancy
Daniel
Index: libvirt.spec.in
===================================================================
RCS file: /data/cvs/libvirt/libvirt.spec.in,v
retrieving revision 1.103
diff -u -p -r1.103 libvirt.spec.in
--- libvirt.spec.in 26 Nov 2008 14:46:49 -0000 1.103
+++ libvirt.spec.in 27 Nov 2008 13:20:24 -0000
@@ -124,6 +124,8 @@ BuildRequires: lvm2
BuildRequires: iscsi-initiator-utils
# For disk driver
BuildRequires: parted-devel
+# For QEMU/LXC numa info
+BuildRequires: numactl-devel
Obsoletes: libvir
# Fedora build root suckage
Index: qemud/Makefile.am
===================================================================
RCS file: /data/cvs/libvirt/qemud/Makefile.am,v
retrieving revision 1.61
diff -u -p -r1.61 Makefile.am
--- qemud/Makefile.am 21 Nov 2008 12:27:11 -0000 1.61
+++ qemud/Makefile.am 27 Nov 2008 13:20:24 -0000
@@ -87,7 +87,6 @@ libvirtd_LDFLAGS = \
$(COVERAGE_LDFLAGS) \
$(POLKIT_LIBS)
-libvirtd_DEPENDENCIES = ../src/libvirt.la
libvirtd_LDADD = \
../gnulib/lib/libgnu.la
@@ -129,6 +128,9 @@ libvirtd_CFLAGS += $(AVAHI_CFLAGS)
libvirtd_LDADD += $(AVAHI_LIBS)
endif
+libvirtd_DEPENDENCIES = $(libvirtd_LDADD)
+
+
default_xml_dest = libvirt/qemu/networks/default.xml
install-data-local: install-init install-data-sasl install-data-polkit
mkdir -p $(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/autostart
Index: src/qemu_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_conf.c,v
retrieving revision 1.108
diff -u -p -r1.108 qemu_conf.c
--- src/qemu_conf.c 19 Nov 2008 16:58:23 -0000 1.108
+++ src/qemu_conf.c 27 Nov 2008 13:20:24 -0000
@@ -37,6 +37,7 @@
#include <sys/utsname.h>
#if HAVE_NUMACTL
+#define NUMA_VERSION1_COMPATIBILITY 1
#include <numa.h>
#endif
@@ -300,11 +301,11 @@ qemudCapsInitGuest(virCapsPtr caps,
#if HAVE_NUMACTL
#define MAX_CPUS 4096
#define MAX_CPUS_MASK_SIZE (sizeof(unsigned long))
-#define MAX_CPUS_MASK_LEN (MAX_CPUS / MAX_CPUS_MASK_SIZE)
-#define MAX_CPUS_MASK_BYTES (MAX_CPUS / 8)
+#define MAX_CPUS_MASK_BITS (MAX_CPUS_MASK_SIZE * 8)
+#define MAX_CPUS_MASK_LEN (MAX_CPUS / (MAX_CPUS_MASK_BITS))
#define MASK_CPU_ISSET(mask, cpu) \
- (((mask)[((cpu) / MAX_CPUS_MASK_SIZE)] >> ((cpu) % MAX_CPUS_MASK_SIZE)) &
1)
+ (((mask)[((cpu) / MAX_CPUS_MASK_BITS)] >> ((cpu) % MAX_CPUS_MASK_BITS)) &
1)
static int
qemudCapsInitNUMA(virCapsPtr caps)
@@ -322,7 +323,8 @@ qemudCapsInitNUMA(virCapsPtr caps)
goto cleanup;
for (n = 0 ; n <= numa_max_node() ; n++) {
- if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_BYTES) < 0)
+
+ if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_LEN) < 0)
goto cleanup;
for (ncpus = 0, i = 0 ; i < MAX_CPUS ; i++)
Index: src/qemu_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_driver.c,v
retrieving revision 1.160
diff -u -p -r1.160 qemu_driver.c
--- src/qemu_driver.c 21 Nov 2008 12:16:08 -0000 1.160
+++ src/qemu_driver.c 27 Nov 2008 13:20:25 -0000
@@ -45,6 +45,7 @@
#include <sys/ioctl.h>
#if HAVE_NUMACTL
+#define NUMA_VERSION1_COMPATIBILITY 1
#include <numa.h>
#endif
Index: src/uml_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/uml_conf.c,v
retrieving revision 1.1
diff -u -p -r1.1 uml_conf.c
--- src/uml_conf.c 19 Nov 2008 16:58:23 -0000 1.1
+++ src/uml_conf.c 27 Nov 2008 13:20:25 -0000
@@ -37,6 +37,7 @@
#include <sys/utsname.h>
#if HAVE_NUMACTL
+#define NUMA_VERSION1_COMPATIBILITY 1
#include <numa.h>
#endif
@@ -56,11 +57,11 @@
#if HAVE_NUMACTL
#define MAX_CPUS 4096
#define MAX_CPUS_MASK_SIZE (sizeof(unsigned long))
-#define MAX_CPUS_MASK_LEN (MAX_CPUS / MAX_CPUS_MASK_SIZE)
-#define MAX_CPUS_MASK_BYTES (MAX_CPUS / 8)
+#define MAX_CPUS_MASK_BITS (MAX_CPUS_MASK_SIZE * 8)
+#define MAX_CPUS_MASK_LEN (MAX_CPUS / (MAX_CPUS_MASK_BITS))
#define MASK_CPU_ISSET(mask, cpu) \
- (((mask)[((cpu) / MAX_CPUS_MASK_SIZE)] >> ((cpu) % MAX_CPUS_MASK_SIZE)) &
1)
+ (((mask)[((cpu) / MAX_CPUS_MASK_BITS)] >> ((cpu) % MAX_CPUS_MASK_BITS)) &
1)
static int
umlCapsInitNUMA(virCapsPtr caps)
@@ -78,7 +79,8 @@ umlCapsInitNUMA(virCapsPtr caps)
goto cleanup;
for (n = 0 ; n <= numa_max_node() ; n++) {
- if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_BYTES) < 0)
+
+ if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_LEN) < 0)
goto cleanup;
for (ncpus = 0, i = 0 ; i < MAX_CPUS ; i++)
Index: src/uml_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/uml_driver.c,v
retrieving revision 1.2
diff -u -p -r1.2 uml_driver.c
--- src/uml_driver.c 21 Nov 2008 10:06:28 -0000 1.2
+++ src/uml_driver.c 27 Nov 2008 13:20:25 -0000
@@ -46,6 +46,7 @@
#include <sys/inotify.h>
#if HAVE_NUMACTL
+#define NUMA_VERSION1_COMPATIBILITY 1
#include <numa.h>
#endif
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|