arm: handle dom0_max_vcpus=0 case properly
authorIan Campbell <ian.campbell@citrix.com>
Wed, 14 Mar 2012 09:47:04 +0000 (09:47 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 14 Mar 2012 09:47:04 +0000 (09:47 +0000)
Also use xzalloc_array.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/domain_build.c

index 92402093519d654af7badc12d326377bf5e9e607..15632f79e716ce09f7a08eae4494f6dd2e099fc7 100644 (file)
@@ -15,13 +15,14 @@ integer_param("dom0_max_vcpus", opt_dom0_max_vcpus);
 
 struct vcpu *__init alloc_dom0_vcpu0(void)
 {
-    dom0->vcpu = xmalloc_array(struct vcpu *, opt_dom0_max_vcpus);
+    if ( opt_dom0_max_vcpus == 0 )
+        opt_dom0_max_vcpus = num_online_cpus();
+    if ( opt_dom0_max_vcpus > MAX_VIRT_CPUS )
+        opt_dom0_max_vcpus = MAX_VIRT_CPUS;
+
+    dom0->vcpu = xzalloc_array(struct vcpu *, opt_dom0_max_vcpus);
     if ( !dom0->vcpu )
-    {
-            printk("failed to alloc dom0->vccpu\n");
         return NULL;
-    }
-    memset(dom0->vcpu, 0, opt_dom0_max_vcpus * sizeof(*dom0->vcpu));
     dom0->max_vcpus = opt_dom0_max_vcpus;
 
     return alloc_vcpu(dom0, 0, 0);