On 11/01/2010 10:35 AM, Daniel P. Berrange wrote:
On Fri, Oct 29, 2010 at 11:19:50AM -0600, Eric Blake wrote:
> diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
> index 974e96b..614c036 100644
> --- a/src/xen/xend_internal.c
> +++ b/src/xen/xend_internal.c
> @@ -5770,10 +5770,11 @@ xenDaemonFormatSxpr(virConnectPtr conn,
> virBufferVSprintf(&buf, "(memory %lu)(maxmem %lu)",
> def->mem.cur_balloon/1024, def->mem.max_balloon/1024);
> virBufferVSprintf(&buf, "(vcpus %u)", def->maxvcpus);
> - /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is 32. */
> - verify(MAX_VIRT_CPUS <= sizeof(1U) * CHAR_BIT);
> + /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
> + either 32, or 64 on a platform where long is big enough. */
> + verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
> if (def->vcpus < def->maxvcpus)
> - virBufferVSprintf(&buf, "(vcpu_avail %u)", (1U <<
def->vcpus) - 1);
> + virBufferVSprintf(&buf, "(vcpu_avail %lu)", (1UL <<
def->vcpus) - 1);
>
> if (def->cpumask) {
> char *ranges = virDomainCpuSetFormat(def->cpumask, def->cpumasklen);
This chunk causes a compile error for me
CC libvirt_driver_xen_la-xend_internal.lo
cc1: warnings being treated as errors
xen/xend_internal.c: In function 'xenDaemonFormatSxpr':
xen/xend_internal.c:5775: error: nested extern declaration of 'verify_function2'
[-Wnested-externs]
make[3]: *** [libvirt_driver_xen_la-xend_internal.lo] Error 1
Which version of gcc? This may be a bug in gnulib's verify module. I
tested successfully on F13, gcc 4.4.4.
Also, what was commited, looks different to this diff here
@@ -5770,9 +5770,11 @@ xenDaemonFormatSxpr(virConnectPtr conn,
virBufferVSprintf(&buf, "(memory %lu)(maxmem %lu)",
def->mem.cur_balloon/1024, def->mem.max_balloon/1024);
virBufferVSprintf(&buf, "(vcpus %u)", def->maxvcpus);
- /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is 32. */
+ /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
+ either 32, or 64 on a platform where long is big enough. */
+ verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
if (def->vcpus < def->maxvcpus)
- virBufferVSprintf(&buf, "(vcpu_avail %u)", (1U <<
def->vcpus) - 1);
+ virBufferVSprintf(&buf, "(vcpu_avail %lu)", (1UL <<
def->vcpus) - 1);
As Diego pointed out, the diff posted to this list was incomplete; it
was a partial patch that I had forgotten to squash in to my first
attempt. What I actually pushed was both patches squashed together; for
reference, here's what the first patch was:
From b67847f84d9d4e8dbad5200df247212bc14221ab Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake(a)redhat.com>
Date: Fri, 29 Oct 2010 10:51:01 -0600
Subject: [PATCH] xen: verify code assumption about MAX_VIRT_CPUS
* src/xen/xend_internal.c (xenDaemonFormatSxpr): Detect if
upstream xen ever changes to support 64 vcpus.
* src/xen/xm_internal.c (xenXMDomainConfigFormat): Likewise.
---
src/xen/xend_internal.c | 1 +
src/xen/xm_internal.c | 2 ++
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index e96b762..974e96b 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -5771,6 +5771,7 @@ xenDaemonFormatSxpr(virConnectPtr conn,
def->mem.cur_balloon/1024,
def->mem.max_balloon/1024);
virBufferVSprintf(&buf, "(vcpus %u)", def->maxvcpus);
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
32. */
+ verify(MAX_VIRT_CPUS <= sizeof(1U) * CHAR_BIT);
if (def->vcpus < def->maxvcpus)
virBufferVSprintf(&buf, "(vcpu_avail %u)", (1U <<
def->vcpus) - 1);
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 430d40b..f80e252 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -2336,6 +2336,8 @@ virConfPtr xenXMDomainConfigFormat(virConnectPtr conn,
if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0)
goto no_memory;
+ /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
32. */
+ verify(MAX_VIRT_CPUS <= sizeof(1U) * CHAR_BIT);
if (def->vcpus < def->maxvcpus &&
xenXMConfigSetInt(conf, "vcpu_avail", (1U << def->vcpus) - 1)
< 0)
goto no_memory;
--
1.7.2.3
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org