提交 d67c189e 编写于 作者: E Eric Blake

vcpu: improve vcpu support in qemu command line

* src/qemu/qemu_conf.c (qemuParseCommandLineSmp): Distinguish
between vcpus and maxvcpus, for new enough qemu.
* tests/qemuargv2xmltest.c (mymain): Add new test.
* tests/qemuxml2argvtest.c (mymain): Likewise.
* tests/qemuxml2xmltest.c (mymain): Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-smp.args: New file.
上级 6c9e6b95
...@@ -3714,6 +3714,8 @@ qemuBuildSmpArgStr(const virDomainDefPtr def, ...@@ -3714,6 +3714,8 @@ qemuBuildSmpArgStr(const virDomainDefPtr def,
virBufferVSprintf(&buf, "%u", def->vcpus); virBufferVSprintf(&buf, "%u", def->vcpus);
if ((qemuCmdFlags & QEMUD_CMD_FLAG_SMP_TOPOLOGY)) { if ((qemuCmdFlags & QEMUD_CMD_FLAG_SMP_TOPOLOGY)) {
if (def->vcpus != def->maxvcpus)
virBufferVSprintf(&buf, ",maxcpus=%u", def->maxvcpus);
/* sockets, cores, and threads are either all zero /* sockets, cores, and threads are either all zero
* or all non-zero, thus checking one of them is enough */ * or all non-zero, thus checking one of them is enough */
if (def->cpu && def->cpu->sockets) { if (def->cpu && def->cpu->sockets) {
...@@ -3726,12 +3728,12 @@ qemuBuildSmpArgStr(const virDomainDefPtr def, ...@@ -3726,12 +3728,12 @@ qemuBuildSmpArgStr(const virDomainDefPtr def,
virBufferVSprintf(&buf, ",cores=%u", 1); virBufferVSprintf(&buf, ",cores=%u", 1);
virBufferVSprintf(&buf, ",threads=%u", 1); virBufferVSprintf(&buf, ",threads=%u", 1);
} }
} } else if (def->vcpus != def->maxvcpus) {
if (def->vcpus != def->maxvcpus) {
virBufferFreeAndReset(&buf); virBufferFreeAndReset(&buf);
/* FIXME - consider hot-unplugging cpus after boot for older qemu */
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("setting current vcpu count less than maximum is " _("setting current vcpu count less than maximum is "
"not supported yet")); "not supported with this QEMU binary"));
return NULL; return NULL;
} }
...@@ -6153,6 +6155,7 @@ qemuParseCommandLineSmp(virDomainDefPtr dom, ...@@ -6153,6 +6155,7 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
unsigned int sockets = 0; unsigned int sockets = 0;
unsigned int cores = 0; unsigned int cores = 0;
unsigned int threads = 0; unsigned int threads = 0;
unsigned int maxcpus = 0;
int i; int i;
int nkws; int nkws;
char **kws; char **kws;
...@@ -6180,12 +6183,14 @@ qemuParseCommandLineSmp(virDomainDefPtr dom, ...@@ -6180,12 +6183,14 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
cores = n; cores = n;
else if (STREQ(kws[i], "threads")) else if (STREQ(kws[i], "threads"))
threads = n; threads = n;
else if (STREQ(kws[i], "maxcpus"))
maxcpus = n;
else else
goto syntax; goto syntax;
} }
} }
dom->maxvcpus = dom->vcpus; dom->maxvcpus = maxcpus ? maxcpus : dom->vcpus;
if (sockets && cores && threads) { if (sockets && cores && threads) {
virCPUDefPtr cpu; virCPUDefPtr cpu;
......
...@@ -221,6 +221,8 @@ mymain(int argc, char **argv) ...@@ -221,6 +221,8 @@ mymain(int argc, char **argv)
DO_TEST("hostdev-pci-address"); DO_TEST("hostdev-pci-address");
DO_TEST("smp");
DO_TEST_FULL("restore-v1", 0, "stdio"); DO_TEST_FULL("restore-v1", 0, "stdio");
DO_TEST_FULL("restore-v2", 0, "stdio"); DO_TEST_FULL("restore-v2", 0, "stdio");
DO_TEST_FULL("restore-v2", 0, "exec:cat"); DO_TEST_FULL("restore-v2", 0, "exec:cat");
......
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1,maxcpus=2,sockets=2,cores=1,threads=1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
...@@ -385,6 +385,8 @@ mymain(int argc, char **argv) ...@@ -385,6 +385,8 @@ mymain(int argc, char **argv)
DO_TEST("qemu-ns", 0); DO_TEST("qemu-ns", 0);
DO_TEST("smp", QEMUD_CMD_FLAG_SMP_TOPOLOGY);
free(driver.stateDir); free(driver.stateDir);
virCapabilitiesFree(driver.caps); virCapabilitiesFree(driver.caps);
......
...@@ -180,6 +180,8 @@ mymain(int argc, char **argv) ...@@ -180,6 +180,8 @@ mymain(int argc, char **argv)
DO_TEST("encrypted-disk"); DO_TEST("encrypted-disk");
DO_TEST("memtune"); DO_TEST("memtune");
DO_TEST("smp");
/* These tests generate different XML */ /* These tests generate different XML */
DO_TEST_DIFFERENT("balloon-device-auto"); DO_TEST_DIFFERENT("balloon-device-auto");
DO_TEST_DIFFERENT("channel-virtio-auto"); DO_TEST_DIFFERENT("channel-virtio-auto");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册