diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index f3e7e1864f..54f5791905 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -488,19 +488,22 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def) const char *str = NULL; int val = 0; - if (xenConfigGetULong(conf, "vcpus", &count, 1) < 0 || - MAX_VIRT_CPUS < count) + if (xenConfigGetULong(conf, "vcpus", &count, 1) < 0) return -1; if (virDomainDefSetVcpusMax(def, count) < 0) return -1; - if (xenConfigGetULong(conf, "vcpu_avail", &count, -1) < 0) + if (virDomainDefSetVcpus(def, count) < 0) return -1; - if (virDomainDefSetVcpus(def, MIN(count_one_bits_l(count), - virDomainDefGetVcpusMax(def))) < 0) - return -1; + if (virConfGetValue(conf, "maxvcpus")) { + if (xenConfigGetULong(conf, "maxvcpus", &count, 0) < 0) + return -1; + + if (virDomainDefSetVcpusMax(def, count) < 0) + return -1; + } if (xenConfigGetString(conf, "cpus", &str, NULL) < 0) return -1; @@ -1494,14 +1497,10 @@ xenFormatCPUAllocation(virConfPtr conf, virDomainDefPtr def) int ret = -1; char *cpus = NULL; - if (xenConfigSetInt(conf, "vcpus", virDomainDefGetVcpusMax(def)) < 0) + if (virDomainDefGetVcpus(def) < virDomainDefGetVcpusMax(def) && + xenConfigSetInt(conf, "maxvcpus", virDomainDefGetVcpusMax(def)) < 0) goto cleanup; - - /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is - either 32, or 64 on a platform where long is big enough. */ - if (virDomainDefHasVcpusOffline(def) && - xenConfigSetInt(conf, "vcpu_avail", - (1UL << virDomainDefGetVcpus(def)) - 1) < 0) + if (xenConfigSetInt(conf, "vcpus", virDomainDefGetVcpus(def)) < 0) goto cleanup; if ((def->cpumask != NULL) && diff --git a/tests/xlconfigdata/test-paravirt-maxvcpus.cfg b/tests/xlconfigdata/test-paravirt-maxvcpus.cfg new file mode 100644 index 0000000000..d506b7549a --- /dev/null +++ b/tests/xlconfigdata/test-paravirt-maxvcpus.cfg @@ -0,0 +1,13 @@ +name = "XenGuest1" +uuid = "45b60f51-88a9-47a8-a3b3-5e66d71b2283" +maxmem = 512 +memory = 512 +maxvcpus = 8 +vcpus = 4 +localtime = 0 +on_poweroff = "preserve" +on_reboot = "restart" +on_crash = "preserve" +vif = [ "mac=5a:36:0e:be:00:09" ] +bootloader = "/usr/bin/pygrub" +disk = [ "/var/lib/xen/images/debian/disk.qcow2,qcow2,xvda,w,backendtype=qdisk" ] diff --git a/tests/xlconfigdata/test-paravirt-maxvcpus.xml b/tests/xlconfigdata/test-paravirt-maxvcpus.xml new file mode 100644 index 0000000000..2e1f8f86fe --- /dev/null +++ b/tests/xlconfigdata/test-paravirt-maxvcpus.xml @@ -0,0 +1,28 @@ + + XenGuest1 + 45b60f51-88a9-47a8-a3b3-5e66d71b2283 + 524288 + 524288 + 8 + /usr/bin/pygrub + + linux + + + preserve + restart + preserve + + + + + + + + + + + + + + diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index de7f8718f5..1db11e74e7 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -192,6 +192,7 @@ mymain(void) ret = -1; \ } while (0) + DO_TEST("paravirt-maxvcpus"); DO_TEST("new-disk"); DO_TEST("spice"); DO_TEST("spice-features"); diff --git a/tests/xmconfigdata/test-paravirt-maxvcpus.cfg b/tests/xmconfigdata/test-paravirt-maxvcpus.cfg new file mode 100644 index 0000000000..8d1ac4d786 --- /dev/null +++ b/tests/xmconfigdata/test-paravirt-maxvcpus.cfg @@ -0,0 +1,13 @@ +name = "XenGuest1" +uuid = "c7a5fdb0-cdaf-9455-926a-d65c16db1809" +maxmem = 579 +memory = 394 +maxvcpus = 4 +vcpus = 2 +localtime = 0 +on_poweroff = "destroy" +on_reboot = "restart" +on_crash = "restart" +vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ] +bootloader = "/usr/bin/pygrub" +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] diff --git a/tests/xmconfigdata/test-paravirt-maxvcpus.xml b/tests/xmconfigdata/test-paravirt-maxvcpus.xml new file mode 100644 index 0000000000..3b0e0ce14f --- /dev/null +++ b/tests/xmconfigdata/test-paravirt-maxvcpus.xml @@ -0,0 +1,31 @@ + + XenGuest1 + c7a5fdb0-cdaf-9455-926a-d65c16db1809 + 592896 + 403456 + 4 + /usr/bin/pygrub + + linux + + + destroy + restart + restart + + + + + + + + + +