Skip to contentSkip to conversation

libxl: Correctly initialize vcpu bitmap

PATCH In review Stefan Bader 3 participants 6 messages Jul 22, 2013 – Jul 24, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: Correctly initialize vcpu bitmap

This fixes the basic setup but there is likely more to do if things like manual CPU hirarchy (nodes, cores, threads) to be working.

Cross-posting to xen-devel to make sure I am doing things correctly.

-Stefan

Quoted 1 line

From 1ec5e7ea0d3498b9f61b83e8aed87cc3cae106de Mon Sep 17 00:00:00 2001

From: Stefan Bader <[email protected]>
Date: Fri, 19 Jul 2013 15:20:00 +0200
Subject: [PATCH] libxl: Correctly initialize vcpu bitmap

The avai_vcpu bitmap has to be allocated before it can be used (using the maximum allowed value for that). Then for each available VCPU the bit in the mask has to be set (libxl_bitmap_set takes a bit position as an argument, not the number of bits to set).

Without this, I would always only get one VCPU for guests created through libvirt/libxl.

---
 src/libxl/libxl_conf.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
src/libxl/libxl_conf.c +11 -3
index 4a0fba9..7592dd2 100644
@@ -331,7 +331,8 @@ error:
 }
 
 static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver, virDomainDefPtr def,
+                      libxl_domain_config *d_config)
 {
     libxl_domain_build_info *b_info = &d_config->b_info;
     int hvm = STREQ(def->os.type, "hvm");
@@ -343,8 +344,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
     else
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+
     b_info->max_vcpus = def->maxvcpus;
-    libxl_bitmap_set((&b_info->avail_vcpus), def->vcpus);
+    if (libxl_cpu_bitmap_alloc(driver->ctx, &b_info->avail_vcpus,
+                               def->maxvcpus))
+        goto error;
+    libxl_bitmap_set_none(&b_info->avail_vcpus);
+    for (i = 0; i < def->vcpus; i++)
+        libxl_bitmap_set((&b_info->avail_vcpus), i);
+
     if (def->clock.ntimers > 0 &&
         def->clock.timers[0]->name == VIR_DOMAIN_TIMER_NAME_TSC) {
         switch (def->clock.timers[0]->mode) {
@@ -802,7 +810,7 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
     if (libxlMakeDomCreateInfo(driver, def, &d_config->c_info) < 0)
         return -1;
 
-    if (libxlMakeDomBuildInfo(def, d_config) < 0) {
+    if (libxlMakeDomBuildInfo(driver, def, d_config) < 0) {
         return -1;
     }
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 8 lines · Stefan Bader

This fixes the basic setup but there is likely more to do if things like manual CPU hirarchy (nodes, cores, threads) to be working.

Cross-posting to xen-devel to make sure I am doing things correctly.

-Stefan

Quoted 6 lines
Quoted 1 line

From 1ec5e7ea0d3498b9f61b83e8aed87cc3cae106de Mon Sep 17 00:00:00 2001

From: Stefan Bader <[email protected]>
Date: Fri, 19 Jul 2013 15:20:00 +0200
Subject: [PATCH] libxl: Correctly initialize vcpu bitmap

The avai_vcpu bitmap has to be allocated before it can be used (using

avail_vcpu ?

Quoted 8 lines

the maximum allowed value for that). Then for each available VCPU the bit in the mask has to be set (libxl_bitmap_set takes a bit position as an argument, not the number of bits to set).

Without this, I would always only get one VCPU for guests created through libvirt/libxl.

The libxl calling logic looks Ok to me. So from the libxl perspective you can tack on Reviewed-by: Konrad Rzeszutek Wilk <[email protected]>

Quoted 52 lines
---
 src/libxl/libxl_conf.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
src/libxl/libxl_conf.c +11 -3
index 4a0fba9..7592dd2 100644
@@ -331,7 +331,8 @@ error:
 }
 
 static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver, virDomainDefPtr def,
+                      libxl_domain_config *d_config)
 {
     libxl_domain_build_info *b_info = &d_config->b_info;
     int hvm = STREQ(def->os.type, "hvm");
@@ -343,8 +344,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
     else
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+
     b_info->max_vcpus = def->maxvcpus;
-    libxl_bitmap_set((&b_info->avail_vcpus), def->vcpus);
+    if (libxl_cpu_bitmap_alloc(driver->ctx, &b_info->avail_vcpus,
+                               def->maxvcpus))
+        goto error;
+    libxl_bitmap_set_none(&b_info->avail_vcpus);
+    for (i = 0; i < def->vcpus; i++)
+        libxl_bitmap_set((&b_info->avail_vcpus), i);
+
     if (def->clock.ntimers > 0 &&
         def->clock.timers[0]->name == VIR_DOMAIN_TIMER_NAME_TSC) {
         switch (def->clock.timers[0]->mode) {
@@ -802,7 +810,7 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
     if (libxlMakeDomCreateInfo(driver, def, &d_config->c_info) < 0)
         return -1;
 
-    if (libxlMakeDomBuildInfo(def, d_config) < 0) {
+    if (libxlMakeDomBuildInfo(driver, def, d_config) < 0) {
         return -1;
     }
 
Signature · 7 lines
1.7.9.5


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw
Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 8 lines · Stefan Bader

This fixes the basic setup but there is likely more to do if things like manual CPU hirarchy (nodes, cores, threads) to be working.

Cross-posting to xen-devel to make sure I am doing things correctly.

-Stefan

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

From 1ec5e7ea0d3498b9f61b83e8aed87cc3cae106de Mon Sep 17 00:00:00 2001

From: Stefan Bader <[email protected]>
Date: Fri, 19 Jul 2013 15:20:00 +0200
Subject: [PATCH] libxl: Correctly initialize vcpu bitmap

The avai_vcpu bitmap has to be allocated before it can be used (using

avail_vcpu ?

*sigh* Yeah, of course I cannot spell. :-P

Quoted 5 lines
Quoted 5 lines

the maximum allowed value for that). Then for each available VCPU the bit in the mask has to be set (libxl_bitmap_set takes a bit position as an argument, not the number of bits to set).

Quoted 7 lines
Quoted 4 lines

Without this, I would always only get one VCPU for guests created through libvirt/libxl.

The libxl calling logic looks Ok to me. So from the libxl perspective you can tack on Reviewed-by: Konrad Rzeszutek Wilk <[email protected]>

Thanks, I will leave that (as well as the complimentary fixing of missing lletters to the libvirt maintainers. :)

-Stefan

Quoted 53 lines
Quoted 53 lines
---
 src/libxl/libxl_conf.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
src/libxl/libxl_conf.c +11 -3
index 4a0fba9..7592dd2 100644
@@ -331,7 +331,8 @@ error:
 }
 
 static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver, virDomainDefPtr def,
+                      libxl_domain_config *d_config)
 {
     libxl_domain_build_info *b_info = &d_config->b_info;
     int hvm = STREQ(def->os.type, "hvm");
@@ -343,8 +344,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
     else
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+
     b_info->max_vcpus = def->maxvcpus;
-    libxl_bitmap_set((&b_info->avail_vcpus), def->vcpus);
+    if (libxl_cpu_bitmap_alloc(driver->ctx, &b_info->avail_vcpus,
+                               def->maxvcpus))
+        goto error;
+    libxl_bitmap_set_none(&b_info->avail_vcpus);
+    for (i = 0; i < def->vcpus; i++)
+        libxl_bitmap_set((&b_info->avail_vcpus), i);
+
     if (def->clock.ntimers > 0 &&
         def->clock.timers[0]->name == VIR_DOMAIN_TIMER_NAME_TSC) {
         switch (def->clock.timers[0]->mode) {
@@ -802,7 +810,7 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
     if (libxlMakeDomCreateInfo(driver, def, &d_config->c_info) < 0)
         return -1;
 
-    if (libxlMakeDomBuildInfo(def, d_config) < 0) {
+    if (libxlMakeDomBuildInfo(driver, def, d_config) < 0) {
         return -1;
     }
 
Signature · 7 lines
1.7.9.5


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#3 lore raw
In reply to Konrad Rzeszutek Wilk

One comment below in addition to Konrad's...

Quoted 55 lines · Konrad Rzeszutek Wilk
Quoted 8 lines · Stefan Bader

This fixes the basic setup but there is likely more to do if things like manual CPU hirarchy (nodes, cores, threads) to be working.

Cross-posting to xen-devel to make sure I am doing things correctly.

-Stefan

Quoted 7 lines
Quoted 1 line

From 1ec5e7ea0d3498b9f61b83e8aed87cc3cae106de Mon Sep 17 00:00:00 2001

From: Stefan Bader <[email protected]>
Date: Fri, 19 Jul 2013 15:20:00 +0200
Subject: [PATCH] libxl: Correctly initialize vcpu bitmap

The avai_vcpu bitmap has to be allocated before it can be used (using

avail_vcpu ?

Quoted 9 lines

the maximum allowed value for that). Then for each available VCPU the bit in the mask has to be set (libxl_bitmap_set takes a bit position as an argument, not the number of bits to set).

Without this, I would always only get one VCPU for guests created through libvirt/libxl.

The libxl calling logic looks Ok to me. So from the libxl perspective you can tack on Reviewed-by: Konrad Rzeszutek Wilk <[email protected]>

Quoted 20 lines
---
 src/libxl/libxl_conf.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
src/libxl/libxl_conf.c +2 -1
index 4a0fba9..7592dd2 100644
@@ -331,7 +331,8 @@ error:
 }
 
 static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver, virDomainDefPtr def,
+                      libxl_domain_config *d_config)
 {
     libxl_domain_build_info *b_info = &d_config->b_info;
     int hvm = STREQ(def->os.type, "hvm");
@@ -343,8 +344,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
Quoted 8 lines

src/libxl/libxl_conf.c libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)

Quoted 8 lines
src/libxl/libxl_conf.c +3 -1
     else
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+
     b_info->max_vcpus = def->maxvcpus;
-    libxl_bitmap_set((&b_info->avail_vcpus), def->vcpus);
+    if (libxl_cpu_bitmap_alloc(driver->ctx, &b_info->avail_vcpus,
+                               def->maxvcpus))
 

You are using the driver-wide libxl_ctx in libxlDriverPrivate here, but should be using the per-domain libxl_ctx in libxlDomainObjPrivate structure IMO.

It looks like libxlBuildDomainConfig, which calls libxlMakeDomBuildInfo, should have just taken virDomainObjPtr instead of virDomainDefPtr. libxlBuildDomainConfig would then have access to the per-domain libxl_ctx, and no longer need the libxlDriverPrivatePtr parameter as well.

Regards,
Jim

Quoted 28 lines
Quoted 26 lines
src/libxl/libxl_conf.c +5 -0
+        goto error;
+    libxl_bitmap_set_none(&b_info->avail_vcpus);
+    for (i = 0; i < def->vcpus; i++)
+        libxl_bitmap_set((&b_info->avail_vcpus), i);
+
     if (def->clock.ntimers > 0 &&
         def->clock.timers[0]->name == VIR_DOMAIN_TIMER_NAME_TSC) {
         switch (def->clock.timers[0]->mode) {
src/libxl/libxl_conf.c +1 -1
@@ -802,7 +810,7 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
     if (libxlMakeDomCreateInfo(driver, def, &d_config->c_info) < 0)
         return -1;
 
-    if (libxlMakeDomBuildInfo(def, d_config) < 0) {
+    if (libxlMakeDomBuildInfo(driver, def, d_config) < 0) {
         return -1;
     }
 
Signature · 7 lines
1.7.9.5


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#4 lore raw
Quoted 71 lines · Jim Fehlig

One comment below in addition to Konrad's...

Quoted 55 lines · Konrad Rzeszutek Wilk
Quoted 8 lines · Stefan Bader

This fixes the basic setup but there is likely more to do if things like manual CPU hirarchy (nodes, cores, threads) to be working.

Cross-posting to xen-devel to make sure I am doing things correctly.

-Stefan

Quoted 7 lines
Quoted 1 line

From 1ec5e7ea0d3498b9f61b83e8aed87cc3cae106de Mon Sep 17 00:00:00 2001

From: Stefan Bader <[email protected]>
Date: Fri, 19 Jul 2013 15:20:00 +0200
Subject: [PATCH] libxl: Correctly initialize vcpu bitmap

The avai_vcpu bitmap has to be allocated before it can be used (using

avail_vcpu ?

Quoted 9 lines

the maximum allowed value for that). Then for each available VCPU the bit in the mask has to be set (libxl_bitmap_set takes a bit position as an argument, not the number of bits to set).

Without this, I would always only get one VCPU for guests created through libvirt/libxl.

The libxl calling logic looks Ok to me. So from the libxl perspective you can tack on Reviewed-by: Konrad Rzeszutek Wilk <[email protected]>

Quoted 20 lines
---
 src/libxl/libxl_conf.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
src/libxl/libxl_conf.c +2 -1
index 4a0fba9..7592dd2 100644
@@ -331,7 +331,8 @@ error:
 }
 
 static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver, virDomainDefPtr def,
+                      libxl_domain_config *d_config)
 {
     libxl_domain_build_info *b_info = &d_config->b_info;
     int hvm = STREQ(def->os.type, "hvm");
@@ -343,8 +344,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
Quoted 8 lines

src/libxl/libxl_conf.c libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config) · line 351

Quoted 8 lines
src/libxl/libxl_conf.c +3 -1
     else
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+
     b_info->max_vcpus = def->maxvcpus;
-    libxl_bitmap_set((&b_info->avail_vcpus), def->vcpus);
+    if (libxl_cpu_bitmap_alloc(driver->ctx, &b_info->avail_vcpus,
+                               def->maxvcpus))
 

You are using the driver-wide libxl_ctx in libxlDriverPrivate here, but should be using the per-domain libxl_ctx in libxlDomainObjPrivate structure IMO.

Quoted 5 lines

It looks like libxlBuildDomainConfig, which calls libxlMakeDomBuildInfo, should have just taken virDomainObjPtr instead of virDomainDefPtr. libxlBuildDomainConfig would then have access to the per-domain libxl_ctx, and no longer need the libxlDriverPrivatePtr parameter as well.

So more like attached v2. I am not sure libxlDriverPrivatePtr can really be dropped (and maybe should not as part of a fix to this issue). Maybe calling libxl_flask_context_to_sid also should use the per domain context. But at least libxlMakeVfbList->libxlMakeVfb->virPortAllocatorAcquire sounds a bit like it might need the driver context.

-Stefan

From 2d4b7e5ae2644e6f7a2ea930d0899ea426cb9c84 Mon Sep 17 00:00:00 2001
From: Stefan Bader <[email protected]>
Date: Fri, 19 Jul 2013 15:20:00 +0200
Subject: [PATCH] libxl: Correctly initialize vcpu bitmap

The avail_vcpu bitmap has to be allocated before it can be used (using the maximum allowed value for that). Then for each available VCPU the bit in the mask has to be set (libxl_bitmap_set takes a bit position as an argument, not the number of bits to set).

Without this, I would always only get one VCPU for guests created through libvirt/libxl.

[v2] Use private ctx from virDomainObjPtr->privateData

---
 src/libxl/libxl_conf.c   |   19 +++++++++++++++----
 src/libxl/libxl_conf.h   |    2 +-
 src/libxl/libxl_driver.c |    2 +-
 3 files changed, 17 insertions(+), 6 deletions(-)
src/libxl/libxl_conf.c +15 -4
index 4a0fba9..f732135 100644
@@ -331,8 +331,10 @@ error:
 }
 
 static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDomBuildInfo(virDomainObjPtr vm, libxl_domain_config *d_config)
 {
+    virDomainDefPtr def = vm->def;
+    libxlDomainObjPrivatePtr priv = vm->privateData;
     libxl_domain_build_info *b_info = &d_config->b_info;
     int hvm = STREQ(def->os.type, "hvm");
     size_t i;
@@ -343,8 +345,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
     else
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+
     b_info->max_vcpus = def->maxvcpus;
-    libxl_bitmap_set((&b_info->avail_vcpus), def->vcpus);
+    if (libxl_cpu_bitmap_alloc(priv->ctx, &b_info->avail_vcpus,
+                               def->maxvcpus))
+        goto error;
+    libxl_bitmap_set_none(&b_info->avail_vcpus);
+    for (i = 0; i < def->vcpus; i++)
+        libxl_bitmap_set((&b_info->avail_vcpus), i);
+
     if (def->clock.ntimers > 0 &&
         def->clock.timers[0]->name == VIR_DOMAIN_TIMER_NAME_TSC) {
         switch (def->clock.timers[0]->mode) {
@@ -795,14 +804,16 @@ libxlMakeCapabilities(libxl_ctx *ctx)
 
 int
 libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
-                       virDomainDefPtr def, libxl_domain_config *d_config)
+                       virDomainObjPtr vm, libxl_domain_config *d_config)
 {
+    virDomainDefPtr def = vm->def;
+
     libxl_domain_config_init(d_config);
 
     if (libxlMakeDomCreateInfo(driver, def, &d_config->c_info) < 0)
         return -1;
 
-    if (libxlMakeDomBuildInfo(def, d_config) < 0) {
+    if (libxlMakeDomBuildInfo(vm, d_config) < 0) {
         return -1;
     }
 
src/libxl/libxl_conf.h +1 -1
index 2b4a281..942cdd5 100644
@@ -126,6 +126,6 @@ libxlMakeVfb(libxlDriverPrivatePtr driver,
 
 int
 libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
-                       virDomainDefPtr def, libxl_domain_config *d_config);
+                       virDomainObjPtr vm, libxl_domain_config *d_config);
 
 #endif /* LIBXL_CONF_H */
src/libxl/libxl_driver.c +1 -1
index 358d387..98b1985 100644
@@ -968,7 +968,7 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
 
     libxl_domain_config_init(&d_config);
 
-    if (libxlBuildDomainConfig(driver, vm->def, &d_config) < 0)
+    if (libxlBuildDomainConfig(driver, vm, &d_config) < 0)
         goto error;
 
     if (driver->autoballoon && libxlFreeMem(priv, &d_config) < 0) {
Signature · 1 line
1.7.9.5
#5 lore raw
Quoted 2 lines · Stefan Bader

On 23.07.2013 23:20, Jim Fehlig wrote:

[...]

Quoted 11 lines
Quoted 10 lines

You are using the driver-wide libxl_ctx in libxlDriverPrivate here, but should be using the per-domain libxl_ctx in libxlDomainObjPrivate structure IMO.

It looks like libxlBuildDomainConfig, which calls libxlMakeDomBuildInfo, should have just taken virDomainObjPtr instead of virDomainDefPtr. libxlBuildDomainConfig would then have access to the per-domain libxl_ctx, and no longer need the libxlDriverPrivatePtr parameter as well.

Quoted 3 lines

So more like attached v2. I am not sure libxlDriverPrivatePtr can really be dropped (and maybe should not as part of a fix to this issue). Maybe calling libxl_flask_context_to_sid also should use the per domain context.

Yeah, I think so, but as a separate patch.

Quoted 4 lines

But at least
libxlMakeVfbList->libxlMakeVfb->virPortAllocatorAcquire sounds a bit like it might need the driver context.

Ah, right, neglected that call chain when suggesting to remove libxlDriverPrivatePtr.

Quoted 10 lines

From 2d4b7e5ae2644e6f7a2ea930d0899ea426cb9c84 Mon Sep 17 00:00:00 2001
From: Stefan Bader <[email protected]>
Date: Fri, 19 Jul 2013 15:20:00 +0200
Subject: [PATCH] libxl: Correctly initialize vcpu bitmap

The avail_vcpu bitmap has to be allocated before it can be used (using the maximum allowed value for that). Then for each available VCPU the bit in the mask has to be set (libxl_bitmap_set takes a bit position as an argument, not the number of bits to set).

Quoted 5 lines

Without this, I would always only get one VCPU for guests created through libvirt/libxl.

[v2] Use private ctx from virDomainObjPtr->privateData

No need for history of patch revisions in the commit message. They can be added with 'git send-email --annotate ...'.

Quoted 24 lines
---
 src/libxl/libxl_conf.c   |   19 +++++++++++++++----
 src/libxl/libxl_conf.h   |    2 +-
 src/libxl/libxl_driver.c |    2 +-
 3 files changed, 17 insertions(+), 6 deletions(-)
src/libxl/libxl_conf.c +3 -1
index 4a0fba9..f732135 100644
@@ -331,8 +331,10 @@ error:
 }
 
 static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDomBuildInfo(virDomainObjPtr vm, libxl_domain_config *d_config)
 {
+    virDomainDefPtr def = vm->def;
+    libxlDomainObjPrivatePtr priv = vm->privateData;
     libxl_domain_build_info *b_info = &d_config->b_info;
     int hvm = STREQ(def->os.type, "hvm");
     size_t i;

src/libxl/libxl_conf.c libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config) · line 352

Quoted 9 lines
src/libxl/libxl_conf.c +3 -1
@@ -343,8 +345,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
     else
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+
     b_info->max_vcpus = def->maxvcpus;
-    libxl_bitmap_set((&b_info->avail_vcpus), def->vcpus);
+    if (libxl_cpu_bitmap_alloc(priv->ctx, &b_info->avail_vcpus,
+                               def->maxvcpus))
 

Fits on one line.

ACK to the patch though. I fixed these minor nits and pushed.

Regards,
Jim

Quoted 53 lines
src/libxl/libxl_conf.c +5 -0
+        goto error;
+    libxl_bitmap_set_none(&b_info->avail_vcpus);
+    for (i = 0; i < def->vcpus; i++)
+        libxl_bitmap_set((&b_info->avail_vcpus), i);
+
     if (def->clock.ntimers > 0 &&
         def->clock.timers[0]->name == VIR_DOMAIN_TIMER_NAME_TSC) {
         switch (def->clock.timers[0]->mode) {
src/libxl/libxl_conf.c +4 -2
@@ -795,14 +804,16 @@ libxlMakeCapabilities(libxl_ctx *ctx)
 
 int
 libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
-                       virDomainDefPtr def, libxl_domain_config *d_config)
+                       virDomainObjPtr vm, libxl_domain_config *d_config)
 {
+    virDomainDefPtr def = vm->def;
+
     libxl_domain_config_init(d_config);
 
     if (libxlMakeDomCreateInfo(driver, def, &d_config->c_info) < 0)
         return -1;
 
-    if (libxlMakeDomBuildInfo(def, d_config) < 0) {
+    if (libxlMakeDomBuildInfo(vm, d_config) < 0) {
         return -1;
     }
 
src/libxl/libxl_conf.h +1 -1
index 2b4a281..942cdd5 100644
@@ -126,6 +126,6 @@ libxlMakeVfb(libxlDriverPrivatePtr driver,
 
 int
 libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
-                       virDomainDefPtr def, libxl_domain_config *d_config);
+                       virDomainObjPtr vm, libxl_domain_config *d_config);
 
 #endif /* LIBXL_CONF_H */
src/libxl/libxl_driver.c +1 -2
index 358d387..98b1985 100644
@@ -968,7 +968,7 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
 
     libxl_domain_config_init(&d_config);
 
-    if (libxlBuildDomainConfig(driver, vm->def, &d_config) < 0)
+    if (libxlBuildDomainConfig(driver, vm, &d_config) < 0)
         goto error;
 
     if (driver->autoballoon && libxlFreeMem(priv, &d_config) < 0) {
-- 1.7.9.5